opencv_createsample: free(): invalid next size (normal):
Hello there,
Not sure how to get around this. I'm trying to use opencv_create sample, but seems like it tries to free an already fred pointer.
I'm using self-compiled opencv 4.0.0-pre (got this using opencv_version).
This is the complete output:
*** Error in `opencv_createsamples': free(): invalid next size (normal): 0x0000000000821460 ***
======= Backtrace: =========
/lib/x86_64-linux-gnu/libc.so.6(+0x777e5)[0x7f9ccfe897e5]
/lib/x86_64-linux-gnu/libc.so.6(+0x8037a)[0x7f9ccfe9237a]
/lib/x86_64-linux-gnu/libc.so.6(cfree+0x4c)[0x7f9ccfe9653c]
/lib/x86_64-linux-gnu/libc.so.6(+0x6dd5d)[0x7f9ccfe7fd5d]
/home/federico/.opencv/opencv/build/lib/libopencv_imgcodecs.so.4.0(+0x4c86d)[0x7f9cd42bb86d]
/home/federico/.opencv/opencv/build/lib/libopencv_imgcodecs.so.4.0(+0x4d2a1)[0x7f9cd42bc2a1]
/home/federico/.opencv/opencv/build/lib/libopencv_imgcodecs.so.4.0(_ZN2cv6imreadERKNS_6StringEi+0xb3)[0x7f9cd42bdfb3]
opencv_createsamples[0x40448a]
opencv_createsamples[0x40ba9c]
opencv_createsamples[0x402040]
/lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xf0)[0x7f9ccfe32830]
opencv_createsamples[0x4026c9]
======= Memory map: ========
....
....
....
Aborted
Using GDB:
Program received signal SIGABRT, Aborted.
0x00007ffff2e2c428 in __GI_raise (sig=sig@entry=6)
at ../sysdeps/unix/sysv/linux/raise.c:54
54 ../sysdeps/unix/sysv/linux/raise.c: No such file or directory.
(gdb) bt
#0 0x00007ffff2e2c428 in __GI_raise (sig=sig@entry=6)
at ../sysdeps/unix/sysv/linux/raise.c:54
#1 0x00007ffff2e2e02a in __GI_abort () at abort.c:89
#2 0x00007ffff2e6e7ea in __libc_message (do_abort=do_abort@entry=2,
fmt=fmt@entry=0x7ffff2f87ed8 "*** Error in `%s': %s: 0x%s ***\n")
at ../sysdeps/posix/libc_fatal.c:175
#3 0x00007ffff2e7737a in malloc_printerr (ar_ptr=<optimized out>,
ptr=<optimized out>, str=0x7ffff2f88030 "free(): invalid next size (normal)",
action=3) at malloc.c:5006
#4 _int_free (av=<optimized out>, p=<optimized out>, have_lock=0) at malloc.c:3867
#5 0x00007ffff2e7b53c in __GI___libc_free (mem=<optimized out>) at malloc.c:2968
#6 0x00007ffff2e64d5d in __fopen_internal (filename=0x63e484 "neg/2014.jpg\r",
mode=0x7ffff75ac9c8 "rb", is32=1) at iofopen.c:90
#7 0x00007ffff72a086d in cv::findDecoder(cv::String const&) ()
from /home/federico/.opencv/opencv/build/lib/libopencv_imgcodecs.so.4.0
#8 0x00007ffff72a12a1 in cv::imread_(cv::String const&, int, int, cv::Mat*) ()
from /home/federico/.opencv/opencv/build/lib/libopencv_imgcodecs.so.4.0
#9 0x00007ffff72a2fb3 in cv::imread(cv::String const&, int) ()
from /home/federico/.opencv/opencv/build/lib/libopencv_imgcodecs.so.4.0
#10 0x000000000040448a in icvGetNextFromBackgroundData(CvBackgroundData*, CvBackgroundReader*) ()
#11 0x000000000040ba9c in cvCreateTestSamples(char const*, char const*, int, int, char---Type <return> to continue, or q <return> to quit---
The command I'm trying to run is: opencv_createsamples -img watch5050.jpg -bg bg.txt -info info/info.lst -pngoutput info -maxxangle 0.5 -maxyangle 0.5 -maxzangle 0.5 -num 1950
(from: https://pythonprogramming.net/haar-ca... - so I'm using the dataset from the article)
Any suggestion on how to get around this?
"neg/2014.jpg\r"
<-- do you see the\r
there ? unlikely, that it should be there.apart from that, use a debug build, so you can dive into findDecoder() and such with gdb.
Hello and thanks for the comment! I also saw that, but there is no-where, neither in the bg.txt nor in the filename so I'm not sure why there is that char there.
well it is there. no ?
and a usual text editor probably won't show it.
btw, that tutorial is shite. in the end he can't detect his watch properly, because the idea of using only 1 positive image, and generating more from it NEVER works in real life. (you still have only 1 image)
get a TON of real positives (~10k for propfessional results) , anything else is a plain waste of (anyone's) time.
you wouldn't believe, how many crap tutorials like that are out there, and how many folks fell into the same trap
hey berak! Thanks a lot for the last comment, I do really appreciate it. In fact, I've used some custom images and the tool is working fine. Still, this error is strange. I've checked the bg.txt file with vim and run :%s/\r// but couldn't find any match. For the filename, I've used ls -lab but didn't find anything. So yeah, it's strange, but since it's working on my own dataset I guess it's cool for me. Thanks a lot
My guess, you must have an image path in your annotations file (the one needed for createsamples), that is incorrect, because I just tested the whole pipeline (opencv_annotation, opencv_createsamples, opencv_traincascade) and everythin runs just fine.