Getting a video buffer and information

Once your GVM is registered to the VIM, you can get a video buffer. Regardless of the kind of buffer requested (raw buffer or converted one), there are 2 possibilities: either your module works on the local system (the robot) or on a remote machine.

My module is a dynamic library

If your module works locally, the memory addresses are shared. So a fast method to get the video buffer is to use the getImageLocal or getDirectRawImageLocal methods.

// First you have to declare an ALImage to get the video buffer. // ( For definitions, have a look at alvisiondefinitions.h and alimage.h ) ALImage* image; //Now you can get the pointer to the video structure. image = ( ALImage* ) (cameraProxy->call<void*>( "getImageLocal", GVM_name )); // Or use the specific video proxy for better efficiency image = ( ALImage* ) cameraProxy->getImageLocal(GVM_name);

Now, you have an access to the image data.

// You can get some information about the image. int width = image->fWidth; int height = image->fHeight; int nbLayers = image->fNbLayers; int colorSpace = image->fColorSpace; long long timeStamp = image->fTimeStamp; //You can get the pointer to the image data. uInt8 *dataPointer = image->getFrame();

> Now, you can implement some processing.

My module is remote

If your module is remote, the memory addresses are not shared. So it's useless to get the pointer to the video buffer. Your module needs the data contained in the video buffer. Therefore, you have to use the getImageRemote or getDirectRawImageRemote methods.

// First you have to declare an ALValue to get the video buffer. ALValue image; // Then declare the size image.arraySetSize(7); //Now you can get the data. image = cameraProxy->call<ALValue>( "getImageRemote", GVM_name ); // Or use the specific video proxy for better efficiency image = cameraProxy->getImageRemote(GVM_name);

Now you have an array containing image data.

// You can get some informations about the image. int width = (int) image[0]; int height = (int) image[1]; int nbLayers = (int) image[2]; int colorSpace = (int) image[3]; long long timeStamp = ((long long)image[4])*1000000LL + (long long)image[5]; // image[4] is the number of seconds, image[5] the number of microseconds // You can get the pointer to the image data and its size const char* dataPointer = static_cast<const char*>(image[6].GetBinary()); int size = image[6].getSize();





Copyright © 2010 Aldebaran-Robotics - All rights reserved