OpenCV的变换使用棋盘 [英] OpenCV Transform using Chessboard

查看:143
本文介绍了OpenCV的变换使用棋盘的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我才刚刚开始尝试OpenCV的一点点。我有一个静态位置的LCD的设置,我想提取被显示在屏幕上的图像是什么。我见过用于校准相机的棋盘格局,但它似乎是用来undistort的形象,这是不完全是我想要做的。

I have only just started experimenting with OpenCV a little bit. I have a setup of an LCD with a static position, and I'd like to extract what is being displayed on the screen from the image. I've seen the chessboard pattern used for calibrating a camera, but it seems like that is used to undistort the image, which isn't totally what I want to do.

我想我会在LCD上显示的棋盘,然后弄清楚到LCD的图像转换成棋盘的理想视图直接开销和裁剪所需要的变革。然后我会存储转换,改变什么液晶显示的是,拍照,执行相同的转换,并获得现在正在显示的内容理想的视图。

I was thinking I'd display the chessboard on the LCD and then figure out the transformations needed to convert the image of the LCD into the ideal view of the chessboard directly overhead and cropped. Then I would store the transformations, change what the LCD is displaying, take a picture, perform the same transformations, and get the ideal view of what was now being displayed.

我想知道如果这听起来像一个好主意吗?有没有更简单的方式来实现我想要做什么?和我应该使用弄清楚转换,执行它们,存储它们的职能任何提示(也许只是保持变换矩阵在内存或写它们到文件),等等?

I'm wondering if that sounds like a good idea? Is there a simpler way to achieve what I'm trying to do? And any tips on the functions I should be using to figure out the transformations, perform them, store them (maybe just keep the transform matrices in memory or write them to file), etc?

推荐答案

我不知道我的理解正确,你正在尝试做的一切,但我承担。

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

有些相机具有导致稍微失真的图像的透镜,并且用于此目的的OpenCV提供方法中的相机校准过程

Some cameras have lenses that cause a little distortion to the image, and for this purpose OpenCV offers methods to aid in the camera calibration process.

实事求是地讲,如果你想编写一个应用程序,它会自动校正图像的失真,第一个后,您需要为发现什么是神奇值的需要要使用撤消此效果。这些数值来自一个适当的校准程序。

Practically speaking, if you want to write an application that will automatically correct the distortion in the image, first, you need to discover what are the magical values that need to be used to undo this effect. These values come from a proper calibration procedure.

的<一个href=\"http://web.archive.org/web/20130515145727/http://www.aishack.in/wp-content/uploads/2010/07/calib-checkerboard.png\"相对=nofollow>棋盘图片一起用的应用程序校准相机。所以,你必须通过相机设备拍摄的棋盘的图像后,这一形象传递到校准应用程序。该应用程序将确定正方形的四个角和计算失真的价值和回报,你需要使用来对抗失真效果的魔法值。在这一点上,你有兴趣通过<返回的2个变量href=\"http://docs.opencv.org/modules/calib3d/doc/camera_calibration_and_3d_reconstruction.html#calibratecamera\"相对=nofollow> calibrateCamera() :他们是 cameraMatrix distCoeffs 。打印出来,并写入数据在一张纸上。

The chessboard image is used together with an application to calibrate the camera. 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 calibrateCamera(): they are cameraMatrix and distCoeffs. Print them, and write the data on a piece of paper.

最后,您正在开发需要系统有一个函数/方法undistort的形象,在这2个变量将在函数内部硬codeD,然后到通话CV :: undistort()(如果你使用的是C ++的OpenCV API):

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 cv::undistort() (if you are using the C++ API of OpenCV):

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

,就是这样。

自动旋转检测可能会有点棘手,但要做的第一件事就是找到你感兴趣的对象的坐标,但如果相机在固定位置,这是一件容易的事。

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.

有关的角度变化和旋转与OpenCV的更多信息,我建议这些其他问题考虑看看:

For more info on perspective change and rotation with OpenCV, I suggest taking a look at these other questions:

一套简历简历执行:: warpPerspective为假纠偏::点

仿射变换,简单的旋转和缩放或别的东西完全?

旋转CV ::垫使用的CV :: warpAffine抵消目的地形象

这篇关于OpenCV的变换使用棋盘的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆