python - 裁剪和调整图像大小以训练支持向量机
问题描述
我使用 OpenCV(Python) 使用 HOG+SVM 检测同一类的对象。我正在按照 Udacitiy-Project 的示例来检测车辆:访问https://github.com/TusharChugh/Vehicle-Detection-HOG/blob/master/src/vehicle-detection.ipynb。在这个例子中,他们使用了一个准备好的车辆数据集,其中包含裁剪和调整大小的图像。
我在问是否有人有裁剪和调整图像大小的想法,其中包含同一图像中的对象和背景?或者如何在上面提到的示例中标记图像并将它们集成?我使用 Windows 10 和 Python 3.6。
提前致谢
解决方案
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)
推荐阅读
- python - 使用 Pandas eval() 进行数据访问比普通 pandas 慢几个数量级
- sql - 获取按日期排序的最后记录的最佳性能方法
- php - 如果父目录的大小写不同,PHP Include_once 将再次包含文件
- java - 如何在 pom.xml 文件中声明用户定义的属性
- python - 包括正确的间隙以模仿 PDB 文件
- sql - 如何通过 Vertica SQL 中的多个列及其类别获取主键计数?
- sql - 按具有起点和终点 SQL Server 的动态间隔分组
- c# - 编辑完成后 C# DataGridView 数据移动到下一个单元格
- c# - 使用 C# 从 MS Graph API 中的消息中获取 EventMessage
- sql - SQL - 计算每年相同日期之间的日期