diff --git a/src/machinevisiontoolbox/ImagePointFeatures.py b/src/machinevisiontoolbox/ImagePointFeatures.py index 565bf536..323404e2 100644 --- a/src/machinevisiontoolbox/ImagePointFeatures.py +++ b/src/machinevisiontoolbox/ImagePointFeatures.py @@ -1242,8 +1242,8 @@ def draw( ) draw_line( img, - (centre[0], circum[0]), - (centre[1], circum[1]), + centre, + circum, color=handcolor, thickness=handthickness, ) diff --git a/tests/test_image_point_features_extra.py b/tests/test_image_point_features_extra.py index cc32d4a0..e862cca2 100644 --- a/tests/test_image_point_features_extra.py +++ b/tests/test_image_point_features_extra.py @@ -626,17 +626,26 @@ def test_draw_filled_circle(self, canvas, one): assert xs.min() >= 28 and xs.max() <= 52 assert ys.min() >= 28 and ys.max() <= 52 - @pytest.mark.xfail( - strict=True, - reason="draw() passes the x pair and the y pair to draw_line as the " - "start and end points, so the hand is vertical, not along the orientation", - ) def test_draw_hand_points_along_the_orientation(self, canvas, one): one.draw(canvas, filled=True, hand=True, color="r", handcolor="g") ys, xs = np.nonzero(canvas.array[:, :, 1] > 0) - # orientation 0 is along +u, so a horizontal line on row 40 + # orientation 0 is along +u, so a horizontal line on row 40, from the + # centre (40, 40) to the circumference at (50, 40) assert (ys == 40).all() - assert xs.min() >= 40 and xs.max() <= 50 + assert xs.min() == 40 and xs.max() == 50 + + def test_draw_hand_follows_a_quarter_turn(self, canvas): + # orientation 90 degrees is along +v: a vertical line down column 40 + f = SIFTFeature( + [cv2.KeyPoint(40.0, 40.0, 10.0, 90.0, 0.5, 0, 0)], + np.zeros((1, 4), dtype=np.float32), + scale=True, + orient=True, + ) + f.draw(canvas, filled=True, hand=True, color="r", handcolor="g") + ys, xs = np.nonzero(canvas.array[:, :, 1] > 0) + assert (xs == 40).all() + assert ys.min() == 40 and ys.max() == 50 def test_draw_hand_is_drawn(self, canvas, one): one.draw(canvas, filled=True, hand=True, color="r", handcolor="g")