I wanted to experiment a bit with the library, so I added CSV output functionality to the parse_camm
code:
in order to generate the csv file for the video you just need to add the argument --csv
python parse_camm.py --videoPath '/path/2/R0013405_1.MP4' --csv
def write_camm_to_csv(camm_data, csv_path):
import csv
headers = ["Time (s)", "Gyroscope X (deg/s)", "Gyroscope Y (deg/s)", "Gyroscope Z (deg/s)",
"Accelerometer X (g)", "Accelerometer Y (g)", "Accelerometer Z (g)"]
with open(csv_path, "w", newline='') as csvfile:
csvwriter = csv.writer(csvfile)
csvwriter.writerow(headers)
for sample in camm_data:
time = sample["sampletime"]
# Convert gyroscope readings from radians/second to degrees/second
GyroscopeX, GyroscopeY, GyroscopeZ = [angle * (180/math.pi) for angle in sample["angularvelocity"]]
# Convert accelerometer readings from meters/second^2 to g
AccelerometerX, AccelerometerY, AccelerometerZ = [accel / 9.81 for accel in sample["acceleration"]]
csvwriter.writerow([time, GyroscopeX, GyroscopeY, GyroscopeZ, AccelerometerX, AccelerometerY, AccelerometerZ])
This unit conversion was necessary because the Fusion library requires the values in a different format.
With the parsed CAMM data now available in CSV format, you can directly utilize the Fusion library without having to build it from source. Simply install it using the following command:
pip install imufusion==1.1.2
The chart you’re seeing is generated using data collected from a Ricoh Theta camera. You can replicate this chart by employing the imufusion_euler_angles.py script.
python imufusion_euler_angles.py -i '/path/2/R0013405_1.csv' -s
Additionally, I stumbled upon another repository by the same author, which demonstrates how to achieve tracking with an IMU. To incorporate this functionality, I also integrated it into the imufusion_tracking.py script.
python imufusion_tracking.py -i '/path/2/R0013405_1.csv'
You can find the relevant details here: GitHub - xioTechnologies/Gait-Tracking
Kind regards