Convert OpenCV with Chessboard

I just started experimenting with OpenCV a bit. I have a static LCD setting and I would like to extract what is displayed on the screen from the image. I saw a checkerboard pattern used to calibrate the camera, but it looks like it is used to distort the image, which is not exactly what I want to do.

I thought I would show the chessboard on the LCD and then figure out the transformations needed to convert the LCD image into the perfect chessboard right above my head and cut. Then I will store the transformations, change what the LCD displays, take a picture, perform the same transformations and get the perfect idea of ​​what is now displayed.

I wonder does this sound good? Is there an easier way to achieve what I'm trying to do? And any tips on the functions that I should use to define transformations, execute them, save them (maybe just save the transformation matrices in memory or write them to a file), etc.?

+6
source share
2 answers

I'm not sure I understood correctly everything that you are trying to do, but carry me.

Some cameras have lenses that cause slight image distortion, and for this purpose, OpenCV offers methods to assist in the process of calibrating the camera .

In fact, if you want to write an application that automatically corrects image distortion, first you need to find out what magic values you need to fix it. These values ​​come from the correct calibration procedure.

The chessboard image is used with the calibrateCamera() application: they are cameraMatrix and distCoeffs . Print them and write the data on a piece of paper.

In the end, your system should have a function / method to distort the image, where these 2 variables will be hardcoded inside the function, and then call cv::undistort() (if you use the OpenCV C ++ API):

 cv::Mat undistorted; cv::undistort(image, undistorted, cameraMatrix, distCoeffs); 

and what is he.

Detecting rotation automatically can be a little complicated, 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, it will be easy.

For more information about the prospects for change and rotation using OpenCV, I suggest taking a look at these other questions:

Running cv :: warpPerspective for fake translation on cv :: Point set

Affine transformation, simple rotation and scaling, or something else?

Rotate cv :: Mat using cv :: warpAffine shifts target image

+16
source

findhomography () is a good choice, but distortion, distortion (camera lens) is a real problem.

C ++: Mat findHomography (InputArray srcPoints, InputArray dstPoints, int method = 0, double ransacReprojThreshold = 3, OutputArray mask = noArray ())

Python: cv2.findHomography (srcPoints, dstPoints [, method [, ransacReprojThreshold [, mask]]]) β†’ retval, mask

C: void cvFindHomography (const CvMat * srcPoints, const CvMat * dstPoints, CvMat * H, int method = 0, double ransacReprojThreshold = 3, CvMat * status = NULL)

http://opencv.itseez.com/modules/calib3d/doc/camera_calibration_and_3d_reconstruction.html#findhomography

0
source

Source: https://habr.com/ru/post/900127/


All Articles