首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何解决函数‘imshow’中的“cv2.错误: OpenCV(4.5.4) :-1:错误:(-5:糟糕的参数)”

如何解决函数‘imshow’中的“cv2.错误: OpenCV(4.5.4) :-1:错误:(-5:糟糕的参数)”
EN

Stack Overflow用户
提问于 2021-12-12 10:51:45
回答 2查看 20.7K关注 0票数 -3

我正在学习如何使用opencv,但我遇到了这个问题。

代码语言:javascript
复制
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)

导致此错误:

代码语言:javascript
复制
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'

我正在使用Python3.8 64位和所有包的最新版本。谢谢。

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2021-12-12 11:17:22

detector.findHands(img)的输出是一个元组。您应该将它的第二个元素作为cv2.imshow()的输入

代码语言:javascript
复制
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)
票数 2
EN

Stack Overflow用户

发布于 2022-01-12 16:05:26

mediapipe增加了一个新的变量,它破坏了手跟踪和姿态估计、呼叫复杂度和model_complexity。见下文。

现在我正在做人脸检测,模块工作得很好,但是当我把它拉到另一个不同的地方时,它就失败了。

用于手动跟踪模块

代码语言:javascript
复制
def __init__(self, mode=False, maxHands=2, complexity = 1, detectionCon=0.5, trackCon=0.5):
    self.mode = mode
    self.maxHands = maxHands
    self.complexity = complexity
    self.detectionCon = detectionCon
    self.trackCon = trackCon
    self.mpHands = mp.solutions.hands
    self.hands = self.mpHands.Hands(self.mode, self.maxHands, self.complexity,
                                    self.detectionCon, self.trackCon, )

关于员额esitimation模块:

代码语言:javascript
复制
def __init__(self, mode = False, model_complexity = 1, smooth = True,
                    enable_segmentation = False, smooth_segmentation = True, min_detection_confidence = 0.5,
                    min_tracking_confidence = 0.5):
    self.mode = mode
    self.model_complexity = model_complexity
    self.smooth = smooth
    self.enable_segmentation = enable_segmentation
    self.smooth_segmentation = smooth_segmentation
    self.detectionCon = min_detection_confidence
    self.trackCon = min_tracking_confidence
    self.mpDraw = mp.solutions.drawing_utils
    self.mpPose = mp.solutions.pose
    self.pose = self.mpPose.Pose(self.mode, self.model_complexity, self.smooth, self.enable_segmentation,
                                 self.detectionCon, self.trackCon)
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/70322873

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档