Ask Your Question
0

Generate a xml file: error with createsamples

asked 2013-07-09 02:18:31 -0600

charlottepel gravatar image

updated 2013-07-09 02:35:31 -0600

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.

edit retag flag offensive close merge delete

Comments

Hey there. Can you please let us know if you are able to run other samples like facedetect, etc.?

Prasanna gravatar imagePrasanna ( 2013-07-09 07:25:18 -0600 )edit

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

charlottepel gravatar imagecharlottepel ( 2013-07-09 20:16:11 -0600 )edit

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 ?

charlottepel gravatar imagecharlottepel ( 2013-07-09 20:18:56 -0600 )edit

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.

Prasanna gravatar imagePrasanna ( 2013-07-10 03:54:46 -0600 )edit

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 opencvpkg-config --libs opencv -o facedetect facedetect.cpp

And 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.

charlottepel gravatar imagecharlottepel ( 2013-07-11 20:33:58 -0600 )edit

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

Prasanna gravatar imagePrasanna ( 2013-07-11 20:53:11 -0600 )edit

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?

charlottepel gravatar imagecharlottepel ( 2013-07-11 22:42:07 -0600 )edit

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.

Prasanna gravatar imagePrasanna ( 2013-07-12 04:27:01 -0600 )edit

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.cpp

And I received :

/tmp/cce6bQUu.o:facedetect.cpp:(.text+0x1f2): undefined reference to cv::CascadeClassifier::CascadeClassifier()' /tmp/cce6bQUu.o:facedetect.cpp:(.text+0x200): undefined reference tocv::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?

charlottepel gravatar imagecharlottepel ( 2013-07-14 20:49:28 -0600 )edit

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.

charlottepel gravatar imagecharlottepel ( 2013-08-06 21:21:08 -0600 )edit

2 answers

Sort by » oldest newest most voted
0

answered 2013-08-06 03:58:52 -0600

charlottepel gravatar image

Hello,

So I have tried to reinstall openCV on Cygwin with update versions of ffmpeg-2.0 and openCV-2.4.6.1. I have followed all this tutorial http://hvrl.ics.keio.ac.jp/kimura/opencv/

But during the 4th step, when I did

make install

I had this error

CMakeFiles/opencv_highgui.dir/src/cap_dshow.cpp.o:cap_dshow.cpp:(.text$_ZN10videoInput23ShowFilterPropertyPagesEP11IBaseFilter+0x37): undefined reference to `IID_ISpecifyPropertyPages'

First time, I tried install OpenCV on Cygwin, I had this error too. I fixed it by adding the following line on cap_dshow.cpp :

DEFINE_GUID(IID_ISpecifyPropertyPages,0xb196b28b,0xbab4,0x101a,0xb6,0x9c,0,0xaa,0,0x34,0x1d,0x7);

Maybe, it was not a good idea and it is for this reason that my installation of openCV was not good.

Does anyone know this kind of error and how to fix it more properly?

Thanks for your help.

Charlotte.

edit flag offensive delete link more
0

answered 2013-08-07 00:57:05 -0600

charlottepel gravatar image

Hello,

So I have continued my installation and finished it (I corrected the problem mentioned above in adding "DEFINE_GUID" line).

Now, I'm trying to reuse opencv_createsamples file and this time I have another problem (that's the one from my first post). (I don't know if I should better open new topic for each new question but I will continue with this one).

I use this command on Cygwin :

opencv_createsamples -img 1a000.pgm -num 2 -bg negative.dat -vec samples.vec -maxxangle 0.6 -maxyangle 0 -maxzangle 0.3 -maxidev 100 -bgcolor 0 -bgthresh 0 -w 20 -h 20

I also read :

Info file name: (NULL)

Img file name: 1a000.pgm

Vec file name: samples.vec

BG file name: negative.dat

Num: 2

BG color: 0

BG threshold: 0

Invert: FALSE

Max intensity deviation: 100

Max x angle: 0.6

Max y angle: 0

Max z angle: 0.3

Show samples: FALSE

Width: 20

Height: 20

Create training samples from single image applying distortions...

And so, a .vec file is created but it is empty - its size is 0 byte. I have find on some other forums people with same kind of problem but unfortunately with no solutions.

For your information, the negative.dat is only composed of three pictures (this file is only to test, I have in fact more pictures) :

negative/neg-0002.jpgnegative/neg-0004.jpgnegative/neg-0005.jpg

And I have tried with two other configurations as :

negative\neg-0002.jpgnegative\neg-0004.jpgnegative\neg-0005.jpg

Or

./negative/neg-0002.jpg./negative/neg-0004.jpg./negative/neg-0005.jpg

With still same result.

Thanks in advance for your help.

Charlotte.

edit flag offensive delete link more

Comments

I have also noticed that if I'm adding -show option in using opencv_createsamples, a window is opened and the closed immediately. I don't know if it can help.

charlottepel gravatar imagecharlottepel ( 2013-08-07 21:07:31 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2013-07-09 02:18:31 -0600

Seen: 1,640 times

Last updated: Aug 07 '13