What is the baseline of a stereo camera? - image-processing

Could someone here explain what exactly is the baseline of a camera?

You're apparently dealing with stereo, where the baseline is (at least normally) the distance between the two lenses.

I believe
Z (depth) = (focalLength * baseline) / disparity
Other coordinates can be found here: http://www.ptgrey.com/support/kb/index.asp?a=4&q=63&ST=

The baseline (distance between both cameras) will influence the depth range that you can observe with a stereo camera, and also your depth resolution. The same also applies to the focal length of the lenses that you use.
Assuming that you process a disparity range with a constant size, then the following rules apply:
Increasing the baseline will increase your depth resolution, but will also increase the minimum distance to the camera
Increasing the focal length will also increase the depth resolution and minimum distance to the camera, but also reduce the field of view.
This relationship can be studied with the following online calculator:
https://nerian.com/support/resources/calculator/

Baseline is the distance between 2 stereo camera.
When you do stereo Calibration, the openCV method return R, T (rotation and translation between your cameras)

Related

Will bad camera calibration affect pixel coordinates?

I am working with Turtlebots and ROS, and using a camera to find the pixel positions of a marker in the camera. I've moved over from simulations to a physical system. The issue I'm having is that the pixel positions in my physical system did not match the pixel positions in the physical system despite the marker and everything else being in the same position as in the simulations. There was a shift in the vertical pixel position by about 40 pixels when everything else like the height between the camera and marker, the marker position, and the distance between the marker and camera were the same in both the physical and simulated system. The simulated system does not need a camera calibration matrix, it is assumed to be ideal.
The resolution I'm using is 640x480, so the center pixels should be cx=320 and cy=240, but what I noticed in the camera calibration matrix I was using in the physical system was that the cx was around 318, which is pretty accurate, but the cy was around 202, which is far from what it should be. This also made me think that the shift in pixel positions in the vertical direction is shifted with about the same amount of pixels that I'm getting as an error.
So is it right to assume that the error in the center pixel in the calibration could be causing the error in the pixel positions?
I have been trying to calibrate a USB camera (Logitech C920 I think) and I've been using the camera_calibrator ROS package found here http://wiki.ros.org/camera_calibration to calibrate the camera. I think the camera calibration did not go that well, seeing as I always have a pretty big error in either cx or cy. Here are the calibration matrices.
First calibration matrix, used 15x10 vertices with size 0.25
Recalibrated but did not actually use this yet, calibrated with 8x6 size 0.25
Same as previous, some difference between the two
The checkerboards were on A4 papers.
Thanks in advance.
I believe the answer to your question is to answer how to perform a better camera calibration.
Quoting from Calib.io enter link description here:
Choose the right size calibration target.
Perform calibration at the approximate working distance (WD) of your final application.
The target should have a high feature count.
Collect images from different areas and tilts.
Use good lighting.
Calibration is only as accurate as the calibration target used. Use laser or inkjet printed targets only to validate and test.
Per sample, proper mounting of calibration target and camera.
Remove bad observations. Carefully inspect reprojection errors.
Obtaining a low re-projection error does not equal a good camera calibration. Be careful of over fitting.

Required tolerance for camera calibration target

In reading about and experimenting with camera calibration I haven't seen any mention of the required tolerance for the placement of calibration targets. For example say I have a field of view of 200mm x 30mm and I want to be able to measure the position of objects in this field to within 1mm. I will calibrate my camera using a grid pattern and the OpenCV calibrateCamera flow. Say my calibration target is a printed chessboard grid with 5mm pitch. What is the tolerance on that 5mm spacing between corners on my target? Does a tighter tolerance result in more accurate pixel to real-world transformation? Does a tighter tolerance result in better distortion removal?
Note I'm measuring objects on a 2D plane, no depth measurement, and unfortunately I don't have the ability to move the calibration targets around and take multiple views of it. So I'm talking specifically about calibrating using a single view.
Calibration using a single view is a poor idea, generally speaking, because of the small number of independent samples it entails, so it is possible that tolerance on the calibration grid manufacture be the least of your worries. But if you must...
The controlling factor here is the sensor's dot pitch. Given the nominal focal length of your lens, and that you want your calibration RMSE to be order of a few tenths of pixel, you can work out the angle spanned by, say, 1/10 of a pixel along the sensor's horizontal axis. Back projecting that at the nominal distance between the lens's exit pupil and the target will give you a length in 3D world that measures the uncertainty in a target's corner location at the calibration optimum. Your physical target points should be known at least as accurately, and normally better.
Example:
Setup: Dot pitch 5um, 16mm focal lens, 200mm working distance to target.
Backprojected 1/10 pixel: 200/16*0.5um =~ 6um.
Backprojected 1/2 pixel : 200/16*2.5um =~ 31um.
You can loosen that if you assume perfect Chi-square scaling of the errors with the square root of the number of the data points. If you have, say, 100 corners, you can multiply that by 10, i.e. ~ 300um for 1/2 pixel
Note that with this kind of tolerances temperature control (for camera and target) may become a factor to keep into account.

Recover Pose OpenCV 3.0

I have calibrated my pinhole camera using opencv 3.0 and got 4 intrinsic parameters (f_x,f_y,u_0,v_0) plus some distortion coefficients. Using this calibration, I estimate the essential matrix from two images at different positions. Finally I want to recover (R|t) using the recover pose function from opencv 3.0. The interface of this function expects a single focal length, but I have two from the calibration procedure. How can a get the focal length f=f_y/s_y = f_x/s_x (Definition according to OpenCV) from f_x an f_y so that I can properly use the recover pose function?
You can simply use the horizontal focal length f_x. The ratio f_y/f_x is just the pixel aspect ratio, an estimate the squareness of the pixels.
Note that, unless you have some absolute scale reference in your image pair (e.g. an object of known size), you can recover pose only up to scale, that is, R and s*t for some unknown scale s.
You can't really derive the actual focal length just from f_x and f_y. For a pinhole camera the actual focal length is the distance from the pinhole to the imaging plane. Your camera probably has the focal length written somewhere in the specs.

how to find pixel disparity , pixel size (depth estimation in stereo vision)

I'm trying to estimate depth from a stereo system with two cameras. The simple equation that I use is:
Depth = (Base line * Focal lenght) / (Pixel disparity * Pixel size)
but i can't find Pixel disparity and Pixel size
how to find pixel disparity , pixel size?
Thank you.
You can get pixel size form spec sheet of your camera sensor. Alternatively, pixel size is not required if you have calibrated your camera, so that calibrated focal length will be in pixels.
So you can modify your formula as:
Depth (in cm) = Baseline(in cm) * Focal Length(in pixels) / Disparity (in Pixels)
For getting pixel disparity, you can use OpenCV Block Matching and Semi-Global Block Matching techniques Calib 3D Docs. There are many more accurate disparity estimation algorithms were published.

Opencv: Find focal lenth in mm in an analog camera

I have sucessfully calibrated an analog camera using opencv. The ouput focal length and principal points are in pixels.
I know in digital cameras you can easily multiply the size of the pixel in the sensor by the focal length in pixels and get the focal length in mm (or whatever).
How can I do with this analog camera to get the focal length in mm?
The lens manufacturers usually write focal length on the lens. Even the name of the lens contains it, e.g. "canon lens 1.8 50mm".
If not, you can try to measure it manually.
Get lens apart from the camera. Take a small well illuminated object, place it in 1-3 meters in from of lens and sheet of paper back from it. Get sharp and focused image of the object on the paper.
Now measure following:
a - distance from lens to the object;
y - object size;
y' - object image size on the paper;
f = a/(1+y/y') - focus distance.
If your output is in pixels, you must be digitizing the analog input at some point. You just need to figure out the size of the pixel that you are creating.
For example, if you are scanning film in, then you use the pixel size of the scanner.

Resources