IMU Data Libraries

The Z1 and the X both have video formats that have high resolution low fps video with a CAMM IMU data track. I’m looking for libraries that can provide easier access to the IMU data from RICOH THETA video files.

thanks to @Jordi_Vallverdu post, our summer intern was able to produce several datasets from the RICOH THETA Z1 3.6K (2 file) video format.

I started looking for next steps for the intern. The Fusion project comes with two Python sample scripts.

Although there is a pip package for imufusion, it didn’t work with the advanced example.

I was able to build the Python library imufusion with python setup.py install and run the sample program.

The data is a csv file. it looks like I can get the same data from the THETA video files.

However, I can’t find the Magnetometer data in the THETA video files.

The next step could be to parse the THETA CAMM data and put it into the CSV format, then run the imufusion library on it.

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

R0013405_1_plot

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

2 Likes

This is fantastic. Thank you for your generosity. I showed this to the intern and she was excited. She would have either been stuck or would have taken a long time.

I ran parse_camm on her existing data and then used the fusion library as a test.

I think she’s in a great position to start making assumptions about the sensor behavior and running tests to verify her assumptions. Your work makes it so much easier!

plot below is from the Z1 data. nice.