Skip to content

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

Description

@Rathi4research

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions