Depth Stream is not showing

Depth Stream is not showing

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 !!

2 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

It looks to me like you have a few options.  If you want to use imshow you should check out the OpenCV sample "intelperc_capture.cpp" which defines a special imshow function for displaying 16-bit depth maps,  Your other option, and what I would recommend would be to use the SDK's UtilRender class which will display your PXCImage*,  The my first C++ application tutorial in the manual shows how to do this.

 

Leave a Comment

Please sign in to add a comment. Not a member? Join today