<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Where is your error? I'm in Software Archive</title>
    <link>https://community.intel.com/t5/Software-Archive/ProjectDepthToCamera/m-p/1105574#M70366</link>
    <description>&lt;P&gt;Where is your error? I'm doing something like this to get depth values of colour points, but in C#. Basic pseudocode is:&lt;/P&gt;

&lt;OL&gt;
	&lt;LI&gt;Get depth image, imageData, depth pixels (depthdata.ToFloatArray) &amp;amp; create projection.&lt;/LI&gt;
	&lt;LI&gt;Create array of colour points&lt;/LI&gt;
	&lt;LI&gt;Give the colour array and depthData to projection.MapColorToDepth&amp;nbsp;&lt;SPAN style="font-size: 13.008px; line-height: 19.512px;"&gt;(I usually only need to do a couple of points at a time which is fine though one use case requires doing this for the whole colour image which takes significant processing time - the docs state this method isn't designed for such a large number of points but none of the other provided methods work.)&lt;/SPAN&gt;&lt;/LI&gt;
	&lt;LI&gt;&lt;SPAN style="font-size: 13.008px; line-height: 19.512px;"&gt;The MapColorToDepth method annoyingly only outputs X&amp;amp;Y coordinates in the depth image so we have to loop through the output array from the previous step and get the depth value of each point from the&amp;nbsp;depthdata.ToFloatArray variable.&lt;/SPAN&gt;&lt;/LI&gt;
	&lt;LI&gt;&lt;SPAN style="font-size: 13.008px; line-height: 19.512px;"&gt;Et voila! We now have an array of depth values aligned to the colour image.&lt;/SPAN&gt;&lt;/LI&gt;
&lt;/OL&gt;

&lt;P&gt;&lt;SPAN style="font-size: 13.008px; line-height: 19.512px;"&gt;I have tried doing this a number of different ways, in particular using the UVMap and InvUVMap though neither of those methods seem to do what they're supposed to (in C# at least. The only working samples I could find of them are in C++ and they work fine but when I translate them to C# they stop working).&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Mon, 18 Jan 2016 10:10:04 GMT</pubDate>
    <dc:creator>jb455</dc:creator>
    <dc:date>2016-01-18T10:10:04Z</dc:date>
    <item>
      <title>ProjectDepthToCamera</title>
      <link>https://community.intel.com/t5/Software-Archive/ProjectDepthToCamera/m-p/1105572#M70364</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;

&lt;P&gt;I'm currently trying to project a 2D depth image to 3D point cloud data. Before, I used QueryVertices top directly get the 3D data but it only gives digital data where I want it to be more detailed and without the value getting rounded.&lt;/P&gt;

&lt;P&gt;So, currently I'm trying to use ProjectDepthToCamera in PXCProjection to convert the data, but I couldn't get it to work.&lt;/P&gt;

&lt;P&gt;Here is a part of my source code:&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; PXCCapture::Sample *sample = sm-&amp;gt;QuerySample();&lt;BR /&gt;
	&amp;nbsp;&amp;nbsp;&amp;nbsp; colorFrame = sample-&amp;gt;color;&lt;BR /&gt;
	&amp;nbsp;&amp;nbsp;&amp;nbsp; depthFrame = sample-&amp;gt;depth;&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; PXCImage::ImageData imgData = {};&lt;BR /&gt;
	&amp;nbsp;&amp;nbsp; &amp;nbsp;pxcStatus sts = depthFrame-&amp;gt;AcquireAccess&lt;BR /&gt;
	&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;(PXCImage::ACCESS_READ, PXCImage::PIXEL_FORMAT_DEPTH_RAW, &amp;amp;imgData);&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; points_buf = (unsigned short*)imgData.planes[0];&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;pcl::PointCloud&amp;lt;pcl::PointXYZRGB&amp;gt;::Ptr cloud_ptr&lt;BR /&gt;
	&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;(new pcl::PointCloud&amp;lt;pcl::PointXYZRGB&amp;gt;(m_depthSize));&lt;/P&gt;

&lt;P&gt;&lt;BR /&gt;
	&amp;nbsp;&amp;nbsp; &amp;nbsp;for(int j = 0; j &amp;lt; CAP_DEPTH_HEIGHT; j++)&lt;BR /&gt;
	&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;for(int i = 0; i &amp;lt; CAP_DEPTH_WIDTH; i++)&lt;BR /&gt;
	&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;{&lt;BR /&gt;
	&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;unsigned int idx = 3 *( j * CAP_DEPTH_WIDTH + i );&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;m_depthPoints[idx/3].x = (pxcF32)points_buf[idx&amp;nbsp; ];&lt;BR /&gt;
	&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;m_depthPoints[idx/3].y = (pxcF32)points_buf[idx+1];&lt;BR /&gt;
	&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;m_depthPoints[idx/3].z = (pxcF32)points_buf[idx+2];&lt;BR /&gt;
	&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;}&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; pxcStatus sts = m_projection-&amp;gt;ProjectDepthToCamera(m_depthSize, m_depthPoints, m_worldPoints);&lt;BR /&gt;
	&amp;nbsp;&amp;nbsp;&amp;nbsp; if( sts &amp;lt; PXC_STATUS_NO_ERROR) cout &amp;lt;&amp;lt; "failed to map depth to world" &amp;lt;&amp;lt; endl;&lt;BR /&gt;
	&amp;nbsp;&amp;nbsp; &amp;nbsp;for(int j = 0; j &amp;lt; CAP_DEPTH_HEIGHT; j++)&lt;BR /&gt;
	&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;for(int i = 0; i &amp;lt; CAP_DEPTH_WIDTH; i++)&lt;BR /&gt;
	&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;{&lt;BR /&gt;
	&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;unsigned int idx = j * CAP_DEPTH_WIDTH + i;&lt;BR /&gt;
	&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;cloud_ptr-&amp;gt;points[idx].x = -m_worldPoints[idx].x;&lt;BR /&gt;
	&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;cloud_ptr-&amp;gt;points[idx].y =&amp;nbsp; m_worldPoints[idx].y;&lt;BR /&gt;
	&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;cloud_ptr-&amp;gt;points[idx].z =&amp;nbsp; m_worldPoints[idx].z;&lt;BR /&gt;
	&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;}&lt;BR /&gt;
	~~~~~~~~&lt;/P&gt;

&lt;P&gt;m_depthSize is int value, m_depthPoints and m_worldPoints is PXCPoint3DF32.&lt;/P&gt;

&lt;P&gt;Anybody knows what I'm doing wrong? Or maybe someone can tell me how to project it without using ProjectDepthToCamera?&lt;/P&gt;

&lt;P&gt;Thank you,&lt;/P&gt;

&lt;P&gt;Michael&lt;/P&gt;</description>
      <pubDate>Fri, 11 Dec 2015 05:41:06 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Archive/ProjectDepthToCamera/m-p/1105572#M70364</guid>
      <dc:creator>Michael_S_18</dc:creator>
      <dc:date>2015-12-11T05:41:06Z</dc:date>
    </item>
    <item>
      <title>Any help would be very</title>
      <link>https://community.intel.com/t5/Software-Archive/ProjectDepthToCamera/m-p/1105573#M70365</link>
      <description>&lt;P&gt;Any help would be very thankful, anyone?&lt;/P&gt;</description>
      <pubDate>Mon, 18 Jan 2016 03:15:49 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Archive/ProjectDepthToCamera/m-p/1105573#M70365</guid>
      <dc:creator>Michael_S_18</dc:creator>
      <dc:date>2016-01-18T03:15:49Z</dc:date>
    </item>
    <item>
      <title>Where is your error? I'm</title>
      <link>https://community.intel.com/t5/Software-Archive/ProjectDepthToCamera/m-p/1105574#M70366</link>
      <description>&lt;P&gt;Where is your error? I'm doing something like this to get depth values of colour points, but in C#. Basic pseudocode is:&lt;/P&gt;

&lt;OL&gt;
	&lt;LI&gt;Get depth image, imageData, depth pixels (depthdata.ToFloatArray) &amp;amp; create projection.&lt;/LI&gt;
	&lt;LI&gt;Create array of colour points&lt;/LI&gt;
	&lt;LI&gt;Give the colour array and depthData to projection.MapColorToDepth&amp;nbsp;&lt;SPAN style="font-size: 13.008px; line-height: 19.512px;"&gt;(I usually only need to do a couple of points at a time which is fine though one use case requires doing this for the whole colour image which takes significant processing time - the docs state this method isn't designed for such a large number of points but none of the other provided methods work.)&lt;/SPAN&gt;&lt;/LI&gt;
	&lt;LI&gt;&lt;SPAN style="font-size: 13.008px; line-height: 19.512px;"&gt;The MapColorToDepth method annoyingly only outputs X&amp;amp;Y coordinates in the depth image so we have to loop through the output array from the previous step and get the depth value of each point from the&amp;nbsp;depthdata.ToFloatArray variable.&lt;/SPAN&gt;&lt;/LI&gt;
	&lt;LI&gt;&lt;SPAN style="font-size: 13.008px; line-height: 19.512px;"&gt;Et voila! We now have an array of depth values aligned to the colour image.&lt;/SPAN&gt;&lt;/LI&gt;
&lt;/OL&gt;

&lt;P&gt;&lt;SPAN style="font-size: 13.008px; line-height: 19.512px;"&gt;I have tried doing this a number of different ways, in particular using the UVMap and InvUVMap though neither of those methods seem to do what they're supposed to (in C# at least. The only working samples I could find of them are in C++ and they work fine but when I translate them to C# they stop working).&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 18 Jan 2016 10:10:04 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Archive/ProjectDepthToCamera/m-p/1105574#M70366</guid>
      <dc:creator>jb455</dc:creator>
      <dc:date>2016-01-18T10:10:04Z</dc:date>
    </item>
    <item>
      <title>Actually it's not an error,</title>
      <link>https://community.intel.com/t5/Software-Archive/ProjectDepthToCamera/m-p/1105575#M70367</link>
      <description>&lt;P&gt;Actually it's not an error, the function worked, but the result is messed up and I can't get what's wrong with it.&lt;/P&gt;

&lt;P&gt;Now I just realized that I put weird values into the depth points I passed onto ProjectDepthToCamera because I was confused between depthFrame and imgData. Problem solved.&lt;/P&gt;

&lt;P&gt;Although, thank you James, for the explanation about mapping depth to color image. I was kinda confused about that one, too.&lt;/P&gt;

&lt;P&gt;Sorry for the ruckus and thanks again.&lt;/P&gt;

&lt;P&gt;Best regards,&lt;/P&gt;

&lt;P&gt;Michael.&lt;/P&gt;</description>
      <pubDate>Mon, 18 Jan 2016 11:59:08 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Archive/ProjectDepthToCamera/m-p/1105575#M70367</guid>
      <dc:creator>Michael_S_18</dc:creator>
      <dc:date>2016-01-18T11:59:08Z</dc:date>
    </item>
    <item>
      <title>Was the mistake you found in</title>
      <link>https://community.intel.com/t5/Software-Archive/ProjectDepthToCamera/m-p/1105576#M70368</link>
      <description>&lt;P&gt;Was the mistake you found in this line:&amp;nbsp;&lt;SPAN style="font-size: 12px; line-height: 18px;"&gt;&amp;nbsp;points_buf = (unsigned short*)imgData.planes[0];?&lt;/SPAN&gt;&lt;/P&gt;

&lt;P&gt;&lt;SPAN style="font-size: 12px; line-height: 18px;"&gt;I thought I'd try to get this working in C# but that's where I'm stuck. What was your solution?&lt;/SPAN&gt;&lt;/P&gt;

&lt;P&gt;&lt;SPAN style="font-size: 12px; line-height: 18px;"&gt;Thanks!&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 19 Jan 2016 09:41:33 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Archive/ProjectDepthToCamera/m-p/1105576#M70368</guid>
      <dc:creator>jb455</dc:creator>
      <dc:date>2016-01-19T09:41:33Z</dc:date>
    </item>
    <item>
      <title>Sort of. I made a mistake on</title>
      <link>https://community.intel.com/t5/Software-Archive/ProjectDepthToCamera/m-p/1105577#M70369</link>
      <description>&lt;P&gt;Sort of. I made a mistake on how I insert the depth data into m_depthPoints, so I changed it to:&lt;/P&gt;

&lt;P&gt;memcpy(depthImg.data, imgData.planes[0], imgData.pitches[0] * CAP_DEPTH_HEIGHT); //depthImg is cv::Mat&lt;BR /&gt;
	&amp;nbsp;&amp;nbsp;&amp;nbsp; for(int j = 0; j &amp;lt; CAP_DEPTH_HEIGHT; j++)&lt;BR /&gt;
	&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;for(int i = 0; i &amp;lt; CAP_DEPTH_WIDTH; i++)&lt;BR /&gt;
	&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;{&lt;BR /&gt;
	&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;unsigned int idx = j * CAP_DEPTH_WIDTH + i;&lt;BR /&gt;
	&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; m_depthPoints[idx].x = i;&lt;BR /&gt;
	&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;m_depthPoints[idx].y = j;&lt;BR /&gt;
	&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;m_depthPoints[idx].z = depthImg.at&amp;lt;USHORT&amp;gt;(idx) * depth_unit/1000;&amp;nbsp; //depth_unit is value of device.QueryDepthUnit()&lt;BR /&gt;
	&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/P&gt;

&lt;P&gt;This way I can use ProjectDepthToCamera fine, giving me world coordinates of the depth data in mm.&lt;/P&gt;

&lt;P&gt;I did project world coordinates to color image using ProjectCameraToColor to give texture to my point cloud (using this, I can get the color information of each point in the world coordinates). I don't use MapDepthToColor or MapColorToDepth so I'm not sure how it works, but if it doesn't solve your problem, how about trying ProjectColorToCamera followed by ProjectCameraToDepth?&lt;/P&gt;</description>
      <pubDate>Wed, 20 Jan 2016 08:49:28 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Archive/ProjectDepthToCamera/m-p/1105577#M70369</guid>
      <dc:creator>Michael_S_18</dc:creator>
      <dc:date>2016-01-20T08:49:28Z</dc:date>
    </item>
  </channel>
</rss>

