Log in or register to post comments

getPixels() crashes my program

April 4, 2012 - 6:32am #1

I'm trying to access the pixel array of the video frame captured,
my code goes like this:

QCAR::Frame f = state.getFrame();

const QCAR::Image* image = f.getImage(1); // get the grayscale image

const char* data = (const char*) image->getPixels();

the line with the getPixels() crashes my program,
and I have absolutely no error messages,
could anyone please shed some light on this?

Re: getPixels() crashes my program

April 5, 2012 - 3:46pm #5

You can set the video mode to MODE_DEFAULT, MODE_OPTIMIZE_SPEED, or MODE_OPTIMIZE_QUALITY. Search for the following in the native file:

QCAR::CameraDevice::MODE_DEFAULT

The results of this are device-specific, depending on the resolutions the camera supports. On some devices it may not have any effect.

- Kim

Re: getPixels() crashes my program

April 4, 2012 - 10:20pm #4
ksiva wrote:

Looking at your code again though, you're using the getImage method improperly. You need to cycle through all the images and check the format. There may not be an image at index 1 (you're passing the index into the images array, not the format type).

Also check that the image is not null before using it (better than crashing the app).

- Kim

that's it,
you save my day,
the problem is due to accessing a null image pointer.
for those need to access the captured frame, you should do this:
for ( int i = 0; i {
const QCAR::Image* image = frame.getImage(i);
....
}

yet another question,
is there absolutely no way to control the resolution of the frame?
thank you so much!

Re: getPixels() crashes my program

April 4, 2012 - 3:46pm #3

Looking at your code again though, you're using the getImage method improperly. You need to cycle through all the images and check the format. There may not be an image at index 1 (you're passing the index into the images array, not the format type).

Also check that the image is not null before using it (better than crashing the app).

- Kim

Re: getPixels() crashes my program

April 4, 2012 - 3:43pm #2

What device are you testing with? We've seen an issue on iOS when using the Frame object alongside the background texture access feature:

QCAR::Renderer::getInstance().bindVideoBackground(0);

Are you using that method?

- Kim

Log in or register to post comments