I was making the sound off/on video when I closed my hand, but I got an error in the first code, what is the reason?
I get the following 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
And this is my code:
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)
Try this
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()
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.