[英]How can I erase the contours drawn in the same image using Python OpenCV?
I am wondering is there a way to erase/delete the Contours drawn on the image from the function cv2.drawContours
?我想知道有没有办法从函数
cv2.drawContours
擦除/删除在图像上绘制的轮廓?
Right now, I can get all the rectangles drawn on the images as shown below:现在,我可以在图像上绘制所有矩形,如下所示:
And to draw the rectangles, I used the following codes.为了绘制矩形,我使用了以下代码。 Note that
items
is a list of points请注意,
items
是一个点列表
rect = cv2.minAreaRect(np.array(items))
box = cv2.boxPoints(rect)
box = np.int0(box)
cv2.drawContours(img, [box], 0, [0,0,255], 1)
However, I hope only one rectangle is shown on the same image each time, but not all the rectangles are shown on the same image.但是,我希望每次只在同一图像上显示一个矩形,但并非所有矩形都显示在同一图像上。
For example,例如,
This is the first rectangle to be shown.这是要显示的第一个矩形。
However, when the second rectangle is shown, the first rectangle should be disappeared but not still on the image.但是,当显示第二个矩形时,第一个矩形应该消失但不会仍然在图像上。
Hopes someone could help me out.希望有人可以帮助我。 Thanks!
谢谢!
box
here is a list probably, so instead of plotting all the points in box on your original image, only plot the point which is at the i
th index of the list and iterate through the box list plotting each point on the original image only.这里的
box
可能是一个列表,所以不要在原始图像上绘制 box 中的所有点,只绘制位于列表第i
个索引处的点,并遍历 box 列表,仅在原始图像上绘制每个点。 You will need to make multiple, cv2 windows for this.您需要为此制作多个 cv2 窗口。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.