2
我目前正在使用python和OpenCV開展一個項目。對於項目的一部分,我想查看一個特定像素(特別是座標爲100,100的像素)是否不等於黑色。我的代碼如下。使用Python檢查OpenCV中的像素顏色
import cv2
img = cv2.imread('/Documents/2016.jpg')
if img[100, 100] != [0, 0, 0]:
print("the pixel is not black")
當我走在終端的樂趣,我得到這個錯誤。
File "/Documents/imCam.py", line 5, in <module>
if img[100, 100] != [0, 0, 0]:
ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
我在做什麼錯?
謝謝!這工作! – user3127854