OpenCV Invalid background description file

前端 未结 5 980
长情又很酷
长情又很酷 2021-01-27 10:54

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

相关标签:
5条回答
  • 2021-01-27 11:04

    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

    0 讨论(0)
  • 2021-01-27 11:05

    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.

    0 讨论(0)
  • 2021-01-27 11:13

    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!

    0 讨论(0)
  • 2021-01-27 11:13

    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.

    0 讨论(0)
  • 2021-01-27 11:18

    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
    
    0 讨论(0)
提交回复
热议问题