def run(self): result = predict_txt(self.image_path, self.model_path["east"]) result_array = cv2.imread(self.image_path) if len(result): result = hard_coords(result[0]) predict = selected_box(result_array, *result) # Stage image selected_pix = QGraphicsPixmapItem(array_to_pixmap(predict)) selected_scene = QGraphicsScene() selected_scene.addItem(selected_pix) self.img_container.setScene(selected_scene) self.img_container.fitInView(selected_pix) # Predict number thread = PredictThread(predict, (256, 32), self.model_path["crnn"], self.txt_container) thread.run() else: self.fail_msg()
def mouseReleaseEvent(self, event): if self.activate: self.flag = False # Manual locate and display it in select area. try: x0, y0 = int(self.start_point.x()), int(self.start_point.y()) x1, y1 = int(self.current_point.x()), int( self.current_point.y()) self.selected_img = selected_box(self.img_array, x0, y0, x1, y1) selected_pix = QGraphicsPixmapItem( array_to_pixmap(self.selected_img)) selected_scene = QGraphicsScene() selected_scene.addItem(selected_pix) self.stage.setScene(selected_scene) self.stage.fitInView(selected_pix) except AttributeError: self.selected_img = None return
def pose_it(self, img_array): # It will not change original img_array, just a copy. pix = array_to_pixmap(img_array) self.diaplay_img.set_item_with_stage(pix, img_array, self.selected_img) self.diaplay_img.set_scene()
def set_selected_img_stage(self, pred_img): selected_pix = QGraphicsPixmapItem(array_to_pixmap(pred_img)) selected_scene = QGraphicsScene() selected_scene.addItem(selected_pix) self.selected_img.setScene(selected_scene) self.selected_img.fitInView(selected_pix)