简体   繁体   中英

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.

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. Typical examples of using Canny to find a paper in an image return results where each page edge is many lines (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.

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.

There is a corner detection filter which can help you find the corners of rectangle ABCD. then you just check if vector AB is perpendicular to BC and AD and so on. Also if there are more than 4 corners detected with reasonable threshold within the compact white area - it is a message "somethings not ok."

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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