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

Can I use .trc files? #17

Open
IvanLiuTW opened this issue Apr 8, 2022 · 1 comment
Open

Can I use .trc files? #17

IvanLiuTW opened this issue Apr 8, 2022 · 1 comment

Comments

@IvanLiuTW
Copy link

IvanLiuTW commented Apr 8, 2022

Hi @omimo,

From your introduction, this library is quite useful to me, because I'd like to animate my data in 3D for analysis. However, I only have .trc mocap files.

Actually , I modified part of nb_play_mocap code to fit my trc file, but at the end the result showed 404: Not Found, as the following picture shows:

image

Is there any way to fix this?

the revised function:


def nb_play_mocap_(mocap, mf, meta=None, frame_time=1/30, scale=1, camera_z=500, base_url=None):
    data_template = 'var dataBuffer = $$DATA$$;'
    data_template += 'var metadata = $$META$$;'
    data_template += 'start(dataBuffer, metadata, $$CZ$$, $$SCALE$$, $$FRAMETIME$$);'
    dir_path = os.path.dirname(os.path.realpath('/Users/ivan/Desktop'))

    if base_url is None:
        base_url = os.path.join(dir_path, 'mocapplayer/playBuffer.html')
    
    # print(dir_path)

    if mf == 'bvh':
        pass
    elif mf == 'pos':
        cols = list(mocap.columns.values)
        for c in cols:
            if 'rotation' in c:
                cols.remove(c)
        
        data_csv = mocap.to_csv(index=False, columns=cols)

        if meta is not None:
            lines = [','.join(item) for item in meta.astype('str')]
            meta_csv = '[' + ','.join('[%s]'%l for l in lines) +']'            
        else:
            meta_csv = '[]'
        
        data_assigned = data_template.replace('$$DATA$$', data_csv)
        data_assigned = data_assigned.replace('$$META$$', meta_csv)
        data_assigned = data_assigned.replace('$$CZ$$', str(camera_z))
        data_assigned = data_assigned.replace('$$SCALE$$', str(scale))
        data_assigned = data_assigned.replace('$$FRAMETIME$$', str(frame_time))

    else:
        return
    
    

    with open(os.path.join(dir_path, 'mocapplayer/data.js'), 'w') as oFile:
        oFile.write(data_assigned)

    url = '%s?&cz=200&order=xzyi&frame_time=%f&scale=%f'%(base_url, frame_time, scale)
    iframe = '<iframe frameborder="0" src=' + url + ' width="100%" height=500></iframe>'
    link = '<a href=%s target="_blank">New Window</a>'%url
    return IPython.display.HTML(iframe+link)

Thanks for your help!

@IvanLiuTW IvanLiuTW changed the title Can I use trc files? Can I use .trc files? Apr 8, 2022
@IvanLiuTW
Copy link
Author

I've solved the problem.😅 It works now.

But.. I'm wondering if I can change some parameters in javascript files?

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

1 participant