Generate a xml file: error with createsamples
Hello,
I'm trying to follow this tutorial: http://note.sonots.com/SciSoftware/haartraining.html#notefoot_1 since several days.
I'm working on Cygwin (version 2.774) and the version 2.4.5 of opencv.
The aim of my project is to generate a xml file for face detection as in the tutorial. I don't manage to create several training samples with one positive images and some negative images.
First of all, I have created two description files, one for negative images (negatives.dat) and second one for positive images (postives.dat).
And after, I have typed this command:
perl createtrainsamples.pl positives.dat negatives.dat Sample
With Sample the name of the folder where I want to store the different vec files. But nothing was created, so I have just tried to create 10 training samples from one positive images with the following command:
opencv_createsamples -img ./Positive/1a000.jpg -num 10 -bg negatives.dat -vec samples.vec
And I have this result:
Info file name: (NULL)
Img file name: ./Positive/1a000.jpg
Vec file name: samples.vec
BG file name: negatives.dat
Num: 10
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: 24
Height: 24
Create training samples from single image applying distortions...
Illegal instruction (core dumped)
I don't understand this error message but maybe someone have an explanation.
For information, I have 3001 negative images in Negative folder and 571 positive images (92*112 pixels) in Positive folder.
Charlotte.
PS : Sorry for my poor english, this is not my mothertongue.
Hey there. Can you please let us know if you are able to run other samples like facedetect, etc.?
Hey, I search for some facedetect files and I found one which is called facedetect.cmd, so I opened cmd.exe and run : facedetect.cmd --cascade="../../data/haarcascades/haarcascade_frontalface_alt.xml" --nested-cascade="../../data/haarcascades/haarcascade_eye.xml" --scale=1.3 %1
Something happened but I stopped it (^C) because it was always the same things : C:\cygwin\tmp\opencv-2.4.5\samples\c>facedetect --cascade="../../data/haarcascades/haarcascade_frontalface_alt.xml" --nested-cascade="../../data/haarcascades/haarcascade_eye.xml" --scale=1.3 %1 --cascade
C:\cygwin\tmp\opencv-2.4.5\samples\c>REM an example of using haar cascade recognition for face and eye detection
I think I don't answer to your question but I don't know what you mean by "samples like facedetect". I have 5 executable files in cygwin/usr/local/bin directory which are opencv_createsamples.exe opencv_haartraining.exe opencv_mergevec.exe (that I added) opencv_performance.exe opencv_trainascade.exe
Do you mean, that I can try to run one of this .exe file on Cygwin ?
In the folder C:\cygwin\tmp\opencv-2.4.5\samples\c\, there will be a file facedetect.cpp. Try compiling it. ( If you have specified the 'build all examples' flag when you built OpenCV, you will find a facedetect.exe (or) a c-example-facedetect.exe in the bin or somewhere. Search for it.) Try running it. It is just to make sure your OpenCV and its utilities are built properly.
So, I have a file facedetect.cpp but no file facedetect.exe. Just in case, I have followed this kind of website to build my version of opencv on Cygwin : http://hvrl.ics.keio.ac.jp/kimura/opencv/ (but for my versions, I cannot find the website link).
So, i'm trying to compile it with this two commands : $ export PKG_CONFIG_PATH=../../../../../usr/local/lib/pkgconfig/ $ g++
pkg-config --cflags opencv
pkg-config --libs opencv
-o facedetect facedetect.cppAnd I have these kind of errors : /tmp/cctiJam4.o:facedetect.cpp:(.text+0x1f2): undefined reference to cv::CascadeClassifier::CascadeClassifier()'
I know that I probably forget something like linking libraries to compile facedetect.cpp but I thought my first command line with 'export' was enough.
I assume that the quote mark ( ' ) at the end of your previous comment (cv::CascadeClassifier::CascadeClassifier()') was a mistake. All I wanted to know was whether your opencv has been built correctly or not as these errors can come because of that too. Try compiling and executing some other program and test if opencv works.
pkg-config takes care of all the linking provided its used correctly. Verify whether the path is set by using : echo $PKG_CONFIG_PATH command in terminal.
For compiling, g++ -o facedetect facedetect.cpp
pkg-config --cflags --libs opencv
So if I used : echo $PKG_CONFIG_PATH, I received : ../../../../usr/local/lib/pkgconfig/. I think the path is good but if I'm trying to compile with your command, I have :
g++: error: pkg-config: No such file or directory
g++: error: unrecognized command line option ‘--cflags’
g++: error: unrecognized command line option ‘--libs’
g++: error: opencv: No such file or directory
And, so it didn't seem ok. When I export PKG_CONFIG_PATH, I should give the path where is opencv.pc?
I am really sorry, there are back quote marks (below tilde symbol)
marks before and after pkg-config. So the command is g++ -o facedetect facedetect.cpp
(back quote)pkg-config --cflags --libs opencv(back quote)` My bad.And why do u need relative path for PKG_CONFIG_PATH? Use absolute path of opencv.pc in export command.
Also this time, I have first using absolute path of opencv.pc
export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig/
And then, I tried
$ g++
pkg-config --cflags --libs opencv
-o facedetect facedetect.cppAnd I received :
/tmp/cce6bQUu.o:facedetect.cpp:(.text+0x1f2): undefined reference to
cv::CascadeClassifier::CascadeClassifier()' /tmp/cce6bQUu.o:facedetect.cpp:(.text+0x200): undefined reference to
cv::CascadeClassifier::CascadeClassifier()' /tmp/cce6bQUu.o:facedetect.cpp:(.text+0x3d2): undefined reference to `cv::CascadeClassifier::load(std::string const&)'...
It seems, indeed I have a problem with the installation of opencv.. Do you have any idea to fix it?
So, I have reinstalled openCV, a more recent version 2.4.6, on Cygwin. I didn't resolve the problem for the undefined reference to IID_ISpecifyPropertyPages (see the post below), I just did again what I explain on the post.
Even if I have still the same problem using opencv_createsamples, this time I succeed to create facedetect.exe. And so, I tried to use it :
./facedetect --cascade="../../data/haarcascades/haarcascade_frontalface_alt.xml" --nested-cascade="../../data/haarcascades/haarcascade_eye.xml" --scale=1.3 1a000.pgm
But I'm not sure about the result, a window "result" opened and closed. Should I see something on it? Because it's not the case.