create_csv: Create CSV file(s) from OpenPose JSON output

View source: R/create_csv.R

create_csvR Documentation

Create CSV file(s) from OpenPose JSON output

Description

Creates one or severeal CSV files (*.csv) from the JSON output files (*.json) generated by OpenPose.

By default, OpenPose generates one JSON file per tracked frame in a video file. These files contain positional (x,y) information as well as a confidence score (c) for every point tracked by the model at this particular frame.

Because CSV files and tabular data are sometimes more convenient to work with, this function reads the JSON files for every frame and combines them into a single CSV file for every model. At a minimum this will be data from the BODY25 model (filename_body25.csv), but may be supplemented by data from a face and hand model.

Usage

create_csv(input_path, filename, output_path, model)

Arguments

input_path

Path to folder containting JSON (*.json) files generated by OpenPose.

filename

Name of the tracked video file. By default, this should be the prefix of all JSON files generated by OpenPose (e.g., filename_framenumber_keypoints.json).

output_path

Optional. Path to folder for output CSV files (*.csv) files. Defaults to input_path.

model

Optional. By default, will generate CSV files (*.csv) for all models for which data is available in the JSON files. Supplying either body25, hands, or face will limit generation of output CSV files to the specified model.

Examples

# Generate CSV for "myvideo" with JSON files located in "~/myvideo"
create_csv("~/myvideo", "myvideo")

# Generate CSV for "myvideo" with JSON files located in "~/myvideo"
# Write output to subfolder /output and only use data from hands model
create_csv("~/myvideo", "myvideo", "~/myvideo/output", model = "hands")

trettenbrein/OpenPoseR documentation built on April 22, 2022, 4:03 a.m.