Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit3132507

Browse files
ivashmakJSpencerPittman
authored andcommitted
Merge pull requestopencv#26742 from ivashmak:fix_homography_inliers
Bug fix foropencv#25546 - Updating inliers for homography estimationopencv#26742Fixesopencv#25546### Pull Request Readiness ChecklistSee details athttps://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request- [x] I agree to contribute to the project under Apache 2 License.- [x] To the best of my knowledge, the proposed patch is not based on a code under GPL or another license that is incompatible with OpenCV- [x] The PR is proposed to the proper branch- [x] There is a reference to the original bug report and related work- [ ] There is accuracy test, performance test and test data in opencv_extra repository, if applicable Patch to opencv_extra has the same branch name.- [x] The feature is well documented and sample code can be built with the project CMake
1 parent164293b commit3132507

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

‎modules/calib3d/src/fundam.cpp‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -414,6 +414,11 @@ cv::Mat cv::findHomography( InputArray _points1, InputArray _points2,
414414

415415
if( result && npoints >4 && method != RHO)
416416
{
417+
// save the original points before compressing
418+
constint npoints_input = npoints;
419+
const Mat src_input = src.clone();
420+
const Mat dst_input = dst.clone();
421+
417422
compressElems( src.ptr<Point2f>(), tempMask.ptr<uchar>(),1, npoints );
418423
npoints =compressElems( dst.ptr<Point2f>(), tempMask.ptr<uchar>(),1, npoints );
419424
if( npoints >0 )
@@ -427,6 +432,16 @@ cv::Mat cv::findHomography( InputArray _points1, InputArray _points2,
427432
MatH8(9,1, CV_64F, H.ptr<double>());
428433
LMSolver::create(makePtr<HomographyRefineCallback>(src, dst),10)->run(H8);
429434
H.convertTo(H, H.type(),scaleFor(H.at<double>(2,2)));
435+
436+
// find new inliers
437+
constfloat thr_sqr =static_cast<float>(ransacReprojThreshold * ransacReprojThreshold);
438+
cv::Mat errors;
439+
cb->computeError(src_input, dst_input, H, errors);
440+
uchar* maskptr = tempMask.ptr<uchar>();
441+
constfloat *const errors_ptr = errors.ptr<float>();
442+
for (int i =0; i < npoints_input; i++) {
443+
maskptr[i] =static_cast<uchar>(errors_ptr[i] <= thr_sqr);
444+
}
430445
}
431446
}
432447

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp