combine a transparent background image in png format with jpg images using opencv_createsamples
up vote
0
down vote
favorite
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 :
- img.png contains a hand with a transparent background
- bg2.txt list of negative jpg images (or background )
- info is the folder where all the samples will be created
- info.lst is a file that contains the image path and the position(s) and number of the positive image(s) in each one
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 ?
thanks for your help
opencv png image-recognition
add a comment |
up vote
0
down vote
favorite
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 :
- img.png contains a hand with a transparent background
- bg2.txt list of negative jpg images (or background )
- info is the folder where all the samples will be created
- info.lst is a file that contains the image path and the position(s) and number of the positive image(s) in each one
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 ?
thanks for your help
opencv png image-recognition
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
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 :
- img.png contains a hand with a transparent background
- bg2.txt list of negative jpg images (or background )
- info is the folder where all the samples will be created
- info.lst is a file that contains the image path and the position(s) and number of the positive image(s) in each one
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 ?
thanks for your help
opencv png image-recognition
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 :
- img.png contains a hand with a transparent background
- bg2.txt list of negative jpg images (or background )
- info is the folder where all the samples will be created
- info.lst is a file that contains the image path and the position(s) and number of the positive image(s) in each one
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 ?
thanks for your help
opencv png image-recognition
opencv png image-recognition
edited Nov 9 at 13:03
asked Nov 9 at 10:49
otmane42
185
185
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
up vote
1
down vote
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.
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
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.
add a comment |
up vote
1
down vote
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.
add a comment |
up vote
1
down vote
up vote
1
down vote
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.
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.
answered Nov 9 at 13:29
sietschie
5,19322446
5,19322446
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53224262%2fcombine-a-transparent-background-image-in-png-format-with-jpg-images-using-openc%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown