when i run opencv_createsamples command on ubuntu server it says "invalid background file". Please help
my bg.txt file contains paths like :-
neg/1.jpg neg/2.jpg
etc
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)
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.
@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.
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?And also make an absolute path for
-img
parameter! That is the one screwing stuff up!@StevenPuttemans i tried using absolute paths everywhere necessary, still it's of no use :(
Well there is also a typo
-pngoutput info
. Thatinfo
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.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
Can you replace info by again an absolute path. No the tool works just fine on ubuntu in my case!
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