Skip to content

additional details in python example #20

Open

Description

@spitzbubchen

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.

Activity

  1. adamrankin commented on Apr 1, 2019

    @adamrankin
    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.

  2. spitzbubchen commented on Apr 11, 2019

    @spitzbubchen
    Author

    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!

  3. lassoan commented on Apr 11, 2019

    @lassoan

    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.

  4. spitzbubchen commented on May 23, 2019

    @spitzbubchen
    Author

    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.

  5. diontan524 commented on Oct 23, 2020

    @diontan524

    @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 ?

  6. adamrankin commented on Oct 28, 2020

    @adamrankin
    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions