Opencv_createsamples因分段错误而失败

时间:2018-03-06 23:27:50

标签: linux opencv image-recognition training-data haar-classifier

我目前正在尝试制作HAAR分类器。我已经制作了一个注释文件并完成了官方openCV教程中所描述的所有内容:https://docs.opencv.org/3.3.0/dc/d88/tutorial_traincascade.html。 但是,当我尝试使用opencv_createsamples创建示例时,出现错误。我的命令:

opencv_createsamples -vec /some_dirs/samples/samples.vec -info /some_dirs/annotations/annotations.dat -w 8 -h 8 -num 100

错误:

Info file name: /home/nikifaets/code/pointsProcessing/annotations/annotations.dat Img file name: (NULL) Vec file name: /home/nikifaets/code/pointsProcessing/samples/samples.vec BG file name: (NULL) Num: 100 BG color: 0 BG threshold: 80 Invert: FALSE Max intensity deviation: 40 Max x angle: 1.1 Max y angle: 1.1 Max z angle: 0.5 Show samples: FALSE Width: 8 Height: 8 Max Scale: -1 RNG Seed: 12345 Create training samples from images collection... OpenCV Error: Assertion failed (ssize.width > 0 && ssize.height > 0) in resize, file /build/opencv/src/opencv-3.4.0/modules/imgproc/src/resize.cpp, line 4044 terminate called after throwing an instance of 'cv::Exception' what(): /build/opencv/src/opencv-3.4.0/modules/imgproc/src/resize.cpp:4044: error: (-215) ssize.width > 0 && ssize.height > 0 in function resize

Aborted (core dumped)

但是,如果我尝试只做两个样本(不知道为什么只有2个......),它会运行并创建.vec文件,尽管我的数据集包含大约300-400张图片。

annotations.dat

的Pastebin

提前感谢您的支持!

1 个答案:

答案 0 :(得分:1)

解决!感谢Micka建议解决方案并且正确。注释文件中存在错误。感兴趣点的描述之一是 0 0 0 0 ,这是无效的。请务必仔细检查您的文件!