def crop_img(img, dim): x = IntTensor.item(dim[0]) #60 y = IntTensor.item(dim[1]) #20 h = IntTensor.item( dim[2]) #* 1.1#increase by 10 percent to improve VGG classification w = IntTensor.item(dim[3]) #* 1.1 croped_img = img[int(y):int(y + w), int(x):int(x + h)] # cv2.imshow("cropped", croped_img) # cv2.waitKey(0) # cv2.destroyAllWindows() return croped_img
def crop_img(img, dim): # x = 551#IntTensor.item(dim[0])#60 # y = 204#IntTensor.item(dim[1])#20 # w = 640#IntTensor.item(dim[2]) * 1.1#increase by 10 percent to improve Yolo/VGG classification # h = 449#IntTensor.item(dim[3]) * 1.1 x = IntTensor.item(dim[0]) #60 y = IntTensor.item(dim[1]) #20 w = IntTensor.item( dim[2] ) #* 1.1#increase by 10 percent to improve Yolo/VGG classification h = IntTensor.item(dim[3]) #* 1.1 #croped_img = img[int(y):int(h), int(x):int(w)] croped_img = img[int(y * 0.8):int(h * 1.1), int(x * 0.8):int(w * 1.2)] # cv2.imshow("cropped", croped_img) # cv2.waitKey(0) # cv2.destroyAllWindows() return croped_img