Search code examples
pythonmotion

Is there any way to extract LABEL from c3d markers?


I am looking for a way to extract LABELs from c3d file.

Using

import c3d

r = c3d.Reader(open('capture.c3d', 'rb'))
for frame_no, points, analog in r.read_frames():
     print('{0.shape} points in this frame'.format(points))

I can read c3d files but it does not give label or other details.

I can see that there are labels through MOKKA and I can extract details using MOKKA.

However, I cannot find any way to find extract labels through python coding, not MOKKA.

Is there any way to extract labels from c3d files?


Solution

  • Per the source (I can't test as I have no c3d data), this will likely work:

    import c3d
    
    r = c3d.Reader(open('capture.c3d', 'rb'))
    print(r.header)
    print(r.header.event_labels)
    

    References

    https://github.com/EmbodiedCognition/py-c3d/blob/master/c3d.py

    https://github.com/EmbodiedCognition/py-c3d/blob/master/scripts/c3d-metadata