# Distance from camera to object.. The error increasing linearly!

I compute the distance from an object (Chessboard) using OpenCV and my camera parameters following those steps:

1- findChessboardCorners

2- solvePnP

3- ->Distance from the translation vector given by solvePnP

The issue is that the error is increasing linearly when I get far from the camera.

The error is simply the difference between the real distance and the one given by my program.

The camera is calibrated (focal length 2.8mm, wide angle + distortion)

I want to know why the error is increasing? Is that normal?

edit retag close merge delete

1

( 2017-04-18 09:38:26 -0500 )edit

@LBerger So what do you think that error is due to? is it normal as I'm using a single camera?

( 2017-04-18 10:29:48 -0500 )edit
1

yes with one camera error should be something like d*pixel_size/focal/2

( 2017-04-18 12:17:55 -0500 )edit
1

Yep. Basically, your error in finding the chessboard corners goes up with the distance, because a 0.1 (or whatever) pixel error is now a larger distance. So a higher uncertainty in your world points means a higher uncertainty in your camera location.

( 2017-04-18 17:42:32 -0500 )edit

@LBerger@Tetragramm Do you have any references about that? I'm interested more in that error so I can correct it with respect to my camera parameters :)

( 2017-04-19 03:41:47 -0500 )edit
1

reference "Multiple view geometry in computer vision" R. Hartley A. Zisserman

( 2017-04-19 04:15:13 -0500 )edit

@LBerger I mean that error d*pixel_size/focal/2, how did you get it ? it's not linear!

( 2017-04-20 02:13:38 -0500 )edit
1

pixel_size is constant, focal length is constant, 2 is constant, only d changes, so it is linear.

What that equation means is basically what I said. As you move further away, each pixel covers more area on the object. So if you double the distance, what was 4 pixels is now one pixel.

( 2017-04-20 20:33:25 -0500 )edit

OK got it! I'll write an answer.. thanks both of you

( 2017-04-26 03:52:00 -0500 )edit

Sort by ยป oldest newest most voted

I'll write an answer to the issue after doing some experiments. I corrected my distance as follow:

Distance_corrected = distNorme+distNorme*correction


distNorme is the distance to the chessboard which is the norm of the translation vector given by solvePnP OpenCV function.

correction is

correction=pixel_size/focal_mm/2 = 2/focal_pixel


The results are better, still have an error increasing linearly though but not very strong as distNorme (distance not corrected).

I'm still seeking for references or documentation of that correction error. I need more details about it.

more

Official site

GitHub

Wiki

Documentation