Ask Your Question
1

How to use createsamples utility?

asked 2013-08-13 01:44:15 -0600

charlottepel gravatar image

Hello,

I'm trying to use createsamples utility (OpenCV 2.4.6.1 on Cygwin 1.7.23). My main folder is called Photos, on it I have one folder neg with one picture img1.bmp (480 by 640 pixels), two file img.bmp (face image 92 by 112 pixels) and nega.txt: neg/img1.bmp

Command line:

$ opencv_createsamples -bgcolor 0 -bgthresh 0 -maxxangle 1.1 -maxyangle 0 -maxzangle 0.5 -maxidev 40 -vec samples.vec -img img.bmp -bg nega.txt -w 20 -h 20 -num 1

Info file name: (NULL)

Img file name: img.bmp

Vec file name: samples.vec

BG file name: nega.txt

Num: 1

BG color: 0

BG threshold: 0

Invert: FALSE

Max intensity deviation: 40

Max x angle: 1.1

Max y angle: 0

Max z angle: 0.5

Show samples: FALSE

Width: 20

Height: 20

Create training samples from single image applying distortions...

I don't receive a Done message and no vec file is created.

However, if I try to create a vec file from a positive descriptive, it works well. The vec file is created anf if I check with -show option, I can see all my picture.

find positive/ -name '*.bmp' -exec echo {} 1 0 0 20 20 \; > samplesdescription.dat

opencv_createsamples -info samplesdescription.dat -vec test.vec -w 92 -h 112

Thanks for further help. Charlotte

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
1

answered 2013-08-13 02:02:57 -0600

Looking at your parameters, you are asking a tool to perform deformations on a single image, by passing it parameters like -num 1. However, looking at the docs for this process we can see that:

-num <number_of_samples> Number of positive samples to generate.

So actually this is what goes wrong. You are telling your algorithm to only make a single positive, with deformations, but that means you only have to have the original one. Try making -num 1000 and it should work.

edit flag offensive delete link more

Comments

In this case, I think I have also to add name of negative picture in my nega.txt file. For example, neg/img1.bmpneg/img2.bmpneg/img3.bmp...neg/img1000.bmp to have 1000 backgroung pictures. Is this right or wrong ?

charlottepel gravatar imagecharlottepel ( 2013-08-13 02:06:53 -0600 )edit

Actually you don't. As long as your negative file is larger than your actual face, many multiple subimages can be retrieved from it to be used as background. However I am not saying that this is a good approach, people usually use multiple 100's of negative images. But your code should work, creating samples with the same background each time. This could be the case in some specific applications, like a photo booth or so.

StevenPuttemans gravatar imageStevenPuttemans ( 2013-08-13 02:11:07 -0600 )edit

Thanks a lot, I have understand what you mean and I tried it. (Even if it's not the good approach for my application, I just want to be sure that createsamples utility is working well). If, I tried once, I have a message error > Illegal instruction (core dumped) and a file opencv_createsamples.exe.stackdump is created. Back to the start ... I have posted a comment for this problem, I thought I have fixed it in reinstalling Cygwin and OpenCV.

charlottepel gravatar imagecharlottepel ( 2013-08-13 02:23:20 -0600 )edit

I am not using cygwin so I have no idea how to work with it. So you are saying the application just crashes down? If so, there should still be a problem with the parameters. Tried debugging it?

StevenPuttemans gravatar imageStevenPuttemans ( 2013-08-13 02:31:43 -0600 )edit
1

Yes, application crashed down and I don't know how to debug it. I have searching some information about this message error on Internet. If I'm to precise (speaking about OpenCV), I don't find anything and if I just mentionned the message error, solutions don't seem to be appropriate to my problem. Maybe, I can have some information with the stackdump file but I'm not sure.

I have choose to use Cygwin to simplify my following of a tutorial which was using Cygwin, now I have some doubts about it :)

charlottepel gravatar imagecharlottepel ( 2013-08-13 02:39:13 -0600 )edit

If you are using Windows, I can only suggest using Visual Studio. Several guides on how to install openCV and run software is at the tutorials section of the docs.

StevenPuttemans gravatar imageStevenPuttemans ( 2013-08-13 03:00:58 -0600 )edit

The link doesn't seem to be correct :s I have already use Visual Studio and OpenCV to make a face trackin application on a Webcam. Can I also use it to create my vec file ?

charlottepel gravatar imagecharlottepel ( 2013-08-13 03:11:54 -0600 )edit

Updated the link, was wrong indeed. And yes you can use visual studio to create the create_samples utility. Open a new empty C++ project, add all headers and cpp files from the create_samples directory and build it. The resulting exe will be able to do it all for you.

StevenPuttemans gravatar imageStevenPuttemans ( 2013-08-13 03:19:33 -0600 )edit

Sorry, I don't know if it is because of my poor English or my poor skills or both but I'm not sure to understand. If I try to resume, you advice me to create my own createsamples.exe in writing code under Visual Studio?

charlottepel gravatar imagecharlottepel ( 2013-08-13 03:36:45 -0600 )edit

Yes, the code is already available under opencv_installation_folder/haartraining/. There you have files like createsamples.cpp, include it in a new project and build the project itself. Cannot make it more clear, I am sorry.

StevenPuttemans gravatar imageStevenPuttemans ( 2013-08-13 03:49:35 -0600 )edit

Question Tools

Stats

Asked: 2013-08-13 01:44:15 -0600

Seen: 2,929 times

Last updated: Aug 13 '13