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

Mocap marker check #649

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
// Point to a python environment with ezc3d installed
// Can be created with
// >>> conda create -n c3d ezc3d numpy debugpy
// This will not be necessary in 7.4 where ezc3d is included.
#path ANYBODY_PATH_PYTHONHOME "c:/Users/mel/mambaforge/envs/c3d/"

#include "../libdef.any"

// Enter and edit Trial Specific Data in this file:
Expand All @@ -10,4 +16,6 @@
#path MOCAP_LAB_SPECIFIC_DATA "Setup/LabSpecificData.any"

// Include the AnyMoCap Framwork
#include "<ANYMOCAP_MODEL>"
#include "<ANYMOCAP_MODEL>"


41 changes: 41 additions & 0 deletions Tools/AnyMocap/CheckAnyMocapConfiguration.any
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,48 @@ Macros =
);
#endif

#if MOCAP_INPUT_DATA_TYPE == "C3D"
#ifndef MOCAP_DISABLE_C3D_MARKER_CHECK
#ifpathexists "c3d_marker_check.py"

AnyMessage C3D_Marker_Check = {

AnyFunEx CheckC3D = {
AnyStringVar Return = "";
AnyFunExMonoPy check_c3d_file = {
ModuleFile = "c3d_marker_check.py";
ArgList = {
AnyString c3dpath = "";
};
};
};

AnyString C3D_warning_str = CheckC3D(FilePathCompleteOf(Main.ModelSetup.C3DFileData.FileName));
TriggerConst = bool(C3D_warning_str);
Type=MSG_Warning;
Message = strformat("\n------------------------------------------------------------------------------------------------------------------------------\n")+
C3D_warning_str +
strformat("\n\n C3D marker checks can be disabled with #define MOCAP_DISABLE_C3D_MARKER_CHECK \n")+
strformat("------------------------------------------------------------------------------------------------------------------------------\n") ;
};
#endif
#endif
#endif

};















};
44 changes: 44 additions & 0 deletions Tools/AnyMocap/c3d_marker_check.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import os
from pathlib import Path
from textwrap import fill
from typing import NamedTuple

import ezc3d

import functools


class Context(NamedTuple):
py_file: str
fun_name: str
anyfun_full_name: str
anyfunex_file: str
anyfunex_line: str
call_location_file:str



def check_c3d_file(context: Context, c3d_file: str):
""" Check if fpath is a writeable file """

report_str = (
"This is an example of analyzing a c3d file.\n" +
"If nothing is returned from python the warning will not be triggered.\n"
)

if not os.path.isfile(c3d_file):
return f"{c3d_file} is not a file\n\n"

c3d = ezc3d.c3d(c3d_file)
points_used = c3d['parameters']['POINT']['USED']['value'][0]; # Print the number of points used
point_data = c3d['data']['points']

report_str += f"Number of Points in c3d file: {points_used}\n"

return report_str




if __name__ == "__main__":
check_c3d_file("test.c3d")