Reputation: 643
I'm currently working on a project that consist of detecting a hand in a given image using OpenCV commands,and due to lack of positive images, I tried to create them artificially with the command opencv_createsamples, the background images (or negative images ) are in .jpg
format, and my positive one is in .png
format with a transparent background, the expected result should be something like:
but what I got after running this command:
opencv_createsamples -img pos2/img.png -bg bg2.txt -info info/info.lst -pnginput info -maxxangle 0.5 -maxyangle 0.5 -maxzangle 0.5 -num 405
where :
was:
as you can see, the positive image still have a white background, and there's no transparency as expected (the image is small because it's a 100x100 and the positive one is 50x50).
My question is, is there a way to get a result similar to the first image using the command opencv_createsamples?
Upvotes: 0
Views: 384
Reputation: 7543
I quickly grepped through the source code of the function that is (I think) used:
https://github.com/opencv/opencv/blob/master/apps/createsamples/utility.cpp
What you can see there is that everytime imread
is called the second parameter is IMREAD_GRAYSCALE
. This means whatever the source image format is it will always be converted to grayscale. If there is an alpha channel present in the image it gets discarded.
So I think given this information it is not possible to get the result you want with this function.
Upvotes: 1