def testLocate(self):
image = mk_img(200, 300)
# draw a rectangle
A = (3, 40)
B = (3, 150)
C = (125, 40)
D = (125, 150)
ABCD = Polygon([A, B, D, C, A])
image = draw_poly(image, ABCD, color=1)
image = draw_circle(image, 40, (250, 150), color=2)
# test locator
locator = SemanticLocator(background=0)
located = locator.locate(image)
polygons, labels = zip(*located)
self.assertEqual(2, len(polygons), "Two polygons found")
self.assertTrue(ABCD.equals(polygons[0]), "Rectangle polygon is found")
self.assertLessEqual(relative_error(polygons[1].area, np.pi * 40 * 40), 0.005)
评论列表
文章目录