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

UnicodeDecodeError when 3 rigid bodies are in view of the Polaris Vicra #46

Open
Larbino1 opened this issue May 23, 2024 · 5 comments
Open

Comments

@Larbino1
Copy link

Stracktrace:

Traceback (most recent call last):
  File "/home/daniellarby/camtracking/vicra/VicraJuliaClient.py", line 142, in <module>
    vc.run()
  File "/home/daniellarby/camtracking/vicra/VicraJuliaClient.py", line 49, in run
    port_numbers, timestamps, framenumbers, transforms, quality = self.tracker.get_frame()
  File "/home/daniellarby/.local/lib/python3.8/site-packages/sksurgerynditracker/nditracker.py", line 461, in get_frame
    ndicapy.ndiCommand(self._device, self._capture_string)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0x8b in position 2: invalid start byte

This reliably happens when I move a third rigid body into the view of the Polaris vicra. Otherwise, tracking works perfectly.

I would really appreciate a bit of guidance as to where to look to fix this problem. Am I right that the error is in this repository, ndicapi? Where does ndicapy reside? Is the Error thrown from python or C++ code?

@Larbino1
Copy link
Author

@thompson318

@thompson318
Copy link
Contributor

This may be a problem with trying to use BX transforms. Have a look at _set_use_bx_transforms in nditracker.py. You can add your devices firmware string to the list at line 169. If that fixes your problem then you should probably transfer this issue to scikit-surgeryndirtracker and create a pull request there.

@thompson318
Copy link
Contributor

We've seen very similar with other trackers: see SciKit-Surgery/scikit-surgerynditracker#17

@lassoan
Copy link

lassoan commented May 28, 2024

A binary buffer is attempted to be interpreted as utf8 encoded string, but of course not all binary stream is valid utf8. To fix it, replace PyString_AsString in ndicapy.ndiCommand to return a bytes object instead (or maybe a latin1-encoded string would work, too).

@Larbino1
Copy link
Author

Larbino1 commented Jun 4, 2024

A binary buffer is attempted to be interpreted as utf8 encoded string, but of course not all binary stream is valid utf8. To fix it, replace PyString_AsString in ndicapy.ndiCommand to return a bytes object instead (or maybe a latin1-encoded string would work, too).

Thanks for the help - I suspected it would be something like this but couldn't find where it was happening. With your comment I've found where this is in the code, built the code and started trying to make a fix!

I'm looking at using PyBytes_FromString instead of PyUnicode_FromUTF8 where a command is received, but this change results in other errors, which I'm now hunting down.

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

3 participants