【问题标题】:crop and resize images to train a support vector machine裁剪和调整图像大小以训练支持向量机
【发布时间】:2018-10-17 05:31:08
【问题描述】:

我使用 OpenCV(Python) 来检测使用 HOG+SVM 的同一类的对象。我正在关注 Udacitiy-Project 的示例来检测车辆:访问 https://github.com/TusharChugh/Vehicle-Detection-HOG/blob/master/src/vehicle-detection.ipynb 。在这个例子中,他们使用了一个准备好的车辆数据集,其中包含裁剪和调整大小的图像。

我在问是否有人有想法裁剪和调整图像,其中包含同一图像中的对象和背景?或者如何在上面提到的示例中标记图像并将它们集成? 我使用 Windows 10 和 Python 3.6。

提前致谢

【问题讨论】:

  • 您必须创建一个程序,在该程序中您可以使用鼠标事件从图像中选择要裁剪的区域。 SEE THIS

标签: python opencv svm


【解决方案1】:
Read a negative input and convert to a Histogram of oriented gradients (HOG) 
    samples = []
    labels = []   
    for filename in glob.glob(os.path.join(negative_path, '*.jpg')):
        img = cv2.imread(filename, 1) 
        hist = hog(img)
        samples.append(hist)
        labels.append(1)

For the positive samples use the same code as above but with:
    labels.append(0)

then just train the svm modell with:
    svm.train(samples, cv2.ml.ROW_SAMPLE, labels)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2013-02-20
    • 1970-01-01
    • 2011-11-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多