Ask Your Question

createsamples.exe crashing

asked 2013-04-02 22:20:23 -0600

RBishnoi gravatar image

I am trying to create samples through createsamples.exe. But I am able to generate samples for smaller value of num (num< 20). It crashes for higher values(num>20). I am running this utility with these args:

-vec "D:\train.vec" -img "D:\object.png" -bg "D:\files.txt" -maxxangle 0 -maxyangle 0 -maxzangle 0 -maxidev 100 -bgcolor 0 -bgthresh 0 -w 4960 -h 3506 - num 50

object.png is of 4644*342 size in pixels.

I am getting this exception:

Unhandled exception at 0x000000013FCBB284 in opencv_createsamples.exe: 0xC0000005: Access violation reading location 0x0000000002AB4000.

While debugging, getting exception in line no. (340 or 345) in cvsamples.cpp inside function void cvWarpPerspective( CvArr* src, CvArr* dst, double quad[4][2] ). The value of src_step at the time of exception is 4644.

if( isrc_x >= 0 && isrc_x <= src_size.width && //line no. 337 isrc_y >= -1 && isrc_y < src_size.height ) //line no. 338 { i01 = s[src_step]; // line no. 340 }

if( isrc_x >= -1 && isrc_x < src_size.width && // line no.342 isrc_y >= -1 && isrc_y < src_size.height ) // line no. 343 { i11 = s[src_step+1]; // line no. 345 }

It is also giving the same exception when giving non zero values of max?angle. Is there any issue in the way I am using this utility or is there any issue with the code? Using OpenCv 2.4.9 (src code 30th March build with TBB).

Thanks for any help!!

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted

answered 2013-04-03 02:36:27 -0600

Actually your first mistake is the image size, using images for the createsamples utility of such a large resolution is just asking for memory problems. Expecially if you consider that each of the created images is stored into memory.

--> instead of using -w 4960 -h 3506 try to reduce your image to a reasonable size. Expecially if you know that training depends on size of createsamples vector, and gets stuck easily with sizes larger than 100x100 pixels. I suggest dividing your image size by 100, giving you a 50 x 35 pixel image size.

Also, the createsamples does require you to give degrees of freedom. You do not allow it to actually rotate the image in any dimension. Then how do you expect it to create random samples if no randomness is added?

--> adapt these parameters : -maxxangle 0 -maxyangle 0 -maxzangle 0

Also if you are planning to create an object detector, the createsamples utility will yield terrible result. It is better to actually capture a set of object images under all kinds of circumstances (lighting, orientation, position) and use a annotation file (containing location of objects in input images) to create your sample vector.

edit flag offensive delete link more


Thanks Steven!! The image size in which i have to detect is 4960 * 3506. So I gave these values. When I gave small values, the sample images that are generated have unreasonable object to imagescene ratio which is never going to occur. This may be a reason why the createsamples utility does not give accurate results. I need to know one more thing. Should the size of the object image file (which is 4644*342) be also reduced? As you said, I will run with set of already marked images. I am new to opencv and i would like to know how many marked images should I consider for proper object detection? The scene image files are expected to be noisy...will this method be able to detect object correctly? Big Thanks!!

RBishnoi gravatar imageRBishnoi ( 2013-04-03 03:29:41 -0600 )edit

Ok some more guidance is needed here

  • You need to cut out your objects from your original images and resize these. The createsamples size will eventually define the smallest object that you can detect in your image of that class.

  • If you cut them out, there is not ration between object and background. Background should be sampled by images in the background file, containing no actual objects.

  • I have the idea that you are trying object detection without the proper guidance of a tutorial. Read through the following link, which explains everything for the old haartraining, but it is still usefull for the newer traincascade method : or

StevenPuttemans gravatar imageStevenPuttemans ( 2013-04-03 03:35:09 -0600 )edit

Question Tools


Asked: 2013-04-02 22:20:23 -0600

Seen: 1,126 times

Last updated: Apr 03 '13