saveBestModel() is modified. accuracy test is passed.
This commit is contained in:
parent
87c2b8197a
commit
6dbf13d7b5
@ -399,16 +399,18 @@ cv::Mat cv::findHomography( InputArray _points1, InputArray _points2,
|
|||||||
{
|
{
|
||||||
tempMask = Mat::ones(npoints, 1, CV_8U);
|
tempMask = Mat::ones(npoints, 1, CV_8U);
|
||||||
result = cb->runKernel(src, dst, H) > 0;
|
result = cb->runKernel(src, dst, H) > 0;
|
||||||
}
|
}
|
||||||
else if( method == RANSAC )
|
|
||||||
|
else if( method == RANSAC)
|
||||||
result = createRANSACPointSetRegistrator(cb, 4, ransacReprojThreshold, confidence, maxIters)->run(src, dst, H, tempMask);
|
result = createRANSACPointSetRegistrator(cb, 4, ransacReprojThreshold, confidence, maxIters)->run(src, dst, H, tempMask);
|
||||||
else if( method == LMEDS )
|
else if( method == LMEDS )
|
||||||
result = createLMeDSPointSetRegistrator(cb, 4, confidence, maxIters)->run(src, dst, H, tempMask);
|
result = createLMeDSPointSetRegistrator(cb, 4, confidence, maxIters)->run(src, dst, H, tempMask);
|
||||||
else if( method == RHO ){
|
else if( method == RHO )
|
||||||
result = createAndRunRHORegistrator(confidence, maxIters, ransacReprojThreshold, npoints, src, dst, H, tempMask);
|
result = createAndRunRHORegistrator(confidence, maxIters, ransacReprojThreshold, npoints, src, dst, H, tempMask);
|
||||||
}else
|
else
|
||||||
CV_Error(Error::StsBadArg, "Unknown estimation method");
|
CV_Error(Error::StsBadArg, "Unknown estimation method");
|
||||||
|
|
||||||
|
|
||||||
if( result && npoints > 4 && method != RHO)
|
if( result && npoints > 4 && method != RHO)
|
||||||
{
|
{
|
||||||
compressPoints( src.ptr<Point2f>(), tempMask.ptr<uchar>(), 1, npoints );
|
compressPoints( src.ptr<Point2f>(), tempMask.ptr<uchar>(), 1, npoints );
|
||||||
@ -419,8 +421,9 @@ cv::Mat cv::findHomography( InputArray _points1, InputArray _points2,
|
|||||||
Mat dst1 = dst.rowRange(0, npoints);
|
Mat dst1 = dst.rowRange(0, npoints);
|
||||||
src = src1;
|
src = src1;
|
||||||
dst = dst1;
|
dst = dst1;
|
||||||
if( method == RANSAC || method == LMEDS )
|
if( method == RANSAC || method == LMEDS)
|
||||||
cb->runKernel( src, dst, H );
|
cb->runKernel( src, dst, H );
|
||||||
|
|
||||||
Mat H8(8, 1, CV_64F, H.ptr<double>());
|
Mat H8(8, 1, CV_64F, H.ptr<double>());
|
||||||
createLMSolver(makePtr<HomographyRefineCallback>(src, dst), 10)->run(H8);
|
createLMSolver(makePtr<HomographyRefineCallback>(src, dst), 10)->run(H8);
|
||||||
}
|
}
|
||||||
|
@ -55,7 +55,6 @@
|
|||||||
#include "rhorefc.h"
|
#include "rhorefc.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* Defines */
|
/* Defines */
|
||||||
#define MEM_ALIGN 32
|
#define MEM_ALIGN 32
|
||||||
#define HSIZE (3*3*sizeof(float))
|
#define HSIZE (3*3*sizeof(float))
|
||||||
@ -383,7 +382,7 @@ unsigned rhoRefC(RHO_HEST_REFC* restrict p, /* Homography estimation conte
|
|||||||
* PROSAC Loop
|
* PROSAC Loop
|
||||||
*/
|
*/
|
||||||
|
|
||||||
for(p->ctrl.i=0; p->ctrl.i < p->arg.maxI; p->ctrl.i++){
|
for(p->ctrl.i=0; p->ctrl.i < p->arg.maxI || p->ctrl.i<100; p->ctrl.i++){
|
||||||
sacHypothesize(p) && sacVerify(p);
|
sacHypothesize(p) && sacVerify(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -861,7 +860,28 @@ static inline int sacIsSampleDegenerate(RHO_HEST_REFC* p){
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
static inline void sacGenerateModel(RHO_HEST_REFC* p){
|
static inline void sacGenerateModel(RHO_HEST_REFC* p){
|
||||||
|
#if 1
|
||||||
hFuncRefC(p->curr.pkdPts, p->curr.H);
|
hFuncRefC(p->curr.pkdPts, p->curr.H);
|
||||||
|
#else
|
||||||
|
int mm = 4;
|
||||||
|
cv::Mat _H(3,3,CV_32FC1);
|
||||||
|
std::vector<cv::Point2f> _srcPoints(mm,cv::Point2f());
|
||||||
|
std::vector<cv::Point2f> _dstPoints(mm,cv::Point2f());
|
||||||
|
for (int i=0 ; i< mm ; i++){
|
||||||
|
cv::Point2f tempPoint2f(p->curr.pkdPts[2*i], p->curr.pkdPts[2*i+1]);
|
||||||
|
_srcPoints[i] = tempPoint2f;
|
||||||
|
tempPoint2f=cv::Point2f((float)p->curr.pkdPts[2*i+8],(float) p->curr.pkdPts[2*i+9]);
|
||||||
|
_dstPoints[i] = tempPoint2f;
|
||||||
|
}
|
||||||
|
|
||||||
|
_H = cv::findHomography(_srcPoints, _dstPoints,0,3);
|
||||||
|
double* data = (double*) _H.data;
|
||||||
|
|
||||||
|
p->curr.H[0]=data[0]; p->curr.H[1]=data[1]; p->curr.H[2]=data[2];
|
||||||
|
p->curr.H[3]=data[3]; p->curr.H[4]=data[4]; p->curr.H[5]=data[5];
|
||||||
|
p->curr.H[6]=data[6]; p->curr.H[7]=data[7]; p->curr.H[8]=1.0;
|
||||||
|
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1074,17 +1094,22 @@ static inline int sacIsBestModelGoodEnough(RHO_HEST_REFC* p){
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
static inline void sacSaveBestModel(RHO_HEST_REFC* p){
|
static inline void sacSaveBestModel(RHO_HEST_REFC* p){
|
||||||
float* H = p->curr.H;
|
|
||||||
char* inl = p->curr.inl;
|
|
||||||
unsigned numInl = p->curr.numInl;
|
|
||||||
|
|
||||||
p->curr.H = p->best.H;
|
memcpy(p->best.H, p->curr.H, HSIZE);
|
||||||
p->curr.inl = p->best.inl;
|
memcpy(p->best.inl, p->curr.inl, p->arg.N);
|
||||||
p->curr.numInl = p->best.numInl;
|
p->best.numInl = p->curr.numInl;
|
||||||
|
|
||||||
p->best.H = H;
|
// float* H = p->curr.H;
|
||||||
p->best.inl = inl;
|
// char* inl = p->curr.inl;
|
||||||
p->best.numInl = numInl;
|
// unsigned numInl = p->curr.numInl;
|
||||||
|
|
||||||
|
// p->curr.H = p->best.H;
|
||||||
|
// p->curr.inl = p->best.inl;
|
||||||
|
// p->curr.numInl = p->best.numInl;
|
||||||
|
|
||||||
|
// p->best.H = H;
|
||||||
|
// p->best.inl = inl;
|
||||||
|
// p->best.numInl = numInl;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user