7 Replies Latest reply on May 3, 2017 9:46 AM by Intel Corporation

    Error creating a projection

    Migueel

      Hi, i´m trying to create a projection, i have actually created it following the steps of the SDK documentation,but when i run my program i get an error of reading access, i think i might be doing something wrong with projection, i dón´t know if i need to use projection while i´m recording with the camera... i´m taking a frame from a recorded file with de r200 an trying to obtain the dept and color values with ProjectColortoCamera

       

      The error is:  " Exception produced at 0x00000000 is CameraViewer.cpp_d.exe: 0xC0000005: Access violation when executing location 0x00000000. "

      Here is my code, any ideas of why i´m getting this error?

       

      Thanks!!

       

       

      void readFrame(pxcCHAR *file, bool record) {

       

       

        PXCSenseManager* sm = PXCSenseManager::CreateInstance();

       

       

        // Set file playback name

        sm->QueryCaptureManager()->SetFileName(file, false);

       

       

        // Enable stream and Initialize

        sm->EnableStream(PXCCapture::STREAM_TYPE_COLOR, 640, 480, 0);//En la página ponía 0, 0, simplemente.

        sm->EnableStream(PXCCapture::STREAM_TYPE_DEPTH, 0, 0, 0);

        sm->Init();

       

       

        // Set realtime=false and pause=true

        sm->QueryCaptureManager()->SetRealtime(false);

        sm->QueryCaptureManager()->SetPause(true);

        // Streaming loop

        for (int i = 0; i < 4; i++) {

        // Set to work on every frame of data

        sm->QueryCaptureManager()->SetFrameByIndex(i);

        sm->FlushFrame();

        // Ready for the frame to be ready

        pxcStatus sts = sm->AcquireFrame(true);

        if (sts < PXC_STATUS_NO_ERROR) break;

       

       

        // Retrieve the sample and work on it. The image is in sample->color.

        PXCCapture::Sample* sample = sm->QuerySample();

       

        PXCImage::ImageData data;

        PXCImage::PixelFormat format;

       

        format= PXCImage::PIXEL_FORMAT_DEPTH_RAW;

        sample->depth->AcquireAccess(PXCImage::ACCESS_READ, format, &data);

        

        int width = sample->color->QueryInfo().width;

        int height = sample->color->QueryInfo().height;

       

        if (!format)

        format = sample->depth->QueryInfo().format;

        //printf("Zona 5\n");

       

        PXCPoint3DF32* cp = new PXCPoint3DF32[width * height*100];

        PXCPoint3DF32* cvp = new PXCPoint3DF32[width * height*100];

       

        int *mappedPixels;

       

        for (int j = 0, k = 0; j < height; j++)

        {

        for (int i = 0; i < width; i++, k++)

        {

        //Create 3D point with the colour (x,y) coordinates and corresponding z value 

        if (k == 100000) break;

        cp->x = i;

        cp->y = j;

        cp->z = mappedPixels[j * width + i];

        cp++;

       

        }

        }

       

        PXCCapture::Device* device;                       //  Here i get the error!!!!!

        Projection *projection = device->CreateProjection();

        projection->ProjectColorToCamera(height*width,cp, cvp);

       

        projection->Release();

       

        printf("Acabado\n\n");

        // Resume processing the next frame

        sm->ReleaseFrame();

        }

       

        // Clean up

        sm->Release();

       

      }