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

Import 3d positional data for conversion to other file formats #129

Closed
steakerlife opened this issue Jan 18, 2022 · 2 comments
Closed

Import 3d positional data for conversion to other file formats #129

steakerlife opened this issue Jan 18, 2022 · 2 comments

Comments

@steakerlife
Copy link

steakerlife commented Jan 18, 2022

Hello -

I have acquired, through a markerless motion capture technology, joint positions (x,y,z only) for a series of joints, exported in a non-traditional mocap file format (usually I just throw it into a csv). I am now looking to animate them, and I was looking to convert those joint channels to a traditional motion capture file format without adding rotations. Is this possible? How would I accomplish this using this tool?

I also see that Pyosim could be used in conjunction with this. Is it possible to run an inverse kinematic solve as a means of joint correction on my data using these packages?

Thanks.

@pariterre
Copy link
Member

Hi there!

I am one of the programmer of pyomeca, but not so much of pyomeca itself, so please pardon myself if I am give edgy advices!

So depending on what you are trying to actually achieve, it seems that an actual kinematics model could be interesting (using for instance bioviz or opensim), instead of directly plotting the joint in the 3d space.
If plotting in 3d space is actually what you want to do, the easiest way is to declare them as Markers in pyomeca.
To declare markers in pyomeca, the most direct way is to use the from methods (such as: pyomeca.Markers.from_csv). But they can also be directly declared from a numpy array as such:

import numpy as np
import pyomeca

# generate some data
n_joints = 15
n_frames = 100
data = np.random.rand(3, n_joints, n_frames) * 1000  # Generate XYZ for all the joints center for each frame

# Convert them to pyomeca
d = pyomeca.Markers(data)

Then you can use bioviz to print them in the 3d space (please note, this is not the intended way to use bioviz, as it is supposed to be used from a bioMod file, but it can be bypass like that:

from bioviz.biorbd_vtk import VtkModel, VtkWindow, Mesh

# Create a windows with a nice gray background
vtk_window = VtkWindow(background_color=(0.5, 0.5, 0.5))

# Add marker holders to the window
vtk_markers = VtkModel(vtk_window, markers_color=(1, 0, 0), markers_size=10.0, markers_opacity=1, rt_length=100)

# Animate in loop
i = 0
while vtk_window.is_active:
    vtk_markers.update_markers(d.isel(time=[i]))
    vtk_window.update_frame()
    i += 1
    if i >= n_frames:
        i = 0

For the question in regards pyosym, I cannot help much as I never used it myself. But as far as I am concerned, you can launch every filter of Opensim from that interface

Hope this helps!

@steakerlife
Copy link
Author

I will give this a shot! Thank you!!

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

2 participants