Note that there are some explanatory texts on larger screens.

plurals
  1. POWhat is an "acceptable" return value from cv::calibrateCamera?
    primarykey
    data
    text
    <p><strong>Background:</strong></p> <p>I'm currently working on a stereo vision project using OpenCV. I'm trying to create a disparity map from a set of two rectified images, but I'm not getting the result I expect. When looking at the rectified images, there is a noticeable <em>vertical shift</em> between the images, which should not be there after rectification. I'm currently looking for what the error may be. My code is based on the stereo calibration and correspondence code from the OpenCV book, and <a href="https://code.ros.org/trac/opencv/browser/trunk/opencv/samples/cpp/stereo_match.cpp" rel="noreferrer">this example</a>. I use the C++ interface of OpenCV. My OpenCV version is 2.1, from the Ubuntu 11.04 repository.</p> <p><strong>Short version of question:</strong></p> <p>What RMS return value is acceptable for the function:</p> <pre><code>double cv::calibrateCamera(...) </code></pre> <p>I currently calibrate each camera using a set of ~20 chessboard image pairs. The cameras are two identical PS3 Eyes (with a resolution of 640*480 pixels) mounted beside each other. <code>cv::calibrateCamera</code> returns an RMS error of between <strong>160</strong> and <strong>300</strong> (I've had different result with different image sets). Is this an acceptable value for this image resolution or should I attempt to get better chessboard images?</p> <p><strong>Long version (details, code samples):</strong></p> <p>To get working stereo vision; first, I want to be sure the camera calibration routine works correctly. I use a series of chessboard images to calibrate my stereo setup, like so:</p> <pre><code>// Find chessboard corners cv::Mat left = ... //Load image vector&lt;cv::Point2f&gt; points; bool found = cv::findChessboardCorners(left, patternSize, points, CV_CALIB_CB_ADAPTIVE_THRESH | CV_CALIB_CB_NORMALIZE_IMAGE); if(found) cv::cornerSubPix(left, points, cv::Size(11, 11), cv::Size(-1, -1), cv::TermCriteria(CV_TERMCRIT_EPS + CV_TERMCRIT_ITER, 30, 0.1)); imagePointsLeft.push_back(points); </code></pre> <p>I do this for a number of image pairs and put the resulting points in <code>imagePointsLeft</code> and <code>imagePointsRight</code>. I have run a check in a separate program on the same images where I visually confirm that the left and right images correctly register all corners, in the same order, using <code>cv::drawChessboardCorners</code>. For each image pair I also fill a set of object coordinates like so:</p> <pre><code>vector&lt;cv::Point3f&gt; obj; for(int i = 0; i &lt; ny; i++) for(int j = 0; j &lt; nx; j++) obj.push_back(cv::Point3f(i*squareSize,j*squareSize,0.0)); objectPoints.push_back(obj); </code></pre> <p>I then attempt to calibrate the cameras with these images:</p> <pre><code>double rms = cv::calibrateCamera(objectPoints, imagePointsLeft, m_imageSize, m_cameraMatrixLeft, m_distortionMatrixLeft, rvecsLeft, tvecsLeft); </code></pre> <p>I use the camera intrinsics from this function when I call <code>cv::stereoCalibrate</code> using the flag <code>CV_CALIB_FIX_INTRINSIC</code> (this way of stereo calibration is suggested in the documentation, <a href="http://opencv.willowgarage.com/documentation/cpp/calib3d_camera_calibration_and_3d_reconstruction.html#stereoCalibrate" rel="noreferrer">here</a>).</p> <p>I proceed to call <code>cv::stereoRectify</code> and <code>cv::initUndistortRectifyMap</code>, the latter for both cameras. The rectified images are produced with <code>cv::remap</code> using the output of <code>initUndistortRectifyMap</code> and a camera livefeed. Both images contain only valid pixels (no black areas). My problem is that the pixels of a given row does not match the same row in the other image (there is a slight vertical offset). This makes it difficult to get any good results from correspondence algorithms such as StereoBM.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload