Single-threaded text detection for all images.
(self, image_list)
| 52 | self.rec_threads.append(t) |
| 53 | |
| 54 | def detect_text(self, image_list): |
| 55 | """Single-threaded text detection for all images.""" |
| 56 | for image_id, (img_numpy, ori_img) in enumerate(image_list): |
| 57 | dt_boxes = self.text_detector(img_numpy=img_numpy)[0]['boxes'] |
| 58 | if dt_boxes is None: |
| 59 | self.results[image_id] = [] # If no boxes, set empty results |
| 60 | continue |
| 61 | |
| 62 | dt_boxes = sorted_boxes(dt_boxes) |
| 63 | img_crop_list = [] |
| 64 | for box in dt_boxes: |
| 65 | tmp_box = np.array(box).astype(np.float32) |
| 66 | img_crop = (get_rotate_crop_image(ori_img, tmp_box) |
| 67 | if self.det_box_type == 'quad' else |
| 68 | get_minarea_rect_crop(ori_img, tmp_box)) |
| 69 | img_crop_list.append(img_crop) |
| 70 | self.queue.put( |
| 71 | (image_id, dt_boxes, img_crop_list |
| 72 | )) # Put image ID, detected box, and cropped image in queue |
| 73 | |
| 74 | # Signal that no more items will be added to the queue |
| 75 | self.stop_signal.set() |
| 76 | |
| 77 | def recognize_text(self): |
| 78 | """Recognize text in each cropped image.""" |
no test coverage detected