with using python, openCV and mediapipe I wrote the code below:
import mediapipe as mp
import cv2
# Initial MediaPipe hand detection
mp_hand = mp.solutions.hands
mp_drawing = mp.solutions.drawing_utils
hands = mp_hand.Hands(min_detection_confidence=0.8, min_tracking_confidence=0.5)
# Initial webcam read
cap = cv2.VideoCapture(0)
assert cap.isOpened(), "Camera not found"
while cap.isOpened():
# Read img from webcam
success, img = cap.read()
if not success:
break
# Convert the image color from BGR to RGB
img_rgb = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
# Detect hand by MediaPipe
results = hands.process(img_rgb)
# Draw hand landmarks
if results.multi_hand_landmarks:
for hand_landmarks in results.multi_hand_landmarks:
mp_drawing.draw_landmarks(img, hand_landmarks, mp_hand.HAND_CONNECTIONS)
# Display results
cv2.imshow('webcam', img)
if cv2.waitKey(1) & 0xff == ord('q'):
break
# Release resources
cap.release()
cv2.destroyAllWindows()
output:
enter image description here
I want to prevent this little vibration during detection. how can I do that?
New contributor
Erfan Riahi is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.