Advertisement
lamiastella

SR300Camera::fillInZCoords

May 22nd, 2017
164
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 3.80 KB | None | 0 0
  1. void SR300Camera::fillInZCoords()
  2. {
  3.  
  4.     Image::ImageData depthImage;
  5.     Image *depthMap = sample->depth;
  6.     depthMap->AcquireAccess(Image::ACCESS_READ, &depthImage);
  7.     Image::ImageInfo imgInfo = depthMap->QueryInfo();
  8.     int depth_stride = depthImage.pitches[0] / sizeof(pxcU16);
  9.     Projection * projection = device->CreateProjection();
  10.  
  11.    
  12.     unsigned int wxhDepth = depth_width * depth_height;
  13.     // create the array of depth coordinates + depth value (posUVZ) within the defined ROI
  14.     Point3DF32* posUVZ = new Point3DF32[wxhDepth];
  15.     pxcU16 *dpixels = (pxcU16*)depthImage.planes[0];
  16.     unsigned int dpitch = depthImage.pitches[0] / sizeof(pxcU16); /* aligned width */
  17.    
  18.     for (unsigned int yy = 0, k = 0; yy < depth_height; yy++)
  19.     {
  20.         for (unsigned int xx = 0; xx < depth_width; xx++, k++)
  21.         {
  22.             //posUVZ[k].x = (pxcF32)xx*depth_width;
  23.             posUVZ[k].x = (pxcF32)xx;
  24.             //posUVZ[k].y = (pxcF32)yy *depth_height;
  25.             posUVZ[k].y = (pxcF32)yy;
  26.             posUVZ[k].z = ((short *)depthImage.planes[0])[yy* depth_stride + xx];
  27.  
  28.             //posUVZ[k].z = (pxcF32)dpixels[yy * dpitch + xx];
  29.             //posUVZ[k].z = static_cast<pxcF32>(reinterpret_cast<pxcI16*>(depthImage.planes[0]
  30.       //+ static_cast<int>(posUVZ[k].y) * depthImage.pitches[0])[static_cast<int>(posUVZ[k].x)]);
  31.             //posUVZ[k].z = static_cast<pxcF32>(reinterpret_cast<pxcI16*>(depthImage.planes[0]
  32.                 //+ static_cast<int>(yy) * depthImage.pitches[0])[static_cast<int>(xx)]);
  33.             cout << "xx is " << posUVZ[k].x << endl;
  34.             cout << "yy is " << posUVZ[k].y << endl;
  35.             cout << "zz is " << posUVZ[k].z<< endl;
  36.         }
  37.     }
  38.  
  39.     vector<PointF32> depthPoints;
  40.     vector<PointF32> projPoints;
  41.  
  42.  
  43.  
  44.     //CImageGUI::DEPTH_IMG = 1
  45.    
  46.  
  47.    
  48.  
  49.     // convert the array of depth coordinates + depth value (posUVZ) into the world coordinates (pos3D) in mm
  50.     Point3DF32* pos3D = new Point3DF32[wxhDepth];
  51.     //projection->DepthToWorld(depthMap, depthPoints, projPoints);
  52.     /*
  53.     for (unsigned int yy = 0, k = 0; yy < depth_height; yy++)
  54.     {
  55.         for (unsigned int xx = 0; xx < depth_width; xx++, k++)
  56.         {
  57.             cout << "xx is " << [k] << endl;
  58.             //cout << "yy is " << pos3D[k].y*1000.0 << endl;
  59.             //cout << "zz is " << pos3D[k].z*1000.0 << endl;
  60.             //xyzBuffer.push_back(cv::Point3f(pos3D[k].x, pos3D[k].y, pos3D[k].z));
  61.         }
  62.     }
  63.     */
  64.     int dsize = depth_height*depth_width;
  65.     vector<Point3DF32> dcordsAbs;
  66.     /*
  67.     for (auto i = 0; i < ; i++) {
  68.         dcordsAbs[i].x = dcords[i].x * dwidth, dcordsAbs[i].y = dcords[i].y * dheight;
  69.         dcordsAbs[i].z = static_cast<pxcF32>(reinterpret_cast<pxcI16*>(ddata.planes[0] + static_cast<int>(dcordsAbs[i].y) * ddata.pitches[0])[static_cast<int>(dcordsAbs[i].x)]);
  70.     }
  71.     */
  72.     //depth->ReleaseAccess(&ddata);
  73.     //projection->DepthToWorld(depthMap, depthPoints, pos3D);
  74.  
  75.     //projection->ProjectDepthToCamera(wxhDepth, posUVZ, pos3D);
  76.     /*
  77.     if (projection->ProjectDepthToCamera(wxhDepth, posUVZ, pos3D) < PXC_STATUS_NO_ERROR)
  78.     {
  79.         delete[] posUVZ;
  80.         delete[] pos3D;
  81.         cout << "projection unsucessful";
  82.         return;
  83.     }
  84.     */
  85.     /*
  86.     for (unsigned int yy = 0, k = 0; yy < depth_height; yy++)
  87.     {
  88.         for (unsigned int xx = 0; xx < depth_width; xx++, k++)
  89.         {
  90.             cout << "xx is " << pos3D[k].x*1000.0 << endl;
  91.             cout << "yy is " << pos3D[k].y*1000.0 << endl;
  92.             cout << "zz is " << pos3D[k].z*1000.0 << endl;
  93.             xyzBuffer.push_back(cv::Point3f(pos3D[k].x, pos3D[k].y, pos3D[k].z));
  94.         }
  95.     }
  96.     */
  97.  
  98.     /*
  99.     for (int idx = 0; idx < wxhDepth; idx++) {
  100.  
  101.         cout << "x is " << pos3D[idx].x*1000.0 << endl;
  102.         cout << "y is " << pos3D[idx].y*1000.0 << endl;
  103.         cout << "z is " << pos3D[idx].z*1000.0 << endl;
  104.         xyzBuffer.push_back(cv::Point3f(pos3D[idx].x, pos3D[idx].y, pos3D[idx].z));
  105.     }
  106.     */
  107.    
  108.     //xyzMap = cv::Mat(xyzMap.size(), xyzMap.type, &pos3D);
  109.     //xyzMap = cv::Mat(xyzBuffer);
  110.     //cout << "xyzMap = " << endl << " " << xyzMap << endl << endl;
  111.  
  112.     projection->Release();
  113.     delete[] posUVZ;
  114.     delete[] pos3D;
  115.    
  116. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement