Simple hand tracking using opencv and mediapipe.
I start from the code of opencvhandracking library that actually do not work on my python 3.6 and 3.8. I copy their classes and I use it into a very simple script.
You need to have python and pip and install the following libraries
pip install mediapipe opencv-python
The code can be downloaded here
Now connect a webcam and exec it with:
As in the figure you will see the output of your webcam and the hand tracking draw. Press ‘q’ to quit.
This code is very simple and use only 51 lines of codes, but when the library will work well with pip it can be replaced with 10 as follow
from opencvtracking import HandGesturecap = cv2.VideoCapture(0)
handtrckingdetector = HandGesture()while True:
success, img = cap.read()
img = handtrckingdetector.drawHand(img)
# landmarkList = handtrckingdetector.handPosition(img)
if cv2.waitKey(1) & 0xFF == ord('q'):
This can be very useful for to much applications, for example to create interactive museum objects.