Skip to content

Pass RANSAC parameters as function input - #10569

Merged
vpisarev merged 12 commits into
opencv:3.4from
branka-plateiq:modify-estimate-rigid-transform
Jun 26, 2018
Merged

vpisarev merged 12 commits into
opencv:3.4from
branka-plateiq:modify-estimate-rigid-transform

Conversation

@branka-plateiq

Copy link
Copy Markdown
Contributor

This pullrequest changes

This pull request changes estimateRigidTransform so it takes as input some RANSAC parameters instead of having them hardcoded in the function.

@hrnr

hrnr commented Jan 10, 2018

Copy link
Copy Markdown
Contributor

please check estimateAffine2D and estimateAffinePartial2D. I think we should deprecate estimateRigidTrasform in video module.

Comment thread modules/video/src/lkpyramid.cpp Outdated
int idx[RANSAC_SIZE0];
Point2f a[RANSAC_SIZE0];
Point2f b[RANSAC_SIZE0];
Point2f *a =new Point2f[RANSAC_SIZE0];

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

std::vector<Point2f> a(RANSAC_SIZE0); may be better, since it
abstracts away new/delete.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree; also, those vectors should better be placed outside of the loop.

*/
CV_EXPORTS_W Mat estimateRigidTransform( InputArray src, InputArray dst, bool fullAffine );
CV_EXPORTS_W Mat estimateRigidTransform( InputArray src, InputArray dst, bool fullAffine, int RANSAC_MAX_ITERS=500, double RANSAC_GOOD_RATIO=0.5,
int RANSAC_SIZE0=3);

@vpisarev vpisarev Jan 11, 2018 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. In OpenCV 3.x we preserve binary compatibility. So you need to add another function with those extra parameters.
  2. the parameters should use mixed case names, not all-capital names that are normally used for constants.


const int COUNT = 15;
const int WIDTH = 160, HEIGHT = 120;
const int RANSAC_MAX_ITERS = 500;

@vpisarev vpisarev Jan 11, 2018 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since you now pass parameters instead of using constants, there should be some code added to check the parameters for reasonable value ranges. For example, RANSAC_SIZE0 should not be smaller than 3

@vpisarev vpisarev self-assigned this Jan 11, 2018
@hrnr

hrnr commented Jan 11, 2018

Copy link
Copy Markdown
Contributor

@vpisarev: What do you think about estimateAffine2D and estimateAffinePartial2D in calib3d module? I think they provide all this functionality (+ some more) and are much cleaner.

We might want to remove this function in OpenCV 4.0.

@branka-plateiq

branka-plateiq commented Jan 11, 2018 •

Copy link
Copy Markdown
Contributor Author

@hrnr I will check estimateAffine2D and estimateAffinePartial2D and see if they give me the functionality I need. Thanks for the info. If they do, I will close this, if not I will make the required changes. @vpisarev @csukuangfj thanks for the review

@branka-plateiq

Copy link
Copy Markdown
Contributor Author

@hrnr estimateAffine2D and estimateAffinePartial2D do not have the option of setting the minimum acceptable percentage of inliers for a model to be valid. I would like to go ahead with this PR because that is what I need and it was easy to add it here.

Replace array with vector.

Correct naming convention for input variables.

Add checks on input variables.
@vpisarev

Copy link
Copy Markdown
Contributor

let's finally merge it in. It's for 3.4 branch; in OpenCV 4.0 we will probably revise RANSAC kernels and remove redundant functionality 👍

@vpisarev
vpisarev merged commit 34ad9b8 into opencv:3.4 Jun 26, 2018
@alalek alalek mentioned this pull request Jul 2, 2018
SavyaSanchi-Sharma pushed a commit to SavyaSanchi-Sharma/opencv that referenced this pull request Jul 30, 2026
* Pass RANSAC parameters as function input

* Clean up unnecessary code

* Keep the original function signature

* Clean up based on PR comments

Replace array with vector.

Correct naming convention for input variables.

Add checks on input variables.

* Use vector instead of array for dynamic size

* Revert change.

* Use dynamic array

* Fix wrong syntax in array allocation

* Undo change

* Fix variable name

* Use vector and not array

* fixed compile warning on Windows
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants