Ask Your Question
0

Circle not appearing on my image.

asked 2017-12-29 03:51:19 -0600

NirvanaDon gravatar image

Hey guys, im tried drawing a circle on the midpoint of my line but there's no circle. It created a gap between the lines instead. Please advice thanks!

image description

below the code i used.

M = cv2.moments(ske)

centroid_x = int(M['m10']/M['m00'])

centroid_y = int(M['m01']/M['m00'])

cv2.circle(ske,(centroid_x,centroid_y), 5, (0,0,255), -1)

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
0

answered 2017-12-29 04:02:02 -0600

berak gravatar image

updated 2017-12-29 04:14:13 -0600

above is a binary (1 channel) image, -- you cannot draw something in color on that. only the 1st channel of your drawingcolor will be used, and that is 0, so you draw a black circle on black background.

solution1:

## draw a grey circle, so you have some contrast to both line & bg:
cv2.circle(ske, (centroid_x,centroid_y), 5, (127,0,0), -1)

solution2:

## convert to 3 channels, then draw your red circle into that:
bgr = cvtColor(ske, cv2.COLORGRAY2BGR)
cv2.circle(bgr, (centroid_x,centroid_y), 5, (0,0,255), -1)
edit flag offensive delete link more

Comments

Thank you ! i manage to get the grey circle from solution 1.

NirvanaDon gravatar imageNirvanaDon ( 2018-01-01 20:37:52 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2017-12-29 03:51:19 -0600

Seen: 3,470 times

Last updated: Dec 29 '17