获取一个视频缓冲区及信息
一旦GVM注册至VIM之后,您就可以获得一个视频缓冲区。无论所需缓冲区的类型如何(原始或是经过转换的缓冲区),都有两种可能性:模块或是运行在本地系统(即机器人)上,或是运行在一个远程的机器上。
模块为动态库
如果您的模块为本地执行,内存地址就为共享。因此,获得视频缓冲区一个比较快捷的方式就是使用getImageLocal或getDirectRawImageLocal方法。
// 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<int>( "getImageLocal", GVM_name ));
现在,您就获得了一个对图像数据的访问。
// 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();
> 现在,您可以进行一些处理。
远程模式
如果您的模块是远程模块,内存地址就不是共享的。因此,视频缓冲区指针的用处不大。模块需要的是包含在视频缓冲区里的数据。所以,您必须使用getImageRemote或getDirectRawImageRemote方法。
// 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 );
现在,您获得了一个包含图像数据的数组。
// 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();