[英]OpenCV Won't draw circle - Python
What's wrong with this - why won't it draw the circle in the window I create? 这有什么问题-为什么它不能在我创建的窗口中绘制圆?
threeDWinName = "3D View"
cv2.namedWindow(threeDWinName, cv2.CV_WINDOW_AUTOSIZE)
img2 = cv2.imread('white.png', 0)
cv2.imshow(threeDWinName,img2)
cv2.circle(img2, (100,100),100,255,-1)
cv2.imshow(threeDWinName,img2)
Your code works for me. 您的代码对我有用。 I see the file you are reading is called
white.png
, and by loading it with the 0
you are loading it in grayscale
, so the circle you are drawing is also white. 我看到您正在读取的文件称为
white.png
,并通过将其加载为0
来加载grayscale
,因此您绘制的圆也是白色的。 That could be the problem ;) 那可能是问题;)
img2 = cv2.imread('black.png', 0)
cv2.circle(img2, (100,100),100,255,-1)
cv2.imwrite('circle.png', img2)
or if you use img2 = cv2.imread('black.png')
, then you get this: 或者,如果您使用
img2 = cv2.imread('black.png')
,则会得到以下信息:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.