Ask Your Question

Circle not appearing on my 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!

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 close merge delete

1 answer

Sort by ยป oldest newest most voted

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)
more

Comments

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

( 2018-01-01 20:37:52 -0500 )edit

Stats

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

Seen: 1,143 times

Last updated: Dec 29 '17