when i run opencv_createsamples command on ubuntu server it says "invalid background file". Please help

asked 2016-07-27 02:52:52 -0500

updated 2016-07-27 03:20:47 -0500

berak gravatar image

my bg.txt file contains paths like :-

neg/1.jpg neg/2.jpg


edit retag flag offensive close merge delete



please show us your complete cmdline.

(also, always use an absolute path for filenames in bg.txt, info.txt, and also the txt files on the cmdline)

berak gravatar imageberak ( 2016-07-27 03:06:49 -0500 )edit

If it says invalid background file, then it was not able to open the image file, as seen on this line of code. So like @berak said, this is solved by using absolute paths, probably the file is not on the exact relative position to the executable. This isssue is avoided with absolute paths.

StevenPuttemans gravatar imageStevenPuttemans ( 2016-07-27 03:18:00 -0500 )edit

@berak and @StevenPuttemans command i'm using is "opencv_createsamples -img original.jpg -bg bg.txt -info info/info.lst -pngoutput info -maxxangle 0.5 -maxyangle 0.5 -maxzangle 0.5 -num 2000"

and i tried using absolute paths in bg.txt file such as /home/ubuntu/opencv_dir/neg/1.jpg

still facing the same issue.

akumar6 gravatar imageakumar6 ( 2016-07-27 03:44:41 -0500 )edit

Can you do a eog /home/ubuntu/opencv_dir/neg/1.jpg at the location of your executable and check whether the image opens up?

StevenPuttemans gravatar imageStevenPuttemans ( 2016-07-27 03:54:33 -0500 )edit

And also make an absolute path for -img parameter! That is the one screwing stuff up!

StevenPuttemans gravatar imageStevenPuttemans ( 2016-07-27 03:55:52 -0500 )edit

@StevenPuttemans i tried using absolute paths everywhere necessary, still it's of no use :(

akumar6 gravatar imageakumar6 ( 2016-07-28 01:51:07 -0500 )edit

Well there is also a typo -pngoutput info. That info should not be there. Can you remove it and try again? Also provide your new complete command and content of your files by editing the question.

StevenPuttemans gravatar imageStevenPuttemans ( 2016-07-28 03:18:51 -0500 )edit

that info is the directory where i want to send my positive images created by merging original.jpg and negative images. Also, I tried same thing on CentOS. Command worked fine there and it created samples. Can it be because of the platform ??? @StevenPuttemans

akumar6 gravatar imageakumar6 ( 2016-07-28 04:40:54 -0500 )edit

Can you replace info by again an absolute path. No the tool works just fine on ubuntu in my case!

StevenPuttemans gravatar imageStevenPuttemans ( 2016-07-28 09:13:16 -0500 )edit

command worked. I used python script to create the bg.txt file and it was, I'm guessing, inserting some character which is normally not visible after every new line statement and hence opencv was failing to read it. I manually created the bg.txt with VI editer on server itself by putting in location of 10 images and it worked. That way i automated the process for all images and it is working fine.

thanks a lot for your time and support, @StevenPuttemans

akumar6 gravatar imageakumar6 ( 2016-07-29 06:20:33 -0500 )edit