|
28 | 28 | from icdar import restore_rectangle |
29 | 29 | from opencvlib import nms |
30 | 30 |
|
| 31 | + |
31 | 32 | class Flags(): |
32 | 33 | images_path = '' |
33 | 34 | gpu_list = '0' |
@@ -212,7 +213,9 @@ def main(): |
212 | 213 |
|
213 | 214 | im_fn_list = get_images() |
214 | 215 | for im_fn in im_fn_list: |
215 | | - im = cv2.imread(im_fn)[:, :, ::-1] |
| 216 | + im = cv2.imread(im_fn) |
| 217 | + h, w, _ = im.shape |
| 218 | + im = im[:, :, ::-1] |
216 | 219 | start_time = time.time() |
217 | 220 | im_resized, (ratio_h, ratio_w) = resize_image(im) |
218 | 221 |
|
@@ -244,13 +247,16 @@ def main(): |
244 | 247 | continue |
245 | 248 |
|
246 | 249 | box_cv2 = [box.astype(np.int32).reshape((-1, 1, 2))] |
247 | | - |
| 250 | + |
248 | 251 | if i == 0: |
249 | 252 | boxes_out = np.array(box_cv2) |
| 253 | + #x1, y1, x2, y2, x2 - x1, edge colour |
| 254 | + boxes_for_cluster = np.array(box[0, 0]/w, box[0, 1]/h, box[2, 0]/w, box[2, 1]/h, box[2, 1]/h - box[0, 1]/h) |
| 255 | + # for_cluster = np.array(box[0, 0], box[0, 1], box[1, 0], box[1, 1], box[2, 0], box[2, 1], box[3, 0], box[3, 1]) |
250 | 256 | else: |
251 | 257 | boxes_out = np.vstack((boxes_out, np.array(box_cv2))) |
252 | 258 |
|
253 | | - #f.write('{},{},{},{},{},{},{},{}\r\n'.format(box[0, 0], box[0, 1], box[1, 0], box[1, 1], box[2, 0], box[2, 1], box[3, 0], box[3, 1],)) |
| 259 | + #f.write('{},{},{},{},{},{},{},{}\r\n'.format(,)) |
254 | 260 | if FLAGS.write_images: |
255 | 261 | cv2.polylines(im[:, :, ::-1], box_cv2, True, color=(255, 255, 0), thickness=1) |
256 | 262 | np.save(res_file_pickle, boxes_out) |
|
0 commit comments