import os
import cv2
import numpy as np
from PIL import Image
import matplotlib.pyplot as plt
def save(cropImg, framenum, tracker):
pathnew = "../images1_cut/"
if (os.path.exists(pathnew)):
cv2.imwrite(pathnew + framenum + '_' + tracker + '.jpg', cropImg, [int(cv2.IMWRITE_JPEG_QUALITY), 100])
else:
os.makedirs(pathnew)
cv2.imwrite(pathnew + framenum + tracker + '.jpg', cropImg, [int(cv2.IMWRITE_JPEG_QUALITY), 100])
f = open("../person.txt", "r")
lines = f.readlines()
for line in lines:
li = line.split(' ')
print(li[0], li[1], li[2], li[3], li[4], li[5])
filename = li[0] + '.jpg'
img = cv2.imread("../images1/" + filename)
a = int(float(li[3]))
b = int(float(li[5]))
c = int(float(li[2]))
d = int(float(li[4]))
cropImg = img[a:b, c:d]
save(cropImg, li[0], str(li[1]).split('.')[1][:3])