RANSAC and 2D point clouds
I have 2 point clouds in 2D and I want to use RANSAC to determine transformation matrix between them. I have no pairs of points, just 2 sets of points. How can I do this in OpenCV?
I tried to write ransac-like scheme for my purposes.
- Get 4 random points from 1st set and from 2nd set.
- Compute transform matrix H using getPerspectiveTransform.
- Warp 1st set of points using H and test how they aligned to the 2nd set of points using some metric(I don't know what metric I should use I tried sum of min distance for all points in 1st set, but it seems it's not work good if points group together after transform)
- Repeat 1-3 N times and choose best transform according to metric.
maybe I should use different metric?
Also I have idea that I can match points using shape context algorithm and only then use RANSAC(or some other algorithm) to determine transformation.