1 | initial version |
i neither have the device, nor the sdk, so all of it "with a grain of salt", but it might boil down to something like this:
initialization (once):
Mat rgb(480,640,CV_8UC3);
Mat depth(240,320,CV_16UC1);
Mat ampli(240,320,CV_16UC1);
mtfFrameInfo stFrameInfo;
unsigned short** depth_amp = new unsigned short *[2];
depth_amp [0] = (unsigned short*)depth.data;
depth_amp [1] = (unsigned short*)ampli.data;
//1. get connect device list
MTF_API::mtfHandle m_pHnd; //control device handle
MTF_API::mtfDeviceInfo m_pDevInfo[MAX_DEVICE]; //device info
int nDevCount = 0;
MTF_API::mtfGetDeviceList(m_pDevInfo, &nDevCount);
//2. set control device handle
m_pHnd = m_pDevInfo[0].mtfHnd;//deivce 0 handle
//3.open device
CV_Assert(MTF_API::mtfDeviceOpen(m_pHnd) == MTF_API::ERROR_NO);
MTF_API::mtfReadBufInit(m_pHnd);
per frame:
MTF_API::mtfGrabStart(m_pHnd);
//Get Depth Data From device
MTF_API::mtfReadFromDevice(m_pHnd, (unsigned short**)depth_amp, &stFrameInfo) ;
//Get RGB Depth Data From device
MTF_API::mtfReadFromDevice_RGB888(m_pHnd, (unsigned char*)rgb.data, &stFrameInfo);
MTF_API::mtfGrabStop(m_pHnd);