Exemplo n.º 1
0
    def test_simple(self):
        boxes = [
                    Box(50,50),
                    Box(150,52),
                    Box(250,48),
                    Box(350,43),

                    Box(50,150),
                    Box(150,152),
                    Box(250,148),
                    Box(350,143),
                ]
        expected_clusters = [
                    Cluster([
                        Box(50,50),
                        Box(150,52),
                        Box(250,48),
                        Box(350,43),
                    ]),
                    Cluster([
                        Box(50,150),
                        Box(150,152),
                        Box(250,148),
                        Box(350,143),
                    ])
                ]
        clusters = cluster(boxes)
        self.assertEquals(clusters,expected_clusters)
Exemplo n.º 2
0
    def segment(img):
        """
        img should be filename
        """

        raw_boxes = get_bounding_boxes(img)
        clusters = cluster(raw_boxes)
        total = []
        index = 0
        total,index = crop(img,[c.bounding_box() for c in clusters],index)

        result = {'arith': total, 'mat': []}
        return result