Finding location of rectangles in an image with OpenCV

前端 未结 6 1857
自闭症患者
自闭症患者 2020-12-08 05:52

I\'m trying to use OpenCV to \"parse\" screenshots from the iPhone game Blocked. The screenshots are cropped to look like this:

6条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-08 05:57

    Since your problem is the small rectangles I would start by removing them. Since those lines are much thinner than the borders of the rectangles I would start by applying morphological operations on the image.

    Using a structural element that looks like this:

     element = [ 1 1
                 1 1 ]
    

    should remove lines that are less than two pixels wide. After the small lines are removed the rectangle finding algorithm of OpenCV will most likely do the rest of the job for you. The erosion can be done in OpenCV by the function cvErode

提交回复
热议问题