Esempio n. 1
0
def run_pipeline(image):
    if not isinstance(image, np.ndarray):
        image = aux.to_opencv_type(image)
    image = aux.remove_alpha_channel(image)
    image = aux.brightness_contrast_optimization(image, 1, 0.5)
    colors = aux.run_kmeans(image, 2)
    image = remove_lines(image, colors)
    image = aux.image_resize(image, height=image.shape[0] * 4)
    image = aux.open_close_filter(image, cv2.MORPH_CLOSE)
    image = aux.brightness_contrast_optimization(image, 1, 0.5)
    image = aux.unsharp_mask(image, (3, 3), 0.5, 1.5, 0)
    image = aux.dilate_image(image, 1)

    image = aux.binarize_image(image)
    image = aux.open_close_filter(image, cv2.MORPH_CLOSE, 1)

    sorted_results = aux.east_process(image)
    sorted_chars = ' '.join(
        map(lambda position_and_word: position_and_word[1], sorted_results))

    return sorted_chars
Esempio n. 2
0
 def test_resize_image_height_width(self):
     image = self.cv_image
     image_shape = image.shape
     image_returned = aux.image_resize(image, 4000, 4000)
     image_returned_shape = image_returned.shape
     self.assertNotEqual(image_shape, image_returned_shape)
Esempio n. 3
0
 def test_resize_image(self):
     image = self.cv_image
     image_shape = image.shape
     image_returned = aux.image_resize(image)
     image_returned_shape = image_returned.shape
     self.assertEqual(image_shape, image_returned_shape)
Esempio n. 4
0
 def test_apply_boxes(self):
     boxes = np.array([[630, 348, 869, 678], [132, 348, 378, 678],
                       [390, 348, 620, 678]])
     image = aux.binarize_image(aux.image_resize(self.cv_image, 1024))
     results = aux.apply_boxes(boxes, image, 1, 1, 1024, 1024, 0)
     self.assertEqual(len(results[0]), 3)