Commit 54d65f9d authored by Linus Ericsson's avatar Linus Ericsson Committed by Maksim Shabunin

Added python bindings for rgbd module (#1284)

* Added python bindings for whole rgbd module

* changed exposed constructors to static Ptr<class>::create() functions

* removed python bindings for isValidDepth*

* removed operator bindings
parent 2a9d1b22
......@@ -104,12 +104,14 @@ namespace rgbd
* ``Gradient Response Maps for Real-Time Detection of Texture-Less Objects``
* by S. Hinterstoisser, C. Cagniart, S. Ilic, P. Sturm, N. Navab, P. Fua, and V. Lepetit
*/
class CV_EXPORTS RgbdNormals: public Algorithm
class CV_EXPORTS_W RgbdNormals: public Algorithm
{
public:
enum RGBD_NORMALS_METHOD
{
RGBD_NORMALS_METHOD_FALS, RGBD_NORMALS_METHOD_LINEMOD, RGBD_NORMALS_METHOD_SRI
RGBD_NORMALS_METHOD_FALS = 0,
RGBD_NORMALS_METHOD_LINEMOD = 1,
RGBD_NORMALS_METHOD_SRI = 2
};
RgbdNormals()
......@@ -133,10 +135,13 @@ namespace rgbd
* @param method one of the methods to use: RGBD_NORMALS_METHOD_SRI, RGBD_NORMALS_METHOD_FALS
*/
RgbdNormals(int rows, int cols, int depth, InputArray K, int window_size = 5, int method =
RGBD_NORMALS_METHOD_FALS);
RgbdNormals::RGBD_NORMALS_METHOD_FALS);
~RgbdNormals();
CV_WRAP static Ptr<RgbdNormals> create(int rows, int cols, int depth, InputArray K, int window_size = 5, int method =
RgbdNormals::RGBD_NORMALS_METHOD_FALS);
/** Given a set of 3d points in a depth image, compute the normals at each point.
* @param points a rows x cols x 3 matrix of CV_32F/CV64F or a rows x cols x 1 CV_U16S
* @param normals a rows x cols x 3 matrix
......@@ -147,54 +152,54 @@ namespace rgbd
/** Initializes some data that is cached for later computation
* If that function is not called, it will be called the first time normals are computed
*/
void
CV_WRAP void
initialize() const;
int getRows() const
CV_WRAP int getRows() const
{
return rows_;
}
void setRows(int val)
CV_WRAP void setRows(int val)
{
rows_ = val;
}
int getCols() const
CV_WRAP int getCols() const
{
return cols_;
}
void setCols(int val)
CV_WRAP void setCols(int val)
{
cols_ = val;
}
int getWindowSize() const
CV_WRAP int getWindowSize() const
{
return window_size_;
}
void setWindowSize(int val)
CV_WRAP void setWindowSize(int val)
{
window_size_ = val;
}
int getDepth() const
CV_WRAP int getDepth() const
{
return depth_;
}
void setDepth(int val)
CV_WRAP void setDepth(int val)
{
depth_ = val;
}
cv::Mat getK() const
CV_WRAP cv::Mat getK() const
{
return K_;
}
void setK(const cv::Mat &val)
CV_WRAP void setK(const cv::Mat &val)
{
K_ = val;
}
int getMethod() const
CV_WRAP int getMethod() const
{
return method_;
}
void setMethod(int val)
CV_WRAP void setMethod(int val)
{
method_ = val;
}
......@@ -212,7 +217,7 @@ namespace rgbd
/** Object that can clean a noisy depth image
*/
class CV_EXPORTS DepthCleaner: public Algorithm
class CV_EXPORTS_W DepthCleaner: public Algorithm
{
public:
/** NIL method is from
......@@ -238,10 +243,12 @@ namespace rgbd
* @param window_size the window size to compute the normals: can only be 1,3,5 or 7
* @param method one of the methods to use: RGBD_NORMALS_METHOD_SRI, RGBD_NORMALS_METHOD_FALS
*/
DepthCleaner(int depth, int window_size = 5, int method = DEPTH_CLEANER_NIL);
DepthCleaner(int depth, int window_size = 5, int method = DepthCleaner::DEPTH_CLEANER_NIL);
~DepthCleaner();
CV_WRAP static Ptr<DepthCleaner> create(int depth, int window_size = 5, int method = DepthCleaner::DEPTH_CLEANER_NIL);
/** Given a set of 3d points in a depth image, compute the normals at each point.
* @param points a rows x cols x 3 matrix of CV_32F/CV64F or a rows x cols x 1 CV_U16S
* @param depth a rows x cols matrix of the cleaned up depth
......@@ -252,30 +259,30 @@ namespace rgbd
/** Initializes some data that is cached for later computation
* If that function is not called, it will be called the first time normals are computed
*/
void
CV_WRAP void
initialize() const;
int getWindowSize() const
CV_WRAP int getWindowSize() const
{
return window_size_;
}
void setWindowSize(int val)
CV_WRAP void setWindowSize(int val)
{
window_size_ = val;
}
int getDepth() const
CV_WRAP int getDepth() const
{
return depth_;
}
void setDepth(int val)
CV_WRAP void setDepth(int val)
{
depth_ = val;
}
int getMethod() const
CV_WRAP int getMethod() const
{
return method_;
}
void setMethod(int val)
CV_WRAP void setMethod(int val)
{
method_ = val;
}
......@@ -309,7 +316,7 @@ namespace rgbd
* @param registeredDepth the result of transforming the depth into the external camera
* @param depthDilation whether or not the depth is dilated to avoid holes and occlusion errors (optional)
*/
CV_EXPORTS
CV_EXPORTS_W
void
registerDepth(InputArray unregisteredCameraMatrix, InputArray registeredCameraMatrix, InputArray registeredDistCoeffs,
InputArray Rt, InputArray unregisteredDepth, const Size& outputImagePlaneSize,
......@@ -321,7 +328,7 @@ namespace rgbd
* @param in_points the list of xy coordinates
* @param points3d the resulting 3d points
*/
CV_EXPORTS
CV_EXPORTS_W
void
depthTo3dSparse(InputArray depth, InputArray in_K, InputArray in_points, OutputArray points3d);
......@@ -346,13 +353,13 @@ namespace rgbd
* @param depth the desired output depth (floats or double)
* @param out The rescaled float depth image
*/
CV_EXPORTS
CV_EXPORTS_W
void
rescaleDepth(InputArray in, int depth, OutputArray out);
/** Object that can compute planes in an image
*/
class CV_EXPORTS RgbdPlane: public Algorithm
class CV_EXPORTS_W RgbdPlane: public Algorithm
{
public:
enum RGBD_PLANE_METHOD
......@@ -360,7 +367,7 @@ namespace rgbd
RGBD_PLANE_METHOD_DEFAULT
};
RgbdPlane(RGBD_PLANE_METHOD method = RGBD_PLANE_METHOD_DEFAULT)
RgbdPlane(int method = RgbdPlane::RGBD_PLANE_METHOD_DEFAULT)
:
method_(method),
block_size_(40),
......@@ -393,59 +400,59 @@ namespace rgbd
void
operator()(InputArray points3d, OutputArray mask, OutputArray plane_coefficients);
int getBlockSize() const
CV_WRAP int getBlockSize() const
{
return block_size_;
}
void setBlockSize(int val)
CV_WRAP void setBlockSize(int val)
{
block_size_ = val;
}
int getMinSize() const
CV_WRAP int getMinSize() const
{
return min_size_;
}
void setMinSize(int val)
CV_WRAP void setMinSize(int val)
{
min_size_ = val;
}
int getMethod() const
CV_WRAP int getMethod() const
{
return method_;
}
void setMethod(int val)
CV_WRAP void setMethod(int val)
{
method_ = val;
}
double getThreshold() const
CV_WRAP double getThreshold() const
{
return threshold_;
}
void setThreshold(double val)
CV_WRAP void setThreshold(double val)
{
threshold_ = val;
}
double getSensorErrorA() const
CV_WRAP double getSensorErrorA() const
{
return sensor_error_a_;
}
void setSensorErrorA(double val)
CV_WRAP void setSensorErrorA(double val)
{
sensor_error_a_ = val;
}
double getSensorErrorB() const
CV_WRAP double getSensorErrorB() const
{
return sensor_error_b_;
}
void setSensorErrorB(double val)
CV_WRAP void setSensorErrorB(double val)
{
sensor_error_b_ = val;
}
double getSensorErrorC() const
CV_WRAP double getSensorErrorC() const
{
return sensor_error_c_;
}
void setSensorErrorC(double val)
CV_WRAP void setSensorErrorC(double val)
{
sensor_error_c_ = val;
}
......@@ -465,27 +472,29 @@ namespace rgbd
/** Object that contains a frame data.
*/
struct CV_EXPORTS RgbdFrame
struct CV_EXPORTS_W RgbdFrame
{
RgbdFrame();
RgbdFrame(const Mat& image, const Mat& depth, const Mat& mask=Mat(), const Mat& normals=Mat(), int ID=-1);
virtual ~RgbdFrame();
virtual void
CV_WRAP static Ptr<RgbdFrame> create(const Mat& image=Mat(), const Mat& depth=Mat(), const Mat& mask=Mat(), const Mat& normals=Mat(), int ID=-1);
CV_WRAP virtual void
release();
int ID;
Mat image;
Mat depth;
Mat mask;
Mat normals;
CV_PROP int ID;
CV_PROP Mat image;
CV_PROP Mat depth;
CV_PROP Mat mask;
CV_PROP Mat normals;
};
/** Object that contains a frame data that is possibly needed for the Odometry.
* It's used for the efficiency (to pass precomputed/cached data of the frame that participates
* in the Odometry processing several times).
*/
struct CV_EXPORTS OdometryFrame : public RgbdFrame
struct CV_EXPORTS_W OdometryFrame : public RgbdFrame
{
/** These constants are used to set a type of cache which has to be prepared depending on the frame role:
* srcFrame or dstFrame (see compute method of the Odometry class). For the srcFrame and dstFrame different cache data may be required,
......@@ -502,29 +511,31 @@ namespace rgbd
OdometryFrame();
OdometryFrame(const Mat& image, const Mat& depth, const Mat& mask=Mat(), const Mat& normals=Mat(), int ID=-1);
virtual void
CV_WRAP static Ptr<OdometryFrame> create(const Mat& image=Mat(), const Mat& depth=Mat(), const Mat& mask=Mat(), const Mat& normals=Mat(), int ID=-1);
CV_WRAP virtual void
release();
void
CV_WRAP void
releasePyramids();
std::vector<Mat> pyramidImage;
std::vector<Mat> pyramidDepth;
std::vector<Mat> pyramidMask;
CV_PROP std::vector<Mat> pyramidImage;
CV_PROP std::vector<Mat> pyramidDepth;
CV_PROP std::vector<Mat> pyramidMask;
std::vector<Mat> pyramidCloud;
CV_PROP std::vector<Mat> pyramidCloud;
std::vector<Mat> pyramid_dI_dx;
std::vector<Mat> pyramid_dI_dy;
std::vector<Mat> pyramidTexturedMask;
CV_PROP std::vector<Mat> pyramid_dI_dx;
CV_PROP std::vector<Mat> pyramid_dI_dy;
CV_PROP std::vector<Mat> pyramidTexturedMask;
std::vector<Mat> pyramidNormals;
std::vector<Mat> pyramidNormalsMask;
CV_PROP std::vector<Mat> pyramidNormals;
CV_PROP std::vector<Mat> pyramidNormalsMask;
};
/** Base class for computation of odometry.
*/
class CV_EXPORTS Odometry: public Algorithm
class CV_EXPORTS_W Odometry: public Algorithm
{
public:
......@@ -534,32 +545,32 @@ namespace rgbd
ROTATION = 1, TRANSLATION = 2, RIGID_BODY_MOTION = 4
};
static inline float
CV_WRAP static inline float
DEFAULT_MIN_DEPTH()
{
return 0.f; // in meters
}
static inline float
CV_WRAP static inline float
DEFAULT_MAX_DEPTH()
{
return 4.f; // in meters
}
static inline float
CV_WRAP static inline float
DEFAULT_MAX_DEPTH_DIFF()
{
return 0.07f; // in meters
}
static inline float
CV_WRAP static inline float
DEFAULT_MAX_POINTS_PART()
{
return 0.07f; // in [0, 1]
}
static inline float
CV_WRAP static inline float
DEFAULT_MAX_TRANSLATION()
{
return 0.15f; // in meters
}
static inline float
CV_WRAP static inline float
DEFAULT_MAX_ROTATION()
{
return 15; // in degrees
......@@ -583,15 +594,15 @@ namespace rgbd
Rt is 4x4 matrix of CV_64FC1 type.
* @param initRt Initial transformation from the source frame to the destination one (optional)
*/
bool
CV_WRAP bool
compute(const Mat& srcImage, const Mat& srcDepth, const Mat& srcMask, const Mat& dstImage, const Mat& dstDepth,
const Mat& dstMask, Mat& Rt, const Mat& initRt = Mat()) const;
const Mat& dstMask, OutputArray Rt, const Mat& initRt = Mat()) const;
/** One more method to compute a transformation from the source frame to the destination one.
* It is designed to save on computing the frame data (image pyramids, normals, etc.).
*/
bool
compute(Ptr<OdometryFrame>& srcFrame, Ptr<OdometryFrame>& dstFrame, Mat& Rt, const Mat& initRt = Mat()) const;
CV_WRAP_AS(compute2) bool
compute(Ptr<OdometryFrame>& srcFrame, Ptr<OdometryFrame>& dstFrame, OutputArray Rt, const Mat& initRt = Mat()) const;
/** Prepare a cache for the frame. The function checks the precomputed/passed data (throws the error if this data
* does not satisfy) and computes all remaining cache data needed for the frame. Returned size is a resolution
......@@ -599,32 +610,32 @@ namespace rgbd
* @param frame The odometry which will process the frame.
* @param cacheType The cache type: CACHE_SRC, CACHE_DST or CACHE_ALL.
*/
virtual Size prepareFrameCache(Ptr<OdometryFrame>& frame, int cacheType) const;
CV_WRAP virtual Size prepareFrameCache(Ptr<OdometryFrame>& frame, int cacheType) const;
static Ptr<Odometry> create(const String & odometryType);
CV_WRAP static Ptr<Odometry> create(const String & odometryType);
/** @see setCameraMatrix */
virtual cv::Mat getCameraMatrix() const = 0;
CV_WRAP virtual cv::Mat getCameraMatrix() const = 0;
/** @copybrief getCameraMatrix @see getCameraMatrix */
virtual void setCameraMatrix(const cv::Mat &val) = 0;
CV_WRAP virtual void setCameraMatrix(const cv::Mat &val) = 0;
/** @see setTransformType */
virtual int getTransformType() const = 0;
CV_WRAP virtual int getTransformType() const = 0;
/** @copybrief getTransformType @see getTransformType */
virtual void setTransformType(int val) = 0;
CV_WRAP virtual void setTransformType(int val) = 0;
protected:
virtual void
checkParams() const = 0;
virtual bool
computeImpl(const Ptr<OdometryFrame>& srcFrame, const Ptr<OdometryFrame>& dstFrame, Mat& Rt,
computeImpl(const Ptr<OdometryFrame>& srcFrame, const Ptr<OdometryFrame>& dstFrame, OutputArray Rt,
const Mat& initRt) const = 0;
};
/** Odometry based on the paper "Real-Time Visual Odometry from Dense RGB-D Images",
* F. Steinbucker, J. Strum, D. Cremers, ICCV, 2011.
*/
class CV_EXPORTS RgbdOdometry: public Odometry
class CV_EXPORTS_W RgbdOdometry: public Odometry
{
public:
RgbdOdometry();
......@@ -640,90 +651,95 @@ namespace rgbd
* @param maxPointsPart The method uses a random pixels subset of size frameWidth x frameHeight x pointsPart
* @param transformType Class of transformation
*/
RgbdOdometry(const Mat& cameraMatrix, float minDepth = DEFAULT_MIN_DEPTH(), float maxDepth = DEFAULT_MAX_DEPTH(),
float maxDepthDiff = DEFAULT_MAX_DEPTH_DIFF(), const std::vector<int>& iterCounts = std::vector<int>(),
const std::vector<float>& minGradientMagnitudes = std::vector<float>(), float maxPointsPart = DEFAULT_MAX_POINTS_PART(),
int transformType = RIGID_BODY_MOTION);
RgbdOdometry(const Mat& cameraMatrix, float minDepth = Odometry::DEFAULT_MIN_DEPTH(), float maxDepth = Odometry::DEFAULT_MAX_DEPTH(),
float maxDepthDiff = Odometry::DEFAULT_MAX_DEPTH_DIFF(), const std::vector<int>& iterCounts = std::vector<int>(),
const std::vector<float>& minGradientMagnitudes = std::vector<float>(), float maxPointsPart = Odometry::DEFAULT_MAX_POINTS_PART(),
int transformType = Odometry::RIGID_BODY_MOTION);
CV_WRAP static Ptr<RgbdOdometry> create(const Mat& cameraMatrix = Mat(), float minDepth = Odometry::DEFAULT_MIN_DEPTH(), float maxDepth = Odometry::DEFAULT_MAX_DEPTH(),
float maxDepthDiff = Odometry::DEFAULT_MAX_DEPTH_DIFF(), const std::vector<int>& iterCounts = std::vector<int>(),
const std::vector<float>& minGradientMagnitudes = std::vector<float>(), float maxPointsPart = Odometry::DEFAULT_MAX_POINTS_PART(),
int transformType = Odometry::RIGID_BODY_MOTION);
virtual Size prepareFrameCache(Ptr<OdometryFrame>& frame, int cacheType) const;
CV_WRAP virtual Size prepareFrameCache(Ptr<OdometryFrame>& frame, int cacheType) const;
cv::Mat getCameraMatrix() const
CV_WRAP cv::Mat getCameraMatrix() const
{
return cameraMatrix;
}
void setCameraMatrix(const cv::Mat &val)
CV_WRAP void setCameraMatrix(const cv::Mat &val)
{
cameraMatrix = val;
}
double getMinDepth() const
CV_WRAP double getMinDepth() const
{
return minDepth;
}
void setMinDepth(double val)
CV_WRAP void setMinDepth(double val)
{
minDepth = val;
}
double getMaxDepth() const
CV_WRAP double getMaxDepth() const
{
return maxDepth;
}
void setMaxDepth(double val)
CV_WRAP void setMaxDepth(double val)
{
maxDepth = val;
}
double getMaxDepthDiff() const
CV_WRAP double getMaxDepthDiff() const
{
return maxDepthDiff;
}
void setMaxDepthDiff(double val)
CV_WRAP void setMaxDepthDiff(double val)
{
maxDepthDiff = val;
}
cv::Mat getIterationCounts() const
CV_WRAP cv::Mat getIterationCounts() const
{
return iterCounts;
}
void setIterationCounts(const cv::Mat &val)
CV_WRAP void setIterationCounts(const cv::Mat &val)
{
iterCounts = val;
}
cv::Mat getMinGradientMagnitudes() const
CV_WRAP cv::Mat getMinGradientMagnitudes() const
{
return minGradientMagnitudes;
}
void setMinGradientMagnitudes(const cv::Mat &val)
CV_WRAP void setMinGradientMagnitudes(const cv::Mat &val)
{
minGradientMagnitudes = val;
}
double getMaxPointsPart() const
CV_WRAP double getMaxPointsPart() const
{
return maxPointsPart;
}
void setMaxPointsPart(double val)
CV_WRAP void setMaxPointsPart(double val)
{
maxPointsPart = val;
}
int getTransformType() const
CV_WRAP int getTransformType() const
{
return transformType;
}
void setTransformType(int val)
CV_WRAP void setTransformType(int val)
{
transformType = val;
}
double getMaxTranslation() const
CV_WRAP double getMaxTranslation() const
{
return maxTranslation;
}
void setMaxTranslation(double val)
CV_WRAP void setMaxTranslation(double val)
{
maxTranslation = val;
}
double getMaxRotation() const
CV_WRAP double getMaxRotation() const
{
return maxRotation;
}
void setMaxRotation(double val)
CV_WRAP void setMaxRotation(double val)
{
maxRotation = val;
}
......@@ -733,7 +749,7 @@ namespace rgbd
checkParams() const;
virtual bool
computeImpl(const Ptr<OdometryFrame>& srcFrame, const Ptr<OdometryFrame>& dstFrame, Mat& Rt,
computeImpl(const Ptr<OdometryFrame>& srcFrame, const Ptr<OdometryFrame>& dstFrame, OutputArray Rt,
const Mat& initRt) const;
// Some params have commented desired type. It's due to AlgorithmInfo::addParams does not support it now.
......@@ -754,7 +770,7 @@ namespace rgbd
/** Odometry based on the paper "KinectFusion: Real-Time Dense Surface Mapping and Tracking",
* Richard A. Newcombe, Andrew Fitzgibbon, at al, SIGGRAPH, 2011.
*/
class ICPOdometry: public Odometry
class CV_EXPORTS_W ICPOdometry: public Odometry
{
public:
ICPOdometry();
......@@ -768,85 +784,89 @@ namespace rgbd
* @param iterCounts Count of iterations on each pyramid level.
* @param transformType Class of trasformation
*/
ICPOdometry(const Mat& cameraMatrix, float minDepth = DEFAULT_MIN_DEPTH(), float maxDepth = DEFAULT_MAX_DEPTH(),
float maxDepthDiff = DEFAULT_MAX_DEPTH_DIFF(), float maxPointsPart = DEFAULT_MAX_POINTS_PART(),
const std::vector<int>& iterCounts = std::vector<int>(), int transformType = RIGID_BODY_MOTION);
ICPOdometry(const Mat& cameraMatrix, float minDepth = Odometry::DEFAULT_MIN_DEPTH(), float maxDepth = Odometry::DEFAULT_MAX_DEPTH(),
float maxDepthDiff = Odometry::DEFAULT_MAX_DEPTH_DIFF(), float maxPointsPart = Odometry::DEFAULT_MAX_POINTS_PART(),
const std::vector<int>& iterCounts = std::vector<int>(), int transformType = Odometry::RIGID_BODY_MOTION);
virtual Size prepareFrameCache(Ptr<OdometryFrame>& frame, int cacheType) const;
CV_WRAP static Ptr<ICPOdometry> create(const Mat& cameraMatrix = Mat(), float minDepth = Odometry::DEFAULT_MIN_DEPTH(), float maxDepth = Odometry::DEFAULT_MAX_DEPTH(),
float maxDepthDiff = Odometry::DEFAULT_MAX_DEPTH_DIFF(), float maxPointsPart = Odometry::DEFAULT_MAX_POINTS_PART(),
const std::vector<int>& iterCounts = std::vector<int>(), int transformType = Odometry::RIGID_BODY_MOTION);
cv::Mat getCameraMatrix() const
CV_WRAP virtual Size prepareFrameCache(Ptr<OdometryFrame>& frame, int cacheType) const;
CV_WRAP cv::Mat getCameraMatrix() const
{
return cameraMatrix;
}
void setCameraMatrix(const cv::Mat &val)
CV_WRAP void setCameraMatrix(const cv::Mat &val)
{
cameraMatrix = val;
}
double getMinDepth() const
CV_WRAP double getMinDepth() const
{
return minDepth;
}
void setMinDepth(double val)
CV_WRAP void setMinDepth(double val)
{
minDepth = val;
}
double getMaxDepth() const
CV_WRAP double getMaxDepth() const
{
return maxDepth;
}
void setMaxDepth(double val)
CV_WRAP void setMaxDepth(double val)
{
maxDepth = val;
}
double getMaxDepthDiff() const
CV_WRAP double getMaxDepthDiff() const
{
return maxDepthDiff;
}
void setMaxDepthDiff(double val)
CV_WRAP void setMaxDepthDiff(double val)
{
maxDepthDiff = val;
}
cv::Mat getIterationCounts() const
CV_WRAP cv::Mat getIterationCounts() const
{
return iterCounts;
}
void setIterationCounts(const cv::Mat &val)
CV_WRAP void setIterationCounts(const cv::Mat &val)
{
iterCounts = val;
}
double getMaxPointsPart() const
CV_WRAP double getMaxPointsPart() const
{
return maxPointsPart;
}
void setMaxPointsPart(double val)
CV_WRAP void setMaxPointsPart(double val)
{
maxPointsPart = val;
}
int getTransformType() const
CV_WRAP int getTransformType() const
{
return transformType;
}
void setTransformType(int val)
CV_WRAP void setTransformType(int val)
{
transformType = val;
}
double getMaxTranslation() const
CV_WRAP double getMaxTranslation() const
{
return maxTranslation;
}
void setMaxTranslation(double val)
CV_WRAP void setMaxTranslation(double val)
{
maxTranslation = val;
}
double getMaxRotation() const
CV_WRAP double getMaxRotation() const
{
return maxRotation;
}
void setMaxRotation(double val)
CV_WRAP void setMaxRotation(double val)
{
maxRotation = val;
}
Ptr<RgbdNormals> getNormalsComputer() const
CV_WRAP Ptr<RgbdNormals> getNormalsComputer() const
{
return normalsComputer;
}
......@@ -856,7 +876,7 @@ namespace rgbd
checkParams() const;
virtual bool
computeImpl(const Ptr<OdometryFrame>& srcFrame, const Ptr<OdometryFrame>& dstFrame, Mat& Rt,
computeImpl(const Ptr<OdometryFrame>& srcFrame, const Ptr<OdometryFrame>& dstFrame, OutputArray Rt,
const Mat& initRt) const;
// Some params have commented desired type. It's due to AlgorithmInfo::addParams does not support it now.
......@@ -878,7 +898,7 @@ namespace rgbd
/** Odometry that merges RgbdOdometry and ICPOdometry by minimize sum of their energy functions.
*/
class RgbdICPOdometry: public Odometry
class CV_EXPORTS_W RgbdICPOdometry: public Odometry
{
public:
RgbdICPOdometry();
......@@ -894,95 +914,101 @@ namespace rgbd
* if they have gradient magnitude less than minGradientMagnitudes[level].
* @param transformType Class of trasformation
*/
RgbdICPOdometry(const Mat& cameraMatrix, float minDepth = DEFAULT_MIN_DEPTH(), float maxDepth = DEFAULT_MAX_DEPTH(),
float maxDepthDiff = DEFAULT_MAX_DEPTH_DIFF(), float maxPointsPart = DEFAULT_MAX_POINTS_PART(),
RgbdICPOdometry(const Mat& cameraMatrix, float minDepth = Odometry::DEFAULT_MIN_DEPTH(), float maxDepth = Odometry::DEFAULT_MAX_DEPTH(),
float maxDepthDiff = Odometry::DEFAULT_MAX_DEPTH_DIFF(), float maxPointsPart = Odometry::DEFAULT_MAX_POINTS_PART(),
const std::vector<int>& iterCounts = std::vector<int>(),
const std::vector<float>& minGradientMagnitudes = std::vector<float>(),
int transformType = Odometry::RIGID_BODY_MOTION);
CV_WRAP static Ptr<RgbdICPOdometry> create(const Mat& cameraMatrix = Mat(), float minDepth = Odometry::DEFAULT_MIN_DEPTH(), float maxDepth = Odometry::DEFAULT_MAX_DEPTH(),
float maxDepthDiff = Odometry::DEFAULT_MAX_DEPTH_DIFF(), float maxPointsPart = Odometry::DEFAULT_MAX_POINTS_PART(),
const std::vector<int>& iterCounts = std::vector<int>(),
const std::vector<float>& minGradientMagnitudes = std::vector<float>(),
int transformType = RIGID_BODY_MOTION);
int transformType = Odometry::RIGID_BODY_MOTION);
virtual Size prepareFrameCache(Ptr<OdometryFrame>& frame, int cacheType) const;
CV_WRAP virtual Size prepareFrameCache(Ptr<OdometryFrame>& frame, int cacheType) const;
cv::Mat getCameraMatrix() const
CV_WRAP cv::Mat getCameraMatrix() const
{
return cameraMatrix;
}
void setCameraMatrix(const cv::Mat &val)
CV_WRAP void setCameraMatrix(const cv::Mat &val)
{
cameraMatrix = val;
}
double getMinDepth() const
CV_WRAP double getMinDepth() const
{
return minDepth;
}
void setMinDepth(double val)
CV_WRAP void setMinDepth(double val)
{
minDepth = val;
}
double getMaxDepth() const
CV_WRAP double getMaxDepth() const
{
return maxDepth;
}
void setMaxDepth(double val)
CV_WRAP void setMaxDepth(double val)
{
maxDepth = val;
}
double getMaxDepthDiff() const
CV_WRAP double getMaxDepthDiff() const
{
return maxDepthDiff;
}
void setMaxDepthDiff(double val)
CV_WRAP void setMaxDepthDiff(double val)
{
maxDepthDiff = val;
}
double getMaxPointsPart() const
CV_WRAP double getMaxPointsPart() const
{
return maxPointsPart;
}
void setMaxPointsPart(double val)
CV_WRAP void setMaxPointsPart(double val)
{
maxPointsPart = val;
}
cv::Mat getIterationCounts() const
CV_WRAP cv::Mat getIterationCounts() const
{
return iterCounts;
}
void setIterationCounts(const cv::Mat &val)
CV_WRAP void setIterationCounts(const cv::Mat &val)
{
iterCounts = val;
}
cv::Mat getMinGradientMagnitudes() const
CV_WRAP cv::Mat getMinGradientMagnitudes() const
{
return minGradientMagnitudes;
}
void setMinGradientMagnitudes(const cv::Mat &val)
CV_WRAP void setMinGradientMagnitudes(const cv::Mat &val)
{
minGradientMagnitudes = val;
}
int getTransformType() const
CV_WRAP int getTransformType() const
{
return transformType;
}
void setTransformType(int val)
CV_WRAP void setTransformType(int val)
{
transformType = val;
}
double getMaxTranslation() const
CV_WRAP double getMaxTranslation() const
{
return maxTranslation;
}
void setMaxTranslation(double val)
CV_WRAP void setMaxTranslation(double val)
{
maxTranslation = val;
}
double getMaxRotation() const
CV_WRAP double getMaxRotation() const
{
return maxRotation;
}
void setMaxRotation(double val)
CV_WRAP void setMaxRotation(double val)
{
maxRotation = val;
}
Ptr<RgbdNormals> getNormalsComputer() const
CV_WRAP Ptr<RgbdNormals> getNormalsComputer() const
{
return normalsComputer;
}
......@@ -992,7 +1018,7 @@ namespace rgbd
checkParams() const;
virtual bool
computeImpl(const Ptr<OdometryFrame>& srcFrame, const Ptr<OdometryFrame>& dstFrame, Mat& Rt,
computeImpl(const Ptr<OdometryFrame>& srcFrame, const Ptr<OdometryFrame>& dstFrame, OutputArray Rt,
const Mat& initRt) const;
// Some params have commented desired type. It's due to AlgorithmInfo::addParams does not support it now.
......
......@@ -804,7 +804,7 @@ bool testDeltaTransformation(const Mat& deltaRt, double maxTranslation, double m
}
static
bool RGBDICPOdometryImpl(Mat& Rt, const Mat& initRt,
bool RGBDICPOdometryImpl(OutputArray _Rt, const Mat& initRt,
const Ptr<OdometryFrame>& srcFrame,
const Ptr<OdometryFrame>& dstFrame,
const Mat& cameraMatrix,
......@@ -920,8 +920,9 @@ bool RGBDICPOdometryImpl(Mat& Rt, const Mat& initRt,
isOk = true;
}
}
Rt = resultRt;
_Rt.create(resultRt.size(), resultRt.type());
Mat Rt = _Rt.getMat();
resultRt.copyTo(Rt);
if(isOk)
{
......@@ -991,6 +992,14 @@ warpFrameImpl(const Mat& image, const Mat& depth, const Mat& mask,
///////////////////////////////////////////////////////////////////////////////////////////////
Ptr<RgbdNormals> RgbdNormals::create(int rows_in, int cols_in, int depth_in, InputArray K_in, int window_size_in, int method_in) {
return makePtr<RgbdNormals>(rows_in, cols_in, depth_in, K_in, window_size_in, method_in);
}
Ptr<DepthCleaner> DepthCleaner::create(int depth_in, int window_size_in, int method_in) {
return makePtr<DepthCleaner>(depth_in, window_size_in, method_in);
}
RgbdFrame::RgbdFrame() : ID(-1)
{}
......@@ -1001,6 +1010,10 @@ RgbdFrame::RgbdFrame(const Mat& image_in, const Mat& depth_in, const Mat& mask_i
RgbdFrame::~RgbdFrame()
{}
Ptr<RgbdFrame> RgbdFrame::create(const Mat& image_in, const Mat& depth_in, const Mat& mask_in, const Mat& normals_in, int ID_in) {
return makePtr<RgbdFrame>(image_in, depth_in, mask_in, normals_in, ID_in);
}
void RgbdFrame::release()
{
ID = -1;
......@@ -1017,6 +1030,10 @@ OdometryFrame::OdometryFrame(const Mat& image_in, const Mat& depth_in, const Mat
: RgbdFrame(image_in, depth_in, mask_in, normals_in, ID_in)
{}
Ptr<OdometryFrame> OdometryFrame::create(const Mat& image_in, const Mat& depth_in, const Mat& mask_in, const Mat& normals_in, int ID_in) {
return makePtr<OdometryFrame>(image_in, depth_in, mask_in, normals_in, ID_in);
}
void OdometryFrame::release()
{
RgbdFrame::release();
......@@ -1041,7 +1058,7 @@ void OdometryFrame::releasePyramids()
bool Odometry::compute(const Mat& srcImage, const Mat& srcDepth, const Mat& srcMask,
const Mat& dstImage, const Mat& dstDepth, const Mat& dstMask,
Mat& Rt, const Mat& initRt) const
OutputArray Rt, const Mat& initRt) const
{
Ptr<OdometryFrame> srcFrame(new OdometryFrame(srcImage, srcDepth, srcMask));
Ptr<OdometryFrame> dstFrame(new OdometryFrame(dstImage, dstDepth, dstMask));
......@@ -1049,7 +1066,7 @@ bool Odometry::compute(const Mat& srcImage, const Mat& srcDepth, const Mat& srcM
return compute(srcFrame, dstFrame, Rt, initRt);
}
bool Odometry::compute(Ptr<OdometryFrame>& srcFrame, Ptr<OdometryFrame>& dstFrame, Mat& Rt, const Mat& initRt) const
bool Odometry::compute(Ptr<OdometryFrame>& srcFrame, Ptr<OdometryFrame>& dstFrame, OutputArray Rt, const Mat& initRt) const
{
checkParams();
......@@ -1116,6 +1133,13 @@ RgbdOdometry::RgbdOdometry(const Mat& _cameraMatrix,
}
}
Ptr<RgbdOdometry> RgbdOdometry::create(const Mat& _cameraMatrix, float _minDepth, float _maxDepth,
float _maxDepthDiff, const std::vector<int>& _iterCounts,
const std::vector<float>& _minGradientMagnitudes, float _maxPointsPart,
int _transformType) {
return makePtr<RgbdOdometry>(_cameraMatrix, _minDepth, _maxDepth, _maxDepthDiff, _iterCounts, _minGradientMagnitudes, _maxPointsPart, _transformType);
}
Size RgbdOdometry::prepareFrameCache(Ptr<OdometryFrame>& frame, int cacheType) const
{
Odometry::prepareFrameCache(frame, cacheType);
......@@ -1177,7 +1201,7 @@ void RgbdOdometry::checkParams() const
CV_Assert(minGradientMagnitudes.size() == iterCounts.size() || minGradientMagnitudes.size() == iterCounts.t().size());
}
bool RgbdOdometry::computeImpl(const Ptr<OdometryFrame>& srcFrame, const Ptr<OdometryFrame>& dstFrame, Mat& Rt, const Mat& initRt) const
bool RgbdOdometry::computeImpl(const Ptr<OdometryFrame>& srcFrame, const Ptr<OdometryFrame>& dstFrame, OutputArray Rt, const Mat& initRt) const
{
return RGBDICPOdometryImpl(Rt, initRt, srcFrame, dstFrame, cameraMatrix, (float)maxDepthDiff, iterCounts, maxTranslation, maxRotation, RGBD_ODOMETRY, transformType);
}
......@@ -1204,6 +1228,12 @@ ICPOdometry::ICPOdometry(const Mat& _cameraMatrix,
setDefaultIterCounts(iterCounts);
}
Ptr<ICPOdometry> ICPOdometry::create(const Mat& _cameraMatrix, float _minDepth, float _maxDepth,
float _maxDepthDiff, float _maxPointsPart, const std::vector<int>& _iterCounts,
int _transformType) {
return makePtr<ICPOdometry>(_cameraMatrix, _minDepth, _maxDepth, _maxDepthDiff, _maxPointsPart, _iterCounts, _transformType);
}
Size ICPOdometry::prepareFrameCache(Ptr<OdometryFrame>& frame, int cacheType) const
{
Odometry::prepareFrameCache(frame, cacheType);
......@@ -1276,7 +1306,7 @@ void ICPOdometry::checkParams() const
CV_Assert(cameraMatrix.size() == Size(3,3) && (cameraMatrix.type() == CV_32FC1 || cameraMatrix.type() == CV_64FC1));
}
bool ICPOdometry::computeImpl(const Ptr<OdometryFrame>& srcFrame, const Ptr<OdometryFrame>& dstFrame, Mat& Rt, const Mat& initRt) const
bool ICPOdometry::computeImpl(const Ptr<OdometryFrame>& srcFrame, const Ptr<OdometryFrame>& dstFrame, OutputArray Rt, const Mat& initRt) const
{
return RGBDICPOdometryImpl(Rt, initRt, srcFrame, dstFrame, cameraMatrix, (float)maxDepthDiff, iterCounts, maxTranslation, maxRotation, ICP_ODOMETRY, transformType);
}
......@@ -1309,6 +1339,13 @@ RgbdICPOdometry::RgbdICPOdometry(const Mat& _cameraMatrix,
}
}
Ptr<RgbdICPOdometry> RgbdICPOdometry::create(const Mat& _cameraMatrix, float _minDepth, float _maxDepth,
float _maxDepthDiff, float _maxPointsPart, const std::vector<int>& _iterCounts,
const std::vector<float>& _minGradientMagnitudes,
int _transformType) {
return makePtr<RgbdICPOdometry>(_cameraMatrix, _minDepth, _maxDepth, _maxDepthDiff, _maxPointsPart, _iterCounts, _minGradientMagnitudes, _transformType);
}
Size RgbdICPOdometry::prepareFrameCache(Ptr<OdometryFrame>& frame, int cacheType) const
{
if(frame->image.empty())
......@@ -1397,7 +1434,7 @@ void RgbdICPOdometry::checkParams() const
CV_Assert(minGradientMagnitudes.size() == iterCounts.size() || minGradientMagnitudes.size() == iterCounts.t().size());
}
bool RgbdICPOdometry::computeImpl(const Ptr<OdometryFrame>& srcFrame, const Ptr<OdometryFrame>& dstFrame, Mat& Rt, const Mat& initRt) const
bool RgbdICPOdometry::computeImpl(const Ptr<OdometryFrame>& srcFrame, const Ptr<OdometryFrame>& dstFrame, OutputArray Rt, const Mat& initRt) const
{
return RGBDICPOdometryImpl(Rt, initRt, srcFrame, dstFrame, cameraMatrix, (float)maxDepthDiff, iterCounts, maxTranslation, maxRotation, MERGED_ODOMETRY, transformType);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment