Error "Train dataset for temp stage can not be filled." while using traincascade tool of OpenCV
First, for me too, the error was with the bg file. I use Opencv 2.4.10.1.
I got the error when I specified the absolute path to the bg file in the command (like the author of the post). Looks like the authors did a really, really crappy job on figuring out the full negative image paths. One simple workaround is to simply CD to the dir of the .info file (note -bg infofile.txt)
cd D:\OpenCV\Classifiers\lbpclassifier1\temp\negative
train_cascade -data D:\OpenCV\Classifiers\lbpclassifier1\temp\data -vec D:\OpenCV\Classifiers\lbpclassifier1\temp\samples.vec -bg infofile.txt -numPos 40 -numNeg 40 -precalcIdxBufSize 500 -precalcValBufSize 500 -stageType BOOST -featureType LBP -w 24 -h 24
I am also learning how to use OpenCV object detection tools.
I noticed that if the bg file (in your case "D:\OpenCV\Classifiers\lbpclassifier1\temp\negative\infofile.txt") has a wrong format or contains a entry with non-existent file, opencv_traincascade produces error.
Hope it helps.
I hope to close this question. For those who stumbled over this as well. I know its old. I debugged the traincascade and found, that at some point the following line:
src = imread( imgFilenames[last++], CV_LOAD_IMAGE_GRAYSCALE );
returns a null mat. This line should read the background images.
This bug occures, if you build traincascade.cpp as debug and are using the release libs and dlls of opencv. (The other way around shouldn't work as well.