仿射变换,简单的旋转和缩放或别的东西完全? [英] Affine Transform, Simple Rotation and Scaling or something else entirely?

查看:170
本文介绍了仿射变换,简单的旋转和缩放或别的东西完全?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

场景是这样的:我有,我想做些OCR纸的图片。因此,采取下面的图片作为我的输入例如:

The scenario goes like this: I have a picture of a paper that I would like to do some OCR. So take the image below as my input example:

在成功地检测对应于我留下了一个矢量&lt纸上的区域;点> 的该图像内确定其位置4坐标。请注意,这些坐标可能不符合标准的矩形,由于摄像头和角的距离拍摄照片时。观看目的,我连的子图像中的点,所以你可以看到我的意思是:

After successfully detecting the area that corresponds to the paper I'm left with a vector<Point> of 4 coordinates that define its location inside the image. Note that these coordinates will probably not correspond to a perfect rectangle due to the distance of the camera and angle when the picture was taken. For viewing purposes I connected the points in the sub-image so you can see what I mean:

在这种情况下,要点是:[1215 43],[52,67],[56,869]和[1216 884]

In this case, the points are: [1215, 43] , [52, 67] , [56, 869] and [1216, 884]

在这个时刻,我需要让他们变成水平对齐调整这些点。我是什么意思呢?如果发现上述子图像的区域,它是一个小旋转:在图像的右侧的点比在另一侧点位于高一点

At this moment, I need to adjust these points so they become aligned horizontally. What do I mean by that? If you notice the area of the sub-image above, it is a little rotated: the points on right side of the image are positioned a little higher than points on the other side.

在换句话说,我们有图像的 A ,这是夸张的目的,看起来比实际多了几分扭曲/旋转,然后图像的 - 这是什么我想,这是操作的最终结果:

In other words, we have image A, which was exaggerated on purpose to look a little more distorted/rotated than reality, and then image B - which is what I would like as the final result of this procedure:

A) B)

A) B)

我不知道的哪些技术可以用来实现这种转换。该应用程序还需要自动检测旋转多少需要如何做,因为我没有在图像采集过程的控制。

I'm not sure which techniques could be used to achieve this transformation. The application also needs to detect automatically how much rotation needs to be done, as I don't have control over the image acquisition procedure.

的目的是为了有一个新的的子图像。我现在不担心可能的图像失真,我只是在寻找一种方式,以确定需要多大的旋转而子图像上完成,以及如何运用它,并获得更的矩形区域

The purpose is to have a new Mat with the normalized sub-image. I'm not worried about a possible image distortion right now, I'm just looking for a way to identify how much rotation needs to be done on the sub-image and how to apply it and get a more rectangular area.

推荐答案

我觉得<一个href=\"http://felix.abecassis.me/2011/10/opencv-rotation-deskewing/\">http://felix.abecassis.me/2011/10/opencv-rotation-deskewing/和<一个href=\"http://felix.abecassis.me/2011/10/opencv-bounding-box-skew-angle/\">http://felix.abecassis.me/2011/10/opencv-bounding-box-skew-angle/会派上用场。上述职位不包括翘曲角度(只旋转)。为了获得最佳效果,你必须使用<一个href=\"http://opencv.willowgarage.com/documentation/cpp/imgproc_geometric_image_transformations.html#warpPerspective\"><$c$c>warpPerspective (也许与一起getRotationMatrix2D )。使用线段之间的角度找出你需要多少扭曲的视角。这里的假设是,它们应始终是90度,并且最接近的一个为90度是在接近的载体至于立体而言

I think http://felix.abecassis.me/2011/10/opencv-rotation-deskewing/ and http://felix.abecassis.me/2011/10/opencv-bounding-box-skew-angle/ will come in handy. The aforementioned posts don't cover perspective warping (only rotation). To get the best results, you'll have to use warpPerspective (maybe in conjunction with getRotationMatrix2D). Use the angles between line segments to find out how much you need to warp the perspective. THe assumption here is that they should always be 90 degrees and that the closest one to 90 degrees is the "closest" vector as far as the perspective is concerned.

不要忘了你的正常化载体!

Don't forget to normalize your vectors!

这篇关于仿射变换,简单的旋转和缩放或别的东西完全?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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