0

Got an image with a chessboard of known size (the cyan line is 2cm long)

the naive way of determining the FOV would be like this:

    catX = x1 - x0
    catY = y1 - y0
    hypoPx = sqrt(catX ** 2 + catY ** 2)
    pxRatio = hypoPx / 200  # pixels/mm

    pxHeight, pxWidth = img.shape[:2]
    width, height = width / pxRatio, height / pxRatio

But it doesn't account for the perspective distortion. So I got its rotation and transform vectors using solvePnPRansac (the axes on the image illustrate its orientation correctly).

I suppose it should be enough data to determine the field of view in mm almost precisely, but could not move further, I'm not very good at matrices and stuff ... Any hints?

illustration

mderk
  • 796
  • 4
  • 13

1 Answers1

0

fov is atan(object size/distance to object). You will have 2 fov's: fov_x and fov_y. Calibration object must be parallel to sensor plane.

Andrey Smorodov
  • 10,649
  • 2
  • 35
  • 42
  • The distance to the object is unknown. I know only of the distance (in pixels and mm) between certain points, and (I suppose) the orientation of the plane in 3d. – mderk Oct 29 '20 at 17:36
  • You mean that i could not get it right anyway because the chessboard is not parallel to the sensor plane? Hmm... The axes seem to represent the actual orientation correctly ... – mderk Oct 29 '20 at 17:39
  • You can use several images to calibrate camera first and then you'll be able to get camera parameters. https://docs.opencv.org/master/dc/dbb/tutorial_py_calibration.html – Andrey Smorodov Oct 29 '20 at 18:47
  • Check also this: https://stackoverflow.com/questions/39992968/how-to-calculate-field-of-view-of-the-camera-from-camera-intrinsic-matrix – Andrey Smorodov Oct 29 '20 at 18:57
  • I have seen these, they don't answer the question. The task is to measure FOV on a random photo using an object of known size on that photo. There are no several images to calibrate the camera. I don't control the conditions of making the images. It seems to me the orientation was determined correctly though, so the question is - is it possible to measure the FOV using the data available. – mderk Oct 29 '20 at 20:27
  • No. It's not possible. Varying lens focus and distance to your object, you can get infinite number of the same images. – Andrey Smorodov Oct 30 '20 at 06:49
  • Doesn't that means that all that infinity of images would have the same FOV? Same image size and same size of the object on that image does. – mderk Oct 30 '20 at 09:47
  • FOV is an angle. Lens focus changes image peojection size on image plane placed on the same distance. Angular size of an object is atan(s[pixels] / dist[pixels]), where s - object size in pixels, d - distance to object in pixels (problemmatic to measure). But to work in real units [mm], you need physical parameters of camera optic system: FOV = 2 atan (h/(2*f)), where h-sensor size in mm and f - focal lengrh of lens in mm. Physical parameters you can get only after calibration process. – Andrey Smorodov Oct 30 '20 at 10:30
  • It seems we're talking about different things. I mean the size of the observable field in mm, as in microscopy. Granted we know the size of the object in mm, we could derive the size of the whole image from it, if the object plane and the camera are in parallel. When not parallel, there's a perspective. The question is, if the PnP parameters are known, how to apply them to the size of the object in px to account for the perspective. – mderk Oct 30 '20 at 11:01
  • Not sure I got you correct again, but for taking in account perspective, you need to know depth to plane you want to measure ) . If you have perspective, than same size square in different distance will take different pixels on screen. – Andrey Smorodov Oct 30 '20 at 12:43
  • Since we have PnP parameters, I suppose the angle to the surface plane could be derived somehow. If so, the plane (with the chessboard) could be "extended" to the sides of the image. Since we know the px/mm ratio of the square at the certain point on the image, the "nearest" (to the side) square size in pixels could be calculated using the perspective adjustment. That's the logic. I'm not sure it is correct enough though :) – mderk Oct 30 '20 at 14:07
  • You can "embed" your measured flat object to chessboard and woek in chessboard plane then you can compute "fov" but for chessboard plane. You can compute perspective transform for the chessboard using its corners and and apply inverse transformation. Your chessboard will be normal to image. And you'll be able to measure your object. But it will not allow you get "fov" as you mean here. – Andrey Smorodov Oct 31 '20 at 10:35