4 Replies Latest reply on May 22, 2017 4:53 PM by Intel Corporation

    vertices values are all zero from QueryVertices

    MonaJalal

      I have the following code:

       

      /***
      Reads the depth data from the sensor and fills in the matrix
      ***/
      void SR300Camera::fillInZCoords()
      {
       //int res = pmdGet3DCoordinates(hnd, dists, 3 * numPixels * sizeof(float)); //store x,y,z coordinates dists (type: float*)
       ////float * zCoords = new float[1]; //store z-Coordinates of dists in zCoords
       //xyzMap = cv::Mat(xyzMap.size(), xyzMap.type(), dists);
       Projection *projection = pp->QueryCaptureManager()->QueryDevice()->CreateProjection();
       std::vector<Point3DF32> vertices;
       vertices.resize(depth_width * depth_height);
       projection->QueryVertices(sample->depth, vertices.data());
       xyzBuffer.clear();
       //for (int i = 0; i < bufferSize.width*bufferSize.height; i++) {
       for (int i=0; i< depth_width*depth_height; i++) {
        //cv::Point3f p;
        //p.x = vertices[i].x;
        //p.y = vertices[i].y;
        //p.z = vertices[i].z;
        //xyzBuffer.push_back(p);
        cout << "x= " << vertices[i].x << endl;
        cout << "y= " << vertices[i].y << endl;
        cout << "z= " << vertices[i].z << endl;
        xyzBuffer.push_back(cv::Point3f(vertices[i].x, vertices[i].y, vertices[i].z));
       }
      
       xyzMap = cv::Mat(xyzBuffer);
       cout << "xyzMap = " << endl << " " << xyzMap << endl << endl;
       projection->Release();
      }
      

       

       

      it returns zero for all the x, y, z. Basically, I am trying to write the same function as below for RealSense:

      void PMDCamera::fillInZCoords()
      {
       int res = pmdGet3DCoordinates(hnd, dists, 3 * numPixels * sizeof(float)); //store x,y,z coordinates dists (type: float*)
       //float * zCoords = new float[1]; //store z-Coordinates of dists in zCoords
       xyzMap = cv::Mat(xyzMap.size(), xyzMap.type(), dists);
      }
      

       

      Any thought on how to fix my RealSense counterpart to get the correct values instead of zero is really appreciated.

       

      cv::Mat xyzMap;
      std::vector<cv::Point3f> xyzBuffer;
      

       

      My question is similar to The PXCProjection::ProjectDepthToCamera function  in that I am trying to get the xyzMap from the realsense. Unfortunately, I couldn't find a working piece of code yet for so.