Convert an IplImage to SDL_Surface with single nChannals
How to convert an IpLImage to SDL_Surface.
I used this post
to convert an image with 8 nChannels and it worked perfectly, but when I try this with an image of a single nChannel it displays the following message on the console:
Depth 8, nChannels 1, pitch 640
Unable to convert the IplImage image ! SDL Error: Unknown pixel format
And this is the code I used :
int pitch = colored_capture->nChannels * colored_capture->width;
printf("Depth %d, nChannels %d, pitch %dn", colored_capture->depth,
colored_capture->nChannels, pitch);
surface_1 = SDL_CreateRGBSurfaceFrom((void*)colored_capture->imageData,
colored_capture->width,
colored_capture->height,
colored_capture->depth * colored_capture->nChannels,
colored_capture->widthStep,
0x0000ff, 0x00ff00, 0xff0000, 0);
if (surface_1 == NULL)
{
fprintf ( stderr ,"Unable to convert the IplImage image ! SDL
Error: %s n", SDL_GetError());
}
c opencv sdl sdl-2 iplimage
|
show 2 more comments
How to convert an IpLImage to SDL_Surface.
I used this post
to convert an image with 8 nChannels and it worked perfectly, but when I try this with an image of a single nChannel it displays the following message on the console:
Depth 8, nChannels 1, pitch 640
Unable to convert the IplImage image ! SDL Error: Unknown pixel format
And this is the code I used :
int pitch = colored_capture->nChannels * colored_capture->width;
printf("Depth %d, nChannels %d, pitch %dn", colored_capture->depth,
colored_capture->nChannels, pitch);
surface_1 = SDL_CreateRGBSurfaceFrom((void*)colored_capture->imageData,
colored_capture->width,
colored_capture->height,
colored_capture->depth * colored_capture->nChannels,
colored_capture->widthStep,
0x0000ff, 0x00ff00, 0xff0000, 0);
if (surface_1 == NULL)
{
fprintf ( stderr ,"Unable to convert the IplImage image ! SDL
Error: %s n", SDL_GetError());
}
c opencv sdl sdl-2 iplimage
If it is only 8 bits per pixel, why masks describe it as 24 bit? What is your source data? Is it grayscale? Indexed? In what format do you want to get your resulting surface?
– keltar
Nov 19 '18 at 19:00
I applied theCannyEdgeFilter
on a image captured by a camera and when I tried to convert it toSDL_Surface
with the code appove, it didn't work.
– SenDjasni
Nov 20 '18 at 16:31
..which creates grayscale image, as I had to google just now. Still no indication of what you need SDL surface for, and what format should it have. If you really don't care (can't imagine why), take a look at e.g. stackoverflow.com/questions/27204397/greyscale-image-in-sdl2
– keltar
Nov 20 '18 at 17:44
well, I need to visualize two images, the original one and another that I will apply some CV processing on it, and all that using only low-level library, that why I chose SDL. For the format, I think it doesn't matter cuz all I do is visualization.
– SenDjasni
Nov 20 '18 at 20:43
@keltar what do you think about using Gtk instead of SDL ?
– SenDjasni
Nov 24 '18 at 17:50
|
show 2 more comments
How to convert an IpLImage to SDL_Surface.
I used this post
to convert an image with 8 nChannels and it worked perfectly, but when I try this with an image of a single nChannel it displays the following message on the console:
Depth 8, nChannels 1, pitch 640
Unable to convert the IplImage image ! SDL Error: Unknown pixel format
And this is the code I used :
int pitch = colored_capture->nChannels * colored_capture->width;
printf("Depth %d, nChannels %d, pitch %dn", colored_capture->depth,
colored_capture->nChannels, pitch);
surface_1 = SDL_CreateRGBSurfaceFrom((void*)colored_capture->imageData,
colored_capture->width,
colored_capture->height,
colored_capture->depth * colored_capture->nChannels,
colored_capture->widthStep,
0x0000ff, 0x00ff00, 0xff0000, 0);
if (surface_1 == NULL)
{
fprintf ( stderr ,"Unable to convert the IplImage image ! SDL
Error: %s n", SDL_GetError());
}
c opencv sdl sdl-2 iplimage
How to convert an IpLImage to SDL_Surface.
I used this post
to convert an image with 8 nChannels and it worked perfectly, but when I try this with an image of a single nChannel it displays the following message on the console:
Depth 8, nChannels 1, pitch 640
Unable to convert the IplImage image ! SDL Error: Unknown pixel format
And this is the code I used :
int pitch = colored_capture->nChannels * colored_capture->width;
printf("Depth %d, nChannels %d, pitch %dn", colored_capture->depth,
colored_capture->nChannels, pitch);
surface_1 = SDL_CreateRGBSurfaceFrom((void*)colored_capture->imageData,
colored_capture->width,
colored_capture->height,
colored_capture->depth * colored_capture->nChannels,
colored_capture->widthStep,
0x0000ff, 0x00ff00, 0xff0000, 0);
if (surface_1 == NULL)
{
fprintf ( stderr ,"Unable to convert the IplImage image ! SDL
Error: %s n", SDL_GetError());
}
c opencv sdl sdl-2 iplimage
c opencv sdl sdl-2 iplimage
edited Nov 19 '18 at 18:33
asked Nov 19 '18 at 14:22
SenDjasni
3810
3810
If it is only 8 bits per pixel, why masks describe it as 24 bit? What is your source data? Is it grayscale? Indexed? In what format do you want to get your resulting surface?
– keltar
Nov 19 '18 at 19:00
I applied theCannyEdgeFilter
on a image captured by a camera and when I tried to convert it toSDL_Surface
with the code appove, it didn't work.
– SenDjasni
Nov 20 '18 at 16:31
..which creates grayscale image, as I had to google just now. Still no indication of what you need SDL surface for, and what format should it have. If you really don't care (can't imagine why), take a look at e.g. stackoverflow.com/questions/27204397/greyscale-image-in-sdl2
– keltar
Nov 20 '18 at 17:44
well, I need to visualize two images, the original one and another that I will apply some CV processing on it, and all that using only low-level library, that why I chose SDL. For the format, I think it doesn't matter cuz all I do is visualization.
– SenDjasni
Nov 20 '18 at 20:43
@keltar what do you think about using Gtk instead of SDL ?
– SenDjasni
Nov 24 '18 at 17:50
|
show 2 more comments
If it is only 8 bits per pixel, why masks describe it as 24 bit? What is your source data? Is it grayscale? Indexed? In what format do you want to get your resulting surface?
– keltar
Nov 19 '18 at 19:00
I applied theCannyEdgeFilter
on a image captured by a camera and when I tried to convert it toSDL_Surface
with the code appove, it didn't work.
– SenDjasni
Nov 20 '18 at 16:31
..which creates grayscale image, as I had to google just now. Still no indication of what you need SDL surface for, and what format should it have. If you really don't care (can't imagine why), take a look at e.g. stackoverflow.com/questions/27204397/greyscale-image-in-sdl2
– keltar
Nov 20 '18 at 17:44
well, I need to visualize two images, the original one and another that I will apply some CV processing on it, and all that using only low-level library, that why I chose SDL. For the format, I think it doesn't matter cuz all I do is visualization.
– SenDjasni
Nov 20 '18 at 20:43
@keltar what do you think about using Gtk instead of SDL ?
– SenDjasni
Nov 24 '18 at 17:50
If it is only 8 bits per pixel, why masks describe it as 24 bit? What is your source data? Is it grayscale? Indexed? In what format do you want to get your resulting surface?
– keltar
Nov 19 '18 at 19:00
If it is only 8 bits per pixel, why masks describe it as 24 bit? What is your source data? Is it grayscale? Indexed? In what format do you want to get your resulting surface?
– keltar
Nov 19 '18 at 19:00
I applied the
CannyEdgeFilter
on a image captured by a camera and when I tried to convert it to SDL_Surface
with the code appove, it didn't work.– SenDjasni
Nov 20 '18 at 16:31
I applied the
CannyEdgeFilter
on a image captured by a camera and when I tried to convert it to SDL_Surface
with the code appove, it didn't work.– SenDjasni
Nov 20 '18 at 16:31
..which creates grayscale image, as I had to google just now. Still no indication of what you need SDL surface for, and what format should it have. If you really don't care (can't imagine why), take a look at e.g. stackoverflow.com/questions/27204397/greyscale-image-in-sdl2
– keltar
Nov 20 '18 at 17:44
..which creates grayscale image, as I had to google just now. Still no indication of what you need SDL surface for, and what format should it have. If you really don't care (can't imagine why), take a look at e.g. stackoverflow.com/questions/27204397/greyscale-image-in-sdl2
– keltar
Nov 20 '18 at 17:44
well, I need to visualize two images, the original one and another that I will apply some CV processing on it, and all that using only low-level library, that why I chose SDL. For the format, I think it doesn't matter cuz all I do is visualization.
– SenDjasni
Nov 20 '18 at 20:43
well, I need to visualize two images, the original one and another that I will apply some CV processing on it, and all that using only low-level library, that why I chose SDL. For the format, I think it doesn't matter cuz all I do is visualization.
– SenDjasni
Nov 20 '18 at 20:43
@keltar what do you think about using Gtk instead of SDL ?
– SenDjasni
Nov 24 '18 at 17:50
@keltar what do you think about using Gtk instead of SDL ?
– SenDjasni
Nov 24 '18 at 17:50
|
show 2 more comments
0
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
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%2f53376641%2fconvert-an-iplimage-to-sdl-surface-with-single-nchannals%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
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%2f53376641%2fconvert-an-iplimage-to-sdl-surface-with-single-nchannals%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
If it is only 8 bits per pixel, why masks describe it as 24 bit? What is your source data? Is it grayscale? Indexed? In what format do you want to get your resulting surface?
– keltar
Nov 19 '18 at 19:00
I applied the
CannyEdgeFilter
on a image captured by a camera and when I tried to convert it toSDL_Surface
with the code appove, it didn't work.– SenDjasni
Nov 20 '18 at 16:31
..which creates grayscale image, as I had to google just now. Still no indication of what you need SDL surface for, and what format should it have. If you really don't care (can't imagine why), take a look at e.g. stackoverflow.com/questions/27204397/greyscale-image-in-sdl2
– keltar
Nov 20 '18 at 17:44
well, I need to visualize two images, the original one and another that I will apply some CV processing on it, and all that using only low-level library, that why I chose SDL. For the format, I think it doesn't matter cuz all I do is visualization.
– SenDjasni
Nov 20 '18 at 20:43
@keltar what do you think about using Gtk instead of SDL ?
– SenDjasni
Nov 24 '18 at 17:50