我尝试运行这个程序
for (x,y,w,h) in jeruks1 and jeruks2:
cv2.rectangle(img1,(x,y),(x+w,y+h),(17,126,234),2)
font = cv2.FONT_HERSHEY_SIMPLEX
cv2.putText(img1,'Jeruk',(x+w,y+h), font, 1, (17,126,234), 2, cv2.LINE_AA) #---write the text
cv2.rectangle(img2,(x,y),(x+w,y+h),(17,126,234),2)
font = cv2.FONT_HERSHEY_SIMPLEX
cv2.putText(img2,'Jeruk',(x+w,y+h), font, 1, (17,126,234), 2, cv2.LINE_AA) #---write the text
roi_gray = cam1[y:y+h, x:x+w]
roi_color = img1[y:y+h, x:x+w]
roi_gray = cam2[y:y+h, x:x+w]
roi_color = img2[y:y+h, x:x+w]
但我收到此错误
Traceback (most recent call last):
File "/home/arizal/Documents/Sorting Jeruk/dual.py", line 54, in <module>
for (x,y,w,h) in jeruks1 and jeruks2:
ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
我只是尝试使用双摄像头在1个for循环上加载2个cascade.xml 有人可以帮助我吗?
Python 中的
and
一词用于获取两个布尔值的逻辑“与”,例如True and False
评估为 False
。您收到的错误是 Python 说,“嘿,我想将 jeruks1
和 jeruks2
转换为布尔值,以便我可以获取它们的 and
,但我无法进行该转换!”
您可以使用
+
符号组合两个列表。例如,[1,5] + [2, 3]
的计算结果为 [1,5,2,3]
。