首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >CV2图像内存

CV2图像内存
EN

Stack Overflow用户
提问于 2020-11-01 12:25:11
回答 1查看 25关注 0票数 0

我有一个在图像上绘制矩形的函数。输入图像总是相同的,但是在我运行函数来绘制和绘制带有轮廓的图像之后,如果我再次运行它,它会保持旧的轮廓。每次在函数开始时读取原始图像,所以我不明白为什么它不初始化它,就好像以前没有绘制过轮廓一样。

我是python和opencv的新手。如果您有任何建议在再次应用轮廓之前清除图像,请让我知道

代码语言:javascript
复制
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)

使用不同的等高线再次运行函数后的示例

first run

second run

EN

回答 1

Stack Overflow用户

发布于 2020-11-01 21:33:14

我通过使用图像的副本(date_headers.copy())解决了这个问题。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/64628659

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档