a big patch; use special proxy types (Input/OutputArray, Input/OutputArrayOfArrays) for passing in vectors, matrices etc.

This commit is contained in:
Vadim Pisarevsky
2011-04-17 13:14:45 +00:00
parent 335370a7c0
commit abeeb40d46
94 changed files with 10831 additions and 9631 deletions

View File

@@ -452,34 +452,34 @@ bool cv::Affine3DEstimator::checkSubset( const CvMat* ms1, int count )
return j == i;
}
int cv::estimateAffine3D(const Mat& from, const Mat& to, Mat& out, vector<uchar>& outliers, double param1, double param2)
int cv::estimateAffine3D(const InputArray& _from, const InputArray& _to,
OutputArray _out, OutputArray _outliers,
double param1, double param2)
{
int count = from.cols*from.rows*from.channels()/3;
Mat from = _from.getMat(), to = _to.getMat();
int count = from.checkVector(3, CV_32F);
CV_Assert( count >= 4 && from.isContinuous() && to.isContinuous() &&
from.depth() == CV_32F && to.depth() == CV_32F &&
((from.rows == 1 && from.channels() == 3) || from.cols*from.channels() == 3) &&
((to.rows == 1 && to.channels() == 3) || to.cols*to.channels() == 3) &&
count == to.cols*to.rows*to.channels()/3);
CV_Assert( count >= 0 && to.checkVector(3, CV_32F) == count );
out.create(3, 4, CV_64F);
outliers.resize(count);
fill(outliers.begin(), outliers.end(), (uchar)1);
_out.create(3, 4, CV_64F);
Mat out = _out.getMat();
_outliers.create(count, 1, CV_8U, -1, true);
Mat outliers = _outliers.getMat();
outliers = Scalar::all(1);
vector<Point3d> dFrom;
vector<Point3d> dTo;
copy(from.ptr<Point3f>(), from.ptr<Point3f>() + count, back_inserter(dFrom));
copy(to.ptr<Point3f>(), to.ptr<Point3f>() + count, back_inserter(dTo));
Mat dFrom, dTo;
from.convertTo(dFrom, CV_64F);
to.convertTo(dTo, CV_64F);
CvMat F3x4 = out;
CvMat mask = cvMat( 1, count, CV_8U, &outliers[0] );
CvMat m1 = cvMat( 1, count, CV_64FC3, &dFrom[0] );
CvMat m2 = cvMat( 1, count, CV_64FC3, &dTo[0] );
CvMat mask = outliers;
CvMat m1 = dFrom;
CvMat m2 = dTo;
const double epsilon = numeric_limits<double>::epsilon();
param1 = param1 <= 0 ? 3 : param1;
param2 = (param2 < epsilon) ? 0.99 : (param2 > 1 - epsilon) ? 0.99 : param2;
return Affine3DEstimator().runRANSAC(&m1,& m2, &F3x4, &mask, param1, param2 );
return Affine3DEstimator().runRANSAC(&m1, &m2, &F3x4, &mask, param1, param2 );
}