我正在學習如何使用 opencv,但我遇到了這個問題。
from cvzone.HandTrackingModule import HandDetector
import cv2
cap = cv2.VideoCapture("https://192.168.178.49:8080/video")
detector = HandDetector(maxHands=1, detectionCon=0.7)
while True:
success, img= cap.read()
img = detector.findHands(img)
cv2.imshow("AI", img)
cv2.waitKey(1)
導致此錯誤:
INFO: Created TensorFlow Lite XNNPACK delegate for CPU.
Traceback (most recent call last):
File "d:\Programming\Arm Code\testhandai.py", line 13, in <module>
cv2.imshow("AI", img)
cv2.error: OpenCV(4.5.4) :-1: error: (-5:Bad argument) in function 'imshow'
> Overload resolution failed:
> - mat is not a numerical tuple
> - Expected Ptr<cv::cuda::GpuMat> for argument 'mat'
> - Expected Ptr<cv::UMat> for argument 'mat'
我正在使用 Python 3.8 64 位和所有軟體包的最新版本。謝謝你。
uj5u.com熱心網友回復:
的輸出detector.findHands(img)是一個元組。您應該將它的第二個元素作為輸入cv2.imshow():
from cvzone.HandTrackingModule import HandDetector
import cv2
cap = cv2.VideoCapture("https://192.168.178.49:8080/video")
detector = HandDetector(maxHands=1, detectionCon=0.7)
while True:
success, img= cap.read()
img = detector.findHands(img)
cv2.imshow("AI", img[1])
cv2.waitKey(1)
轉載請註明出處,本文鏈接:https://www.uj5u.com/qiye/382334.html
上一篇:為什么將int分配給列舉型別在OpenCV_InputArray::kind()中有效?
下一篇:使用函式作為卷積核
