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

additional details in python example #20

Open
spitzbubchen opened this issue Apr 1, 2019 · 6 comments
Open

additional details in python example #20

spitzbubchen opened this issue Apr 1, 2019 · 6 comments

Comments

@spitzbubchen
Copy link

Sorry, is there a reference doc listing the ndicapi commands for a Polaris camera? Otherwise, would it be possible to add more NDI camera commands in the ndiBasicExample.py example file? Maybe some basic commands as:

  • loading a passive ROM tool file
  • start tracking of the tool

I think these two basic commands would meet the requirements for most users.

@adamrankin
Copy link
Member

The python API isn't officially supported, but has been worked on by a couple of users. I would recommend reaching out to them to see if they might be willing to implement this.

@spitzbubchen
Copy link
Author

spitzbubchen commented Apr 11, 2019

Basically, ndiBasicExample.py runs fine. It connects to the camera and I can do tasks such as reading firmware and whatnot. It is the remaining steps that are unclear. I have done the following:

ndiCommand(device, 'PHRQ:********010A**')
port_handle = ndiGetPHRQHandle(device)                            #returns port "1"
ndiPVWRFromFile(device, port_handle, "passive_tool.rom")
ndiCommand(device, 'TSTART:')

for _ in range(5):
	ndiCommand(device, 'BX:0001')
	test = ndiGetBXTransform(device, str(port_handle).encode())
	print(test)
	time.sleep(0.3)

ndiClose(device)

Basically the result that I get from ndiGetBXTransform is "DISABLED". I have the feeling I'm missing a small step somewhere. Please let me know if you have any advice. Once I have this running I can add it to ndiBasicExample.py and submit a PR. Thanks!

@lassoan
Copy link

lassoan commented Apr 11, 2019

There is a quite complicated protocol to start tracking, for example, you need to explicitly enable each tool you want to use. See implementation in the Plus toolkit (that uses the same ndicapi library but from C++) here: https://github.com/PlusToolkit/PlusLib/blob/master/src/PlusDataCollection/NDICAPITracking/vtkPlusNDITracker.cxx

If you don't want to go into such low-level details then you can download and use PlusToolkit's PlusServer application, which connects to the tracker and broadcasts tracking data via OpenIGTLink. You can receive data in Python using https://github.com/SlicerIGT/pyIGTLink.

@spitzbubchen
Copy link
Author

spitzbubchen commented May 23, 2019

Thanks for the suggestions! Unfortunately, I was never able to get ndicapi to work with my camera so I ended up writing my own python script which seems to work well. This may be due to the fact that my polaris camera is over 10 years old (serial port only) and ndicapi may be compatible only with newer cameras...?

Another question to the experts. My python code currently works well with the BX 0001 command in that it reports the quaternion of the tool. However, I would like to get the 3D positions of the individual IR markers on the tool. I tried the BX 0008 command and it seems to work in the sense it accepts the command and sends back a properly formatted reply, but the first component is "Number of Markers" which is always 0. I believe that is not an interpretation mistake on my end because the reply block length is short, consistent with no actual marker information.

Does anyone have an idea of what I am doing wrong? Looking at the NDI API documentation it seems BX 0008 is the correct command.

Reply Option 0008 : Markers are returned in alphabetical according to how they are labelled in
the tool definition file. For example, for a tool with markers labelled A, G, M and S, the system
will return the marker positions in the order A G M S. Reply option 0008 only returns data for
markers that the system detects. To identify which marker is which, compare the reply option
0008 data to the data returned with reply option 0002. The marker order is the same for both
replies; each marker that does not have a status of 0000 (“missing”) in
reply option 0002 corresponds to a marker in reply option 0008.

@diontan524
Copy link

@spitzbubchen hey there, i am facing the same issue like you where i encounter DISABLED with ndiGetBXTransform. How do you fix this issue? Do u you mind sharing your python script ?

@adamrankin
Copy link
Member

Hi @spitzbubchen,

Sorry I'm not well versed enough in the NDI API protocol to answer about the BX0008 command. You could reach out to NDI support to see if they have any resources you might draw on.

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

4 participants