OpenCV - How to find rectangle contour of a rectangle with round corner?

前端 未结 3 1075
野性不改
野性不改 2020-12-30 06:29

I\'m trying to find the contour of a rectangle object with round corner in a image. I tried HoughLinesP and findContours, but did not achieve the d

3条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-30 07:02

    You can find bounding rectangle of nonzero points.

    image = cv2.imread("./img/findrect0.png", 1)
    gray = util.grayImage(image)
    gray_inv = cv2.bitwise_not(gray)
    points = cv2.findNonZero(gray)
    rect = cv2.boundingRect(points)
    

提交回复
热议问题