0

I am trying to estimate dimensions of a object A, from known information about another object B. Assume there is a camera overlooking the road and capturing picture. The picture has two objects in it. One of the object is known and therefore, we know the dimension. The problem is how can this be used to estimate dimension of another object. For this problem, it can be assumed that both objects are flat on the road and have 0 height.

Uniform Linear scaling of dimensions of object B to estimate object A does not work.

Visual representation of scenario

Marek R
  • 32,568
  • 6
  • 55
  • 140
Hem
  • 41
  • 1
  • 3
  • can you get angles for these objects from the camera? and do you have a height from ground to camera? – Raffallo Aug 02 '19 at 07:01
  • I do not have the height information. I known the real dimensions and pixel coordinates of the known object, as in this image https://i.stack.imgur.com/FK0gx.jpg – Hem Aug 02 '19 at 07:02
  • ok, so you have in this example real and pixel coordinates of all corner of the object A, and pixels coordinates of the object B? Do you know the coordinates of the camera maybe or real distances from the camera to the corners of the object A? – Raffallo Aug 02 '19 at 07:04
  • Sounds like you haven't gotten past the math portion of the job yet. I'd start there and come back to Stack Overflow when you've reached the programming part. Perhaps ask at [the Mathematics Stack Exchange sites](https://math.stackexchange.com/help/asking) – user4581301 Aug 02 '19 at 07:04
  • Yes Raffallo - I have real and pixel coordinates of A, but I do not know real distance from camera to corners of A. I do not think that I can get that distance either. Hence, this problem. I am also looking at alternative ways that can help. – Hem Aug 02 '19 at 07:10
  • what accuracy do you need to achieve? – Raffallo Aug 02 '19 at 07:17
  • As much as the math and resolution allows to be possible. But essentially, it will be okay to be approximate here to begin with. – Hem Aug 02 '19 at 07:20
  • hmmm I'm thinking that you could make camera calibration (ie.: in OpenCV) and then you could easily calculate these object B parameters :) but if you want to do it more manually with given mathematical formulas I would have to think about it for a moment, but only after work – Raffallo Aug 02 '19 at 07:25
  • How do I go about calibrating? I am not sure if one known object (or its 4 corners) are enough for calibration. – Hem Aug 02 '19 at 07:26
  • You can use OpenCV `getPerspectiveTransform()` to calculate perspective transformation matrix based on coordinates of known object. Then do `perspectiveTransform()` of coordinates of unknown object. – sklott Aug 02 '19 at 07:27
  • Thanks. I will look into it. Will `getPerspectiveTransform()` work if the origin is set as one of the four corners of the known object? Please let me know if I am understanding it correctly - Because I don't know the origin, I can set the origin at one corner and calculate x,y for other three corners (as z=0). Then generate transform matrix and use this to get coordinates of unknown object. Then dimensions can be calculated based on the corner coordinates of the unknown object. – Hem Aug 02 '19 at 07:37
  • Yes. Origin can be anything you want. Just remember that it will be origin for all coordinates calculated using this matrix. – sklott Aug 02 '19 at 08:36

0 Answers0