zoukankan      html  css  js  c++  java
  • 根据小图文件名在原图画框

    找到小图片在原图的位置进行标记

    import cv2, os
    
    cells_root = './cells/crop/' #小图路径
    FOV_range_root = 'origin_imgs_range' #原图路径
    
    def get_cells_location(cells_root_):
        cells_dir = os.listdir(cells_root_)
        cells_location = []
        for n in cells_dir:
            temp = []
            cellroot_split = n.split('_')
            temp.append(cellroot_split[0]) # FOV名字
            temp.append(cellroot_split[3]) # 坐标
            temp.append(cellroot_split[4])
            temp.append(cellroot_split[5])
            temp.append(cellroot_split[6].split('.')[0])
            cells_location.append(temp)
        return cells_location
            
    def FOV_range_fun(cells_location_, FOV_range_root_):
        for n in cells_location_:
            print(n)
            fov_Id = n[0]
            fov_Id_path = os.path.join(FOV_range_root_, fov_Id)
            fov_Id_path_new = os.path.join(FOV_range_root_, fov_Id)
            x1 ,y1, x2, y2 = int(n[1]), int(n[2]), int(n[3]), int(n[4])
            x_o = int((x1+x2)/2)
            y_o = int((y1+y2)/2)
            side = 50
            x1_, y1_, x2_, y2_ = x_o - side, y_o - side, x_o + side, y_o + side
            print(fov_Id_path, x1_, y1_, x2_, y2_)
            img = cv2.imread(fov_Id_path)
            first_point = (x1_, y1_)
            last_point = (x2_, y2_)
            cv2.rectangle(img, first_point, last_point, (0,255,0),2)
            cv2.imwrite(fov_Id_path_new,img)
    
    if __name__ == '__main__':
        cells_location = get_cells_location(cells_root)
    #     print(cells_location)
        FOV_range_fun(cells_location, FOV_range_root)
    

      

  • 相关阅读:
    YXY-压测
    禅道使用
    抓https包
    数据库基本查询语句
    限制网速 制造测试条件
    测试中认识 sqlite
    Adb 命令
    jmeter 查看提取的参数
    jmeter传入字符时文本显示乱码
    nginx 访问springboot项目
  • 原文地址:https://www.cnblogs.com/niulang/p/12047844.html
Copyright © 2011-2022 走看看