[英]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.