【发布时间】:2016-05-28 03:51:25
【问题描述】:
我目前正在使用 python 和 OpenCV 进行项目。对于项目的一部分,我想检查一个特定像素(特别是坐标为 100、100 的像素)是否不等于黑色。我的代码如下。
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()
我做错了什么?
【问题讨论】:
标签: python image opencv pixels