mediapipe
mediapipe copied to clipboard
Facemesh.process() returns None after second image is sent to process.
Please make sure that this is a solution issue. Hi there everyone I hope everyone is doing well. I was trying some solutions with mediapipe and noticed I found an interesting error. I think my implementation should be still viable but it is indeed a weird bug I would like to adress. First of all, let me specify my system. OS: Windows 10 Coding Language: Python Mediapipe version: 0.8.10 Solution: Mediapipe Facemesh
The standalone code to get the result.
import cv2
import mediapipe as mp
mp_face_mesh = mp.solutions.face_mesh
face_mesh = mp_face_mesh.FaceMesh(min_detection_confidence=0.5)
image1=(cv2.imread("image_path_1"))
image2=(cv2.imread(r"image_path_2"))
results = face_mesh.process(image1)
results_2=face_mesh.process(image2)
print(results.multi_face_landmarks,results_2.multi_face_landmarks)
Here what I tried was to read 2 images and then multiprocess them one after another. However, the results_2.multi_face_landmarks just returns none. In my code I was able to solve this issue by running face_mesh.process again if the result is null. But I don't think this is viable at all. I don't know what might be causing this issue. I tried to put a time.sleep() before results_2 process but the second landmark always returns None. What might be the problem here?
I also want to note the image paths are definitely correct so there is no fault in there cause I can read images independently from the given path
Hi @Kutayykilic , Could you share any reference video w.r.t above issue.
Hi there,
This is not used on a video, instead it is used on the two single frame images should it not work that way?
Hi @Kutayykilic , Two single frame images can not work for facemesh , please use single image.
Okay let me improve on that with a little bit of work I have tried.
Initializing the face mesh module again after each image is processed seems to solve the issue if anyone is interested on making it work this way.
Otherwise I don't really get why it's not implemented to work with 2 single frame images, what's the reason behind this?
Hi @Kutayykilic , We consider it as a great feature and share with internal team.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you.
Closing as stale. Please reopen if you'd like to work on this further.
Closing as stale. Please reopen if you'd like to work on this further.
@Kutayykilic The issue could not be reproduced at our end. Here is what I have done as reproduction steps.
- Copied the given gist to a jupyter notebook.
- Clicked two images from webcam of with variable camera distance and angles.
- Added their paths in the gist and ran the code.
The landmarks were correctly printed. So I suppose the problem could be with the images. Can you provide sample images so that we can investigate further?
Hi,
Thanks for responding. I could not resolve the same issue with the latest version of mediapipe sadly. I have deleted the previous images I have been working and added two new pictures. I have also tried adding those pictures in a loop of a 10000 and run them many more times. But as you have said I can't replicate the issue here.
@Kutayykilic Sorry for the late reply from our end in the first place. I suspect the problem must have been in the image size, since the FaceMesh model requires an image size of 192x192 pixels focusing the face. You can refer the model card here for more details on input, output, limitations and environmental conditions. However, since the issue is not replicable at your end as well, can you please close the issue? You are welcome to open another issue if you face any problem in future.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you.
Will do. Thank you for your help!