intel-aero / meta-intel-aero

Yocto layer to support Intel Aero platform
https://github.com/intel-aero/meta-intel-aero
GNU General Public License v2.0
218 stars 119 forks source link

How to print Intel Aero Realsense camera frames ? #408

Closed RohanKurane closed 5 years ago

RohanKurane commented 5 years ago

Hello,

I am trying to print the frames coming from the intel aero realsense camera. However I do not see anything in the buffer I print. Its empty when I print the last statement. What am I doing wrong here ? The camera is initialized prior to this correctly.

I have the following code

                char *camera_data = malloc(640*480*3);
                rs_wait_for_frames( camera, &e);
                if ( e  || !camera )
                {
                    printf( "rs_error was raised when calling %s( %s ):\n", rs_get_failed_function( e), rs_get_failed_args( e ) );
                    printf(" %s\n", rs_get_error_message( e ) );
                    return NULL;
                }

                // Pull the depth and RGB data from the LibRealSense streams
                uint16_t *depth = ( uint16_t* )   rs_get_frame_data( camera, RS_STREAM_DEPTH, &e);
                if ( e )
                    printf("error returning depth\n");

                struct rgb *rgb = ( struct rgb* ) rs_get_frame_data( camera, RS_STREAM_COLOR, &e);
                if ( e )
                    printf("error returning rgb\n");

               // Create the merge of depth data onto the rgb data Basically, trying to create
               // our own depth image here by varying the red intensity

               for( int i = 0, end = 640 * 480; i < end; ++i )
               {
                   rgb[ i ].r /= 4;
                   rgb[ i ].g /= 4;
                   rgb[ i ].b /= 4;
               }

               memcpy(camera_data, rgb, 640 * 480 * 3);
               printf ("buffer is %s---- \n", camera_data);

@lbegani @lucasdemarchi

RohanKurane commented 5 years ago

Does camera_data need to of type unsigned char ? So

unsigned char *camera_data = (unsigned char *)malloc(640*48-*3*sizeof(char)) ?
memcpy(camera_data, rgb, 640 * 480 * 3);