hi,
i converted depth stream into mat variable in opencv.
when i run the code it runs successfully. but nothing is shown in the screen. and after few second the screen become black.
I am not able to figure out what mistake i am doing.
below is the code :
int wmain(int argc, WCHAR* argv[]) { //Create the IplImage headers IplImage* depthimg = cvCreateImageHeader(cvSize(320, 240), 16, 1);
// create the PXCSenseManager
PXCSenseManager *psm=0;
psm = PXCSenseManager::CreateInstance();
if (!psm) {
wprintf_s(L"Unable to create the PXCSenseManager\n");
return 1;
}
// select the color stream of size 640x480 and depth stream of size 320x240
psm->EnableStream(PXCCapture::STREAM_TYPE_DEPTH, 640, 480);
// initialize the PXCSenseManager
if(psm->Init() != PXC_STATUS_NO_ERROR) return 2;
PXCImage *colorIm, *depthIm;
for (int i=0; i<MAX_FRAMES; i++)
{
if (psm->AcquireFrame(true)<PXC_STATUS_NO_ERROR) break;
// retrieve all available image samples
PXCCapture::Sample *sample = psm->QuerySample();
// retrieve the image or frame by type from the sample
depthIm = sample->depth;
PXCImage *depth_image = depthIm;
PXCImage::ImageData depthImageData;
depth_image->AcquireAccess( PXCImage::ACCESS_READ, &depthImageData );
cvSetData( depthimg, (short*)depthImageData.planes[0], depthimg->width * sizeof(short) );
Mat depthMat(depthimg );
imshow( "depth", depthMat );
depth_image->ReleaseAccess(&depthImageData);
}
waitKey();
}
thanks !!