简体   繁体   English

非常精确的行检测,openCV Java

[英]Very precise line detection, openCV Java

I will start by explaining the problem in a real world application; 我将首先在实际应用中解释问题; I have a camera that is pointed at a dark surface. 我有一台对准黑暗表面的相机。 A paper feeder (just simple machine that spits out pages when it's told to by the controlling computer) feeds paper into the area the camera is looking. 进纸器(只是一台简单的机器,当控制计算机通知时,它会吐出页面)将纸张进给相机正在查看的区域。

Using openCV I am to process the image, and determine if the feeder fed correctly. 我使用openCV处理图像,并确定进纸器是否正确进纸。

This means that I have to be able to determine not just if a page is present, but if multiple pages are present. 这意味着我不仅要确定是否存在一个页面,还要确定是否存在多个页面。 Sometimes multiple pages are fed because they stuck together, in which case the pages are so close to perfectly aligned with eachother they visually appear to be one page unless you look very closely. 有时会因为粘贴在一起而送入多页,在这种情况下,各页之间的距离非常接近,无法彼此完全对齐,除非您仔细观察,否则它们看起来像是一页。

The problem I am having is that Canny Edge Detection, combined with the Hough Transform, does not give me the accuracy I need. 我遇到的问题是Canny Edge Detection结合了Hough变换,无法满足我的精度要求。 Typical examples of using Canny to find a paper in an image return results where each page edge is many lines (5-15). 使用Canny在图像中查找纸张的典型示例会返回每个页面边缘多行(5-15)的结果。 Using find contours determines this is a rectangle. 使用查找轮廓确定这是一个矩形。

These typical examples do not help as I need to be able to detect that there is another line very close to the edge of the page. 这些典型示例无济于事,因为我需要能够检测到另一行非常靠近页面边缘。

I've been playing with the threshold values of the hough transform as well as how much blur I apply before Canny and have gotten it fairly reliable, but the problem is I believe the sensitivity is now too low and any pages that feed in the above example (on top of eachother) will not be detected by this system. 我一直在研究霍夫变换的阈值以及在Canny之前应用的模糊程度,并获得了相当可靠的效果,但是问题是我认为灵敏度现在太低了,上面提供的任何页面该系统将不会检测到示例(位于彼此之上)。

Examples: 例子: 饲料

The above image has two visible pages, one that has just come out of the feeder. 上图有两个可见的页面,其中一个页面刚刚从进纸器出来。 There is text on the page. 页面上有文字。 I need to be able to identify the page's angle, and that there is in fact only one page. 我需要能够识别页面的角度,并且实际上只有一页。

The problem I'm having is that I need the line detection sensitive enough to be able to tell if there is two pages stuck together, but I also need to not have the lines from the text on the page detected. 我遇到的问题是,我需要对行检测足够敏感,以便能够分辨出是否有两个页面粘在一起,但是我也不必检测到页面上文本中的行。

I would suggest you not looking for faint line of one paper covering the other, but look for the overall shape of this white area. 我建议您不要寻找一张覆盖另一张纸的模糊线条,而要寻找这个白色区域的整体形状。 If you know that all these pages are of A4 size - you find the rectangle of white area and check if the angles are right and if proportion of sides is square root of 2. And if the two pieces of paper are perfectly alligned - you would not detect it anyway, unless you measure the thickness of paper somehow. 如果您知道所有这些页面均为A4尺寸-您会找到白色区域的矩形,并检查角度是否正确,并且边的比例是否为2的平方根。并且,如果这两张纸都完全贴合了,您会除非您以某种方式测量纸张的厚度,否则还是无法检测到它。

There is a corner detection filter which can help you find the corners of rectangle ABCD. 有一个角检测过滤器,可以帮助您找到矩形ABCD的角。 then you just check if vector AB is perpendicular to BC and AD and so on. 那么您只需检查矢量AB是否垂直于BC和AD等。 Also if there are more than 4 corners detected with reasonable threshold within the compact white area - it is a message "somethings not ok." 同样,如果在紧凑的白色区域内检测到超过4个具有合理阈值的角,则显示消息“某些情况不正常”。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM