Using the OptiTrack camera over the network
In order to use the OptiTrack camera you need to connect it to a PC running Windows XP. It is recommended to run Windows in a virtual machine on the Mac that will use the data. This minimizes the network delay and creates a more stable connection.
On the windows machine you need to install the DataStreamRelayServer. A working image is on oliver in: Public->Software->Motion Tracking Disk Images. You might need to ask your supervisor to get it.
- Install Visual Studio
- Install Bonjour
- Install the OptiTrack SDK (found on oliver: Public->Software->Device Dependent Software->OptiTrack)
- Get the current version of the DataStreamRelayServer from git:
cd Emitter
git branch --track OptiTrack origin/OptiTrack
git checkout OptiTrack
To start the stream simply start the RelayServer.
On the Mac Side you need the ViconDataStreamFramework. Include it to your project (Important: the project is not allowed to use ARC since it has to run on 32bit which doesn't support ARC)
- Drag the framework into the 'Linked Frameworks&Binaries Section'
- Set the Target to 32bit (Target - Build Settings)
- Add a 'Copy Files' Build Phase, set the destination to 'Frameworks' and add the framework
- Change the implementation of the window property (add the IBOutlet as an ivar and change 'synthesize window=_window' to 'synthesize window')
Now you can access the stream using the following code in your project. These methods were created for the Vicon system but they also work for OptiTrack.
// Include Framework #import <ViconDataStreamFramework/ViconDataStreamFramework.h> // Setup: vicon = [[VDSVicon alloc] initWithBonjour]; vicon.delegate = self; // Delegate method: -(void)viconIsReady:(VDSVicon*)theVicon; { [theVicon startStream:kVDSUnlabeledMarkerStreamType withTarget:self andSelector:@selector(viconDidReceiveFrame:markers:)]; } // Data processing method: -(void)viconDidReceiveFrame:(NSNumber *)theFrame markers:(NSDictionary *)theMarkers; { NSLog(@"%@: %@", theFrame, theMarkers); // theMarkers is a dictionary of markers. The keys are a unique name like, “<unlabeled> 1”. The values are arrays of x, y, z. } // Stop: [vicon stopStream:kVDSUnlabeledMarkerStreamType];
When the connection is established you can adjust the exposure, threshold and intensity of the camera on the windows machine.
- To control the exposure: hold 'e' and use the up/down arrow keys
- To control the intensity: hold 'i' and use the up/down arrow keys
- To control the threshold: hold 't' and use the up/down arrow keys