本文介绍了如何验证网络摄像机的校准的正确性?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 我是全新的相机校准技术...我使用OpenCV棋盘技术...我使用Quantum的网络摄像头...I am totally new to camera calibration techniques... I am using OpenCV chessboard technique... I am using a webcam from Quantum...这里是我的观察和步骤..Here are my observations and steps.. 我保持每个棋子正方形= 3.5厘米。它是一个7 x 5的棋盘,内有 6 x 4 内角。 我遵循学习OpenCV中的C代码作为校准的 Bradski 。 我的校准代码是I have kept each chess square side = 3.5 cm. It is a 7 x 5 chessboard with 6 x 4 internal corners. I am taking total of 10 images in different views/poses at a distance of 1 to 1.5 m from the webcam.I am following the C code in Learning OpenCV by Bradski for the calibration.my code for calibration iscvCalibrateCamera2(object_points,image_points,point_counts,cvSize(640,480),intrinsic_matrix,distortion_coeffs,NULL,NULL,CV_CALIB_FIX_ASPECT_RATIO); 在调用此函数之前,我沿着内对角线的第一个和第二个元素矩阵作为一个保持焦距比率不变并使用 CV_CALIB_FIX_ASPECT_RATIO棋盘的 fx 和 fy 正随着 fx:fy 几乎等于1.有 cx 和 cy 值的顺序为200到400.With the change in distance of the chess board the fx and fy are changing with fx:fy almost equal to 1. there are cx and cy values in order of 200 to 400. the fx and fy are in the order of 300 - 700 when I change the distance.目前,我把所有的失真系数归零,因为我没有得到包括失真系数的好的结果。Presently I have put all the distortion coefficients to zero because I did not get good result including distortion coefficients. My original image looked handsome than the undistorted one!!我正在进行校准吗?应该使用 CV_CALIB_FIX_ASPECT_RATIO ?之外的任何其他选项。如果是,是哪个?Am I doing the calibration correctly?. Should I use any other option than CV_CALIB_FIX_ASPECT_RATIO?. If yes, which one?推荐答案你在寻找帅哥还是准确?Hmm, are you looking for "handsome" or "accurate"?相机校准是计算机视觉中很少的主题之一,其精确度可以直接在物理方面进行量化,并通过物理实验进行验证。通常的教训是,(a)你的数字与你投入的努力(和金钱)一样好,(b)真实的准确性(而不是想象中的)是昂贵的,所以你应该提前知道你的应用程序真正需要的精度的方式。Camera calibration is one of the very few subjects in computer vision where accuracy can be directly quantified in physical terms, and verified by a physical experiment. And the usual lesson is that (a) your numbers are just as good as the effort (and money) you put into them, and (b) real accuracy (as opposed to imagined one) is expensive, so you should figure out in advance what your application really requires in the way of precision.如果您查找甚至非常便宜的lens / ccd combos的几何规格(在百万像素范围及以上),很容易看出亚sub-mm校准理论上可以在顶部空间体积内实现精度。只需从相机的传感器的规格表中计算出一个像素的立体角 - 你会被你的钱包范围内的空间分辨率所感动。然而,实际上达到REPEATABLY接近理论准确度的东西需要工作。If you look up the geometrical specs of even very cheap lens/ccd combos (in the megapixel range and above), it becomes readily apparent that sub-sub-mm calibration accuracies are theoretically achievable within a table-top volume of space. Just work out (from the spec sheet of your camera's sensor) the solid angle spanned by one pixel - you'll be dazzled by the spatial resolution you have within reach of your wallet. However, actually achieving REPEATABLY something near that theoretical accuracy takes work.这里有一些建议(从个人经验)获得自己的设备良好的校准经验。 / p>Here are some recommendations (from personal experience) for getting a good calibration experience with home-grown equipment. 如果您的方法使用平面目标(棋盘或类似的),制造一个好的。选择一个非常平坦的背衬(对于你提到的窗口玻璃5毫米厚或更多是优秀的,虽然显然脆弱)。验证它的平面度对另一边缘(或更好,激光束)。在厚纸上打印图案,不会太容易拉伸。在胶合之后将其印刷在背衬上,并验证正方形边确实非常接近正交。便宜的喷墨打印机或激光打印机不是为了严格的几何精度而设计的,不要盲目地相信他们。最好的做法是使用专业的打印店(即使是金科也比大多数家用打印机做得更好)。然后非常仔细地附加图案到背衬,使用喷涂胶和慢慢用软布擦拭,以避免气泡和拉伸。等待一天或更长时间的胶水固化,胶纸应力达到其长期稳定状态。最后用好的厚度和放大镜测量角位置。您可以使用一个单一的数字来表示平均平方尺寸,但它必须是实际测量的平均值,而不是希望祷告的平均值。最佳做法是实际使用测量位置表。If your method uses a flat target ("checkerboard" or similar), manufacture a good one. Choose a very flat backing (for the size you mention window glass 5 mm thick or more is excellent, though obviously fragile). Verify its flatness against another edge (or, better, a laser beam). Print the pattern on thick-stock paper that won't stretch too easily. Lay it after printing on the backing before gluing and verify that the square sides are indeed very nearly orthogonal. Cheap ink-jet or laser printers are not designed for rigorous geometrical accuracy, do not trust them blindly. Best practice is to use a professional print shop (even a Kinko's will do a much better job than most home printers). Then attach the pattern very carefully to the backing, using spray-on glue and slowly wiping with soft cloth to avoid bubbles and stretching. Wait for a day or longer for the glue to cure and the glue-paper stress to reach its long-term steady state. Finally measure the corner positions with a good caliper and a magnifier. You may get away with one single number for the "average" square size, but it must be an average of actual measurements, not of hopes-n-prayers. Best practice is to actually use a table of measured positions.观察温度和湿度变化:纸张吸收空气中的水分,背衬膨胀和收缩。令人惊讶的是,您可以找到多少文章,报告亚毫米校准精度,而无需引用环境条件(或对它们的目标响应)。不用说,他们大多是垃圾。与普通钣金相比,玻璃的较低温度膨胀系数是优选前者作为背衬的另一个原因。Watch your temperature and humidity changes: paper adsorbs water from the air, the backing dilates and contracts. It is amazing how many articles you can find that report sub-millimeter calibration accuracies without quoting the environment conditions (or the target response to them). Needless to say, they are mostly crap. The lower temperature dilation coefficient of glass compared to common sheet metal is another reason for preferring the former as a backing.不用说,您必须禁用相机的自动对焦功能拍摄大量的测量和图片。你想要每个图像数百个测量(角),和几十个图像。在数据涉及的地方,越多越好。一个10x10的棋盘是我会考虑的绝对最小。Take lots of measurements and pictures. You want hundreds of measurements (corners) per image, and tens of images. Where data is concerned, the more the merrier. A 10x10 checkerboard is the absolute minimum I would consider. I normally worked at 20x20.在拍摄照片时,可跨越校准音量。理想情况下,您希望测量结果均匀分布在您将使用的空间体积中。最重要的是,确保在某些图片中相对于焦点轴显着地倾斜目标 - 以校准您需要看到一些真实透视缩短的焦距。为了获得最佳效果,请使用可重复的机械夹具移动目标。Span the calibration volume when taking pictures. Ideally you want your measurements to be uniformly distributed in the volume of space you will be working with. Most importantly, make sure to angle the target significantly with respect to the focal axis in some of the pictures - to calibrate the focal length you need to "see" some real perspective foreshortening. For best results use a repeatable mechanical jig to move the target. A good one is a one-axis turntable, which will give you an excellent prior model for the motion of the target.最小化振动和相关的运动模糊,这是一个很好的选择。Minimize vibrations and associated motion blur when taking photos.使用良好的照明。真。令人惊奇的是,我经常看到人们在游戏的后期才意识到,你需要光子来校准任何相机:-)使用漫反射的环境照明,并在视野两侧的白卡上反弹。Use good lighting. Really. It's amazing how often I see people realize late in the game that you need photons to calibrate any camera :-) Use diffuse ambient lighting, and bounce it off white cards on both sides of the field of view.观察你的角色提取代码在做什么。在图像的顶部绘制检测到的角位置(例如,在Matlab或Octave中),并判断它们的质量。Watch what your corner extraction code is doing. Draw the detected corner positions on top of the images (in Matlab or Octave, for example), and judge their quality. Removing outliers early using tight thresholds is better than trusting the robustifier in your bundle adjustment code.如果可以的话,约束你的模型。例如,如果你没有足够的理由相信你的镜头显着偏离图像,不要尝试估计主要点,只是在第一次尝试时将其固定在图像中心。主点位置通常很少被观察到,因为其本质上与非线性失真的中心混淆,并且通过平行于目标到目标的图像平面的分量被 相机的翻译。得到它正确需要一个仔细设计的程序,产生三个或更多的独立的消失点的场景和非常好的包围的非线性失真。同样,除非你有理由怀疑镜头焦点轴是真的倾斜w.r.t.传感器平面,将相机矩阵的(1,2)分量固定为零。一般来说,使用满足您的测量和您的应用需求(这是Ockam的剃刀为您)的最简单的模型。Constrain your model if you can. For example, don't try to estimate the principal point if you don't have a good reason to believe that your lens is significantly off-center w.r.t the image, just fix it at the image center on your first attempt. The principal point location is usually poorly observed, because it is inherently confused with the center of the nonlinear distortion and by the component parallel to the image plane of the target-to-camera's translation. Getting it right requires a carefully designed procedure that yields three or more independent vanishing points of the scene and a very good bracketing of the nonlinear distortion. Similarly, unless you have reason to suspect that the lens focal axis is really tilted w.r.t. the sensor plane, fix at zero the (1,2) component of the camera matrix. Generally speaking, use the simplest model that satisfies your measurements and your application needs (that's Ockam's razor for you).具有来自优化器的校准解,具有足够低的RMS误差(十分之一像素,通常,见下面的其他答案),绘制残差的XY模式(所有图像中每个角的prediction_xy-measured_xy)和看看它是否是以(0,0)为中心的圆形云。When you have a calibration solution from your optimizer with low enough RMS error (a few tenths of a pixel, typically, see other answer below), plot the XY pattern of the residual errors (predicted_xy - measured_xy for each corner in all images) and see if it's a round-ish cloud centered at (0, 0). "Clumps" of outliers or non-roundness of the cloud of residuals are screaming alarm bells that something is very wrong - most likely outliers, or an inappropriate lens distortion model.拍摄额外的图像,以验证解决方案的准确性 - 使用它们来验证镜头失真实际上被删除,以及由校准模型预测的平面单应性实际上匹配从测量角落恢复的平面单应性。Take extra images to verify the accuracy of the solution - use them to verify that the lens distortion is actually removed, and that the planar homography predicted by the calibrated model actually matches the one recovered from the measured corners. 这篇关于如何验证网络摄像机的校准的正确性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!