![](/img/trans.png)
[英]Getting errors with opencv and mediapipe for making Hand Tracking Module in Python 3.7.9
[英]The code I wrote with hand tracking module and mediapipe gives an error
当我合上手时,我正在关闭/打开视频的声音,但我在第一个代码中出现错误,这是什么原因?
我收到以下错误:
raceback (most recent call last):
File "c:\Users\yegen\Desktop\ses denemeeeeee\sesdeneme2.py", line 15, in <module>
detector = htm.handDetector(detectionCon=0.5)
File "c:\Users\yegen\Desktop\ses denemeeeeee\elizlememodulu.py", line 11, in __init__
self.hands = self.mpHands.Hands(self.mode, self.maxHands,
File "C:\Users\yegen\AppData\Local\Programs\Python\Python39\lib\site-packages\mediapipe\python\solutions\hands.py", line 114, in __init__
super().__init__(
File "C:\Users\yegen\AppData\Local\Programs\Python\Python39\lib\site-packages\mediapipe\python\solution_base.py", line 258, in __init__
self._input_side_packets = {
File "C:\Users\yegen\AppData\Local\Programs\Python\Python39\lib\site-packages\mediapipe\python\solution_base.py", line 259, in <dictcomp>
name: self._make_packet(self._side_input_type_info[name], data)
File "C:\Users\yegen\AppData\Local\Programs\Python\Python39\lib\site-packages\mediapipe\python\solution_base.py", line 513, in _make_packet return getattr(packet_creator, 'create_' + packet_data_type.value)(data)
TypeError: create_int(): incompatible function arguments. The following argument types are supported:
1. (arg0: int) -> mediapipe.python._framework_bindings.packet.Packet
Invoked with: 0.5
[ WARN:0] global D:\a\opencv-python\opencv-python\opencv\modules\videoio\src\cap_msmf.cpp (438) `anonymous-namespace'::SourceReaderCB::~SourceReaderCB terminating async callback
这是我的代码:
import cv2
import time
import numpy as np
import handtrackingmodule as htm
import math
###############################
wCam, hCam = 640, 480
###############################
cap = cv2.VideoCapture(0)
cap.set(3, wCam)
cap.set(4, hCam)
detector = htm.handDetector(detectionCon=0.5)
while True:
success, img = cap.read()
img = detector.findHands(img)
cv2.imshow("İmg", img)
cv2.waitKey(1)
尝试这个
import cv2
import time
import numpy as np
import handtrackingmodule as htm
import math
###############################
wCam, hCam = 640, 480
###############################
cap = cv2.VideoCapture(0,cv2.CAP_DSHOW)
cap.set(3, wCam)
cap.set(4, hCam)
detector = htm.handDetector(detectionCon=0.5)
while True:
success, img = cap.read()
img = detector.findHands(img)
cv2.imshow("İmg", img)
cv2.waitKey(1)
cv2.destroyAllWindows()
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.