cv2.polylines:颜色被忽略

时间:2017-08-23 19:47:51

标签: python opencv polyline

在以下代码的倒数第二行中,我绘制了一条折线,并将颜色指定为黑色(0,0,0)。然而线条是用白色绘制的。任何人都可以解释我为什么?

这是我的代码:

import numpy as np
import cv2
import matplotlib.pyplot as plt
import matplotlib.image as mpimg
%matplotlib inline

# helper function
def showImage(img, title):
    fig = plt.figure()
    plt.suptitle(title)
    plt.imshow(img)


# read and show test image
img = mpimg.imread('undistorted.jpg')
showImage(img, "undistorted")


# source points
top_left = [427,564]
top_right = [873,564]
bottom_right = [1074,690]
bottom_left = [249,690]
pts = np.array([top_left, top_right, bottom_right, bottom_left])

cv2.polylines(img,np.int32([pts]),True,(0,0,0), 5) # line color given as (0,0,0) = black, but drawn as white?
showImage(img, "preview")

这是输出: enter image description here

这是我使用的输入图像: enter image description here

感谢你提供任何暗示!

0 个答案:

没有答案