I’ve been working on hand gesture controlled led brightness on Arduino. And i get this error in python code.
TypeError: create_int(): incompatible function arguments. The following argument types are supported:
1. (arg0: int) -> mediapipe.python._framework_bindings.packet.Packet
Invoked with: 0.8
and this is the code that i wrote
import serial
import cvzone
import math
import cv2
from cvzone.HandTrackingModule import HandDetector
serialcomm = serial.Serial('COM7', 9600)
serialcomm.timeout = 1
cap=cv2.VideoCapture(0)
detector = HandDetector(detectionCon=0.8, maxHands=1)
l=[]
while True:
success,img =cap.read()
img=cv2.resize(img,(500, 500))
img=detector.findHands(img)
l,box = detector.findPosition(img,draw=False)
if l:
#f=detector.fingersUp()
x1=l[4][0]
y1=l[4][1]
x2=l[8][0]
y2=l[8][1]
cv2.circle(img,(x1,y1),7,(0,255,255),1)
cv2.circle(img,(x2,y2),7,(0,255,255),1)
cv2.line(img,(x1,y1),(x2,y2),(0,255,0),2)
d=int(math.sqrt(math.pow(x2 - x1, 2)+math.pow(y2 - y1, 2) * 1.0))
d=int((d/110)*255)
e='n'
if 0<d<256:
cv2.putText(img,str(d),(20,30),cv2.FONT_HERSHEY_COMPLEX,.7,(255,255,255),1)
serialcomm.write(str(d).encode())
serialcomm.write(e.encode())
cv2.imshow('Image',img)
if cv2.waitKey(20) & 0xFF == 27:
break
cv2.destroyAllWindows()
and there is full error
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
Cell In[1], line 9
7 serialcomm.timeout = 1
8 cap=cv2.VideoCapture(0)
----> 9 detector = HandDetector(detectionCon=0.8, maxHands=1)
10 l=[]
11 while True:
File ~AppDataLocalProgramsPythonPython311Libsite-packagescvzoneHandTrackingModule.py:33, in HandDetector.__init__(self, mode, maxHands, detectionCon, minTrackCon)
30 self.minTrackCon = minTrackCon
32 self.mpHands = mp.solutions.hands
---> 33 self.hands = self.mpHands.Hands(self.mode, self.maxHands,
34 self.detectionCon, self.minTrackCon)
35 self.mpDraw = mp.solutions.drawing_utils
36 self.tipIds = [4, 8, 12, 16, 20]
File ~AppDataRoamingPythonPython311site-packagesmediapipepythonsolutionshands.py:114, in Hands.__init__(self, static_image_mode, max_num_hands, model_complexity, min_detection_confidence, min_tracking_confidence)
89 def __init__(self,
90 static_image_mode=False,
91 max_num_hands=2,
92 model_complexity=1,
93 min_detection_confidence=0.5,
94 min_tracking_confidence=0.5):
95 """Initializes a MediaPipe Hand object.
96
97 Args:
(...)
112 https://solutions.mediapipe.dev/hands#min_tracking_confidence.
113 """
--> 114 super().__init__(
115 binary_graph_path=_BINARYPB_FILE_PATH,
116 side_inputs={
117 'model_complexity': model_complexity,
118 'num_hands': max_num_hands,
119 'use_prev_landmarks': not static_image_mode,
120 },
121 calculator_params={
122 'palmdetectioncpu__TensorsToDetectionsCalculator.min_score_thresh':
123 min_detection_confidence,
124 'handlandmarkcpu__ThresholdingCalculator.threshold':
125 min_tracking_confidence,
126 },
127 outputs=[
128 'multi_hand_landmarks', 'multi_hand_world_landmarks',
129 'multi_handedness'
130 ])
File ~AppDataRoamingPythonPython311site-packagesmediapipepythonsolution_base.py:259, in SolutionBase.__init__(self, binary_graph_path, graph_config, calculator_params, graph_options, side_inputs, outputs, stream_type_hints)
256 for stream_name in self._output_stream_type_info.keys():
257 self._graph.observe_output_stream(stream_name, callback, True)
--> 259 self._input_side_packets = {
260 name: self._make_packet(self._side_input_type_info[name], data)
261 for name, data in (side_inputs or {}).items()
262 }
263 self._graph.start_run(self._input_side_packets)
File ~AppDataRoamingPythonPython311site-packagesmediapipepythonsolution_base.py:260, in <dictcomp>(.0)
256 for stream_name in self._output_stream_type_info.keys():
257 self._graph.observe_output_stream(stream_name, callback, True)
259 self._input_side_packets = {
--> 260 name: self._make_packet(self._side_input_type_info[name], data)
261 for name, data in (side_inputs or {}).items()
262 }
263 self._graph.start_run(self._input_side_packets)
File ~AppDataRoamingPythonPython311site-packagesmediapipepythonsolution_base.py:571, in SolutionBase._make_packet(self, packet_data_type, data)
568 return getattr(packet_creator, 'create_' + packet_data_type.value)(
569 data, image_format=image_frame.ImageFormat.SRGB)
570 else:
--> 571 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.8
New contributor
gncrrr s is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.