I am trying to run the createsamples example from the OpenCV library. I can load in one image at a time and it seems to work fine. However, when I try to load in a collection of images I get a parse error. I am not sure if it is something in my collection file that is invalid or if I am missing something elsewhere. Below is the exact format of my text document.
Text document details:
Target1.JPG 1 0 0 1296 1152
Target2.jpg 1 0 0 1890 709
Command line call:
-info "C:\Users\seb\Desktop\Learning Samples\Target\Target.txt" -num 10 -vec "C:\Users\seb\Desktop\Learning Samples\Target\Target.vec" -maxxangle 0.6 -maxyangle 0 -maxzangle 0.3 -maxidev 100 -bgcolor 0 -bgthresh 0 -w 20 -h 20
Any help is greatly appreciated.
The parse error is because when you do not specify the number of pos image samples you want to generate, the createsamples will use the default value which is 1000. But if your annotation text document contains less than 1000 bounding boxes of objects, you will get the parse error. You can still use the .vec file for training cascade. The only problem is that the information of number is incorrect. There are two ways to fix it.
You manually count the number of object bounding boxes in the text document. And specify the value less or equal to the number for the option “-num”
e.g. createsamples -info xxxxx.txt -vec pos.vec -num [value]
You can revise the OPENCV_ROOT_DIR/modules/haartraining/createsamples.cpp. When the -num is not specified, set the number of pos samples as the number of object bounding boxes in the text document
code snippet:
In createsamples.cpp
int num = 0;
In cvsamples.cpp