Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I'm not sure I understood correctly everything you are trying to do, but bear with me.</p> <p>Some cameras have lenses that cause a little distortion to the image, and for this purpose OpenCV offers methods to aid in the <a href="http://dsynflo.blogspot.com/2010/03/camera-calibration-using-opencv.html" rel="nofollow noreferrer">camera calibration process</a>.</p> <p>Practically speaking, if you want to write an application that will automatically correct the distortion in the image, <strong>first</strong>, you need to <strong>discover what are the magical values</strong> that need to be used to undo this effect. These values come from a proper calibration procedure. </p> <p>The <a href="http://web.archive.org/web/20130515145727/http://www.aishack.in/wp-content/uploads/2010/07/calib-checkerboard.png" rel="nofollow noreferrer">chessboard image</a> is used together with an <a href="http://www.aishack.in/tutorials/calibrating-undistorting-with-opencv-in-c-oh-yeah/" rel="nofollow noreferrer">application to calibrate the camera</a>. So, after you have an image of the chessboard taken by the camera device, pass this image to the calibration app. The app will identify the corners of the squares and compute the values of the distortion and return the magical values you need to use to counter the distortion effect. At this point, you are interested in 2 variables returned by <a href="http://docs.opencv.org/modules/calib3d/doc/camera_calibration_and_3d_reconstruction.html#calibratecamera" rel="nofollow noreferrer"><code>calibrateCamera()</code></a>: they are <code>cameraMatrix</code> and <code>distCoeffs</code>. Print them, and write the data on a piece of paper.</p> <p>At the end, the system you are developing needs to have a function/method to undistort the image, where these 2 variables will be hard coded inside the function, followed by a call to <code>cv::undistort()</code> (if you are using the C++ API of OpenCV):</p> <pre><code>cv::Mat undistorted; cv::undistort(image, undistorted, cameraMatrix, distCoeffs); </code></pre> <p>and that's it. </p> <p>Detecting rotation automatically might be a bit tricky, but the first thing to do is find the coordinates of the object you are interested in. But if the camera is in a fixed position, this is going to be easy. </p> <p>For more info on perspective change and rotation with OpenCV, I suggest taking a look at these other questions:</p> <p><a href="https://stackoverflow.com/q/7838487/176769">Executing cv::warpPerspective for a fake deskewing on a set of cv::Point</a></p> <p><a href="https://stackoverflow.com/q/7800905/176769">Affine Transform, Simple Rotation and Scaling or something else entirely?</a></p> <p><a href="https://stackoverflow.com/q/7813376/176769">Rotate cv::Mat using cv::warpAffine offsets destination image</a></p>
    singulars
    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.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      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