I am working on object detection project and to measure it dimension correctly, for that I am using coin for reference, to measure accurately, I need a bird eye view of this image. [Image Here]
-
2What have you tried already? – Flimm Aug 16 '22 at 13:06
-
Refer to this link: https://stackoverflow.com/help/how-to-ask – Jeffrey Ram Aug 16 '22 at 13:11
-
If the scene is planar you can use perspective homographies. You will need 4 reference points. Using a coin isnt perfect, since on a circle you cant easily identify 4 known points. – Micka Aug 16 '22 at 13:43
-
I have tried template matching to find homography to use perspective transform, but coin in image is not that feature rich to get homography @Flimm – Strange Aug 16 '22 at 13:54
-
we used coin cause its commonly found object in anyone pocket @Micka, I cant change the coin. – Strange Aug 16 '22 at 13:58
-
if you can find the circle center of a perspectively distorted circle (which looks like and ellipse but ellipse center isnt the circle center) you can generate 4 points of that circle. – Micka Aug 16 '22 at 14:49
-
have a look at: https://www.drawinghowtodraw.com/stepbystepdrawinglessons/2014/01/drawing-circles-in-perspective-how-to-draw-circles-and-ellipses-in-correct-perspective/ – Micka Aug 16 '22 at 14:51
-
have a look at: https://math.stackexchange.com/questions/1459395/calculate-centers-of-circles-from-their-ellipse-perspective and https://math.stackexchange.com/questions/1459395/calculate-centers-of-circles-from-their-ellipse-perspective – Micka Aug 16 '22 at 14:58
-
Fit an ellipse and get the major and minor axes where they are on the ellipse. That presents 4 points. You know it should be a circle. So that gives 4 other points, once you decide on the circle radius (perhaps the major axis radii of the ellipse). Those 4 pairs of coordinates should allow you to compute the homography. The use warpPerspective() – fmw42 Aug 16 '22 at 15:18
-
1@fmw42 that wont work, since the ellipse center isnt equal to the circle center. Have a look at: https://stackoverflow.com/a/26196054/2393191 – Micka Aug 16 '22 at 15:24
-
1@Micka True, but I would think that this would give a good first approximation. Furthermore, it does not matter where the output center is located, but it does matter some where the input center is located. – fmw42 Aug 16 '22 at 16:56
1 Answers
Disclaimer: This approach is not mathematically complete nor exact, I know. Although I hope someone will find it useful for real life applications or has some positive ideas how to improve it.
As you can see from the discussion you can't get an accurate estimation of the vanishing point / the horizon by just one coin because a circle can be projected to the same ellipse for different vananishing points. However if there are two coins of same size at bottom center and top center of the image it should be manageble to get an acceptable accuracy:
If your business allows it you can do assumptions that will lower the accuracy but make it easier to implement:
- Assume that the plane's normal vector is parallel to the yz-plane of your image, i.e the camera is held in a "normal" way and - in relation to the plane - not tilted to the left or right.
- Assume that the two coins are placed in the middle of the picture.
With this you can:
- Extract the two ellipses.
- Get the two tangents of both ellipses left and right.
- Get the two horizontal tangents of the bigger ellipse.
- Finnally get the four points where the tangents intersect.
- Use the four points as input to
warpPerspective
as descibed here.
Of course, if we are talking about a mobile app, then sensor and camera data from the phone could help without bothering the user too much.

- 5,976
- 5
- 6
- 21