pyomeca / ezc3d

Easy to use C3D reader/writer for C++, Python and Matlab
https://pyomeca.github.io/Documentation/ezc3d/index.html
MIT License
142 stars 44 forks source link

ezc3d for Python failed to open a c3d file : Bad c3d formatting: unspecified iostream_category error #233

Closed NLantos closed 2 years ago

NLantos commented 2 years ago

Hello and thank you for sharing your code.

We try to open via ezc3d with the python interface a c3d file and it fails with the following error:

Traceback (most recent call last): File "/Users/lantos/PycharmProjects/Expe_Stage_Kelly/test_ezc3d.py", line 12, in c = c3d(filename) File "/opt/miniconda3/lib/python3.9/site-packages/ezc3d/init.py", line 128, in init self.c3d_swig = ezc3d.c3d(path) File "/opt/miniconda3/lib/python3.9/site-packages/ezc3d/ezc3d.py", line 1686, in init _ezc3d.c3d_swiginit(self, _ezc3d.new_c3d(*args)) RuntimeError: Bad c3d formatting: unspecified iostream_category error

The file was generated from Optitrack file and is readable by the python module c3d with no execution error.

The file is rather big 1.53 Gb, how do you want to proceed so that I transfer it to you?

My configuration is a Macbook pro 2.6 GHz Intel Core i7 quatre cœurs and Python 3.9. ezc3d was installed with miniconda.

Thanks in advance.

pariterre commented 2 years ago

Hi @NLantos ! I can see why it does not work. You can drop the file at this address! I have a look ASAP :) https://cloud.pariterre.net/index.php/s/K9y6Nn9MimF72MQ

NLantos commented 2 years ago

Hi @pariterre, Thank you for your quick response. I have downloaded the file "bloc3_orientation_ok.c3d" through the link you sent me. Best Regards

pariterre commented 2 years ago

Hi @NLantos ! Sorry for taking so long, I actually forgot about this issue..

So I had a look at your file, and it is indeed corrupted. Not in the sense that the data are not there, but in the sense that the parameters are not stored properly. There is an easy fix.. in the reading process of parameter, I do a sanity check over the pointer in the file with the predicted position of the next parameter. If I bypass the check and replace it by a break, it seems to work fine if (file.tellg() != nextParamByteInFile)

I'll see if I can safely push this fix!

pariterre commented 2 years ago

Sorry I miss clicked on resolved

NLantos commented 2 years ago

Sorry for the delay and thank you for your answer. Do you know when you will be able to integrate this change if of course it is safe to push it? I have another c3d file that produced the same error. Would you like me to send it to you for testing? Thank you in any case.

pariterre commented 2 years ago

Hi @NLantos ! I'll make a fix for another Issue next weekend, I'll have a deeper look to see if this check can actually be ignored safely. So I'd say next weekend I should push a fix :)

pariterre commented 2 years ago

I pushed the fix, it should be on conda in few hours :)

NLantos commented 1 year ago

Hello @pariterre , As mentioned in the PR #238, I was late. I'm really sorry. I have re-run the case for this PR and I still get the same error.

/opt/miniconda3/bin/python.app /Users/lantos/PycharmProjects/Expe_Stage_Kelly/run_PP_ezc3d.py

ezc3d 1.5.0 input_filename 0_Inputs/4_Optitrack/P5/bloc3_orientation_ok.c3d Reading ezc3d 2022-09-15 17:24:55.162406 Traceback (most recent call last): File "/Users/lantos/PycharmProjects/Expe_Stage_Kelly/run_PP_ezc3d.py", line 75, in c = c3d(input_filename) File "/opt/miniconda3/lib/python3.9/site-packages/ezc3d/init.py", line 128, in init self.c3d_swig = ezc3d.c3d(path, ignore_bad_formatting) File "/opt/miniconda3/lib/python3.9/site-packages/ezc3d/ezc3d.py", line 1901, in init _ezc3d.c3d_swiginit(self, _ezc3d.new_c3d(*args)) RuntimeError: Bad c3d formatting: unspecified iostream_category error

Could it be that your patch was not integrated in this version 1.5.0? Thanks in advance.