anion0278 / mediapipe-jetson

Google's MediaPipe (v0.8.9) and Python Wheel installer for Jetson Nano (JetPack 4.6) compiled for CUDA 10.2
Apache License 2.0
9 stars 3 forks source link

How to use facemesh on jetson nano? #3

Closed VieiraJardel closed 1 year ago

VieiraJardel commented 1 year ago

I followed your tutorial, but I want to describe how to use FaceMesh on Jetson Nano. I tried this simple program, but I received a "ModuleNotFoundError: No module named 'dataclasses'."

Jetpack 4.6.4 Python 3.6 mediapipe 0.8.9 opencv 4.8.0

import cv2
import mediapipe as mp

mp_face_mesh = mp.solutions.face_mesh
face_mesh = mp_face_mesh.FaceMesh()

# WEBcam
cam=cv2.VideoCapture(0)
cam.set(3, 640)
cam.set(4, 480)

while True:
  check,frame=cam.read()
  height, width, _ = frame.shape
  result = face_mesh.process(frame)
  #print(result)
  try:
    for facial_landmarks in result.multi_face_landmarks:
        for i in range(0, 468):
            landmrk = facial_landmarks.landmark[i]
            locx = int(landmrk.x * width)
            locy = int(landmrk.y * height)
            frame = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)
            cv2.circle(frame, (locx, locy), 1, (0, 200, 0), 0)
            cv2.imshow("Image", frame)

  except:
    cv2.imshow("Image", frame)
  key=cv2.waitKey(1)
  if key==ord('q'):
    break
anion0278 commented 1 year ago

@VieiraJardel hello, I have not tried running face landmark detection in this build (as mentioned in the readme "hand landmarks detection and selfie segmentation only"), it is possible that some more work is required to make it work. Have you tried simply running the installation of the package? Maybe it will be sufficient.

pip install dataclasses

Unfortunately, I don't have access to Jetson anymore, so I cannot investigate it myself.

VieiraJardel commented 1 year ago

Thanks! It works perfectly for me!

anion0278 commented 1 year ago

you are welcome!