Esempio n. 1
0
    def ctpn(self, sess, net, img):
        im, im_scale = self.check_img(img)
        timer = Timer()
        timer.tic()
        scores, boxes = test_ctpn(sess, net, im)
        timer.toc()
        print(('Detection took {:.3f}s for '
               '{:d} object proposals').format(timer.total_time,
                                               boxes.shape[0]))

        # Visualize detections for each class
        CONF_THRESH = 0.9
        NMS_THRESH = 0.3
        dets = np.hstack((boxes, scores[:, np.newaxis])).astype(np.float32)
        keep = nms(dets, NMS_THRESH)
        dets = dets[keep]

        keep = np.where(dets[:, 4] >= 0.7)[0]
        dets = dets[keep, :]
        text_lines = self.connect_proposal(dets[:, :], dets[:, 4],
                                           im.shape[:2])
        tmp = im.copy()
        text_recs = draw_boxes(tmp, text_lines, caption="im_name", wait=True)
        # self.show_results(tmp,im_scale, text_recs, thresh=0.9)
        return tmp, text_recs
Esempio n. 2
0
def text_detect(img):
    #ctpn
    scale, max_scale = Config.SCALE,Config.MAX_SCALE
    img,f = resize_im(img,scale=scale,max_scale=max_scale)
    scores, boxes = test_ctpn(sess, net, img)
    textdetector  = TextDetector()
    boxes = textdetector.detect(boxes,scores[:, np.newaxis],img.shape[:2])
    text_recs,tmp = draw_boxes(img, boxes, caption='im_name', wait=True,is_display=False)
    return text_recs,tmp,img
Esempio n. 3
0
def text_detect(img):
    scores, boxes, img = ctpn(img)
    textdetector = TextDetector()
    boxes = textdetector.detect(boxes, scores[:, np.newaxis], img.shape[:2])
    text_recs, tmp = draw_boxes(img,
                                boxes,
                                caption='im_name',
                                wait=True,
                                is_display=False)
    return text_recs, tmp, img
Esempio n. 4
0
 def __text_detection(self):
     scores, self._boxes, self._image = ctpn(self._image, sess, net)
     self._boxes = self._text_detector.detect(self._boxes,
                                              scores[:, np.newaxis],
                                              self._image.shape[:2])
     self._boxes, self.img_drawed_boxes = draw_boxes(self._image,
                                                     self._boxes,
                                                     caption='im_name',
                                                     wait=True,
                                                     is_display=False)
     self._boxes, self._image = correct_box(sort_box(self._boxes),
                                            self._image, self._text_process)