Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Mat structure for depth map?

I am reading an image in to a cv::Mat.

cv::Mat depth_map = cv::imread("patio_depth.jpg", -1);

The Mat is then passed to this function: (that gets xyz coordinates from a depth map).

 inline cv::Point3d getPoint3D(int x, int y) const
 {

    cv::Point3d point;
    point.x = depth_map.at<cv::Vec3f>(y, x)[0];
    point.y = depth_map.at<cv::Vec3f>(y, x)[1];
    point.z = depth_map.at<cv::Vec3f>(y, x)[2];

    return point; }

Which causes an assertion error.

Assertion failed <dims &lt;="2" &amp;&amp;="" data="" &amp;&amp;="" <unsigned="">i0 <unsigned>size.p[0] && <unsigned><i1*datatype<_tp>::channels> in \core\mat.hpp

I assume that this means the Mat I am using is incompatible with the function, but what Mat structure WILL work? Or do I need to convert it somehow before I pass it through?