import os import cv2 import pandas as pd files='images' label='labels' import numpy as np files1=os.listdir(files) for file in files1: photo=files+'/'+file lable1=label+'/'+file[:-4]+'.txt' data = pd.read_table(lable1, sep = ' ', header = None) color_img = cv2.imread(photo) print(data.iloc[0,4]) print(data.iloc[0,5]) cv2.rectangle(color_img, (int(data.iloc[0,4]),int(data.iloc[0,5])),(int(data.iloc[0,6]),int(data.iloc[0,7])), (0, 255, 0),2) cv2.imshow('Gray Image',color_img) cv2.waitKey(0)
标签:标记,int,cv2,color,import,iloc,data,图片 From: https://www.cnblogs.com/hahaah/p/16894485.html