Depth to point cloud
<p>I'm trying to create a point cloud from a depth video frame, which has pixel values between 0 and 4500 (recorded from the kinect v2).
So if i do <code>cout &lt;&lt; depth</code> i can see those values.
Now i try to create a point cloud using PCL with</p>

<pre><code> for (int y = 0; y &lt; depthImageSize.height; ++y)
    {
        for (int x = 0; x &lt; depthImageSize.width; ++x)
        {
            pcl::PointXYZRGBA &amp;pt = result-&gt;at(x, y);

            float depthValue = (float) depth.at&lt;float&gt;(y, x);

            pt.x = (static_cast&lt;float&gt;(x) - centerX) * scaleFactorX * depthValue;
            pt.y = (centerY - static_cast&lt;float&gt;(y)) * scaleFactorY * depthValue;
            pt.z = depthValue;
         }
    }
</code></pre>

<p>I found this depth to point cloud conversion plenty of times while researching. The float conversion of <code>(float) depth.at&lt;float&gt;(y, x);</code>does not result in the same values between 0 and 4500 though, it results in values like -6.54209e+35, 1.82232e-40 or -nan.</p>

<p>Any idea why the conversion fails?</p>