Topic locked

How to get RGB format frame from camera

September 26, 2012 - 1:23am #1

Hi,

I am trying to get RGB format of camera data, either 565 or 888.   I put the following call in initApplicationNative().

QCAR::setFrameFormat( QCAR::RGB565, true );

 

When I check the image returned in renderFrame() by calling following:

 

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

for(int i=0; i<qcarframe.getNumImages();i++)

{

   const QCAR::Image *pimg = qcarframe.getImage(i);

   LOG( "Image format = %d", pimg->getFormat() );

 

The result is always 4, which is grayscale image.

 

I am using vuforia-1.5.9 on Android 2.3.  Did I do something wrong?  Please help.

 

Thanks,

Jason

How to get RGB format frame from camera

August 27, 2015 - 12:13am #12

How to get RGB format frame from camera

February 22, 2015 - 6:41am #11

Here are some guidelines on Unity Camera Image access:

https://developer.vuforia.com/resources/dev-guide/unity-camera-image-access

 

How to get RGB format frame from camera

February 22, 2015 - 2:57am #10

Hello guys,

 

Could do this with Unity ? Image processing ? 

Thanks for help !

How to get RGB format frame from camera

October 1, 2014 - 9:08am #9

Good to hear :-)

How to get RGB format frame from camera

October 1, 2014 - 7:31am #8

Thanks, that tutorial helped me. By moving the setFrameFormat call to directly after camera start solved the problem for me.

How to get RGB format frame from camera

October 1, 2014 - 2:58am #7

Hi Peter,

not all devices support RGB888 as camera format; so, even if you try and set RGB888 frame format, this may fail on some devices;

in general, devices that do not support RGB888 should support the alternate format RGB565  (and a few "lucky" devices support both formats, i.e. RGB888 and RGB565).

So, what I would suggest here is to try the following approach; try to set RGB888, and if it fails, then try to set RGB565 as a fallback case.

This way you should be sure to have at least one "non-grayscale" format enabled (note that RGB565 is just a sort of 'compressed' version of RGB888...)

 

Once you have one of those 2 formats enabled, you can then capture a camera frame in one format or the other, following this tutorial:

https://developer.vuforia.com/forum/faq/android-how-can-i-access-camera-image

Hope this helps.

 

How to get RGB format frame from camera

October 1, 2014 - 2:38am #6

I'm having the same problem using Vuforia 3.0.9 on Android. Was there an answer to how to get an RGB/RGBA image from the camera?

I have tried to put the setFrameFormat(QCAR::RGB888,true) in different places in the code, the result from it is always false and getNumImages() is always returning 4 greyscale images.

 

How to get RGB format frame from camera

March 25, 2013 - 6:46am #5

Yes, as per the enumerated types in QCAR.h

 

/// Pixel encoding types

enum PIXEL_FORMAT {

    UNKNOWN_FORMAT = 0,         ///< Unknown format - default pixel type for

                                ///< undefined images

    RGB565 = 1,                 ///< A color pixel stored in 2 bytes using 5

                                ///< bits for red, 6 bits for green and 5 bits

                                ///< for blue

    RGB888 = 2,                 ///< A color pixel stored in 3 bytes using

                                ///< 8 bits each

    GRAYSCALE = 4,              ///< A grayscale pixel stored in one byte

    YUV = 8,                    ///< A color pixel stored in 12 or more bits

                                ///< using Y, U and V planes

    RGBA8888 = 16,              ///< A color pixel stored in 32 bits using 8 bits

                                ///< each and an alpha channel.

};

Have a look also at this related thread: 

https://developer.vuforia.com/forum/ios/qcarimage-convert-yuv-png-or-jpg

HTH

 

N

How to get RGB format frame from camera

March 25, 2013 - 6:35am #4

hi,i have image format=1 what does it mean? is it rgb565?

How to get RGB format frame from camera

September 26, 2012 - 5:35am #3

Hi NalinS,

I guess canUseFrame is used as a delay counter.  So I add canUseFrame++ each time entering the render loop.   

Also, I think setFrameFormat( QCAR::RGB888, true) is still required, so it is kept.  

I am still unable to get RGB888 image.   In each loop, the number of images returned are always 4.  each image is of different resolution, namely 640x480, 320x240, 160x120, 80x60.  All are grayscale images.

Please help.

Thanks.

Jason

How to get RGB format frame from camera

September 26, 2012 - 3:15am #2

Hi Jason

Here's some sample code that I use on iOS to get the frame within the render loop, which you can probably use as a basis.

Note the extra test for the image on qcarImage.

BTW the canUseFrame gets around an issue that can cause a crash if you access the camera too early after startup - this will be fixed in the next release.

HTH

N

 

    static int canUseFrame = 0;

    

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

    

    if (canUseFrame > 100)

    { 

        for (int i = 0; i < frame.getNumImages(); i++)

        {

            

            const QCAR::Image *qcarImage = frame.getImage(i);

 

            

            NSLog(@"Creating frame image %d   pixel format  %d", i, qcarImage->getFormat() );

 

            

            if (qcarImage->getFormat() == QCAR::RGB888)

            {

                self.backgroundImage = [self createUIImage:qcarImage];     

                break;

            }

     

     

        }

    }

 

Topic locked