Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to create .pkl file for my own video #63

Open
Rathi4research opened this issue Oct 29, 2023 · 0 comments
Open

How to create .pkl file for my own video #63

Rathi4research opened this issue Oct 29, 2023 · 0 comments

Comments

@Rathi4research
Copy link

Rathi4research commented Oct 29, 2023

Hi,
I'm trying to create .pkl file(landmarks file) for my own video but I'm facing an error. Please help me with the procedure to create .pkl file in the same way as how it is created for the LRW dataset. PFB the details on how i tried to create.

First, I tried to create using the below code. And when it tried to use it for my own video, it is throwing the error "TypeError: unsupported operand type(s) for /: 'dict' and 'int'"

Code used to create .pkl(Using Google colab)

import cv2
import face_recognition
import pickle

cap = cv2.VideoCapture("myvideo.mp4")
landmarks_data = [] 
while cap.isOpened():
    ret, frame = cap.read()
    if not ret:
        break

    # Convert BGR image to RGB (required for face_recognition)
    rgb_frame = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)

    # Find all face landmarks in the frame
    face_landmarks_list = face_recognition.face_landmarks(rgb_frame)

    # Append the detected landmarks to the list
    landmarks_data.append(face_landmarks_list)

cap.release()

# Serialize and save the landmarks data to a .pkl file
with open("myvideo.pkl", "wb") as file:
    pickle.dump(landmarks_data, file)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant