问题描述
是否有任何辅助方法来绘制由 cv2.minAreaRect()大概是 如何从直线上绘制旋转的矩形-围绕中心点或给定的第一个点旋转? 应该可以解决问题. 来源: 1) http://opencvpython.blogspot.in/2012/06/contours-2-brotherhood.html Are there any helper methods to draw a rotated rectangle that is returned by cv2.minAreaRect() presumably as How could a rotated rectangle be drawn from lines - rotate about the center point or the first point given? should do the trick. sources: 1) http://opencvpython.blogspot.in/2012/06/contours-2-brotherhood.html 这篇关于OpenCV Python:绘制minAreaRect(未实现RotatedRect)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!((x1,y1),(x2,y2),angle)
? cv2.rectangle()不支持角度.并且由于返回的元组不是"RotatedRect"类的(因为它似乎未在Python绑定中实现),因此没有points()
方法,如C ++教程rect = cv2.minAreaRect(cnt)
box = cv2.cv.BoxPoints(rect) # cv2.boxPoints(rect) for OpenCV 3.x
box = np.int0(box)
cv2.drawContours(im,[box],0,(0,0,255),2)
((x1,y1),(x2,y2),angle)
? cv2.rectangle() does not support an angle.And since the tuple returned is not of the "RotatedRect" class (because it seems to not be implemented in the Python bindings) there is no points()
method, as shown in the C++ tutorial "Creating Bounding rotated boxes and ellipses for contours¶".rect = cv2.minAreaRect(cnt)
box = cv2.cv.BoxPoints(rect) # cv2.boxPoints(rect) for OpenCV 3.x
box = np.int0(box)
cv2.drawContours(im,[box],0,(0,0,255),2)