Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Native Development

Reply
Developer
Posts: 1,636
Registered: ‎07-14-2008
My Device: Z10
My Carrier: Fido

Camera video buffer and stride question

I want to read the camera video buffer frame and apply some kind of filtering on the buffer.

In the call back function it passes camera_buffer_t variable.

 

I can get the data using data by accessing

 

    uint8_t                *framebuf;

but when i apply the filter the image doesn't look right.

 

this is how I access the data in the frame buffer.

 

unsigned int *data = (unsigned int *)inbuffer->framebuf;

 

and this is how I write to data

 

*data++ = int_value;

 

do I have to de-stride the buffer like this?

 

data += stride  or do i need to add the stride for each width of the frame?

 

 

 

 

BlackBerry Development Advisor
Posts: 683
Registered: ‎11-29-2011
My Device: PRIV
My Carrier: Rogers

Re: Camera video buffer and stride question

Hi.

All of the image properties can be found in the camera_frame_nv12_t descriptor accessible via:

buf->framedesc.nv12  (eg. stride, width, height, uv_offset, uv_stride)

 

Note that this descriptor is only valid if buf->frametype == CAMERA_FRAMETYPE_NV12.

 

you realize that switching to unsigned int* means you'll be modifying 32 bits at a time (4 pixels), right?  Is this what your filter is meant to do?  If you are indexing into an int* array, you will have to make sure you divide appropriately, because width is reported in pixels and the strides are reported in bytes.

 

Cheers,

Sean

 

 

 

 

 

Developer
Posts: 1,068
Registered: ‎11-24-2011
My Device: PlayBook
My Carrier: x

Re: Camera video buffer and stride question

>you realize that switching to unsigned int* means you'll be modifying 32 bits at a time (4 pixels), right? 

1 pixel - 1 byte? should pixel/bytes be calculated based on width and stride? more reliable in my opinion.

Developer
Posts: 1,041
Registered: ‎07-16-2008
My Device: ಠ_ಠ

Re: Camera video buffer and stride question

@BGmot - it depends what pixel format you are using. NV12 doesn't arrange the parts of a pixel in the same order that RGB does.

BlackBerry Development Advisor
Posts: 683
Registered: ‎11-29-2011
My Device: PRIV
My Carrier: Rogers

Re: Camera video buffer and stride question


BGmot wrote:
1 pixel - 1 byte? should pixel/bytes be calculated based on width and stride? more reliable in my opinion.

nope.  that's what a bits-per-pixel field is for.  in NV12, it's actually 12 bits per pixel, but it's semi-planar.  And as for using width and stride to calculate bits per pixel.. that only works if you know that the first pixel of line 2 follows the last pixel of line 1 in memory, which is not always the case (on the OMAP platform we're using, the stride tends to be 4096 bytes).