[英]CV2 Image Memory
我有一个在图像上绘制矩形的函数。 输入图像总是相同的,但是在我运行函数来绘制和绘制带有轮廓的图像后,如果我再次运行它,它会保留旧的轮廓。 每次在函数开始时都会读取原始图像,所以我不明白为什么它不初始化它,就好像之前没有绘制轮廓一样。
我是 python 和opencv
新手。 如果您有任何建议在再次应用轮廓之前清除图像,请告诉我
def get_last_col(date_headers):
n_tables = len(date_headers)
print(n_tables)
image=date_headers[0][0]
for header in date_headers:
h_d = header[1]
page_h = image.shape[0]
last_col = h_d[h_d.bloc_x==max(h_d.bloc_x)]
last_col['width'] = last_col.bloc_xw - last_col.bloc_x
min_w = int(min(last_col.width))
# X of most bottom left corner date in header
bottom_left = min( int(min(last_col['bloc_x'])-50), int(min(last_col['bloc_x'])-min_w) )
# Y of of most bottom date element
bottom_top = int(last_col.Y_DATE)-20
#X of most bottom right corner date in header
bottom_right = int(max(h_d['bloc_xw'])+min_w)-10
cv2.rectangle(image, (bottom_left,bottom_top), (bottom_right,page_h), (36,255,12), 2)
plt.figure(figsize = (30,30))
plt.imshow(image)
运行该函数一次后的示例,然后使用不同的轮廓再次运行
我通过使用图像的副本 (date_headers[0][0].copy()) 弄清楚了
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.