Commit fbfc0cc9 authored by Maria Dimashova's avatar Maria Dimashova

added special cases to RGBDOdometry (translation only, rotation only)

parent f4e5209d
...@@ -629,13 +629,19 @@ namespace cv ...@@ -629,13 +629,19 @@ namespace cv
* Estimate the rigid body motion from frame0 to frame1. The method is based on the paper * Estimate the rigid body motion from frame0 to frame1. The method is based on the paper
* "Real-Time Visual Odometry from Dense RGB-D Images", F. Steinbucker, J. Strum, D. Cremers, ICCV, 2011. * "Real-Time Visual Odometry from Dense RGB-D Images", F. Steinbucker, J. Strum, D. Cremers, ICCV, 2011.
*/ */
CV_EXPORTS struct TransformationType
{
enum { ROTATION = 1,
TRANSLATION = 2,
RIGID_BODY_MOTION = 4
};
};
CV_EXPORTS bool RGBDOdometry( cv::Mat& Rt, CV_EXPORTS bool RGBDOdometry( cv::Mat& Rt,
const cv::Mat& image0, const cv::Mat& depth0, const cv::Mat& mask0, const cv::Mat& image0, const cv::Mat& depth0, const cv::Mat& mask0,
const cv::Mat& image1, const cv::Mat& depth1, const cv::Mat& mask1, const cv::Mat& image1, const cv::Mat& depth1, const cv::Mat& mask1,
const cv::Mat& cameraMatrix, const std::vector<int>& iterCounts, const cv::Mat& cameraMatrix, const std::vector<int>& iterCounts,
const std::vector<float>& minGradientMagnitudes, const std::vector<float>& minGradientMagnitudes,
float minDepth, float maxDepth, float maxDepthDiff ); float minDepth, float maxDepth, float maxDepthDiff, int transformType=TransformationType::RIGID_BODY_MOTION );
} }
#include "opencv2/contrib/retina.hpp" #include "opencv2/contrib/retina.hpp"
......
This diff is collapsed.
...@@ -78,10 +78,14 @@ int main(int argc, char** argv) ...@@ -78,10 +78,14 @@ int main(int argc, char** argv)
const Mat cameraMatrix = Mat(3,3,CV_32FC1,vals); const Mat cameraMatrix = Mat(3,3,CV_32FC1,vals);
const Mat distCoeff(1,5,CV_32FC1,Scalar(0)); const Mat distCoeff(1,5,CV_32FC1,Scalar(0));
if( argc != 5 ) if( argc != 5 && argc != 6 )
{ {
cout << "Format: image0 depth0 image1 depth1" << endl; cout << "Format: image0 depth0 image1 depth1 [transformationType]" << endl;
cout << "Depth file must be 16U image stored depth in mm." << endl; cout << "Depth file must be 16U image stored depth in mm." << endl;
cout << "Transformation types:" << endl;
cout << " -rbm - rigid body motion (default)" << endl;
cout << " -r - rotation rotation only" << endl;
cout << " -t - translation only" << endl;
return -1; return -1;
} }
...@@ -97,6 +101,29 @@ int main(int argc, char** argv) ...@@ -97,6 +101,29 @@ int main(int argc, char** argv)
return -1; return -1;
} }
int transformationType = TransformationType::RIGID_BODY_MOTION;
if( argc == 6 )
{
string ttype = argv[5];
if( ttype == "-rbm" )
{
transformationType = TransformationType::RIGID_BODY_MOTION;
}
else if ( ttype == "-r")
{
transformationType = TransformationType::ROTATION;
}
else if ( ttype == "-t")
{
transformationType = TransformationType::TRANSLATION;
}
else
{
cout << "Unsupported transformation type." << endl;
return -1;
}
}
Mat grayImage0, grayImage1, depthFlt0, depthFlt1/*in meters*/; Mat grayImage0, grayImage1, depthFlt0, depthFlt1/*in meters*/;
cvtColor( colorImage0, grayImage0, CV_BGR2GRAY ); cvtColor( colorImage0, grayImage0, CV_BGR2GRAY );
cvtColor( colorImage1, grayImage1, CV_BGR2GRAY ); cvtColor( colorImage1, grayImage1, CV_BGR2GRAY );
...@@ -126,7 +153,7 @@ int main(int argc, char** argv) ...@@ -126,7 +153,7 @@ int main(int argc, char** argv)
bool isFound = cv::RGBDOdometry( Rt, grayImage0, depthFlt0, Mat(), bool isFound = cv::RGBDOdometry( Rt, grayImage0, depthFlt0, Mat(),
grayImage1, depthFlt1, Mat(), grayImage1, depthFlt1, Mat(),
cameraMatrix, iterCounts, minGradMagnitudes, cameraMatrix, iterCounts, minGradMagnitudes,
minDepth, maxDepth, maxDepthDiff ); minDepth, maxDepth, maxDepthDiff, transformationType );
tm.stop(); tm.stop();
cout << "Rt = " << Rt << endl; cout << "Rt = " << Rt << endl;
...@@ -141,9 +168,9 @@ int main(int argc, char** argv) ...@@ -141,9 +168,9 @@ int main(int argc, char** argv)
Mat warpedImage0; Mat warpedImage0;
warpImage<Point3_<uchar> >( colorImage0, depthFlt0, Rt, cameraMatrix, distCoeff, warpedImage0 ); warpImage<Point3_<uchar> >( colorImage0, depthFlt0, Rt, cameraMatrix, distCoeff, warpedImage0 );
imshow( "im0", colorImage0 ); imshow( "image0", colorImage0 );
imshow( "warped_im0", warpedImage0 ); imshow( "warped_image0", warpedImage0 );
imshow( "im1", colorImage1 ); imshow( "image1", colorImage1 );
waitKey(); waitKey();
return 0; return 0;
......
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