def testLocator(self):
image = mk_img(400, 600)
# draw a rectangle
A = (5, 80)
B = (5, 300)
C = (250, 80)
D = (250, 300)
ABCD = Polygon([A, B, D, C, A])
image = draw_poly(image, ABCD)
image, circle = draw_circle(image, 85, (500, 300), return_circle=True)
# test locator
locator = BinaryLocator()
located = locator.locate(image)
polygons, labels = zip(*located)
self.assertEqual(2, len(polygons), "Two polygons found")
self.assertTrue(ABCD.equals(polygons[1]), "Rectangle polygon is found")
self.assertLessEqual(relative_error(polygons[0].area, np.pi * 85 * 85), 0.005)
评论列表
文章目录