Ask Your Question
1

OpenCV 3.1 cratesamples

asked 2016-08-22 04:11:34 -0500

danaro gravatar image

updated 2016-08-22 10:35:46 -0500

I'm trying to create a .vec file with 1200 samples as the following:

C:\opencv3\build\install\x64\vc12\bin>opencv_createsamplesd -vec vec.vec -bg tl_neg_2.txt -info tl_pos_vec_2\filenames.txt -num 1200 -maxxangle 0.1 -maxyangle 0.1 -maxzangle 0 -w 24 -h 24

EDIT: The tl_neg_2.txt (1200 objects):

 C:\opencv3\build\install\x64\vc12\bin\tl_neg\neg-0.jpg
C:\opencv3\build\install\x64\vc12\bin\tl_neg\neg-1.jpg
C:\opencv3\build\install\x64\vc12\bin\tl_neg\neg-2.jpg
C:\opencv3\build\install\x64\vc12\bin\tl_neg\neg-3.jpg
C:\opencv3\build\install\x64\vc12\bin\tl_neg\neg-4.jpg
C:\opencv3\build\install\x64\vc12\bin\tl_neg\neg-5.jpg
C:\opencv3\build\install\x64\vc12\bin\tl_neg\neg-6.jpg
C:\opencv3\build\install\x64\vc12\bin\tl_neg\neg-7.jpg
C:\opencv3\build\install\x64\vc12\bin\tl_neg\neg-8.jpg
C:\opencv3\build\install\x64\vc12\bin\tl_neg\neg-9.jpg
...

The tl_pos_vec_2\filenames.txt (27 objects):

0.jpg 1 0 0 40 40
1.jpg 1 0 0 40 40
10.jpg 1 0 0 40 40
11.jpg 1 0 0 40 40
12.jpg 1 0 0 40 40
13.jpg 1 0 0 40 40
14.jpg 1 0 0 40 40
15.jpg 1 0 0 40 40
16.jpg 1 0 0 40 40
17.jpg 1 0 0 40 40
18.jpg 1 0 0 40 40
19.jpg 1 0 0 40 40
2.jpg 1 0 0 40 40
20.jpg 1 0 0 40 40
21.jpg 1 0 0 40 40
22.jpg 1 0 0 40 40
23.jpg 1 0 0 40 40
24.jpg 1 0 0 40 40
25.jpg 1 0 0 40 40
26.jpg 1 0 0 40 40
3.jpg 1 0 0 40 40
4.jpg 1 0 0 40 40
5.jpg 1 0 0 40 40
6.jpg 1 0 0 40 40
7.jpg 1 0 0 40 40
8.jpg 1 0 0 40 40
9.jpg 1 0 0 40 40

I get:

Info file name: tl_pos_vec_2\filenames.txt
Img file name: (NULL)
Vec file name: vec.vec
BG  file name: tl_neg_2.txt
Num: 1200
BG color: 0
BG threshold: 80
Invert: FALSE
Max intensity deviation: 40
Max x angle: 0.1
Max y angle: 0.1
Max z angle: 0
Show samples: FALSE
Width: 24
Height: 24
Max Scale: -1
Create training samples from images collection...
tl_pos_vec_2\filenames.txt(28) : parse errorDone. Created 27 samples

So instead of 1200 samples I get a .vec file containing only 27, what should I do to fix this problem?

Thank you, Dan.

edit retag flag offensive close merge delete

Comments

so, it did not find your negatives. try an absolute path for the images in the text file.

berak gravatar imageberak ( 2016-08-22 07:06:07 -0500 )edit

Ok, I did that, But I still get the same result

danaro gravatar imagedanaro ( 2016-08-22 08:48:38 -0500 )edit

"tl_pos_vec_2\filenames.txt(28) : parse errorDone. Created 27 samples"

well, .... there is something weird on line 28.

berak gravatar imageberak ( 2016-08-22 08:51:36 -0500 )edit
1

also, please use single forward, not backward slashes.

berak gravatar imageberak ( 2016-08-22 08:52:53 -0500 )edit

I posted the whole filenames text file, there is no 28th line.

danaro gravatar imagedanaro ( 2016-08-22 10:36:23 -0500 )edit

it might be something, you don't see (in your editor)

berak gravatar imageberak ( 2016-08-22 10:40:39 -0500 )edit

I viewed the file with Visual Studio and there is no line but the 27th. BTW, I use opencv_createsamplesd which seems a bit weird not like in the previous 2.3.14 version where it was opencv_createsamples

danaro gravatar imagedanaro ( 2016-08-22 10:55:59 -0500 )edit

the d at the end means, you're using the debug version

berak gravatar imageberak ( 2016-08-22 11:03:45 -0500 )edit

Could it help if I build OpenCV in the release version?

danaro gravatar imagedanaro ( 2016-08-22 11:05:38 -0500 )edit

unlikely. the debug version is the same code. your problems are unrelated.

berak gravatar imageberak ( 2016-08-22 11:20:40 -0500 )edit

1 answer

Sort by » oldest newest most voted
0

answered 2016-08-23 06:54:58 -0500

Please take a look at the documentation and tutorial on training OpenCV models using cascade classifiers. Basically you need to choose to either, provide the images as a list of images, and then magically generate positives from that OR you decide to give it a file with the exact locations of objects and only retrieve those.

You file clearly indicates you want the second approach, telling the application that you want 1200 positives while you only have 28 image names there with literally 1 bounding box, so it continous and tries to read the following line, which is not there and just crashes.

So please, read again the tutorial. For now you can even use the updated version, which is still under reviewing!

edit flag offensive delete link more

Comments

Sir, I read the documentation and it says:

-num <number_of_samples>

Number of positive samples to generate.

So 1200 is a valid declaration, moreover, I have 1200 negatives.

danaro gravatar imagedanaro ( 2016-08-23 11:03:18 -0500 )edit

@danaro, please read again ... you are mixing interfaces. the -info interface is used, which does not cope with -maxangle parameter. Instead you need the -img parameter!

StevenPuttemans gravatar imageStevenPuttemans ( 2016-08-24 04:40:11 -0500 )edit
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2016-08-22 04:11:34 -0500

Seen: 208 times

Last updated: Aug 23 '16