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 output csv file from input mp4 using openfaceoffline? #1084

Open
limchengwei opened this issue Apr 30, 2024 · 6 comments
Open

How to output csv file from input mp4 using openfaceoffline? #1084

limchengwei opened this issue Apr 30, 2024 · 6 comments

Comments

@limchengwei
Copy link

Hi,
I would like to input mp4 video(s) and wish to get the CSV outputs?
I have tried the code below, but I did not get CSV file in output_directory path?
Help please, thank you.

import subprocess
import os

def process_video(video_path):
    # Check if the video file exists
    if not os.path.isfile(video_path):
        print(f"Error: Video file '{video_path}' not found.")
        return

    # Run OpenFaceOffline.exe with the video file
    result = subprocess.run(["OpenFaceOffline.exe", "FaceLandmarkVid.exe", "-f", video_path, "-out_dir", "output_directory"], capture_output=True)

    # Print the output
    print(result.stdout.decode())
    print(result.stderr.decode())

if __name__ == "__main__":
    # Specify the path to the MP4 video file
    video_path = "C:/Users/XXX/OneDrive/Desktop/Gaze.mp4"

    # Process the video file with OpenFaceOffline
    process_video(video_path)
@beibidesr
Copy link

coffused about this problem

@kendrew06
Copy link

kendrew06 commented May 29, 2024 via email

@brmarkus
Copy link

@limchengwei when you run one of the samples, do you get the expected output?
And then you want to integrate (parts of) OpenFace into your application?

@limchengwei
Copy link
Author

Hi, I would like to use python script to input MP4 videos to get the CSV outputs. Kindly help me.

@brmarkus
Copy link

Have you found a working base already? When you found one of the samples to provide what you want, then this sample is a good base to start extracting what you are looking for.
Using one of the samples first is a minimal consistancy check for whether your setup is correct and complete. Using one of the samples first also shows you how to use it, which command line parameters are required (e.g. "https://github.com/TadasBaltrusaitis/OpenFace/wiki/Command-line-arguments").

@brmarkus
Copy link

@limchengwei have you found a working sample?

From your initial post you try to call:

result = subprocess.run(["OpenFaceOffline.exe", "FaceLandmarkVid.exe", "-f", video_path, "-out_dir", "output_directory"], capture_output=True)

But do you really want to call two executables, OpenFaceOffline.exe and FaceLandmarkVid.exe in the same command line?

Under Linux (in a Docker container of OpenFace) this is working for me:

result = subprocess.run(["/home/openface-build/build/bin/FaceLandmarkVid", "-f", video_path, "-out_dir", "/home/openface-build/build/bin/outdir/"], capture_output=True)

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

4 participants