Runtime error with opencv_createsamples

asked 2013-07-26 06:43:19 -0500

Hemu gravatar image

updated 2013-07-29 07:36:56 -0500

I am trying to create samples for cascade classifier training using opencv_createsamples. I used the following command:

 ./OpenCV-2.4.1/build/bin/opencv_createsamples -vec lab_object.vec -img symbol.jpg -bg bg_lab.txt -num 1000 -maxidev 30 -maxxangle 0.2616 -maxyangle 0.2616 -maxzangle 3.1417 -w 24 -h 24 -show

But I am getting the following output on the console along with the error:

Info file name: (NULL)
Img file name: symbol.jpg
Vec file name: lab_object.vec
BG  file name: bg_lab.txt
Num: 1000
BG color: 0
BG threshold: 80
Invert: FALSE
Max intensity deviation: 30
Max x angle: 0.2616
Max y angle: 0.2616
Max z angle: 3.1417
Show samples: TRUE
Scale: 4
Width: 24
Height: 24
Create training samples from single image applying distortions...
*** glibc detected *** ./OpenCV-2.4.1/build/bin/opencv_createsamples: free(): corrupted unsorted chunks: 0x09237e90 ***
*** glibc detected *** ./OpenCV-2.4.1/build/bin/opencv_createsamples: malloc(): memory corruption: 0x0923ad00 ***

I am using OpenCV-2.4.1on Ubuntu 12.04. I tried again by installing a newer version of Opencv. But I am still getting the same error while using opencv_createsamples.

I have also used valgrind to check if there is any problem with memory allocation and deallocation. I got the following result (I do not know how to interpret the result):

==14471== Invalid write of size 1
==14471==    at 0x402C6C3: strcpy (in /usr/lib/valgrind/vgpreload_memcheck-x86-linux.so)
==14471==    by 0x804B3C5: icvCreateBackgroundData(char const*, CvSize) (in /home/hemu/opencv/build/bin/opencv_createsamples)
==14471==    by 0x804B4DA: icvInitBackgroundReaders(char const*, CvSize) (in /home/hemu/opencv/build/bin/opencv_createsamples)
==14471==    by 0x804F938: cvCreateTrainingSamples(char const*, char const*, int, int, char const*, int, int, int, double, double, double, int$
==14471==    by 0x804AE58: main (in /home/hemu/opencv/build/bin/opencv_createsamples)
==14471==  Address 0x76e80d8 is 0 bytes after a block of size 11,520 alloc'd
==14471==    at 0x402BE68: malloc (in /usr/lib/valgrind/vgpreload_memcheck-x86-linux.so)
==14471==    by 0x414F598: cv::fastMalloc(unsigned int) (in /home/hemu/opencv/build/lib/libopencv_core.so.2.9.0)
==14471==    by 0x414F66A: cvAlloc (in /home/hemu/opencv/build/lib/libopencv_core.so.2.9.0)
==14471==    by 0x804B2F9: icvCreateBackgroundData(char const*, CvSize) (in /home/hemu/opencv/build/bin/opencv_createsamples)
==14471==    by 0x804B4DA: icvInitBackgroundReaders(char const*, CvSize) (in /home/hemu/opencv/build/bin/opencv_createsamples)
==14471==    by 0x804F938: cvCreateTrainingSamples(char const*, char const*, int, int, char const*, int, int, int, double, double, double, int$
==14471==    by 0x804AE58: main (in /home/hemu/opencv/build/bin/opencv_createsamples)
==14471==
==14471== Invalid write of size 1
==14471==    at 0x402C6E8: strcpy (in /usr/lib/valgrind/vgpreload_memcheck-x86-linux.so)
==14471==    by 0x804B3C5: icvCreateBackgroundData(char const*, CvSize) (in /home/hemu/opencv/build/bin/opencv_createsamples)
==14471==    by 0x804B4DA: icvInitBackgroundReaders(char const*, CvSize) (in /home/hemu/opencv/build/bin/opencv_createsamples)
==14471==    by 0x804F938: cvCreateTrainingSamples(char const*, char const*, int, int, char const*, int, int, int, double, double, double, int$
==14471==    by 0x804AE58: main (in /home/hemu/opencv/build/bin/opencv_createsamples)
==14471==  Address 0x76e80eb is not stack'd, malloc'd or (recently) free'd
--14471-- VALGRIND INTERNAL ERROR: Valgrind received a ...
(more)
edit retag flag offensive close merge delete

Comments

Can you try to it on a different image. Sometimes CreateSamples doesn't work on some images (may be corrupt headers?).

vinayverma gravatar imagevinayverma ( 2013-08-04 01:11:13 -0500 )edit

I tried it with two other images but the same result. However, the problem was solved using DieHard (a software for error resistant memory allocation). The problem is that I had used the program two months ago without any error but now I am unable to understand the reason of the error.

Hemu gravatar imageHemu ( 2013-08-05 13:13:10 -0500 )edit

opencv_createsamples -img fruits_image.jpg -bg bg.txt -info info/info.lst -pngoutput info -maxxangle 0.5 -maxyangle 0.5 -maxzangle 0.5 -num 1950

i have the same problem, i changed other image but i still get the same error: Create test samples from single image applying distortions... * Error in `opencv_createsamples': free(): corrupted unsorted chunks: 0x0000000002432090 *

can anyone help me please??

wael1992 gravatar imagewael1992 ( 2018-04-03 04:57:14 -0500 )edit