Skip to content

Commit

Permalink
add h,w to label file when crop images
Browse files Browse the repository at this point in the history
  • Loading branch information
WenmuZhou committed Apr 15, 2020
1 parent 647ccb7 commit 5a1f8f5
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions convert/crop_rec.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ def crop(save_gt_path, json_path, save_path):
file_list = []
for img_path, gt in tqdm(data.items()):
img = cv2.imread(img_path)
np_img = cv2.cvtColor(img,cv2.COLOR_BGR2RGB)
np_img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
img = Image.fromarray(np_img)
img_name = pathlib.Path(img_path).stem
for i, (polygon, text, illegibility, language) in enumerate(
Expand All @@ -118,7 +118,8 @@ def crop(save_gt_path, json_path, save_path):
y_max = polygon[:, 1].max()
roi_img = img.crop((x_min, y_min, x_max, y_max))
roi_img.save(roi_img_save_path)
file_list.append(roi_img_save_path + '\t' + text + '\t' + language)
roi_w, roi_h = roi_img.size
file_list.append('{}\t{}\t{}\t{}\t{}'.format(roi_img_save_path, text, roi_w, roi_h, language))
# plt.title(text)
# plt.imshow(roi_img)
# plt.show()
Expand Down

0 comments on commit 5a1f8f5

Please sign in to comment.