mirror of
https://github.com/opencv/opencv_contrib.git
synced 2025-10-22 16:08:41 +08:00
Expose depthTo3d()
and warpFrame()
to the Python wrapper
This commit is contained in:
@@ -334,7 +334,7 @@ namespace rgbd
|
|||||||
* depth of `K` if `depth` is of depth CV_U
|
* depth of `K` if `depth` is of depth CV_U
|
||||||
* @param mask the mask of the points to consider (can be empty)
|
* @param mask the mask of the points to consider (can be empty)
|
||||||
*/
|
*/
|
||||||
CV_EXPORTS
|
CV_EXPORTS_W
|
||||||
void
|
void
|
||||||
depthTo3d(InputArray depth, InputArray K, OutputArray points3d, InputArray mask = noArray());
|
depthTo3d(InputArray depth, InputArray K, OutputArray points3d, InputArray mask = noArray());
|
||||||
|
|
||||||
@@ -1026,10 +1026,10 @@ namespace rgbd
|
|||||||
* @param warpedDepth The warped depth.
|
* @param warpedDepth The warped depth.
|
||||||
* @param warpedMask The warped mask.
|
* @param warpedMask The warped mask.
|
||||||
*/
|
*/
|
||||||
CV_EXPORTS
|
CV_EXPORTS_W
|
||||||
void
|
void
|
||||||
warpFrame(const Mat& image, const Mat& depth, const Mat& mask, const Mat& Rt, const Mat& cameraMatrix,
|
warpFrame(const Mat& image, const Mat& depth, const Mat& mask, const Mat& Rt, const Mat& cameraMatrix,
|
||||||
const Mat& distCoeff, Mat& warpedImage, Mat* warpedDepth = 0, Mat* warpedMask = 0);
|
const Mat& distCoeff, OutputArray warpedImage, OutputArray warpedDepth = noArray(), OutputArray warpedMask = noArray());
|
||||||
|
|
||||||
// TODO Depth interpolation
|
// TODO Depth interpolation
|
||||||
// Curvature
|
// Curvature
|
||||||
|
@@ -941,7 +941,7 @@ template<class ImageElemType>
|
|||||||
static void
|
static void
|
||||||
warpFrameImpl(const Mat& image, const Mat& depth, const Mat& mask,
|
warpFrameImpl(const Mat& image, const Mat& depth, const Mat& mask,
|
||||||
const Mat& Rt, const Mat& cameraMatrix, const Mat& distCoeff,
|
const Mat& Rt, const Mat& cameraMatrix, const Mat& distCoeff,
|
||||||
Mat& warpedImage, Mat* warpedDepth, Mat* warpedMask)
|
OutputArray _warpedImage, OutputArray warpedDepth, OutputArray warpedMask)
|
||||||
{
|
{
|
||||||
CV_Assert(image.size() == depth.size());
|
CV_Assert(image.size() == depth.size());
|
||||||
|
|
||||||
@@ -954,7 +954,8 @@ warpFrameImpl(const Mat& image, const Mat& depth, const Mat& mask,
|
|||||||
projectPoints(transformedCloud.reshape(3, 1), Mat::eye(3, 3, CV_64FC1), Mat::zeros(3, 1, CV_64FC1), cameraMatrix,
|
projectPoints(transformedCloud.reshape(3, 1), Mat::eye(3, 3, CV_64FC1), Mat::zeros(3, 1, CV_64FC1), cameraMatrix,
|
||||||
distCoeff, points2d);
|
distCoeff, points2d);
|
||||||
|
|
||||||
warpedImage = Mat(image.size(), image.type(), Scalar::all(0));
|
_warpedImage.create(image.size(), image.type());
|
||||||
|
Mat warpedImage = _warpedImage.getMat();
|
||||||
|
|
||||||
Mat zBuffer(image.size(), CV_32FC1, std::numeric_limits<float>::max());
|
Mat zBuffer(image.size(), CV_32FC1, std::numeric_limits<float>::max());
|
||||||
const Rect rect = Rect(0, 0, image.cols, image.rows);
|
const Rect rect = Rect(0, 0, image.cols, image.rows);
|
||||||
@@ -978,13 +979,13 @@ warpFrameImpl(const Mat& image, const Mat& depth, const Mat& mask,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(warpedMask)
|
if(warpedMask.needed())
|
||||||
*warpedMask = zBuffer != std::numeric_limits<float>::max();
|
Mat(zBuffer != std::numeric_limits<float>::max()).copyTo(warpedMask);
|
||||||
|
|
||||||
if(warpedDepth)
|
if(warpedDepth.needed())
|
||||||
{
|
{
|
||||||
zBuffer.setTo(std::numeric_limits<float>::quiet_NaN(), zBuffer == std::numeric_limits<float>::max());
|
zBuffer.setTo(std::numeric_limits<float>::quiet_NaN(), zBuffer == std::numeric_limits<float>::max());
|
||||||
*warpedDepth = zBuffer;
|
zBuffer.copyTo(warpedDepth);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1406,7 +1407,7 @@ bool RgbdICPOdometry::computeImpl(const Ptr<OdometryFrame>& srcFrame, const Ptr<
|
|||||||
void
|
void
|
||||||
warpFrame(const Mat& image, const Mat& depth, const Mat& mask,
|
warpFrame(const Mat& image, const Mat& depth, const Mat& mask,
|
||||||
const Mat& Rt, const Mat& cameraMatrix, const Mat& distCoeff,
|
const Mat& Rt, const Mat& cameraMatrix, const Mat& distCoeff,
|
||||||
Mat& warpedImage, Mat* warpedDepth, Mat* warpedMask)
|
OutputArray warpedImage, OutputArray warpedDepth, OutputArray warpedMask)
|
||||||
{
|
{
|
||||||
if(image.type() == CV_8UC1)
|
if(image.type() == CV_8UC1)
|
||||||
warpFrameImpl<uchar>(image, depth, mask, Rt, cameraMatrix, distCoeff, warpedImage, warpedDepth, warpedMask);
|
warpFrameImpl<uchar>(image, depth, mask, Rt, cameraMatrix, distCoeff, warpedImage, warpedDepth, warpedMask);
|
||||||
|
Reference in New Issue
Block a user