Skip to content Skip to sidebar Skip to footer

Sharpen Image To Detect Edges/lines In A Stamped "x" Object On Paper

I'm using python & opencv. My goal is to detect 'X' shaped pieces in an image taken with a raspberry pi camera. The project is that we have pre-printed tic-tac-toe boards, and

Solution 1:

You can try Canny edge detector with Otsu's robust method for determining the dual threshold value.

im = cv2.imread('9WJTNaZ.jpg', 0)
th, bw = cv2.threshold(im, 0, 255, cv2.THRESH_BINARY | cv2.THRESH_OTSU)
edges = cv2.Canny(im, th/2, th)

Then you can use

  • convexity defects of the contours

or

  • the area of the filled contour to the area of the bounding box of the contour

to differentiate the cross marks from circles.

This is what I get when I apply Canny to your image.

edges

Solution 2:

Since you're using ink stamps, implementing an edge detection method and then later some kind of character recognition method (?) is a tough way to go.

Have you tried using a simple connected components algorithm? Even with the lighting variation seen in your image, a bit of tinkering with a few standard binarization techniques should yield reasonable results.

http://docs.opencv.org/master/d3/dc0/group__imgproc__shape.html#gsc.tab=0

Once you have your components, you'll have data about moments, perimeter lengths, and so on that should lead you quickly to a calculation to distinguish the two kinds of marks.

Whatever technique you use, consider reducing the image size first so that you have fewer pixels to process. You may notice some other benefits to creating a smaller image.

And if you can, add a small diffuse light to your camera. This should make your programming task easier and detection more robust.

Post a Comment for "Sharpen Image To Detect Edges/lines In A Stamped "x" Object On Paper"