Motive API: Function Reference
Please use the table of contents to the right to navigate to specific functions or specific group of functions.
Important Note:
Some of the functions may be missing in the documentation. Please refer to the NPTrackingTools header file for any information that are not documented here.
Project Management
TT_Initialize
Initializes the API and prepares all connected devices for capturing. Please note that TT_Initialize also loads the default profile from the ProgramData directory: C:\ProgramData\OptiTrack\MotiveProfile.motive
. When there is a need to load the profile from a separate directory, use TT_LoadProfile function.
NPRESULT TT_Initialize();
Description
This function initializes the API library and prepares all connected devices for capturing.
When using the API, this function needs to be called at the beginning of a program before using the cameras.
Returns an NPRESULT value. When the function successfully updates the data, it returns 0 (or NPRESULT_SUCCESS).
Function Input
None
Function Output
NPRESULT
C++ Example
// Initializing all connected cameras
TT_Initialize();
TT_Shutdown
Shuts down all of the connected devices.
Description
This function closes down all connected devices and the camera library. To ensure that all devices properly shutdown, call this function before terminating an application.
When the function successfully closes down the devices, it returns 0 (or NPRESULT_SUCCESS).
When calling this function, currently configured camera calibration will be saved under the default System Calibration.cal file.
Function Input
None
Function Output
NPRESULT
C++ Example
// Close down all of the connected cameras
TT_Shutdown();
return 0;
TT_Update
Processes incoming frame data from the cameras.
Description
This function updates frame information with the most recent data from the cameras and 3D processing engines.
Another use of this function is to pick up newly connected cameras. Call this function at the beginning of a program in order to make sure that all of the new cameras are properly recognized.
TT_Update vs. TT_UpdateSingleFrame: In the case when a client application stalls momentarily, the program may get behind on updating the frames. In this situation, the TT_Update() function will disregard accumulated frames and service only the most recent frame data, but this also means that the client application will be missing the previous frames. On the other hand, the TT_UpdateSingleFrame function ensures that always a consecutive frame is updated each time the function is called. In general, a user should always use TT_Update(). Only in the case where a user wants to ensure their client application has access to every frame of tracking data and they are having problems calling TT_Update() in a timely fashion, should they consider using TT_UpdateSingleFrame(). If it is important for your program to obtain and process every single frame, use the TT_UpdateSingleFrame() function for updating the data.
Returns an NPRESULT integer value, depending on whether the operation was successful or not. Returns NPRESULT_SUCCESS when it successfully updates the frame data.
Function Input
None
Function Output
NPRESULT
C++ Example
//== Update to pick up recently-arrived cameras ==/
TT_Update();
//== Frame Processing: Polling the frame data ==//
while( programRunning ){
if( TT_Update() == NPRESULT_SUCCESS ){
frameNumber++;
//== Process Frame Data ==//
}
}
TT_UpdateSingleFrame
Updates a single frame of camera data.
NPRESULT TT_UpdateSingleFrame();
Description
Every time this function is called, it updates frame information with the next frame of camera data.
Using this function ensures that every frame of data is processed.
TT_Update() vs. TT_UpdateSingleFrame(): In the case when a client application stalls momentarily, the program may get behind on updating the frames. In this situation, the TT_Update() function will disregard accumulated frames and service only the most recent frame data, but this also means that the client application will be missing the previous frames. On the other hand, the TT_UpdateSingleFrame function ensures that always a consecutive frame is updated each time the function is called. In general, a user should always use TT_Update(). Only in the case where a user wants to ensure their client application has access to every frame of tracking data and they are having problems calling TT_Update() in a timely fashion, should they consider using TT_UpdateSingleFrame(). If it is important for your program to obtain and process every single frame, use the TT_UpdateSingleFrame() function for updating the data.
Returns an NPRESULT value. When the function successfully updates the data, it returns 0 (or NPRESULT_SUCCESS).
Function Input
None
Function Output
NPRESULT
C++ Example
//== Update to pick up recently-arrived cameras ==/
TT_Update();
//== Frame Processing: Polling the frame data ==//
while( programRunning ){
if( TT_UpdateSingleFrame() == NPRESULT_SUCCESS ){
frameNumber++;
//== Process Frame Data ==//
}
}
TT_LoadCalibration, TT_LoadCalibrationW
Loads a Motive camera calibration file.
NPRESULT TT_LoadCalibration(const char *filename);
NPRESULT TT_LoadCalibrationW(const wchar_t *filename);
Description
These functions load a camera calibration file (CAL).
Camera calibration files need to be exported from Motive.
Returns a NPRESULT integer value. If the file was successfully loaded, it returns NPRESULT_SUCCESS.
Function Input
Filename (const char, const wchar_t)
Function Output
NPRESULT
C++ Example
const char *calFileName= "project.ttp";
NPRESULT fileload = TT_LoadCalibration(calFileName);
if (fileload == NPRESULT_SUCCESS)
{
printf("%s successfully loaded.\n", calFileName);
}
else
{
printf("Error: %s\n", TT_GetResultString(fileload));
}
TT_LoadRigidBodies, TT_LoadRigidBodiesW
Imports TRA files and loads Rigid Body assets from it.
NPRESULT TT_LoadRigidBodies(const char *filename);
NPRESULT TT_LoadRigidBodiesW(const wchar_t *filename);
Description
This function imports and loads Rigid Body assets from a saved TRA file.
TRA files contain exported Rigid Body asset definitions from Motive.
All existing assets in the project will be replaced with the Rigid Body assets from the TRA file when this function is called. If you want to keep existing assets and only wish to add new Rigid Bodies, use TT_AddRigidBodies function.
Returns an NPRESULT integer value. It returns NPRESULT_SUCCESS when the file is successfully loaded.
Function Input
Filename (const char, const wchat_t)
Function Output
NPRESULT
C++ Example
//Loading Rigid Body Assets from a TRA file.
const char *traFile = "rigidbody.tra";
TT_LoadRigidBodies(traFile);
TT_SaveRigidBodies, TT_SaveRigidBodiesW
Saves all of the Rigid Body asset definitions into a TRA file.
NPRESULT TT_SaveRigidBodies(const char *filename);
NPRESULT TT_SaveRigidBodiesW(const wchar_t *filename);
Description
This function saves all of the Rigid Body assets from the project into a TRA file.
Attach *.tra extension at the end of the filename.
Returns an NPRESULT integer value. It returns 0 or NPRESULT_SUCCESS when successfully saving the file.
Function Input
Filename (const char, const wchar_t)
Function Output
NPRESULT
C++ Example
//== Save Rigid Bodies ==/
TT_SaveRigidBodies("traFileName.tra");
TT_AddRigidBodies, TT_AddRigidBodiesW
Loads a TRA file and adds its Rigid Body assets onto the project.
NPRESULT TT_AddRigidBodies(const char *filename);
NPRESULT TT_AddRigidBodiesW(const wchar_t *filename);
Description
This function adds Rigid Body assets from the imported TRA file onto the existing list.
Adds Rigid Bodies from imported TRA files onto the asset list of the current project.
Returns an NPRESULT integer value. If the Rigid Bodies have been added successfully, it returns 0 or NPRESULT_SUCCESS.
Function Input
Filename (const char, const wchat_t)
Function Output
NPRESULT
C++ Example
/== Adding Rigid Bodies ==/
TT_AddRigidBodies("rigidbody.tra");
TT_LoadProfile, TT_LoadProfileW
Loads a Motive User Profile (.MOTIVE).
NPRESULT TT_LoadProfile(const char *filename);
NPRESULT TT_LoadProfileW(const wchar_t *filename);
Description
Loads the default application profile file (MOTIVE), which is located in the ProgramData directory:
C:\ProgramData\OptiTrack\MotiveProfile.motive
The MOTIVE files store software configurations as well as other software-wide settings.
Profile files also loads trackable asset definitions. Once the application profile containing trackable assets is imported, there is no need to import TRA and SKL files separately.
Returns an NPRESULT integer value. If the project file was successfully loaded, it returns 0 (NPRESULT_SUCCESS).
Function Input
Filename (const char, const wchar_t)
Function Output
NPRESULT
C++ Example
//== Loading application profile XML file ==/
const char *filename= "UserProfile.ttp";
NPRESULT profileLoad = TT_LoadProfile(filename);
if (profileLoad == NPRESULT_SUCCESS)
{
printf("%s successfully loaded.\n", filename);
}
else
{
printf("Error: %s\n", TT_GetResultString(profileLoad));
}
TT_LoadProject, TT_LoadProjectW
Loads a Motive TTP project file.
NPRESULT TT_LoadProject(const char *filename);
NPRESULT TT_LoadProjectW(const wchar_t *filename);
Description
Loads a Motive TTP project file. TTP project file loads and saves both camera calibration and Rigid Body assets, so when using TTP files, there is no need to import or export CAL or TRA files separately.
Loading a project file will import all of the required information for tracking. These include camera calibration and Rigid Body assets that are associated with a Motive project.
Returns an NPRESULT integer value. If the project file was successfully loaded, it returns 0 (NPRESULT_SUCCESS).
Function Input
Filename (const char, const wchar_t)
Function Output
NPRESULT
C++ Example
//== Loading TTP project file ==/
const char *filename= "project.ttp";
NPRESULT ttpload = TT_LoadProject(filename);
if (ttpload == NPRESULT_SUCCESS)
{
printf("%s successfully loaded.\n", filename);
}
else
{
printf("Error: %s\n", TT_GetResultString(ttpload));
}
TT_SaveProfile, TT_SaveProfileW
Saves current application setting into a Profile XML file.
NPRESULT TT_SaveProfile(const char *filename);
NPRESULT TT_SaveProfileW(const wchar_t *filename);
Description
This function saves the current configuration into an application Profile XML file.
Attach *.xml extension at the end of the filename.
Returns an NPRESULT integer value. If the profile XML file was saved successfully, it returns 0 (NPRESULT_SUCCESS).
Function Input
Filename (const char, const wchar_t)
Function Output
NPRESULT
C++ Example
//== Saving the TTP project ==/
const char *projectname = "project.ttp";
NPRESULT result = TT_SaveProfile(projectname);
if ( result == NPRESULT_SUCCESS ){
printf("Profile XML file saved.");
}
else {
printf("Error: %s", TT_GetResultString(result));
}
TT_SaveProject, TT_SaveProjectW
TT_LoadCalibrationFromMemory
Loads calibration from memory.
NPRESULT TT_LoadCalibrationFromMemory(unsigned char* buffer, int bufferSize);
Description
This function loads camera calibration from memory. In order to do this, the program must have saved calibration memory.
It assumes the pointer argument (unsigned char*) points to a memory block where calibration data is already stored. The address and size of the calibration buffer must be determined by the developer using the API.
Function Input
Buffer (unsigned char*)
Size of the buffer (int)
Function Output
NPRESULT
C++ Example
// get a pointer to the calibration block in memory
int bufferSize;
// get the size of the buffer
NPRESULT result = TT_LoadCalibrationFromMemory(buffer, bufferSize);
TT_CameraExtrinsicsCalibrationFromMemory
Gets camera extrinsics from a calibration file in memory.
NPRESULT TT_CameraExtrinsicsCalibrationFromMemory(unsigned char* buffer, int bufferSize, eMotiveAPIResult& result);
Description
This allows for acquiring camera extrinsics for cameras not connected to system.
It simply returns the list of details for all cameras contained in the calibration file.
Function Input
Buffer (unsigned char*)
Size of the buffer (int)
Result
Function Output
NPRESULT
C++ Example
// get a pointer to the calibration block in memory
int bufferSize;
// get the size of the buffer
NPRESULT result = TT_CameraExtrinsicsCalibrationFromMemory(unsigned char* buffer, int bufferSize, eMotiveAPIResult& result);
Calibration
TT_StartCalibrationWanding
Start a new calibration wanding for all cameras.
void TT_StartCalibrationWanding();
Description
This will cancel any existing calibration process.
Function Input
None
Function Output
C++ Example
TT_CalibrationState
Returns the current calibration state.
NPRESULT TT_CalibrationState();
Description
Returns the current calibration state.
Function Input
None
Function Output
NPRESULT
C++ Example
TT_CalibrationCamerasLackingSamples
During calibration wanding, this will return a vector of camera indices that are lacking the minimum number of calibration samples to begin calculation.
std::vector<int> TT_CalibrationCamerasLackingSamples();
Description
When the returned vector for this method goes to zero size, you can call TT_StartCalibrationCalculation() to begin calibration calculations.
Wanding samples will continue to be collected until TT_StartCalibrationCalculation() is called.
Function Input
None
Function Output
Vector (int)
C++ Example
TT_CameraCalibrationSamples
During calibration wanding.
int TT_CameraCalibrationSamples(int cameraIndex);
Description
This will return the number of wand samples collected for the given camera.
Return 0 otherwise.
Function Input
Camera index (int)
Function Output
Number of samples (int)
C++ Example
TT_CancelCalibration
Cancels wanding or calculation and resets calibration engine.
void TT_CancelCalibration();
Description
Cancels wanding or calculation
Resets calibration engine
Function Input
none
Function Output
Exits either TT_StartCalibrationWanding() or TT_StartCalibratoinCalculation()
C++ Example
TT_StartCalibrationCalculation
Once wanding is complete, call this to begin the calibration calculations.
bool TT_StartCalibrationCalculation();
Description
Starts calibration calculations after wanding.
Function Input
Boolean value
Function Output
Starts calculation
C++ Example
TT_CurrentCalibrationQuality
During calibration calculation.
bool TT_CurrentCalibrationQuality();
Description
This method will return the current calibration quality in the range [0-5], with 5 being best.
Returns zero otherwise
Function Input
none
Function Output
Quality on scale of 0-5 (int)
C++ Example
TT_ApplyCalibrationCalculation
Run once TT_CalibrationState() returns "Complete".
bool TT_ApplyCalibrationCalculation();
Description
Call this method to apply the calibration results to all cameras.
Function Input
none
Function Output
Apply calibration results
C++ Example
TT_SetGroundPlane
Set the ground plane using a standard or custom ground plane template.
bool TT_SetGroundPlane(bool useCustomGroundPlane);
Description
If true then this function will use a custom ground plane.
Function Input
Boolean value of useCustomGroundPlane
Function Output
Either applies custom or preset ground plane to calibration.
C++ Example
TT_TranslateGroundPlane
Translate the existing ground plane (in mm).
void TT_TranslateGroundPlane(float x, float y, float z);
Description
Takes float variables to alter existing ground plane.
Function Input
X, Y, and Z values (float)
Function Output
Applies new values to existing ground plane.
C++ Example
Data Streaming
TT_StreamNP
Enables/disables the NatNet streaming of the Natrual Point tracking data.
NPRESULT TT_StreamNP(bool enabled);
Description
This function enables/disables NaturalPoint data stream.
This is equivalent to the Broadcase Frame Data in the Data Streaming panel in Motive.
Returns a NPRESULT integer value. If the operation was successful, it returns 0 (NPRESULT_SUCCESS).
Function Input
Boolean argument enabled (true) / disabled (false)
Function Output
NPRESULT
C++ Example
//== Enable NP Streaming ==/
TT_StreamNP(true);
TT_StreamTrackd
Enables/disables streaming frame data into trackd.
NPRESULT TT_StreamTrackd(bool enabled);
Description
This function enables/disables streaming data into trackd.
Returns a NPRESULT integer value. If the operation was successful, it returns 0 (NPRESULT_SUCCESS).
Function Input
True for enabling and false for disabling (bool)
Function Output
NPRESULT
C++ Example
//== Enable NP Streaming ==/
TT_StreamTrackd(true);
TT_StreamVRPN
Enables/disables data stream into VRPN.
NPRESULT TT_StreamVRPN(bool enabled, int port);
Description
This function enables/disables data streaming into VRPN.
To stream onto VRPN, the port address must be specified. VRPN server applications run through 3883 port, which is default port for the VRPN streaming.
Returns an NPRESULT integer value. If streaming was successfully enabled, or disabled, it returns 0 (NPRESULT_SUCCESS).
Function Input
True for enabling and false for disabling (bool)
Streaming port address (int)
Function Output
NPRESULT
C++ Example
//== Enable Streaming into VRPN ==/
TT_StreamVRPN(true);
3D Frame Data
TT_FrameMarkerCount
Gets total number of reconstruected markers in a frame.
int TT_FrameMarkerCount();
Description
This function returns a total number of reconstructed 3D markers detected in current capture frame.
Use this function to count a total number of markers, access every markers, and obtain the marker index values.
Function Input
None
Function Output
Total number of reconstructed markers in the frame (int)
C++ Example
//Obtaining total marker count
int totalMarker = TT_FrameMarkerCount();
printf("Total number of markers: %d", totalMarker);
for (int i = 0 ; i < totalMarker; i++) {
//== Use a loop to access every marker in the frame ==//
printf("Marker %d (X/Y/Z): (%f, %f, %f)\n", i,
TT_FrameMarkerX(i), TT_FrameMarkerY(i), TT_FrameMarkerZ(i));
}
TT_FrameMarkerX
Returns x-position of a reconstructed marker.
float TT_FrameMarkerX(int markerIndex);
Description
This function returns X coordinate of a reconstructed 3D marker in respect to the global coordinate system, in meters.
It requires a marker index value.
Function Input
Marker index (int)
Function Output
X-position of the 3D marker (float)
C++ Example
int totalMarker = TT_FrameMarkerCount();
printf("Total number of markers: %d", totalMarker);
//== Outputting marker positions ==//
for (int i = 0 ; i < totalMarker; i++) {
//== Use a loop to access every marker in the frame ==//
printf("Marker %d (X/Y/Z): (%f, %f, %f)", i,
TT_FrameMarkerX(i), TT_FrameMarkerY(i), TT_FrameMarkerZ(i));
}
TT_FrameMarkerY
Returns y-position of a reconstructed marker.
float TT_FrameMarkerY(int markerIndex);
Description
This function returns Y coordinate of a reconstructed 3D marker in respect to the global coordinate system, in meters.
It requires a marker index value.
Function Input
Marker index (int)
Function Output
Y-position of the 3D marker (float)
C++ Example
int totalMarker = TT_FrameMarkerCount();
printf("Total number of markers: %d", totalMarker);
//== Outputting marker positions ==//
for (int i = 0 ; i < totalMarker; i++) {
//== Use a loop to access every marker in the frame ==//
printf("Marker %d (X/Y/Z): (%f, %f, %f)", i,
TT_FrameMarkerX(i), TT_FrameMarkerY(i), TT_FrameMarkerZ(i));
}
TT_FrameMarkerZ
Returns z-position of a reconstructed marker.
float TT_FrameMarkerZ(int markerIndex);
Description
This function returns Z coordinate of a reconstructed 3D marker in respect to the global coordinate system, in meters.
It requires a marker index value.
Function Input
Marker index (int)
Function Output
Z-position of the 3D marker (float)
C++ Example
int totalMarker = TT_FrameMarkerCount();
printf("Total number of markers: %d", totalMarker);
//== Outputting marker positions ==//
for (int i = 0 ; i < totalMarker; i++) {
//== Use a loop to access every marker in the frame ==//
printf("Marker %d (X/Y/Z): (%f, %f, %f)", i,
TT_FrameMarkerX(i), TT_FrameMarkerY(i), TT_FrameMarkerZ(i));
}
TT_FrameMarkerResidual
Returns residual value of a marker.
float TT_FrameMarkerResidual(int markerIndex);
Description
This function returns a residual value for a given marker indicated by the marker index.
Unit of the returned value is in millimeters.
The marker index value may change between frames, but the unique identifier will always remain the same.
Function Input
Marker index (int)
Function Output
Residual value (float)
TT_FrameMarkerLabel
Returns a unique identifier of a marker.
Core::cUID TT_FrameMarkerLabel(int markerIndex);
Description
This function returns a unique identifier (cUID) for a given marker.
Markers have an index from 0 to [totalMarkers -1] for a given frame. In order to access unique identifier of any marker, it's index must be inputted.
The marker index value may change between frames, but the unique identifier will always remain the same.
Function Input
Marker index (int)
Function Output
Marker label (cUID)
C++ Example
int totalMarkers = TT_FrameMarkerCount();
vector<Core::cUID> unique_Marker_ID(totalMarkers);
for (int i = 0; i < totalMarkers; ++i)
{
unique_Marker_ID[i] = TT_FrameMarkerLabel(int markerIndex);
}
TT_FrameTimeStamp
Returns a timestamp value for the current frame.
double TT_FrameTimeStamp();
Description
This function returns a timestamp value of the current frame.
Function Input
None
Function Output
Frame timestamp (double)
C++ Example
int frameNumber = 0;
//== Display Frame number and Time stamp ==//
while( !_kbhit() )
{
if( !TT_Update() ){
frameNumber++; // increment frame number each time a frame is processed.
printf("Frame #%d: (Timestamp: %f)\n", frameNumber, TT_FrameTimeStamp());
}
}
TT_FrameCameraCentroid
Checks whether a camera is contributing to reconstruction of a 3D marker, and saves corresponding 2D location as detected in the camera's view.
bool TT_FrameCameraCentroid(int markerIndex, int cameraIndex, float &x, float &y);
Description
This function evaluates whether the specified camera (cameraIndex) is contributing to point cloud reconstruction of a 3D point (markerIndex).
It returns true if the camera is contributing to the marker.
After confirming that the camera contributes to the reconstruction, this function will save the 2D location of the corresponding marker centroid in respect to the camera's view.
The 2D location is saved in the declared variable.
Function Input
3D reconstructed marker index (int)
Camera index (int)
Reference variables for saving x and y (floats).
Function Output
True / False (bool)
C++ Example
//== Getting 2D location of marker centroids from a camera.==//
float x, y;
int targetcam = 1;
int frameMarkercount = TT_FrameMarkerCount();
for (int i = 0; i < frameMarkercount; i++) // For each detected markers
{
bool result = TT_FrameCameraCentroid(i, targetcam, x, y)
if (result)
{
printf("Marker %d location in camera #%d: %f, %f\n", i, targetcam, x, y);
}
}
TT_FlushCameraQueues
Flushes out the camera queues.
void TT_FlushCameraQueues();
Description
This function flushes camera queues.
In an event when you are tracking a very high number (hundreds) of markers and the application has accumulated data processing latency, you can call TT_FlushCameraQueues() to refresh the camera queue before calling TT_Update() for processing the frame. After calling this function, avoid calling it again until the TT_Update() function is called and NPRESULT_SUCCESS is returned.
Function Input
None
Function Output
Void
C++ Example
//== Flush Camera Queues to remove accumulated latency. ==//
TT_FlushCameraQueues();
//== Update the incoming camera data after. ==//
TT_Update();
Rigid Bodies
TT_IsRigidBodyTracked
Checks whether Rigid Body is tracked or not.
bool TT_IsRigidBodyTracked(int rbIndex);
Description
Checks whether the Rigid Body is being tracked in the current frame.
Returns true if the Rigid Body is tracked.
Function Input
Rigid body index (int)
Function Output
True / False (bool)
C++ Example
int totalRB = TT_RigidBodyCount();
//== Checking if the Rigid Body is tracked or not ==//
for(int i = 0; i < totalRB)
{
If(TT_IsRigidBodyTracked(i))
{
// Process Rigid Body
}
}
TT_RigidBodyLocation
Obtains and saves 3D position, quaternion orientation, and Euler orientation of a Rigid Body
void TT_RigidBodyLocation(int rbIndex,
float *x, float *y, float *z,
float *qx, float *qy, float *qz, float *qw,
float *yaw, float *pitch, float *roll);
Description
This function saves position and orientation of a Rigid Body. Specifically, position and orientation at the Rigid Body pivot point is obtained.
3D coordinates of the Rigid Body will be assigned in declared variable addresses (*x, *y, *z).
Orientation of the Rigid Body will be saved in two different formats; Euler and quaternion rotations. Yaw, pitch, and roll values for Euler representation will be saved in the declared variable addresses (*yaw, *pitch, *roll), and qx, qy, qz, and qw values for the quaternion rotation will be saved in declared variable addresses (*qx, *qy, *qz, and *qw).
Function Input
Rigid body index (int)
Declared variable (float) addresses for:
3D coordinates (x,y,z)
Quaternion Rotation (qx, qy, qz, qw)
Euler Rotation ( yaw, pitch, roll)
Function Output
Void
C++ Example
//== Declared variables ==//
float x, y, z;
float qx, qy, qz, qw;
float yaw, pitch, roll;
int rbcount = TT_RigidBodyCount();
for(int i = 0; i < rbcount; i++)
{
//== Obtaining/Saving the Rigid Body position and orientation ==//
TT_RigidBodyLocation( i, &x, &y, &z, &qx, & qy, &qz, &qw, &yaw, &pitch, &roll );
if( TT_IsRigidBodyTracked( i ) )
{
printf( "%s: Pos (%.3f, %.3f, %.3f) Orient (%.1f, %.1f, %.1f)\n",
TT_RigidBodyName( i ), x, y, z, yaw, pitch, roll );
}
}
TT_ClearRigidBodyList
Clears and removes all Rigid Body assets.
void TT_ClearRigidBodyList();
Description
This function clears all of existing Rigid Body assets in the project.
Function Input
None
Function Output
Void
C++ Example
//== Clear all Rigid Bodies ==//
TT_ClearRigidBodyList();
TT_RemoveRigidBody
Removes a Rigid Body from the project
NPRESULT TT_RemoveRigidBody(int rbIndex);
Description
This function removes a single Rigid Body from a project.
Returns a NPRESULT integer value. If the operation was successful, it returns 0 (NPRESULT_SUCCESS).
Function Input
Rigid body index (int)
Function Output
NPRESULT
C++ Example
//== Removing Rigid Bodies that are not tracked in the scene ==//
int totalRB = TT_RigidBodyCount();
for (int i = 0; i < totalRB; i++)
{
if(!TT_IsRigidBodyTracked(i))
{
TT_RemoveRigidBody(i);
}
}
TT_RigidBodyCount
Returns a total number of Rigid Bodies.
Description
This function returns a total count of Rigid Bodies involved in the project.
This can be used within a loop to set required number iterations and access each of the Rigid Bodies.
Function Input
None
Function Output
Total Rigid Body count (int)
C++ Example
//== Getting names of all Rigid Bodies ==//
int totalRB = TT_RigidBodyCount();
for (int i = 0; i < totalRB; i++)
{
printf("Rigid Body #%d: %s\n", i, TT_RigidBodyName(i));
}
TT_RigidBodyUserData
Returns the User Data ID value of a Rigid Body.
int TT_RigidBodyUserData(int rbIndex);
Description
This function returns the User Data ID number of a Rigid Body.
User ID is a user definable ID for the Rigid Body. When working with capture data in external pipelines, this value can be used to address specific Rigid Bodies in the scene.
Function Input
Rigid body index (int)
Function Output
User Data ID (int)
C++ Example
int totalRB = TT_RigidBodyCount();
//== User Data ID for all Rigid Bodies ==//
for ( int i = 0 ; i < totalRB; i++ )
{
printf("%s User Data ID: %d", TT_RigidBodyName(i), TT_RigidBodyUserData(i));
}
TT_SetRigidBodyUserData
Assigns a User Data ID number to a Rigid Body.
void TT_SetRigidBodyUserData(int rbIndex, int ID);
Description
Assigns a User Data ID number to a Rigid Body.
The User Data ID numbers can be used to point to particular assets when processing the data in external applications.
Function Input
Rigid body index (int)
Desired User Data ID (int)
Function Output
Void
C++ Example
int totalRB = TT_RigidBodyCount();
//== Assigning incremental User Data ID for Rigid Bodies. ==//
for( int i = 0; i < totalRB; i++ )
{
TT_SetRigidBodyUserData(i, i+1);
printf("Rigid Body: %s, \t User Data ID: %d", TT_RigidBodyName(i), TT_RigidBodyUserData(i));
}
TT_RigidBodyMeanError
Returns a mean error of the Rigid Body tracking data.
void TT_RigidBodyMeanError(int rbIndex, int ID);
Description
Returns a mean error value of the respective Rigid Body data for the current frame.
Function Input
Rigid body index (int)
Function Output
Mean error (meters)
TT_RigidBodyName, TT_RigidBodyNameW
Returns the name for the Rigid Body.
const char* TT_RigidBodyName(int rbIndex);
const wchar_t* TT_RigidBodyNameW(int rbIndex);
Description
These functions are used to obtain name of a Rigid Body.
Returns the assigned name of the Rigid Body.
Function Input
Rigid body index (int)
Function Output
Rigid body name (const char*, const w_chart*)
C++ Example
int totalRB = TT_RigidBodyCount();
//== Printing Rigid Body Names ==//
for( int i = 0; i < totalRB; i++ )
{
printf("Rigid Body: %s, \t User Data ID: %d", TT_RigidBodyName(i), TT_RigidBodyUserData(i));
}
TT_SetRigidBodyEnabled
Enables/disables tracking of a Rigid Body.
void TT_SetRigidBodyEnabled(int rbIndex, bool enabled);
Description
This function enables, or disables, tracking of the selected Rigid Body.
All Rigid Bodies are enabled by default. Disabled Rigid Bodies will not be tracked, and no data will be received from it.
Function Input
Rigid body index (int)
Tracking status (bool)
Function Output
Void
C++ Example
int totalRB = TT_RigidBodyCount();
//== Disabling all Rigid Bodies ==//
for(int i = 0; i < totalRB; i++)
{
TT_SetRigidBodyEnabled(i, FALSE);
}
TT_RigidBodyEnabled
Checks whether a Rigid Body is enabled.
bool TT_RigidBodyEnabled(int rbIndex);
Description
This function checks whether tracking of the Rigid Body is enabled or not.
The function returns true is the tracking is enabled.
Function Input
Rigid body index (int)
Function Output
True / False (bool)
C++ Example
int totalRB = TT_RigidBodyCount();
for (int i = 0; i < totalRB; i++)
{
if (TT_RigidBodyEnabled(i))
{
//== Disabling all enabled Rigid Bodies ==//
TT_SetRigidBodyEnabled(i, FALSE);
}
}
TT_RigidBodyTranslatePivot
Translates the pivot point of a Rigid Body.
NPRESULT TT_RigidBodyTranslatePivot(int index, float x, float y, float z);
Description
This function translates a Rigid Body.
3D position of a Rigid Body will be displaced in x/y/z directions by inputted amount (meters).
Translation is applied in respect to the local Rigid Body coordinate axis, not the global axis.
Returns a NPRESULT integer value. If the operation was successful, it returns 0 (NPRESULT_SUCCESS).
Function Input
Rigid body index (int)
Translation along x-axis, in meters. (float)
Translation along y-axis, in meters. (float)
Translation along z-axis, in meters. (float)
Function Output
NPRESULT
C++ Example
int rbIndex = 1;
//== Translating a Rigid Body 2 cm in positive x-direction ==//
TT_RigidBodyTranslate(rbIndex, 0.02, 0, 0);
TT_RigidBodyResetOrientation
Resets orientation of a Rigid Body.
bool TT_RigidBodyResetOrientation(int rbIndex);
Description
This function resets orientation of the Rigid Body and re-aligns its orientation axis with the global coordinate system.
Additional Note: When creating a Rigid Body, its zero orientation is set by aligning its axis with the global axis at the moment of creation. Calling this function essentially does the same thing on an existing Rigid Body asset.
Returns true if the Rigid Body orientation was reset.
Function Input
Rigid body index (int)
Function Input
True / False (bool)
C++ Example
int rbcount = TT_RigidBodyCount();
//== Resetting orientation of each Rigid Body. ==//
for( int i = 0; i < rbcount i++ )
{
if(TT_RigidBodyResetOrientation(i))
{
printf("Rigid body (%s) orientation reset", TT_RigidBodyName(i));
}
}
TT_RigidBodyMarkerCount
Gets total number of markers in a Rigid Body.
int TT_RigidBodyMarkerCount(int rbIndex);
Description
This function returns total number of markers involved in a Rigid Body.
Function Input
Rigid body index (int)
Function Output
Total number of marker in the Rigid Body (int)
C++ Example
int rbcount = TT_RigidBodyCount();
//== Listing out all of the Rigid Body markers ==//
for(int i = 0; i < rbcount; i++)
{
printf("Rigid Body:%s\t Marker Count: %d", TT_RigidBodyName(i), TT_RigidBodyMarkerCount(i));
}
TT_RigidBodyMarker
Saves 3D coordinates of a solved Rigid Body marker in respect to respective Rigid Body's local space.
void TT_RigidBodyMarker(int rbIndex, int markerIndex, float *x, float *y, float *z);
Description
This function gets 3D position of a solved Rigid Body marker and saves them in designated addresses. Rigid body marker positions from this function represents solved (or expected) location of the Rigid Body markers. For actual reconstructed marker positions, use the TT_RigidBodyPointCloudMarker function.
Note that the 3D coordinates obtained by this function is represented in respect to Rigid Body's local coordinate axis. For obtaining 3D coordinate in respect to global coordinates, use TT_RigidBodyPointCloudMarker function.
Function Input
Rigid body index (int)
Marker index (int)
Three declared variable addresses for saving x, y, z coordinates of the marker (float)
Function Output
Void
C++ Example
//== Listing out all of the Rigid Body markers and its respective position. ==//
int rbcount = TT_RigidBodyCount();
for(int i = 0; i < rbcount; i++)
{
float x,y,z;
for(int j = 0; j < TT_RigidBodyMarkerCount(i); j++)
{
printf("Rigid Body:%s\t Marker #%d\n", TT_RigidBodyName(i), j);
//== Marker Locations ==//
TT_RigidBodyMarker(i, j, &x, &y, &z);
printf("Local: (%f, %f, %f)\n", x, y, z);
}
}
TT_RigidBodyUpdateMarker
Changes and updates the Rigid Body marker positions.
bool TT_RigidBodyUpdateMarker( int rbIndex, int markerIndex, float *x, float *y, float *z );
Description
This function is used to change the expected positions of a single Rigid Body marker.
Rigid body markers are expected marker positions. Read about marker types in Motive.
Function Input
Rigid body index (int)
Marker index (int)
New x-position of the Rigid Body marker in respect to the local coordinate system.
New y-position of the Rigid Body marker in respect to the local coordinate system.
New z-position of the Rigid Body marker in respect to the local coordinate system.
Function Output
Returns true if marker locations have been successfully updated.
TT_RigidBodyPointCloudMarker
Saves 3D coordinates of a Rigid Body marker in respect to the global space.
void TT_RigidBodyPointCloudMarker(int rbIndex, int markerIndex, bool &tracked, float &x, float &y, float &z);
Description
This function saves 3D coordinates of each Rigid Body marker in designated addresses.
3D coordinates are saved in respect to global coordinate system.
Function Input
Rigid body index (int)
Marker index (int)
Tracked status, True or False (bool)
Three declared variable addresses for saving x, y, z coordinates of the marker (float).
Function Output
Void
C++ Example
//== Listing out all of the Rigid Body markers and its respective position. ==//
int rbcount = TT_RigidBodyCount();
for(int i = 0; i < rbcount; i++)
{
float gx, gy, gz;
bool tracked;
for(int j = 0; j < TT_RigidBodyMarkerCount(i); j++)
{
printf("Rigid Body:%s\t Marker #%d\n", TT_RigidBodyName(i), j);
//== Rigid Body Marker Global Coordinates ==//
TT_RigidBodyPointCloudMarker(i, j, tracked, gx, gy, gz);
printf("Global: (%f, %f, %f)\n", x, y, z);
}
}
TT_RigidBodyPlacedMarker
Saves 3D coordinates of a Rigid Body solved marker positions in respect to the global space. Unlike TT_RigidBodyPointCloudMarker function, it does not report point cloud solved positions, but it reports the expected marker positions in respect to Rigid Body position and orientation.
void TT_RigidBodyPlacedMarker(int rbIndex, int markerIndex, bool &tracked, float &x, float &y, float &z);
Description
This function saves 3D coordinates of each expected Rigid Body marker positions in designated variable addresses.
3D coordinates are saved in respect to global coordinate system.
Function Input
Rigid body index (int)
Marker index (int)
Tracked status, True or False (bool)
Three declared variable addresses for saving x, y, z coordinates of the marker (float).
Function Output
Void
C++ Example
//== Listing out all of the Rigid Body markers and its respective position. ==//
int rbcount = TT_RigidBodyCount();
for(int i = 0; i < rbcount; i++)
{
float gx, gy, gz;
bool tracked;
for(int j = 0; j < TT_RigidBodyMarkerCount(i); j++)
{
printf("Rigid Body:%s\t Marker #%d\n", TT_RigidBodyName(i), j);
//== Expected Rigid Body marker positions. ==//
TT_RigidBodyPlacedMarker(i, j, tracked, gx, gy, gz);
printf("Global: (%f, %f, %f)\n", x, y, z);
}
}
TT_RigidBodyID
This function is used for obtaining unique identifiers for a specific Rigid Body indicated by the Rigid Body index number.
Core::cUID TT_RigidBodyID( int rbIndex );
Function Input
Rigid body index (int)
Function Output
Rigid body unique ID (Core::cUID)
TT_CreateRigidBody
Creates a Rigid Body asset from a set of reconstructed 3D markers.
NPRESULT TT_CreateRigidBody(const char* name, int userDataID, int markerCount, float *markerList);
Description
This functions creates a Rigid Body from the marker list and marker count provided in its argument.
The marker list is expected to contain a list of marker coordinates in the following order: (x1, y1, z1, x2, y2, z2, …, xN, yN, zN). The x/y/z coordinates must be in respect to the Rigid Body pivot point, in meters.
Inputted 3D locations are taken as Rigid Body marker positions about the Rigid Body pivot point. If you are using TT_FrameMarkerX/Y/Z functions to obtain the marker coordinates, you will need to subtract the pivot point location from the global marker locations when creating a Rigid Body. This is shown in the below example. If this is not done, created Rigid Body will have its pivot point at the global origin.
Returns an NPRESULT integer value. If the Rigid Body was successfully created, it returns 0 or NPRESULT_SUCCESS.
Function Input
Rigid body name (char)
User Data ID (int)
Marker Count (int)
Marker list (float list)
Function Output
NPRESULT
C++ Example
int markerCount = TT_FrameMarkerCount;
vector<float> markerListRelativeToGlobal;
// add markers to markerListRelativeToGlobal using TT_FrameMarkerX, etc
for (int i = 0; i < markerCount; ++i)
{
markerListRelativeToGlobal.push_back(TT_FrameMarkerX(i));
markerListRelativeToGlobal.push_back(TT_FrameMarkerY(i));
markerListRelativeToGlobal.push_back(TT_FrameMarkerZ(i));
}
// then average the locations in x, y and z
float sx = 0, sy = 0, sz = 0;
for (int i = 0; i < markerCount; ++i)
{
sx += markerListRelativeToGlobal[3*i];
sy += markerListRelativeToGlobal[3*i + 1];
sz += markerListRelativeToGlobal[3*i + 2];
}
float ax = sx/markerCount;
float ay = sy/markerCount;
float az = sz/markerCount;
vector<float> pivotPoint = {ax, ay, az};
vector<float> markerListRelativeToPivotPoint;
// subtract the pivot point location from the marker location
for (int i = 0; i < markerCount; ++i)
{
markerListRelativeToPivotPoint.push_back(markerListRelativeToGlobal[3*i] - ax);
markerListRelativeToPivotPoint.push_back(markerListRelativeToGlobal[3*i + 1] - ay);
markerListRelativeToPivotPoint.push_back(markerListRelativeToGlobal[3*i + 2] - az);
}
TT_CreateRigidBody("Rigid Body New", 1, markerCount, markerListRelativeToPivotPoint);
TT_RigidBodySettings
Obtains Rigid Body settings for a given asset, and saves them in a cRigidBodySettings instance.
NPRESULT TT_RigidBodySettings(int rbIndex, RigidBodySolver::cRigidBodySettings &settings);
Description
This function obtains Rigid Body settings for a given Rigid Body asset and saves them into a declared cRigidBodySetting instance address.
Rigid body settings are saved into an instance of the cRigidBodySettings class.
For detailed information on member function and variables in the cRigidBodySettings class, refer to its declaration in the RigidBodySettings.h header file.
Returns a NPRESULT integer value.
Function Input
Rigid body index (int)
declared instance address (cRigidBodySettings)
Function Output
NPRESULT
C++ Example
//== Constructor at the Beginning of the program ==//
RigidBodySolver::cRigidBodySettings::cRigidBodySettings() {};
//== Obtaining Rigid Body Settings ==//
int rbcount = TT_RigidBodyCount();
RigidBodySolver::cRigidBodySettings settings;
for( int i = 0; i < rbcount; i++ )
{
TT_RigidBodySettings(i, settings);
printf("Rigid Body: %s\n", TT_RigidBodyName(i));
//== Printing Some of the Settings==//
printf("MaxMarkerDeflection: %f\n", settings.MaxMarkerDeflection);
printf("MinimumMarkerCount: %d\n", settings.MinimumMarkerCount);
if (settings.Unique)
{
printf("Unique: True\n");
}
}
TT_SetRigidBodySettings
Changes property settings of a Rigid Body.
NPRESULT TT_SetRigidBodySettings(int rbIndex, RigidBodySolver::cRigidBodySettings &settings);
Description
This function assigns a set of Rigid Body settings to a Rigid Body asset.
An instance of cRigidBodySettings will be attached to the provided Rigid Body.
Returns a NPRESULT integer value. If the marker was successfully created, it returns 0 (NPRESULT_SUCCESS).
Function Input
Rigid body index (int)
Function Output
NPRESULT
C++ Example
//== Constructor at the Beginning of the program ==//
int rbcount = TT_RigidBodyCount();
RigidBodySolver::cRigidBodySettings::cRigidBodySettings() {};
RigidBodySolver::cRigidBodySettings settings;
for(int i = 0; i < rbcount; i++)
{
//== Obtaining configured settings for each Rigid Body ==//
TT_RigidBodySettings(i, settings);
if(settings.Unique){
printf("Rigid Body #%d is already set to Unique", i);
}
else
{
//== Setting/assigning all Rigid Bodies to Unique ==//
settings.Unique = TRUE;
TT_SetRigidBodySettings(i,settings);
printf("Rigid Body #%d has been set to Unique", i);
}
TT_RigidBodyRefineStart
Initiates the Rigid Body refinement process. Input the number of samples and the ID of the Rigid Body you wish to refine. After starting the process, TT_RigidBodyRefineSample bust be called on everyframe in order to collect samples.
bool TT_RigidBodyRefineStart( Core::cUID rigidBodyID, int sampleCount );
Description
This function is used to start Rigid Body refinement.
Function Input
Target Rigid Body ID
Sample count (int)
Function Output
Returns true if the refinement process has successfully initiated.
TT_RigidBodyRefineSample
This function collects samples for Rigid Body refinement started by calling the TT_RigidBodyRefineStart function. Call this function for every frame; within the update loop. You can check the progress of calibration by calling the TT_RigidBodyRefineProgress function.
bool TT_RigidBodyRefineSample();
Description
This function collects sample Rigid Body tracking data for refining the definition of corresponding Rigid Body.
Function Input
None. Samples frames for the initialized refine process.
Function Output
Returns true if the refinement process has successfully collected a sample. This function does not collect samples if Rigid Body is not tracked on the frame.
TT_RigidBodyRefineState
This function inquiries the state of the refinement process. It returns TT_RigidBodyRefineStates enum as a result.
TT_RIgidBodyRefineStates TT_RigidBodyRefineState();
Description
This function queries the state of the Rigid Body refinement process. It returns an enum value for indicating whether the proess is intialized, sampling, solving, complete, or uninitialized.
<source> enum TT_RigidBodyRefineStates {
TT_RigidBodyRefine_Initialized = 0,
TT_RigidBodyRefine_Sampling,
TT_RigidBodyRefine_Solving,
TT_RigidBodyRefine_Complete,
TT_RigidBodyRefine_Uninitialized
};
</source>
Function Input
None. Checks the state on the ongoing refinement process.
Function Output
Returns TT_RigidBodyRefineStates enum value.
TT_RigidBodyRefineProgress
This function inquiries the progress of the refinement sampling process.
float TT_RigidBodyRefintProgress();
Description
When the refinement process is under the sampling state, calling this function returns the sampling progress. It will return a percentage value representing the sampling progress in respect to the total number of samples given in the TT_RigidBodyRefineStart parameter.
Function Input
None. Checks the progress on the ongoing refinement process.
Function Output
Returns percentage completness of the sampling process (float).
TT_RigidBodyRefineInitialError / TT_RigidBodyRefineResultError
These two functions returns error values of the Rigid Body definition before and after the refinement.
float TT_RigidBodyRefineInitialError();
float TT_RigidBodyRefineResultError();
Description
Once the refinement process has reached complete stage, these two functions can be called to compare the error values from corresponding Rigid Body defintion before and after the refinement.
Function Input
None.
Function Output
Average error value of the target Rigid Body defintion prior (TT_RigidBodyRefineInitialError) and after (TT_RigidBodyRefineResultError) the refinement.
TT_RigidBodyRefineApplyResult
This function applies the refined result to the corresponding Rigid Body definition.
bool TT_RigidBodyRefineApplyResult();
Description
This function applies the refined Rigid Body definition. After comparing the error values before and after the refinement using TT_RigidBodyRefineInitialError and TT_RigidBodyRefineResultError functions, use this function to apply if the results are satisfying.
Function Input
None.
Function Output
Returns true if the refined results have been successfully applied.
TT_RigidBodyRefineReset
This function discards the final refinement result and resets the refinement process.
bool TT_RigidBodyRefineReset();
Description
If the final refinement result from the TT_RigidBodyRefineResultError call is not satisfying, you can call this function to discard the result and start over from the sampling process again.
Function Input
None.
Function Output
Returns true if the refined results have been successfully resetted.
Camera Group
TT_GetCameraManager
Returns pointer to the CameraManager instance.
CameraLibrary::CameraManager* TT_GetCameraManager();
Description
This function returns a pointer to the CameraManager instance from the Camera SDK.
Camera SDK must be installed to use this function.
The version number of Motive and the Camera SDK must match.
Corresponding headers and libraries must be included in the program.
Function Input
None
Function Output
Pointer to the CameraManager instance (CameraLibrary::CameraManager*)
C++ Example
CameraLibrary::CameraManager *cman = TT_GetCameraManager();
// cman is declared as a pointer to a camera manager used in conjuction with the Camera SDK
TT_BuildNumber
Returns Motive build number.
Description
This function returns corresponding Motive build number.
Function Input
None
Function Output
Build number (int)
C++ Example
//== Printing Motive Build Number ==//
printf("Motive Build: %d\n", TT_BuildNumber());
TT_CameraGroupCount
Returns camera group count.
int TT_CameraGroupCount();
Description
This function returns total count of camera groups that are involved in the project.
Function Input
None
Function Output
Camera group count (int)
C++ Example
int groupcount = TT_CameraGroupCount();
//== Processing Camera Groups ==//
for(int i = 0; i < groupcount; i++)
{
//== Process each camera group ==//
}
TT_CreateCameraGroup
Creates a new camera group.
bool TT_CreateCameraGroup();
Description
This function adds an additional camera group (empty) to a project.
Note: Creating an additional camera group is unnecessary for most applications. Most common case is to group cameras to set them as a reference group for recording grayscale videos.
Function Input
None
Function Output
True/False (bool)
C++ Example
//== Creating a new camera group ==//
TT_CreateCameraGroup();
TT_RemoveCameraGroup
Removes a camera group.
bool TT_RemoveCameraGroup(groupIndex);
Description
This function removes a camera group, specified by its index number.
The camera group must contain no cameras in order to be removed.
Returns true if the group was successfully removed.
Function Input
Camera group index (int)
Function Output
True/False (bool)
C++ Example
//== For projects with multiple camera groups ==//
int cameracount = TT_CameraCount();
int groupcount = TT_CameraGroupCount();
if(groupcount > 1)
{
//== Moving all cameras to the first camera group (index = 0) ==//
for(int i = 0; i < cameracount; i++)
{
TT_SetCameraGroup( i, 0);
}
//== Removing all other camera groups==//
for(int j = 1; j < groupcount; j++)
{
TT_RemoveCameraGroup(j);
}
}
TT_CamerasGroup
Returns an index value of a camera group that a camera is involved in.
int TT_CamerasGroup(int cameraIndex);
Description
This function takes an index value of a camera and returns corresponding camera group index which the camera is involved in.
Function Input
Camera index (int)
Function Output
Camera group index (int)
C++ Example
//== Listing out all of the cameras and their associate group index ==//
int cameracount = TT_CameraCount();
for(int i = 0; i < cameracount; i ++)
{
printf("Camera: %s\t CameraGroup: #%d", TT_CameraName(i), TT_CamerasGroup(i));
}
TT_SetGroupShutterDelay
Introduces shutter delay to a camera group.
void TT_SetGroupShutterDelay(int groupIndex, int microseconds);
Description
This function sets a shutter delay (in microseconds) to a camera group, which is designated by its index number.
After assigning the delay, all of the cameras involved in the camera group will shutter at a delayed timing when recording.
Function Input
Camera group index (int)
Delay in microseconds (int)
Function Output
Void
C++ Example
//== Setting one second shutter delay for all camera groups ==//
for(int i = 0; i < TT_CameraGroupCount() ; i++)
{
TT_SetGroupShutterDelay(i, 1000000);
}
TT_SetCameraGroup
Moves a camera to a different camera group.
void TT_SetCameraGroup(int cameraIndex, int groupIndex);
Description
This function assigns/moves a camera to a different camera group
Function Input
Camera index (int)
Camera group index (int)
Function Output
Void
C++ Example
//== For projects with multiple camera groups ==//
int cameracount = TT_CameraCount();
int groupcount = TT_CameraGroup();
if(groupcount > 1)
{
//== Moving all cameras to the first camera group ==//
for(int i = 0; i < cameracount; i++)
{
//== Assigning all cameras to the first camera group (index = 0) ==//
TT_SetCameraGroup(i, 0);
}
//== Removing all other camera groups==//
for(int j = 1; j < groupcount; j++)
{
TT_RemoveCameraGroup(j);
}
}
TT_CameraGroupFilterSettings
Obtains the camera group's filter settings.
NPRESULT TT_CameraGroupFilterSettings(int groupIndex, cCameraGroupFilterSettings &settings);
Description
This function fetches configured 2D filter settings from a camera group and saves the settings in the declared cCameraGroupFilterSettings instance.
Returns a NPRESULT integer value. When the function successfully assigns the filter settings, it returns 0 (or NPRESULT_SUCCESS).
Function Input
Camera group index (int)
Group filter settings instance (cCameraGroupFilterSettings)
Function Output
NPRESULT
C++ Example
//== Declaring cCameraGroupFilterSettings object==//
cCameraGroupFilterSettings filterSettings;
int groupcount = TT_CameraGroupCount();
//== Obtaining filter settings for all of the camera groups ==//
for (int i = 0; i < groupcount; i++)
{
TT_CameraGroupFilterSettings(i, filterSettings);
//== Printing ==//
printf("GroupFilterSettings (group #%d):\n",i);
printf("\tMinMarkerSize: %d\n", filterSettings.MinMarkerSize);
printf("\tMaxMarkerSize: %d\n", filterSettings.MaxMarkerSize);
printf("\tMinRoundness: %f\n", filterSettings.MinRoundness);
if (filterSettings.FilterType == filterSettings.FilterNone)
{
printf("\tFilter: Filter None\n");
}
printf("\n");
}
TT_SetCameraGroupFilterSettings
Assigns camera group filter settings to a camera group.
NPRESULT TT_SetCameraGRoupFilterSettings(int groupIndex, cCameraGroupFilterSettings &settings);
Description
This function assigns inputted filter settings (cCameraGroupFilterSettings) instance to a camera group designated by its index number.
Returns a NPRESULT integer value. When the function successfully assigns the filter settings, it returns 0 (or NPRESULT_SUCCESS).
Function Input
Camera group index (int)
Filter settings instance (cCameraGroupFilterSettings)
Function Output
NPRESULT
C++ Example
int groupcount = TT_CameraGroupCount();
//== Settings MinMarkerSize threshold settings to 20 pixels for all camera groups==//
for (int i = 0; i < groupcount; i++)
{
cCameraGroupFilterSettings new_settings;
TT_CameraGroupFilterSettings(i, new_settings);
// For size and roundness filters
if (new_settings.FilterType == new_settings.FilterSizeRoundness)
{
//== Changing MinMarkerSize setting and reassigning it to the camera group.
filterSettings.MinMarkerSize = 20;
TT_SetCameraGroupFilterSettings(i, new_settings);
printf("\tFilter settings changed");
}
}
TT_CameraGroupPointCloudSettings / TT_SetCameraGroupPointCloudSettings
TT_CameraGroupMarkerSize
Obtains marker size settings of a camera group
NPRESULT TT_CameraGroupMarkerSize(int groupIndex, cCameraGroupMarkerSizeSettings &settings);
Description
This function fetches currently configured marker size settings from a camera group, and saves them onto a declared cCameraGroupMarkerSizeSettings class instance.
The marker size settings determine display properties of the 3D markers reconstructed from a specific group of cameras.
Returns a NPRESULT integer value. When the function successfully obtains the settings, it returns 0 (or NPRESULT_SUCCESS).
Function Input
Camera group index (int)
Marker size settings (cCameraGroupMarkerSizeSettings)
Function Output
NPRESULT
C++ Example
int groupcount = TT_CameraGroupCount();
for (int i = 0; i < groupcount; i++)
{
//== Obtaining marker size settings ==//
cCameraGRoupMarkerSizeSettings mSettings;
TT_CameraGroupMarkerSize(i, mSettings);
//== Outputting the settings==//
printf("Camera Group #%d:\n", i);
printf("\tMarker Size: %f\n", mSettings.MarkerSize);
if (mSettings.MarkerSizeType == cCameraGroupMarkerSizeSettings::MarkerSizeCalculated) {
printf("\tMarkerSizeCalulated\n");
}
else if (mSettings.MarkerSizeType == cCameraGroupMarkerSizeSettings::MarkerSizeFixed)
{
printf("\tMarkerSizeFixed\n");
mSettings.MarkerSize = 20.0
}
}
TT_SetCameraGroupMarkerSize
Applies given marker size settings to a camera group.
NPRESULT TT_SetCameraGroupMarkerSize(int groupIndex, cCameraGroupMarkerSizeSettings &settings);
Description
This function applies an instance cCameraGroupMarkerSizeSettings to a camera group.
The marker size settings determine display properties of 3D markers reconstructed from a specific group of cameras.
Marker sizes are represented by corresponding diameter in millimeters.
Returns a NPRESULT integer value. When the function successfully applies the settings, it returns 0 (or NPRESULT_SUCCESS).
Function Input
Camera group index (int)
Marker size settings (cCameraGroupMarkerSizeSettings)
Function Output
NPRESULT
C++ Example
int groupcount = TT_CameraGroupCount();
//== Setting all camera groups to share a fixed marker size ==//
for (int i = 0; i < groupcount; i++)
{
cCameraGroupMarkerSizeSettings mSettings;
TT_CameraGroupMarkerSize(i, settings);
//== Modify and reapply the settings ==//
mSettings.MarkerSizeType = cCameraGroupMarkerSizeSettings::MarkerSizeFixed;
mSettings.MarkerSize = 10.0;
TT_SetCameraGroupMarkerSize(i, settings);
}
TT_SetCameraGroupReconstruction
Enables or disables marker reconstruction contribution from a camera group.
NPRESULT TT_SetCameraGroupReconstruction(int groupIndex, bool enable);
Description
Enables or disables marker reconstruction contribution from a camera group.
Input TRUE for enable argument in order to allow the camera group to reconstruct markers.
Returns a NPRESULT integer value. When the function successfully enables/disables the reconstruction, it returns 0 (or NPRESULT_SUCCESS).
Function Input
Camera group index (int)
Boolean argument for enabling (true) and disabling (false) the mode.
Function Output
NPRESULT
C++ Example
//== Disabling all camera groups ==//
int groupcount = TT_CameraGroupCount();
bool enabled = false;
for (int i = 0; i < groupcount; i++)
{
TT_SetCameraGroupReconstruction(i, enabled);
}
TT_SetEnabledFilterSwitch
Enables or disables filter switchers.
NPRESULT TT_SetEnabledFilterSwitch(bool enabled);
Description
This function enables or disables filter switches for all of the connected cameras.
Returns a NPRESULT integer value. When the function successfully changes the setting, it returns 0 (or NPRESULT_SUCCESS).
Function Input
Boolean argument for enabling (true) or disabling (false) the filter.
Function Output
NPRESULT
C++ Example
//== Disabling Filter Switches ==//
bool enabled = false;
TT_SetEnabledFilterSwitch(enabled);
TT_IsFilterSwitchEnabled
Checks whether filter switches are enabled or not.
bool TT_IsFilterSwitchEnabled();
Description
This function checks whether filter switch is enabled in all of the cameras,
It returns true if the switches are enabled.
Function Input
Void
Function Output
Enabled/disabled (bool)
C++ Example
//== Enabling disable filter switches ==//
if (!TT_IsFilterSwitchEnabled())
{
printf("Enabling all disabled switches\n");
TT_SetEnabledFilterSwitch(true);
}
Camera
TT_CameraCount
Returns a total number of cameras connected to the system.
Description
This function returns a total camera count.
Function Input
None
Function Output
Total number of cameras (int)
C++ Example
//== Printing Frame rate of the cameras ==//
int totalCamera = TT_CameraCount();
for( int i = 0; i < totalCamera; i++)
{
printf("%s frame rate: %d\n", TT_CameraName(i), TT_CameraFrameRate(i));
}
TT_CameraXLocation
Returns x-position of a camera.
int TT_CameraXLocation(int cameraIndex);
Description
This function returns camera's X position in respect to the global coordinate system
Function Input
Camera index (int)
Function Output
Camera's X position. Measured in meters with reference to global coordinate system. (float)
C++ Example
for(int i = 0; i < TT_CameraCount(); i++)
{
float camX = TT_CameraXLocation(i);
float camY = TT_CameraYLocation(i);
float camZ = TT_CameraZLocation(i);
printf("Camera #%d: (%f, %f, %f)", camX, camY, camZ);
}
TT_CameraYLocation
Returns y-position of a camera.
int TT_CameraYLocation(int cameraIndex);
Description
This function returns camera's Y position in respect to the global coordinate system
Function Input
Camera index (int)
Function Output
Camera Y-position. Measured in meters with reference to global coordinate system. (float)
C++ Example
for(int i = 0; i < TT_CameraCount(); i++)
{
float camX = TT_CameraXLocation(i);
float camY = TT_CameraYLocation(i);
float camZ = TT_CameraZLocation(i);
printf("Camera #%d: (%f, %f, %f)", camX, camY, camZ);
}
TT_CameraZLocation
Returns z-position of a camera.
int TT_CameraZLocation(int cameraIndex);
Description
This function returns camera's Z position in respect to the global coordinate system
Function Input
Camera index (int)
Function Output
Camera's Z position. Measured in meters with reference to global coordinate system. (float)
C++ Example
for(int i = 0; i < TT_CameraCount(); i++)
{
float camX = TT_CameraXLocation(i);
float camY = TT_CameraYLocation(i);
float camZ = TT_CameraZLocation(i);
printf("Camera #%d: (%f, %f, %f)", camX, camY, camZ);
}
TT_CameraOrientationMatrix
Gets a components of the camera's orientation matrix.
float TT_CameraOrientationMatrix(int cameraIndex, int matrixIndex);
Sample output from a program displaying the rotation matrix.
Description
This function returns a single constant from camera's orientation matrix in respect to the global coordinate axis.
The camera index input (int) determines which camera to obtain the matrix from.
The matrix index determines which component of the rotation matrix to return.
Function Input
Camera index (int)
Matrix index (int)
Function Output
Single component of the rotation matrix (float)
C++ Example
printf("Orienation Matrix: \n");
for (int j = 0; j < 3; j++)
{
for (int k = 0; k < 3; k++)
{
//===== Rotation Matrix =====//
printf("\t%f (index %d)", TT_CameraOrientationMatrix(i, k + (3 * j)), k + (3 * j));
}
printf("\n\n");
}
TT_CameraName
Returns coresponding camera's model name and serial number
const char* TT_CameraName(int cameraIndex);
Description
This function returns corresponding camera's name and serial number.
Function Input
Camera index (int)
Function Output
Camera name and serial number (const char)
C++ Example
//== Displaying all connected cameras ==//
int totalCamera = TT_CameraCount();
printf("Detected Cameras:\n");
for (int i = 0; i < totalCamera; i++)
{
printf("\t%s\n", TT_CameraName(i));
}
TT_CameraSerial
Returns coresponding camera's serial number as an integer.
int TT_CameraSerial(int cameraIndex);
Description
This function returns corresponding camera's serial number.
Function Input
Camera index (int)
Function Output
Camera serial number (int)
C++ Example
//== Displaying all connected cameras ==//
int totalCamera = TT_CameraCount();
printf("Detected Cameras Serial Numbers:\n");
for (int i = 0; i < totalCamera; i++)
{
printf("\t%d\n", TT_CameraSerial(i));
}
TT_CameraMarkerCount
Returns a total number of centroids detected by a camera.
int TT_CameraMarkerCount(int cameraIndex);
Description
This function returns a total number of centroids detected by a camera.
A centroid is defined for every group of contiguous pixels that forms a shape that encloses the thresholded pixels.
Size and roundness filter (cCameraGroupFilterSettings) is not applied in this data.
Function Input
Camera index (int)
Function Output
Number of centroids (int)
C++ Example
for (int i = 0; i < TT_CameraCount(); i++)
{
int centroidcount = TT_CameraMarkerCount(i);
printf("Camera #%d detected centroids: %d\n", i, centroidcount);
}
TT_CameraMarker
Returns 2D location of the centroid as seen by a camera.
bool TT_CameraMarker(int cameraIndex, int markerIndex, float &x, float &y);
Description
This function saves 2D location of the centroid as detected by a camera's imager.
Returns true if the function successfully saves the x and y locations.
Function Input
Camera index (int)
Centroid index (int)
Declared variables for saving x and y (float)
Function Output
True/False (bool)
C++ Example
int cameracount = TT_CameraCount();
for (int i = 0; i < cameracount; i++)
{
float x, y;
int centroidcount = TT_CameraMarkerCount(i);
printf("Camera #%d detected centroids: %d\n", i, centroidcount);
for (int j = 0; j < centroidcount; j++)
{
TT_CameraMarker(i, j, x, y);
printf("\t#%d\t(%.2f, %.2f)\n", j, x, y);
}
}
TT_CameraPixelResolution
Saves camera's pixel resolution.
bool TT_CameraPixelResolution(int cameraIndex, int &width, int&height);
Description
This function saves camera's pixel resolutions (width x height) into declared integer variables.
Returns true when successfully saving the values.
Function Input
Camera index (int)
Declared integer variable for saving width (int)
Declared integer variable for saving height (int)
Function Output
True/False (bool)
C++ Example
//== Obtaining Camera Resolutions ==//
int width = 0;
int height = 0;
for (int i = 0; i < TT_CameraCount(); i++)
{
TT_CameraPixelResolution(i, width, height);
printf("Camera #%d Resolution:\t%d\t%d\n", i, width, height);
}
TT_CameraMarkerPredistorted
Saves predistorted 2D location of a centroid.
bool TT_CameraMarkerPredistorted(int cameraIndex, int markerIndex, float &x, float &y);
Description
This function saves predistorted 2D location of a centroid.
This data is basically where the camera would see a marker if there were no effects from lens distortions. For most of our cameras/lenses, this location is only a few pixels different from the distorted position obtained by the TT_CameraMarker function.
Returns true when successfully saving the values.
Function Input
Camera index (int)
Marker (centroid) index (int)
Declared variable for saving x location (float)
Declared variable for saving y location (float)
Function Output
True/False (bool)
C++ Example
for (int i = 0; i < TT_CameraCount(); i++)
{
float x, y, pdx, pdy;
int centroidcount = TT_CameraMarkerCount(i);
printf("Camera #%d detected centroids: %d\n", i, centroidcount);
for (int j = 0; j < centroidcount; j++)
{
TT_CameraMarker(i, j, x, y);
TT_CameraMarkerPredistorted(i, j, pdx, pdy);
printf("\t#%d\t(%.2f, %.2f)\tPredistorted:\t(%.2f, %.2f)\n", j, x, y, pdx, pdy);
}
}
TT_SetCameraSettings
Configures camera settings.
bool TT_SetCameraSettings(int cameraIndex, int videoType, int exposure, int threshold, int intensity);
Description
This function sets camera settings for a camera device specified by its index number.
Input setting parameters must agree with the supported ranges (or video types) of the camera model.
A negative return value indicates the function did not complete the task.
Each of the video types is indicated with the following integers. Supported video types may vary for different camera models. Please check the Data Recording page for more information on which image processing modes are available in different models.
Segment Mode: 0
Raw Grayscale Mode: 1
Object Mode: 2
Precision Mode: 4
MJPEG Mode: 6
Valid exposure ranges depend on the framerate settings:
Prime series and Flex 13: 1 ~ maximum time gap between the frames, which is approximately (1 / framerate) - 200 microseconds with about 200 microseconds gap for protection.
Flex3 and Duo/Trio tracking bars: 1 ~ 480 scanlines.
Valid threshold ranges: 0 - 255
Valid intensity ranges: 0 - 15
Function Input
Camera index (int)
Video type (int)
Camera exposure (int)
Pixel threshold (int)
IR light intensity (int)
For more information on the camera settings, refer to the Devices pane page.
Function Output
True/False (bool)
C++ Example
//== Changing exposure and threshold settings for all of the cameras ==//
int intensity = 10;
int exposure = 200;
int totalCamera = TT_CameraCount();
for (int i = 0; i < totalCamera; i++)
{
TT_SetCameraSettings(i, TT_CameraVideoType(i), exposure, TT_CameraThreshold(i), intensity);
printf("Camera #%d: \tIntensity: %d\t Exposure: %d\tThreshold: %d\n",
i, TT_CameraIntensity(i), TT_CameraExposure(i), TT_CameraThreshold(i));
}
TT_SetCameraFrameRate
Sets camera frame rate.
bool TT_SetCameraFrameRate(int cameraIndex, int framerate);
Description
This function sets the frame rate of a camera.
Returns true if it successfully adjusts the settings.
Note that this function may assign a frame rate setting that is out of the supported range. Check to make sure inputted frame rates are supported.
Function Input
Camera index (int)
Frame rate (int)
Function Output
True/False (bool).
C++ Example
//== Changing frame rate of all cameras ==//
int framerate = 120;
for (int i = 0; i < TT_CameraCount(); i++)
{
TT_SetCameraFrameRate(i, framerate);
printf("\t%s\tFrame Rate: %d", TT_CameraName(i), TT_CameraFrameRate(i));
}
TT_CameraFrameRate
Gets configured frame rate of a camera.
int TT_CameraFrameRate(int cameraIndex);
Description
This function returns frame rate of a camera.
Function Input
Camera index (int)
Function Output
Camera frame rate (int)
C++ Example
//== Checking camera settings ==//
int totalCamera = TT_CameraCount();
for (int i = 0; i < totalCamera; i++)
{
printf("Camera #%d:\tFPS: %d\tIntensity: %d\tExposure: %d\tThreshold: %d\n",
i, TT_CameraFrameRate(i), TT_CameraIntensity(i), TT_CameraExposure(i),
TT_CameraThreshold(i));
}
TT_CameraVideoType
Gets configured video type of a camera.
int TT_CameraVideoType(int cameraIndex);
Description
This function checks and returns configured video type (image processing mode) of a camera.
It returns an integer value which represents a video type:
#define NPVIDEOTYPE_SEGMENT 0
#define NPVIDEOTYPE_GRAYSCALE 1
#define NPVIDEOTYPE_OBJECT 2
#define NPVIDEOTYPE_PRECISION 4
#define NPVIDEOTYPE_MJPEG 6
Function Input
Camera index (int)
Function Output
Video type (int)
C++ Example
//== Checking if any of the cameras are in grayscale mode. ==//
for (int i = 0; i < TT_CameraCount(); i++)
{
int videoType = TT_CameraVideoType(i);
if (videoType == 1 || videoType == 6) {
printf("Camera #%d is in grayscale mode.\n");
}
}
TT_CameraExposure
Gets exposure setting of a camera.
int TT_CameraExposure(int cameraIndex);
Description
This function returns exposure setting of a camera.
Exposure values are measured in microseconds in Prime series and Flex 13 camera models, and they are measured in scanlines for the Duo/Trio tracking bars and Flex 3 cameras.
To change exposure setting, use the TT_SetCameraSettings function.
For more information on camera settings in Motive, read through the Devices pane page.
Function Input
Camera index (int)
Function Output
Camera exposure (int)
C++ Example
//== Checking camera settings ==//
int totalCamera = TT_CameraCount();
for (int i = 0; i < totalCamera; i++)
{
printf("Camera #%d:\tFPS: %d\tIntensity: %d\tExposure: %d\tThreshold: %d\n",
i, TT_CameraFrameRate(i), TT_CameraIntensity(i), TT_CameraExposure(i),
TT_CameraThreshold(i));
}
TT_CameraThreshold
Gets configured threshold (THR) setting of a camera.
int TT_CameraThreshold(int cameraIndex);
Description
This function returns pixel brightness threshold setting of a camera.
When processing the frames, pixels with brightness higher than the configured threshold will be processed, and pixels with lower brightness will be discarded.
To change the threshold setting, use the TT_SetCameraSettings function.
For more information on camera settings in Motive, read through the Devices pane page.
Valid range: 1 - 255.
Function Input
Camera index (int)
Function Output
Pixel brightness threshold (int)
C++ Example
//== Checking camera settings ==//
int totalCamera = TT_CameraCount();
for (int i = 0; i < totalCamera; i++)
{
printf("Camera #%d:\tFPS: %d\tIntensity: %d\tExposure: %d\tThreshold: %d\n",
i, TT_CameraFrameRate(i), TT_CameraIntensity(i), TT_CameraExposure(i),
TT_CameraThreshold(i));
}
TT_CameraIntensity
Gets configured intensity (LED) setting of a camera.
int TT_CameraIntensity(int cameraIndex);
Description
This function returns configured IR illumination intensity setting of a camera.
To change the intensity setting, use the TT_SetCameraSettings function.
For more information on camera settings in Motive, read through the Devices pane page.
Valid range: 1 - 15.
Function Input
Camera index (int)
Function Output
Camera IR intensity (int)
C++ Example
//== Checking camera settings ==//
int totalCamera = TT_CameraCount();
for (int i = 0; i < totalCamera; i++)
{
printf("Camera #%d:\tFPS: %d\tIntensity: %d\tExposure: %d\tThreshold: %d\n",
i, TT_CameraFrameRate(i), TT_CameraIntensity(i), TT_CameraExposure(i),
TT_CameraThreshold(i));
}
TT_CameraTemperature
Measures image board temperature of a camera.
float TT_CameraTemperature(int cameraIndex);
Description
This function returns temperature (in celsius) of a camera's image board.
Temperature sensors are featured only in Prime series camera models.
Function Input
Camera index (int)
Function Output
Image board temperature (float)
C++ Example
//== Temperature settings ==//
for (int i = 0; i < TT_CameraCount(); i++)
{
printf("Camera #%d:\n",i);
printf("\tImage Board Temperature: %.2f\n", TT_CameraTemperature(i));
printf("\tIR Board Temperature: %.2f\n", TT_CameraRinglightTemperature(i));
printf("\n");
}
TT_CameraRinglightTemperature
Measures IR LED board temperature of a camera.
float TT_CameraRinglightTemperature(int cameraIndex);
Description
This function returns temperature (in celsius) of a camera's IR LED board.
Temperature sensors are featured only in Prime series camera models.
Function Input
Camera index (int)
Function Output
IR LED board temperature (float)
C++ Example
//== Temperature settings ==//
for (int i = 0; i < TT_CameraCount(); i++)
{
printf("Camera #%d:\n",i);
printf("\tImage Board Temperature: %.2f\n", TT_CameraTemperature(i));
printf("\tIR Board Temperature: %.2f\n", TT_CameraRinglightTemperature(i));
printf("\n");
}
TT_CameraGrayscaleDecimation
Gets configured grayscale image frame rate decimation ratio of a camera.
int TT_CameraGrayscaleDecimation(int cameraIndex);
Description
This feature is available only in Flex 3 and Trio/Duo tracking bars, and it has been deprecated for other camera models.
This function returns grayscale frame rate decimation ratio of a camera.
Valid decimation ratios are 0, 2, 4, 8. (e.g. When the decimation setting is set to 4, a camera will capture one grayscale frame for four frames of the tracking data)
To set the decimation ratio, use the TT_SetCameraGrayscaleDecimation function.
Grayscale images require more load on data processing. For this reason, you may want to decimate the grayscale frame images and capture the frames at a lower frame rate.
Function Input
Camera index (int)
Function Output
Decimation ratio (int)
C++ Example
//== Checking grayscale decimation ==//
for (int i = 0; i < TT_CameraCount(); i++)
{
if (TT_CameraVideoType(i) == 1 ||TT_CameraVideoType(i) == 6)
{
printf("Camera #%d grayscale video frame decimation: %d\n",
i, TT_CameraGrayscaleDecimation(i));
}
}
TT_SetCameraGrayscaleDecimation
Sets frame rate decimation ratio for processing grayscale images.
bool TT_SetCameraGrayscaleDecimation(int cameraIndex, int value);
Description
This feature is available only in Flex 3 and Trio/Duo tracking bars, and it has been deprecated for other camera models.
This functions sets the frame decimation ratio for processing grayscale images in a camera.
Depending on the decimation ratio, a fewer number of grayscale frames will be captured. This can be beneficial when reducing the processing loads.
Supported decimation ratios: 0, 2, 4, 6, 8. (e.g. When the decimation setting is set to 4, a camera will capture one grayscale frame for 4 frames of the tracking data)
Returns true when it successfully sets the decimation value
Function Input
Camera index (int)
Decimation value (int)
Function Output
True/False (bool)
C++ Example
//== Introducing frame decimation to reference cameras ==//
for (int i = 0; i < TT_CameraCount(); i++)
{
if (TT_CameraVideoType(i) == 1 ||TT_CameraVideoType(i) == 6)
{
TT_SetCameraGrayscaleDecimation(i, 2);
printf("Camera #%d grayscale video frame decimation: %d\n",
i, TT_CameraGrayscaleDecimation(i));
}
}
TT_SetCameraFilterSwitch
Enables or disables IR filter switch of a camera.
bool TT_SetCameraFilterSwitch(int cameraIndex, bool enableIRFilter);
Description
This function enables, or disables, integrated camera filter switch for detecting IR lights.
Different camera models may have different filter switches. Refer to the camera model specifications for detailed information on the type and allowed wavelengths for the filter switch.
Returns true when it successfully enables/disables the filter switch.
Function Input
Camera index (int)
A boolean argument for enabling (true) or disabling (false) the filter.
Function Output
True/False (bool)
C++ Example
//== Setting Camera Filter Switch ==//
int totalCamera = TT_CameraCount();
for (int i = 0; i < totalCamera; i++) {
if (TT_SetCameraFilterSwitch(i, true))
{
printf("Camera #%d filter switch enabled\n", i);
}
}
TT_SetCameraAGC
Enables and disables automatic gain control.
bool TT_SetCameraAGC(int cameraIndex, bool enableIRFilter);
Description
This function enables/disables automatic gain control (AGC).
Automatic Gain Control feature adjusts the camera gain level automatically for best tracking.
AGC is only available in Flex 3's and Duo/Trio tracking bars.
Returns true when the operation was done successfully.
Function Input
Camera index (int)
Enabled (true) / disabled (false) status (bool)
Function Output
True/False (bool)
C++ Example
//== Setting the Automatic Exposure Control ==//
int totalCamera = TT_CameraCount();
for(int i = 0; i < totalCamera; i++)
{
if(TT_SetCameraAGC(i, true))
{
printf("Camera #%d AGC enabled");
}
else
{
printf("AGC not set properly. Check if this is supported.");
}
}
TT_SetCameraAEC
Enables or disables automatic exposure control.
bool TT_SetCameraAEC(int cameraIndex, bool enabeledAutomaticExposureControl);
Description
This function enables, or disables, Automatic Exposure Control (AEC) for featured camera models.
This feature is only available in Flex 3 and Duo/Trio tracking bars.
It allows cameras to automatically adjust its exposure setting by looking at the properties of the incoming frames.
Returns true if the operation was successful.
Function Input
Camera index (int)
A boolean argument for enabling (true) or disabling (false) the filter.
Function Output
True/false (bool)
C++ Example
//== Setting the Automatic Exposure Control ==//
int totalCamera = TT_CameraCount();
for(int i = 0; i < totalCamera; i++)
{
if(TT_SetCameraAEC(i, true))
{
printf("Camera #%d AEC enabled");
}
else
{
printf("AEC not set properly. Check if this is supported.");
}
}
TT_SetCameraHighPower
Enables or disables the high power IR illumination mode.
bool TT_SetCameraHighPower(int cameraIndex, bool enableHighPowerMode);
Description
This function enables or disables, the high power mode for featured cameras.
The high power mode allows brighter IR LED illumination using more power source.
Returns true if the function successfully enables/disables the feature.
Function Input
Camera index (int)
A boolean argument for enabling (true) or disabling (false) the filter.
Function Output
True/False (bool)
C++ Example
//== Enabling high power mode ==//
int totalCamera = TT_CameraCount();
for (int i = 0; i < totalCamera; i++)
{
TT_SetCameraHighPower(i, true);
}
TT_SetCameraMJPEGHighQuality
Sets compression quality of MJPEG images.
bool TT_SetCameraMJPEGHighQuality(int cameraIndex, int mjpegquality);
Description
This function sets the quality of MJPEG images captured by a camera. More specifically, it changes the compression quality of MJPEG frames.
Compression quality is indicated by an integer number between 0 - 100 (no loss).
Lower MJPEG compression quality setting can reduce the processing load for the cameras and reduce latency, but doing so will result in low-quality images.
Returns true when the function successfully enables or disables, the mode.
Function Input
Camera index (int)
MJPEG compression quality (int)
Function Output
True/false (bool)
C++ Example
//== Adjusting MJPEG compression quality to 10==//
int totalCamera = TT_CameraCount();
for (int i = 0; i < TT_CameraCount(); i++) {
if (TT_CameraVideoType(i) == 6)
{
//== For cameras in MJPEG mode ==//
if (TT_SetCameraMJPEGHighQuality(i, 10))
{
printf("Camera Set to Low MJPEG Quality\n");
}
}
}
TT_CameraImagerGain
Gets configured imager gain setting of a camera.
int TT_CameraImagerGain(int cameraIndex);
Description
This function is used to check the imager gain setting of a camera.
It returns configured gain setting as an integer value.
Function Input
Camera index (int)
Function Output
Gain setting (int)
C++ Example
//==
for (int i = 0; i < TT_CameraCount(); i++)
{
printf("Camera #%d gain setting: %d\n",i, TT_CameraImagerGain(i));
}
TT_CameraImagerGainLevels
Gets total number of gain levels available in a camera.
int TT_CameraImagerGainLevels(int cameraIndex);
Description
This function returns a total number of available gain levels in a camera.
Different camera models may have different gain level settings. This function can be used to check the number of available gain levels.
Function Input
Camera index (int)
Function Output
Number of gain levels available (int)
C++ Example
//== Checking number of gain levels ==//
for (int i = 0; i < TT_CameraCount(); i++)
{
printf("%s camera has %d gain levels\n", TT_CameraName(i),TT_CameraImagerGainLevels(i));
}
TT_SetCameraImagerGain
Sets the imager gain level.
void TT_SetCameraImagerGain(int cameraIndex);
Description
This function sets the gain level of a camera's imager.
Using high gain levels may be beneficial for long range tracking. However, note that increasing gain levels may also result in amplified noise signal, which can result in false reconstructions.
Check available gain levels for the camera model using the TT_CameraImagerGainLevels function.
Function Input
Camera index (int)
Function Output
Void
C++ Example
//== Setting the imager gain level to medium ==//
for (int i = 0; i < TT_CameraCount(); i++)
{
int availableGain = TT_CameraImagerGainLevels(i);
int mediumGain = availableGain / 2;
TT_SetCameraImagerGain(i, mediumGain);
printf("%s camera's gain level set to %d (medium)\n", TT_CameraName(i), mediumGain);
}
TT_IsContinuousIRAvailable
Checks if the continuous IR mode is supported.
bool TT_IsContinuousIRAvailalbe(int cameraIndex);
Description
This function checks whether the continuous IR illumination mode is available in the camera model.
In the continuous IR mode, the IR LEDs will not strobe but will illuminate continuously instead.
Continuous IR modes are available only in the Flex 3 camera model and the Duo/Trio tracking bars.
Returns true if continuous IR mode is available.
Function Input
Camera index (int)
Function Output
True / False (bool)
C++ Example
//== Configuring Continuous IR ==//
int totalCamera = TT_CameraCount();
for (int i = 0; i < totalCamera; i++)
{
//== Checking if the mode is available ==//
if (TT_IsContinuousIRAvailable(i))
{
if (TT_ContinuousIR(i))
{
printf("Coninuous IR enabled already\n");
}
else
{
printf("Enabling continuous IR\n");
TT_SetContinuousIR(i, true);
}
}
else
{
printf("Continuous IR is not available\n");
}
}
TT_ContinuousIR
Checks if the continuous IR mode is enabled.
bool TT_ContinuousIR(int cameraIndex);
Description
This function checks if the continuous IR mode is enabled or disabled in a camera.
Returns true if the continuous IR mode is already enabled.
Function Input
Camera index (int)
Function Output
True / False (bool)
C++ Example
int totalCamera = TT_CameraCount();
//== Configuring Continuous IR ==//
for (int i = 0; i < totalCamera; i++)
{
if (TT_IsContinuousIRAvailable(i))
{
//== Checking if already enabled ==//
if (TT_ContinuousIR(i))
{
printf("Coninuous IR enabled already\n");
}
else
{
printf("Enabling continuous IR\n");
TT_SetContinuousIR(i, true);
}
}
else
{
printf("Continuous IR is not available\n");
}
}
TT_SetContinuousIR
Enables/disables continuous IR.
void TT_SetContinuousIR(int cameraIndex, bool enable);
Description
This function enables, or disables, continuous IR illumination in a camera.
Continuous IR mode outputs less light when compared to Strobed (non-continuous) illumination, but this mode could be beneficial in situations where there are extraneous IR reflections in the volume.
Use TT_IsContinuousIRAvailable function to check whether if this mode is supported.
Function Input
Camera index (int)
A boolean argument for enabling (true) or disabling (false)
Function Output
Void
C++ Example
int totalCamera = TT_CameraCount();
//== Configuring Continuous IR ==//
for (int i = 0; i < totalCamera; i++)
{
if (TT_IsContinuousIRAvailable(i))
{
//== Checking if already enabled ==//
if (TT_ContinuousIR(i))
{
printf("Coninuous IR enabled already\n");
}
else
{
printf("Enabling continuous IR\n");
TT_SetContinuousIR(i, true);
}
}
else
{
printf("Continuous IR is not available\n");
}
}
TT_ClearCameraMask
Clears masking from camera's 2D view.
bool TT_ClearCameraMask(int cameraIndex);
Description
This function clears existing masks from the 2D camera view.
Returns true when it successfully removes pixel masks.
Function Input
Camera index (int)
Function Output
True / False (bool)
C++ Example
//== Clearing existing masks for all cameras ==//
int totalCamera = TT_CameraCount();
for (int i = 0; i < totalCamera; i++)
{
TT_ClearCameraMask(i);
}
TT_SetCameraMask
bool TT_SetCameraMask( int cameraIndex, unsigned char* buffer, int bufferSize );
Description
This function allows a user-defined image mask to be applied to a camera.
A mask is an array of bytes, one byte per mask pixel block.
Returns true when masks are applied.
Function Input
Camera index (int)
Buffer
BufferSize
Function Output
True / False (bool)
C++ Example
unsigned char* maskBuffer = nullptr;
int bufferSize = 0;
int cameraCount = TT_CameraCount();
// Retrieve the mask for each camera, perform a simple edit on it, then set it.
for( int i = 0; i < cameraCount; ++i )
{
int maskWidth;
int maskHeight;
int maskGrid;
// Mask dimensions for the camera.
TT_CameraMaskInfo( i, maskWidth, maskHeight, maskGrid );
int newBufferSize = maskWidth * maskHeight;
if( bufferSize < newBufferSize )
{
delete[] maskBuffer;
maskBuffer = new unsigned char[newBufferSize];
bufferSize = newBufferSize;
}
// Retrieve the mask now that the receiving buffer is correctly sized.
TT_CameraMask( i, maskBuffer, bufferSize );
// Add a mask 'pixel' in the approximate center of the image.
// Each pixel is actually a grid of maskGrid size.
int pixelIndex = ( maskHeight / 2 ) * maskWidth + ( maskWidth / 2 );
maskBuffer[pixelIndex] = 1; // Any non-zero value for the byte will do.
// Set the mask image on the camera.
TT_SetCameraMask( i, maskBuffer, bufferSize );
}
TT_CameraMask
bool TT_CameraMask(int cameraIndex, unsigned char * buffer, int bufferSize);
Description
This function returns memory block of the mask.
One bit per a pixel of the mask.
Masking pixels are rasterized from left to right and from top to bottom of the camera's view.
Function Input
Camera index (int)
Buffer
Buffer size
Function Output
True / False (bool)
C++ Example
unsigned char* maskBuffer = nullptr;
int bufferSize = 0;
int cameraCount = TT_CameraCount();
// Retrieve the mask for each camera, perform a simple edit on it, then set it.
for( int i = 0; i < cameraCount; ++i )
{
int maskWidth;
int maskHeight;
int maskGrid;
// Mask dimensions for the camera.
TT_CameraMaskInfo( i, maskWidth, maskHeight, maskGrid );
int newBufferSize = maskWidth * maskHeight;
if( bufferSize < newBufferSize )
{
delete[] maskBuffer;
maskBuffer = new unsigned char[newBufferSize];
bufferSize = newBufferSize;
}
// Retrieve the mask now that the receiving buffer is correctly sized.
TT_CameraMask( i, maskBuffer, bufferSize );
// Add a mask 'pixel' in the approximate center of the image.
// Each pixel is actually a grid of maskGrid size.
int pixelIndex = ( maskHeight / 2 ) * maskWidth + ( maskWidth / 2 );
maskBuffer[pixelIndex] = 1; // Any non-zero value for the byte will do.
// Set the mask image on the camera.
TT_SetCameraMask( i, maskBuffer, bufferSize );
}
TT_CameraMaskInfo
bool TT_CameraMaskInfo(int cameraIndex, int &blockingMaskWidth, int &blockingMaskHeight, int &blockingMaskGrid);
Description
This function retrieves the width, height, and grid size of the mask for the camera at the given index.
One byte per pixel of the mask. Masking width * masking height gives the required size of the buffer.
Returns true when the information is successfully obtained and saved.
Function Input
Camera index (int)
Declared variables:
Masking width (int)
Masking height (int)
Masking grid (int)
Function Output
True / False (bool)
C++ Example
unsigned char* maskBuffer = nullptr;
int bufferSize = 0;
int cameraCount = TT_CameraCount();
// Retrieve the mask for each camera, perform a simple edit on it, then set it.
for( int i = 0; i < cameraCount; ++i )
{
int maskWidth;
int maskHeight;
int maskGrid;
// Mask dimensions for the camera.
TT_CameraMaskInfo( i, maskWidth, maskHeight, maskGrid );
int newBufferSize = maskWidth * maskHeight;
if( bufferSize < newBufferSize )
{
delete[] maskBuffer;
maskBuffer = new unsigned char[newBufferSize];
bufferSize = newBufferSize;
}
// Retrieve the mask now that the receiving buffer is correctly sized.
TT_CameraMask( i, maskBuffer, bufferSize );
// Add a mask 'pixel' in the approximate center of the image.
// Each pixel is actually a grid of maskGrid size.
int pixelIndex = ( maskHeight / 2 ) * maskWidth + ( maskWidth / 2 );
maskBuffer[pixelIndex] = 1; // Any non-zero value for the byte will do.
// Set the mask image on the camera.
TT_SetCameraMask( i, maskBuffer, bufferSize );
}
TT_AutoMaskAllCameras
void TT_AutoMaskAllCameras();
Description
Auto-mask all cameras.
This is additive to any existing masking.
To clear masks on a camera, call TT_ClearCameraMask prior to auto-masking.
Function Input
none
Function Output
Auto masks all cameras
C++ Example
TT_SetCameraState
Sets camera state of a camera.
bool TT_SetCameraState(int cameraIndex, eCameraStates state);
Description
This function configures camera state of a camera. Different camera states are defined in the eCameraStates enumeration.
Returns true when it successfully sets the camera state.
enum eCameraStates
{
Camera_Enabled = 0,
Camera_Disabled_For_Reconstruction = 1,
Camera_Disabled = 2,
CameraStatesCount = 3
};
Function Input
Camera index (int)
Camera state (eCameraStates)
Function Output
True / False (bool)
C++ Example
int totalCamera = TT_CameraCount();
//== Disabling all of the cameras from contributing to reconstruction ==//
for (int i = 0; i < totalCamera; i++)
{
TT_SetCameraState(i, Camera_Enabled);
}
TT_CameraState
Checks camera states.
bool TT_CameraState(int cameraIndex, eCameraStates cameraState);
Camera_Enabled
0
Camera_Disabled_For_Reconstruction
1
Camera_Disabled
2
CameraStatesCount
3
Description
This function obtains and saves the camera state of a camera onto the declared variables.
Returns true if it successfully saves configured state.
Function Input
Camera index (int)
Declared variable for camera state (eCameraState)
Function Output
True / False (bool)
C++ Example
//== Checking Camera Status ==//
int totalCamera = TT_CameraCount();
eCameraStates cameraState;
for (int i = 0; i < totalCamera; i++)
{
//== Checking the Camera Status ==//
TT_CameraState(i, cameraState);
if (cameraState == 0) {
printf("Camera #%d State: Camera_Enabled\n", i);
}
else if (cameraState == 1)
{
printf("Camera #%d State: Camera_Disabled_For_Reconstruction\n",i );
}
else if (cameraState == 2)
{
printf("Camera #%d State: Camera_Disabled\n", i);
}
else if (cameraState == 3)
{
printf("Camera #%d State: CameraStatesCount\n", i);
}
}
TT_CameraID
Returns the Camera ID.
int TT_CameraID(int cameraIndex);
Description
This function takes in a camera index number and returns the camera ID number.
Camera ID numbers are the numbers that get displayed on the devices.
The Camera ID number is different from the camera index number. On Prime camera systems, Camera IDs are assigned depending on where the cameras are positioned within the calibrated volume. On Flex camera systems, Camera IDs are assigned according to the order in which devices connected to the OptiHub(s).
Function Input
Camera index (int)
Function Output
Camera ID (int)
C++ Example
int totalCamera = TT_CameraCount();
for(int i = 0; i < totalCamera; i++){
// Listing Camera Name, index, and ID
printf("Camera %s:\tIndex:%d\tID:%d\n", TT_CameraName(i), i, TT_CameraID(i));
}
TT_CameraFrameBuffer
Fills a buffer with image from camera's view.
bool TT_CameraFrameBuffer(int cameraIndex, int bufferPixelWidth, int bufferPixelHeight,
int bufferByteSpan, int bufferPixelBitDepth, unsigned char *buffer);
Description
This function fetches raw pixels from a single frame of a camera and fills the provided memory block with the frame buffer.
The resulting image depends on what video mode the camera is in. For example, if the camera is in grayscale mode, a grayscale image will be saved from this function call.
For obtaining buffer pixel width and height, you can use TT_CameraPixelResolution function to obtain respective camera resolution.
Byte span: Byte span is the number of bytes for each row of the frame. In a case of 8-bit pixel images (one byte per pixel), the number of pixels in the frame width will equal to the byte size of the span.
Buffer pixel bit depth: Pixel bit size for the image buffer that will be stored in the memory. If the imagers on the OptiTrack cameras capture 8-bit grayscale pixels, you will need to input 8 for this input.
Buffer: make sure enough memory is allocated for the frame buffer. A frame buffer will require memory of at least (Byte span * pixel height * Bytes per pixel) bytes. For example, on a 640 x 480 image with 8-bit black and white pixels, you will need (640 * 480 * 1) bytes allocated for the frame buffer.
Returns true if it successfully saves the image in the buffer.
Function Input
Camera index (int)
Buffer pixel width (int)
Buffer pixel height (int)
Buffer byte span (int)
Buffer pixel bit depth (int)
Buffer address (unsigned char*)
Function Output
True / False (bool)
C++ Example
// Sample code for saving frame buffer from a camera (index 0)
int cameraIndex = 0;
int reswidth;
int resheight;
int bytespan;
// Obtaining pixel resolution
TT_CameraPixelResolution(cameraIndex, reswidth, resheight);
printf("Camera #%d:\tWidth:%d\tHeight:%d\n", i, reswidth, resheight);
// Defining span size of the buffer
bytespan = reswidth;
// Allocating memory block for the buffer
unsigned char* frameBuffer = (unsigned char*)std::malloc(bytespan*resheight*1);
bool result = TT_CameraFrameBuffer(cameraIndex, reswidth, resheight, bytespan, 8, frameBuffer);
if (result == true)
{
printf("Frame Buffer Saved.");
}
TT_CameraFrameBufferSaveAsBMP
Saves image buffer of a camera into a BMP file.
bool TT_CameraFrameBufferSaveAsBMP(int cameraIndex, const char* filename);
Description
This function saves image frame buffer of a camera into a BMP file.
Video type of the saved image depends on configured camera settings
Attach *.bmp at the end of the filename.
Returns true if it successfully saves the file.
Function Input
Camera index (int)
Filename (const char*)
Function Output
True / False (bool)
C++ Example
int cameraCount = TT_CameraCount();
std::vector<std::string> filenames(cameraCount);
for (int i = 0; i < cameraCount; ++i)
{
filenames[i] = "camera" + std::to_string(i) + ".bmp";
TT_CameraFrameBufferSaveAsBMP(i, filenames[i].c_str());
}
TT_CameraBackproject
Obtains 2D position, of a 3D marker as seen by one of the cameras.
void TT_CameraBackProject(int cameraIndex, float x, float y, float z, float &cameraX, float &cameraY);
Description
This function reverts 3D data into 2D data. If you input a 3D location (in meters) and a camera, it will return where the point would be seen from the 2D view of the camera (in pixels) using the calibration information. In other words, it locates where in the camera's FOV a point would be located.
If a 3D marker is reconstructed outside of the camera's FOV, saved 2D location may be beyond the camera resolution range.
Respective 2D location is saved in the declared X-Y address, in pixels.
Function Input
Camera index (int)
3D x-position (float)
3D y-position (float)
3D z-position (float)
Declared variable for x and y location from camera's 2D view (float)
Function Output
Void
C++ Example
//== All 2D locations of reconstructed markers seen by camera 1 ==//
int targetcam = 0;
for (int i = 0; i < TT_FrameMarkerCount(); i++)
{
float markerX = TT_FrameMarkerX(i);
float markerY = TT_FrameMarkerY(i);
float markerZ = TT_FrameMarkerZ(i);
float cam2dx;
float cam2dy;
TT_CameraBackproject(targetcam, markerX, markerY, markerZ, cam2dx, cam2dy);
}
TT_CameraUndistort2DPoint
Removes lens distortion.
void TT_CameraUndistort2DPoint(int cameraIndex, float &x, float &y);
Description
This function removes the effect of the lens distortion filter and obtains undistorted raw x and y coordinates (as seen by the camera) and saves in the declared variables.
Lens distortion is measured during the camera calibration process.
If you want to apply the lens distortion filter back again, you can use the TT_CameraDistort2DPoint.
Function Input
Camera index (int)
Declared variables for x and y position in respect to camera's view (float)
Function Ouput
Void
C++ Example
// Reflection detected at (125, 213) from 2D view of a camera 1.
int x = 125;
int y = 213;
int cameraIndex = 1;
// Saving raw, undistorted, coordinates as seen by the imager
TT_CameraUndistort2DPoint(cameraIndex, x, y);
TT_CameraDistort2DPoint
Reapplies lens distortion model.
void TT_CameraDistort2DPoint(int cameraIndex, float &x, float &y);
Description
This function restores the effect of default model for accommodating effects of the camera lens.
Note all reported 2D coordinates are already distorted to accommodate for effects of the camera lens. Apply this function to coordinates that are undistorted by using the TT_CameraUndistort2DPoint function.
This can be used to obtain raw data for 2D points that have been undistorted using the TT_CameraUndistort2DPoint function.
Function Input
Camera index (int)
Declared variables for x and y position in respect to camera's view (float)
Function Input
Void
C++ Example
// Reflection detected at (125, 213) from 2D view of a camera 1.
int x = 125;
int y = 213;
int cameraIndex = 1;
// Saving raw, undistorted, coordinates as seen by the imager.
TT_CameraUndistort2DPoint(cameraIndex, x, y);
// Process undistorted x y coordinates..
// Apply the distortion back again
TT_CameraDistort2DPoint(cameraIndex, x, y);
TT_CameraRay
Obtains 3D vector from a camera to a 3D point.
bool TT_CameraRay(int cameraIndex, float x, float y,
float &rayStartX, float &rayStartY, float &rayStartZ,
float &rayEndX, float &rayEndY, float &rayEndX);
Description
This function takes in an undistorted 2D centroid location seen by a camera's imager and creates a 3D vector ray connecting the point and the camera.
Use TT_CameraUndistort2DPoint to undistort the 2D location before obtaining the 3D vector.
XYZ locations of both the start point and end point are saved into the referenced variables.
Returns true when it successfully saves the ray vector components.
Function Input
Camera index (int)
x location, in pixels, of a centroid (float)
y location, in pixels, of a centroid (float)
Three reference variables for X/Y/Z location, in meters, of the start point (float)
Three reference variables for X/Y/Z location, in meters, of the end point (float)
Function Output
True / False (bool)
C++ Example
//== Obtaining a 3D vector for centroid detected at (100, 300) on a camera's 2D imager ==//
int targetcam = 0;
float rayStartX, rayStartY, rayStartZ; //meters
float rayEndX, rayEndY, rayEndZ; //meters
float x = 100; //pixels
float y = 300; //pixels
TT_CameraUndistort2DPoint(targetcam, x, y);
TT_CameraRay(targetcam, x, y, rayStartX, rayStartY, rayStartZ, rayEndX, rayEndY, rayEndZ);
TT_CameraModel
Gets camera parameters for the OpenCV intrinsic model.
bool TT_CameraModel(int cameraIndex, float x, float y, float z, float* orientation,
float principleX, float principleY, float focalLengthX, float focalLengthY,
float kc1, float kc2, float kc3, float tangential10, float tangential1);
Description
This function sets camera's extrinsic (position & orientation) and intrinsic (lens distortion) parameters with values compatible with the OpenCV intrinsic model.
For retaining the extrinsic parameters, you can use the TT_CameraXLocation, TT_CameraYLocation, TT_CameraZLocation, and TT_CameraOrientationMatrix functions.
Returns true if the operation was successful.
Function Input
Camera index (int)
Three arguments for camera x,y,z-position, in mm, within the global space (float)
Camera orientation (float)
Lens center location, principleX and principleY, in pixels (float)
Lens focal length, in pixels. (float)
Barrel distortion coefficients: kc1, kc2, kc3 (float)
Tangential distortion (float)
Function Output
True / False (bool)
C++ Example
int index = 0;
//Get the position and orientation of the camera using so it can be retained
float x = TT_CameraXLocation(index);
float y = TT_CameraYLocation(index);
float z = TT_CameraZLocation(index);
float pose(9);
for (int i = 0; i < 9; ++i)
{
pose[i] = TT_CameraOrientationMatrix(index, i);
}
//Manually modify intrinsic values according to OpenCV model
float px = 0.0;
float py = 0.0;
float fx = 100.0;
float fy = 100.0;
float kc1 = 0.1;
float kc2 = 0.1;
float kc3 = 0.1;
float t1 = 0.1;
float t2 = 0.1;
bool result = TT_CameraModel(index, x, y, z,
pose, px, py, fx, fy
kc1, kc2, kc3, t1, t2);
TT_GetCamera
Gets pointer to the camera object from Camera SDK.
CameraLibrary::Camera* TT_GetCamera(int cameraIndex);
Description
This function returns a pointer to the Camera SDK's camera pointer.
While the API takes over the data path which prohibits fetching the frames directly from the camera, it is still very useful to be able to communicate with the camera directly for setting camera settings or attaching modules.
The Camera SDK must be installed to use this function.
Camera SDK libraries and the camera library header file (cameralibrary.h) must be included.
Returns Camera SDK Camera.
Function Input
Camera index (int)
Function Output
Camera SDK camera pointer (CameraLibrary::Camera*)
C++ Example
CameraLibrary::Camera *cam = TT_GetCameraManager();
// cam is declared as a pointer to a camera object used in conjuction with the Camera SDK
Additional Features
TT_OrientTrackingBar
Changes position and orientation of the tracking bars.
NPRESULT TT_OrientTrackingBar(float positionX, float positionY, float positionZ,
float orientationX, float orientationY, float orientationZ,
float orientationW);
Description
This function makes changes to the position and orientation of the tracking bar within the global space.
Note that this function will shift or rotate the entire global space, and the effects will be reflected in other tracking data as well.
By default, center location and orientation of a Tracking bar (Duo/Trio) determines the origin of the global coordinate system. Using this function, you can set a Tracking Bar to be placed in a different location within the global space instead of origin.
Function Input
X position (float)
Y position (float)
Z position (float)
Quaternion orientation X (float)
Quaternion orientation Y (float)
Quaternion orientation Z (float)
Quaternion orientation W (float)
Function Output
NPRESULT
C++ Example
//== Changing position and orientation of a tracking bar within the global space. ==//
TT_OrientTrackingBar(10, 10, 10, 0.5, 0.5, 0.5, 0.5);
TT_AttachCameraModule / TT_DetachCameraModule
Attaches/detaches cCameraModule instance to a camera object.
void TT_AttachCameraModule(int cameraindex, CameraLibrary::cCameraModule *module);
void TT_DetachCameraModule(int cameraIndex, CameraLibrary::cCameraModule *module);
Description
This function attaches/detaches the cCameraModule class to a camera defined by its index number.
This function requires the project to be compiled against both the Motive API and the Camera SDK.
The cCameraModule class is inherited from the Camera SDK, and this class is used to inspect raw 2D data from a camera. Use this function to attach the module to a camera. For more details on the cCameraModule class, refer to the cameramodulebase.h header file from the Camera SDK.
The Camera SDK must be installed.
Function Input
Camera index (int)
cCameraModule instance (CameraLibrary::cCameraModule)
Function Output
Void
C++ Example
int main(){
//...
//Creating and attaching camera module
myCameraModule *module;
int cameraIndex = 0;
TT_AttachCameraModule(cameraIndex, module);
//...
TT_DetachCameraModule(cameraIndex, module);
}
// Compile the project against the Camera SDK
class myCameraModule : public cCameraModule
{
//..override functions implementations here
};
TT_AttachRigidBodySolutionTest / TT_DetachRigidBodySolutionTest
Attaches/detaches cRigidBodySolutionTest class to a Rigid Body.
void TT_AttachRigidBodySolutionTest(int rbIndex, cRigidBodySolutionTest* test);
void TT_DetachRigidBodySolutionTest(int rbIndex, cRigidBodySolutionTest* test);
Description
This function attaches/detaches the cRigidBodySolutionTest class onto a Rigid Body.
Once an instance of cRigidBodySolutionTest to a Rigid Body, it will evaluate the Rigid Body solution and return false if the solution does not qualify the provided condition.
The cRigidBodySolutionTest class uses the C++ inheritance design model. Inherit this class into your project with same function and class names, then attach the inherited class.
Function Input
Rigid body index (int)
Rigid body test module (cRigidBodySolutionTest*)
Function Output
Void
C++ Example
int main(){
// Create a Rigid Body solution test
// and attach onto a Rigid Body
mySolutionTest *test;
int rbIndex = 0;
TT_AttachRigidBodySolutionTest(rbIndex, test);
//...
TT_DetachRigidBodySolutionTest(rbIndex, test);
}
// Create a mySolutionTest class that handles the callback.
class mySolutionTest : public cRigidBodySolutionTest
{
public:
bool RigidBodySolutionTest(int markerCount, Core::cMarker *markers, bool *markerExists)
{
//Modify criteria for a successful Rigid Body solution.
}
};
TT_AttachListener / TT_DetachListener
Attaches/detaches cTTAPIListener onto a TTAPI project.
void TT_AttachListener(cTTAPIListener* listener);
void TT_DetachListener(cTTAPIListener* listener);
Description
This function attaches/detaches a cTTAPIListener inherited class onto a TTAPI project.
The cTTAPIListener class uses the C++ inheritance design model. Inherit this class into your project with the same function and class names, then attach the inherited class.
This listener class includes useful callback functions that can be overrided. Including TTAPIFrameAvailable, TTAPICameraConnected, TTAPICameraDisconnected, InitialPointCloud, ApplyContinuousCalibrationResult.
Function Input
cTTAPIListener
Function Output
Void
C++ Example
int main()
{
//...
//Within the main, attach the Listener
myListener listener;
TT_AttachListener(&listener);
//...
TT_DetachListener(&listener);
}
// Create a new listener class that inherites from the cTTAPIListner class to handle the callback.
class myListener : public cTTAPIListener
{
public:
//overriding TTAPIFrameAvailable function from the cTTAPIListener class
virtual void TTAPIFrameAvailable() override
{
// When the Listener is attached.
// This function will be executed each time a new frame is available.
// Process frame
}
};
TT_GetResultString
Returns plain text message that corresponds to a NPRESULT value.
const char* TT_GetResultString(NPRESULT result);
Description
Returns plain text message that corresponds to a result that a NPRESULT value indicates.
Function Input
NPRESULT
Function Output
Result text (const char)
C++ Example
//== Sample Check Result Function (marker.cpp) ==//
void CheckResult( NPRESULT result )
{
if( result!= NPRESULT_SUCCESS)
{
//== Treat all errors as failure conditions. ==//
printf( "Error: %s\n\n(Press any key to continue)\n", TT_GetResultString(result) );
Sleep(20);
exit(1);
}
}
TT_TestSoftwareMutex
Checks whether there is another OptiTrack software using the devices.
NPRESULT TT_TestSoftwareMutex();
Description
Checks whether there is another OptiTrack software using the devices. Only one software should be occupying the devices at a time.
Function Input
None
Function Output
NPRESULT
Last updated
Was this helpful?