import os, sys, glob, cv2
path=sys.argv[1]
al = glob.glob(path+'/*txt')
al.sort()
n=len(al)
i =0while(1):
a=al[i]
b=a.replace('txt','jpg')print(i, b)
im=cv2.imread(b)
ih,iw,_=im.shape
for line inopen(a):
sp=line.split()
c=sp[0]
x=float(sp[1])*iw
y=float(sp[2])*ih
w=float(sp[3])*iw
h=float(sp[4])*ih
x1=int(x-w/2)
x2=int(x+w/2)
y1=int(y-h/2)
y2=int(y+h/2)
cv2.rectangle(im,(x1,y1),(x2,y2),(0,0,255))
cv2.imshow('ss', im)
ch=cv2.waitKey()&0xffif ch ==102:#f
i -=1if i <0: i =0elif ch ==27:breakelse:
i +=1if i >= n: i = n-1