When I try using this Command: opencv_createsamples -img image.jpg -bg bg.txt -info /info/info.lst -pngoutput info -num 2600
it tells me: Invalid background descrip
I was experiencing the same problem and it was very frustrating. But now it's solved.
1) CTRL + A ; CTRL + C;
on your background description file to copy all it's content.
2) Create a new background description file (e.g.: bg2.txt), and CTRL + V
to paste all the content you copied. Save it.
3) Run your command again, using, of course, the new bg description file (-bg bg2.txt).
It worked for me and might work for you.
Cheers,
Geraldo Neto
I had the same problem and tried many different things (adding full path names in the bg.txt, convert to UTF-8,...) - which resulted in getting slightly different looking errors - but still, no success. I am following this tutorial - and I am preparing all the files on my windows laptop & then pushing them to a ubuntu server.
Then I read it might be caused by difference in line ending (CLRF and LF) and checked my file (on the ubuntu server):
$ file bg.txt
bg.txt: UTF-8 Unicode (with BOM) text, with CRLF line terminators
I converted the file from dos2unix:
$ sudo apt install dos2unix
$ dos2unix bg.txt
dos2unix: converting file bg.txt to Unix format ...
$ file bg.txt
bg.txt: ASCII text
And now the opencv_createsamples command worked.
I had the exact same problem. I tried changing the bg.txt
encoding and it made no difference. I deleted all instances of OpenCV on my Ubuntu server and rebooted. I typed:
git clone https://github.com/Itseez/opencv.git
into the terminal.
Once downloaded, rebooted the server and proceeded with:
opencv_createsamples -img image.jpg -bg bg.txt -info /info/info.lst -pngoutput info -num 1500
That seemed to fix my "Invalid background description file" error.
Bear in mind that I tried to create a new folder and add a fresh download of OpenCV to use on a separate project and it just copied my existing file.
Delete all instances of the OpenCV folder before rebooting and redownloading it!
On Linux (Ubuntu) adding one more empty line doe snot work. File was in utf-8 encoding. Resolved with converting from "linux" to "dos" line ending format.
I had this problem too and I solved it by changing encoding of my bg.txt to UTF-8. Also, my file looks like:
neg/1.jpg
neg/2.jpg