OpenCV不会绘制圆圈 - Python

时间:2013-01-27 13:13:31

标签: python opencv computer-vision

这有什么问题 - 为什么它不会在我创建的窗口中绘制圆圈?

    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)

1 个答案:

答案 0 :(得分:6)

您的代码适合我。我看到您正在阅读的文件名为white.png,加载0后,您将其加载到grayscale,因此您绘制的圆圈也是白色的。这可能是问题;)

img2 = cv2.imread('black.png', 0)
cv2.circle(img2, (100,100),100,255,-1)
cv2.imwrite('circle.png', img2)

enter image description here

或者如果你使用img2 = cv2.imread('black.png'),那么你就明白了:

enter image description here