Main Page → Developer Tools → Motive API → Function Reference
Project Management
TT_Initialize
TT_Shutdown
TT_Update
TT_UpdateSingleFrame
TT_LoadCalibrationW
TT_LoadCalibration
TT_LoadRigidBodiesW
TT_LoadRigidBodies
TT_SaveRigidBodiesW
TT_SaveRigidBodies
TT_AddRigidBodiesW
TT_AddRigidBodies
TT_LoadProfileW
TT_LoadProfile
TT_SaveProfileW
TT_SaveProfile
TT_LoadProjectW
TT_LoadProject
TT_SaveProjectW
TT_SaveProject
TT_LoadCalibrationFromMemory
Data Streaming
TT_StreamNP
TT_StreamTrackd
TT_StreamVRPN
3D Frame Data
TT_FrameMarkerCount
TT_FrameMarkerX
TT_FrameMarkerY
TT_FrameMarkerZ
TT_FrameMarkerLabel
TT_FrameMarkerResidual
TT_FrameTimeStamp
TT_FrameCameraCentroid
TT_FlushCameraQueues
Rigid Bodies
TT_IsRigidBodyTracked
TT_RigidBodyLocation
TT_ClearRigidBodyList
TT_RemoveRigidBody
TT_RigidBodyCount
TT_RigidBodyUserData
TT_SetRigidBodyUserData
TT_RigidBodyName
TT_RigidBodyNameW
TT_SetRigidBodyEnabled
TT_RigidBodyEnabled
TT_RigidBodyTranslatePivot
TT_RigidBodyResetOrientation
TT_RigidBodyMarkerCount
TT_RigidBodyMarker
TT_RigidBodyUpdateMarker
TT_RigidBodyPointCloudMarker
TT_RigidBodyPlacedMarker
TT_RigidBodyID
TT_CreateRigidBody
TT_RigidBodySettings
TT_SetRigidBodySettings
Camera Group
TT_GetCameraManager
TT_BuildNumber
TT_CameraGroupCount
TT_CreateCameraGroup
TT_RemoveCameraGroup
TT_CamerasGroup
TT_SetGroupShutterDelay
TT_SetCameraGroup
TT_CameraGroupFilterSettings
TT_SetCameraGroupFilterSettings
TT_CameraGroupPointCloudSettings
TT_SetCameraGroupPointCloudSettings
TT_CameraGroupMarkerSize
TT_SetCameraGroupMarkerSize
TT_SetCameraGroupReconstruction
TT_SetEnabledFilterSwitch
TT_IsFilterSwitchEnabled
Camera
TT_CameraCount
TT_CameraXLocation
TT_CameraYLocation
TT_CameraZLocation
TT_CameraOrientationMatrix
TT_CameraName
TT_CameraMarkerCount
TT_CameraMarker
TT_CameraPixelResolution
TT_CameraMarkerPredistorted
TT_SetCameraSettings
TT_SetCameraFrameRate
TT_CameraFrameRate
TT_CameraVideoType
TT_CameraExposure
TT_CameraThreshold
TT_CameraIntensity
TT_CameraTemperature
TT_CameraRinglightTemperature
TT_CameraGrayscaleDecimation
TT_SetCameraGrayscaleDecimation
TT_SetCameraFilterSwitch
TT_SetCameraAGC
TT_SetCameraAEC
TT_SetCameraHighPower
TT_SetCameraMJPEGHighQuality
TT_CameraImagerGain
TT_CameraImagerGainLevels
TT_SetCameraImagerGain
TT_IsContinuousIRAvailable
TT_ContinuousIR
TT_SetContinuousIR
TT_ClearCameraMask
TT_SetCameraMask
TT_CameraMask
TT_CameraMaskInfo
TT_SetCameraState
TT_CameraState
TT_CameraID
TT_CameraFrameBuffer
TT_CameraFrameBufferSaveAsBMP
TT_CameraBackproject
TT_CameraUndistort2DPoint
TT_CameraDistort2DPoint
TT_CameraRay
TT_CameraModel
TT_GetCamera
Additional
TT_OrientTrackingBar
TT_AttachCameraModule
TT_DetachCameraModule
TT_AttachRigidBodySolutionTest
TT_DetachRigidBodySolutionTest
TT_AttachListener
TT_DetachListener
TT_GetResultString
Initializes the API and prepares all connected devices for capturing.
NPRESULT TT_Initialize();
// Initializing all connected cameras TT_Initialize();
↑
Shuts down all of the connected devices.
NPRESULT TT_Shutdown();
// Close down all of the connected cameras TT_Shutdown(); return 0;
Processes incoming frame data from the cameras.
NPRESULT TT_Update();
//== 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 ==// } }
Updates a single frame of camera data.
NPRESULT TT_UpdateSingleFrame();
//== 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 ==// } }
Loads a Motive camera calibration file.
NPRESULT TT_LoadCalibration(const char *filename);
NPRESULT TT_LoadCalibrationW(const wchar_t *filename);
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)); }
Continuous Calibration
Imports TRA files and loads rigid body assets from it.
NPRESULT TT_LoadRigidBodies(const char *filename);
NPRESULT TT_LoadRigidBodiesW(const wchar_t *filename);
Filename (const char, const wchat_t)
NPRESULT
//Loading Rigid Body Assets from a TRA file. const char *traFile = "rigidbody.tra"; TT_LoadRigidBodies(traFile);
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);
Filename (const char, const wchar_t)
//== Save Rigid Bodies ==/ TT_SaveRigidBodies("traFileName.tra");
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);
/== Adding Rigid Bodies ==/ TT_AddRigidBodies("rigidbody.tra");
Loads a Profile XML file.
NPRESULT TT_LoadProfile(const char *filename);
NPRESULT TT_LoadProfileW(const wchar_t *filename);
//== 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)); }
TTP project files are getting deprecated starting from next release of Motive. Export and use XML Profiles instead.
Loads a Motive TTP project file.
NPRESULT TT_LoadProject(const char *filename);
NPRESULT TT_LoadProjectW(const wchar_t *filename);
//== 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)); }
Saves current application setting into a Profile XML file.
NPRESULT TT_SaveProfile(const char *filename);
NPRESULT TT_SaveProfileW(const wchar_t *filename);
//== 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 functions have been deprecated
What happened to the Project TTP Files?
Loads calibration from memory.
NPRESULT TT_LoadCalibrationFromMemory(unsigned char* buffer, int bufferSize);
// get a pointer to the calibration block in memory int bufferSize; // get the size of the buffer NPRESULT result = TT_LoadCalibrationFromMemory(buffer, bufferSize);
Enables/disables the NatNet streaming of the Natrual Point tracking data.
NPRESULT TT_StreamNP(bool enabled);
//== Enable NP Streaming ==/ TT_StreamNP(true);
Enables/disables streaming frame data into trackd.
NPRESULT TT_StreamTrackd(bool enabled);
//== Enable NP Streaming ==/ TT_StreamTrackd(true);
Enables/disables data stream into VRPN.
NPRESULT TT_StreamVRPN(bool enabled, int port);
//== Enable Streaming into VRPN ==/ TT_StreamVRPN(true);
Gets total number of reconstruected markers in a frame.
int TT_FrameMarkerCount();
//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)); }
Returns x-position of a reconstructed marker.
float TT_FrameMarkerX(int markerIndex);
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)); }
Returns y-position of a reconstructed marker.
float TT_FrameMarkerY(int markerIndex);
Returns z-position of a reconstructed marker.
float TT_FrameMarkerZ(int markerIndex);
Returns residual value of a marker.
float TT_FrameMarkerResidual(int markerIndex);
Returns a unique identifier of a marker.
Core::cUID TT_FrameMarkerLabel(int markerIndex);
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); }
Returns a timestamp value for the current frame.
double TT_FrameTimeStamp();
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()); } }
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);
//== 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); } }
Flushes out the camera queues.
void TT_FlushCameraQueues();
//== Flush Camera Queues to remove accumulated latency. ==// TT_FlushCameraQueues(); //== Update the incoming camera data after. ==// TT_Update();
Checks whether rigid body is tracked or not.
bool TT_IsRigidBodyTracked(int rbIndex);
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 } }
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);
//== 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 ); } }
Euler Angles
There are many potential combinations of Euler angles so it is important to understand the order in which rotations are applied, the handedness of the coordinate system, and the axis (positive or negative) that each rotation is applied about. The following conventions are used for representing Euler orientation in Motive:
Clears and removes all rigid body assets.
void TT_ClearRigidBodyList();
//== Clear all rigid bodies ==// TT_ClearRigidBodyList();
Removes a rigid body from the project
NPRESULT TT_RemoveRigidBody(int rbIndex);
//== 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); } }
Returns a total number of rigid bodies.
int TT_RigidBodyCount();
//== 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)); }
Returns the User Data ID value of a rigid body.
int TT_RigidBodyUserData(int rbIndex);
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)); }
Assigns a User Data ID number to a rigid body.
void TT_SetRigidBodyUserData(int rbIndex, int ID);
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)); }
Returns the name for the rigid body.
const char* TT_RigidBodyName(int rbIndex);
const wchar_t* TT_RigidBodyNameW(int rbIndex);
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)); }
Enables/disables tracking of a rigid body.
void TT_SetRigidBodyEnabled(int rbIndex, bool enabled);
int totalRB = TT_RigidBodyCount(); //== Disabling all rigid bodies ==// for(int i = 0; i < totalRB; i++) { TT_SetRigidBodyEnabled(i, FALSE); }
Checks whether a rigid body is enabled.
bool TT_RigidBodyEnabled(int rbIndex);
int totalRB = TT_RigidBodyCount(); for (int i = 0; i < totalRB; i++) { if (TT_RigidBodyEnabled(i)) { //== Disabling all enabled rigid bodies ==// TT_SetRigidBodyEnabled(i, FALSE); } }
Translates the pivot point of a rigid body.
NPRESULT TT_RigidBodyTranslatePivot(int index, float x, float y, float z);
int rbIndex = 1; //== Translating a rigid body 2 cm in positive x-direction ==// TT_RigidBodyTranslate(rbIndex, 0.02, 0, 0);
Resets orientation of a rigid body.
bool TT_RigidBodyResetOrientation(int rbIndex);
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)); } }
Gets total number of markers in a rigid body.
int TT_RigidBodyMarkerCount(int rbIndex);
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)); }
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);
//== 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); } }
Changes and updates the rigid body marker positions.
bool TT_RigidBodyUpdateMarker( int rbIndex, int markerIndex, float *x, float *y, float *z );
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);
//== 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); } }
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);
//== 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); } }
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 );
Creates a rigid body asset from a set of reconstructed 3D markers.
NPRESULT TT_CreateRigidBody(const char* name, int userDataID, int markerCount, float *markerList);
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);
Obtains rigid body settings for a given asset, and saves them in a cRigidBodySettings instance.
NPRESULT TT_RigidBodySettings(int rbIndex, RigidBodySolver::cRigidBodySettings &settings);
//== 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"); } }
Changes property settings of a rigid body.
NPRESULT TT_SetRigidBodySettings(int rbIndex, RigidBodySolver::cRigidBodySettings &settings);
//== 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); }
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 );
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();
This function inquiries the state of the refinement process. It returns TT_RigidBodyRefineStates enum as a result.
TT_RIgidBodyRefineStates TT_RigidBodyRefineState();
<source> enum TT_RigidBodyRefineStates {
TT_RigidBodyRefine_Initialized = 0, TT_RigidBodyRefine_Sampling, TT_RigidBodyRefine_Solving, TT_RigidBodyRefine_Complete, TT_RigidBodyRefine_Uninitialized
};
This function inquiries the progress of the refinement sampling process.
float TT_RigidBodyRefintProgress();
These two functions returns error values of the rigid body definition before and after the refinement.
float TT_RigidBodyRefineInitialError(); float TT_RigidBodyRefineResultError();
This function applies the refined result to the corresponding rigid body definition.
bool TT_RigidBodyRefineApplyResult();
This function discards the final refinement result and resets the refinement process.
bool TT_RigidBodyRefineReset();
Returns pointer to the CameraManager instance.
CameraLibrary::CameraManager* TT_GetCameraManager();
CameraLibrary::CameraManager *cman = TT_GetCameraManager(); // cman is declared as a pointer to a camera manager used in conjuction with the Camera SDK
Returns Motive build number.
int TT_BuildNumber();
//== Printing Motive Build Number ==// printf("Motive Build: %d\n", TT_BuildNumber());
Returns camera group count.
int TT_CameraGroupCount();
int groupcount = TT_CameraGroupCount(); //== Processing Camera Groups ==// for(int i = 0; i < groupcount; i++) { //== Process each camera group ==// }
Creates a new camera group.
bool TT_CreateCameraGroup();
//== Creating a new camera group ==// TT_CreateCameraGroup();
Removes a camera group.
bool TT_RemoveCameraGroup(groupIndex);
//== 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); } }
Returns an index value of a camera group that a camera is involved in.
int TT_CamerasGroup(int cameraIndex);
//== 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)); }
Introduces shutter delay to a camera group.
void TT_SetGroupShutterDelay(int groupIndex, int microseconds);
//== Setting one second shutter delay for all camera groups ==// for(int i = 0; i < TT_CameraGroupCount() ; i++) { TT_SetGroupShutterDelay(i, 1000000); }
Moves a camera to a different camera group.
void TT_SetCameraGroup(int cameraIndex, int groupIndex);
//== 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); } }
Obtains the camera group's filter settings.
NPRESULT TT_CameraGroupFilterSettings(int groupIndex, cCameraGroupFilterSettings &settings);
//== 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"); }
Assigns camera group filter settings to a camera group.
NPRESULT TT_SetCameraGRoupFilterSettings(int groupIndex, cCameraGroupFilterSettings &settings);
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"); } }
Obtains point cloud reconstruction settings of a camera group.
NPRESULT TT_CameraGroupPointCloudSettings(int groupIndex, cCameraGroupPointCloudSettings &settings);
//== Obtaining point cloud settings from all of the camera groups ==// int groupcount = TT_CameraGroupCount(); bool bval; double dval; long lval; for (int i = 0; i < groupcount; i++) { cCameraGroupPointCloudSettings current_settings; TT_CameraGroupPointCloudSettings(i, current_settings); printf("Camera Group #%d:\n", i); //== Fetching and printing the paremeters using the member functions ==// //bool parameters current_settings.BoolParameter(cCameraGroupPointCloudSettings::eRankRays, bval); printf("\teRankRays: %d\n", bval); current_settings.BoolParameter(cCameraGroupPointCloudSettings::eResolvePointCloud, bval); printf("\teResolvePointCloud: %d\n", bval); //double parameters current_settings.DoubleParameter(cCameraGroupPointCloudSettings::ePCMaxRayLength, dval); printf("\tePCMaxRayLength: %.2f\n", dval); current_settings.DoubleParameter(cCameraGroupPointCloudSettings::ePCMinRayLength, dval); printf("\tePCMinRayLength: %.2f\n", dval); current_settings.DoubleParameter(cCameraGroupPointCloudSettings::ePCResidual, dval); printf("\tePCResidual: %.2f\n", dval); //long parameters current_settings.LongParameter(cCameraGroupPointCloudSettings::ePCMinRays, lval); printf("\tePCMinRays: %ld\n", lval); current_settings.LongParameter(cCameraGroupPointCloudSettings::ePointCloudEngine, lval); printf("\tePointCloudEngine: %ld\n", lval); }
Applies point cloud settings to a camera group.
NPRESULT TT_SetCameraGroupPointCloudSettings(int groupIndex, cCameraGroupPointCloudSettings &settings);
int groupcount = TT_CameraGroupCount(); for (int i = 0; i < groupcount; i++) { // Fetching and modifying the point cloud settings cCameraGroupPointCloudSettings new_settings; TT_CameraGroupPointCloudSettings(i, new_settings); new_settings.SetBoolParameter(cCameraGroupPointCloudSettings::eRankRays, true); new_settings.SetDoubleParameter(cCameraGroupPointCloudSettings::ePCResidual, 2.50); new_settings.SetLongParameter(cCameraGroupPointCloudSettings::ePCMinRays, 3.0); NPRESULT result = TT_SetCameraGroupPointCloudSettings(0, new_settings); }
Obtains marker size settings of a camera group
NPRESULT TT_CameraGroupMarkerSize(int groupIndex, cCameraGroupMarkerSizeSettings &settings);
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 } }
Applies given marker size settings to a camera group.
NPRESULT TT_SetCameraGroupMarkerSize(int groupIndex, cCameraGroupMarkerSizeSettings &settings);
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); }
Enables or disables marker reconstruction contribution from a camera group.
NPRESULT TT_SetCameraGroupReconstruction(int groupIndex, bool enable);
//== Disabling all camera groups ==// int groupcount = TT_CameraGroupCount(); bool enabled = false; for (int i = 0; i < groupcount; i++) { TT_SetCameraGroupReconstruction(i, enabled); }
Enables or disables filter switchers.
NPRESULT TT_SetEnabledFilterSwitch(bool enabled);
//== Disabling Filter Switches ==// bool enabled = false; TT_SetEnabledFilterSwitch(enabled);
Checks whether filter switches are enabled or not.
bool TT_IsFilterSwitchEnabled();
//== Enabling disable filter switches ==// if (!TT_IsFilterSwitchEnabled()) { printf("Enabling all disabled switches\n"); TT_SetEnabledFilterSwitch(true); }
Returns a total number of cameras connected to the system.
int TT_CameraCount();
//== 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)); }
Returns x-position of a camera.
int TT_CameraXLocation(int cameraIndex);
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); }
Returns y-position of a camera.
int TT_CameraYLocation(int cameraIndex);
Returns z-position of a camera.
int TT_CameraZLocation(int cameraIndex);
Gets a components of the camera's orientation matrix.
float TT_CameraOrientationMatrix(int cameraIndex, int matrixIndex);
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"); }
Returns coresponding camera's model name and serial number
const char* TT_CameraName(int cameraIndex);
//== 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)); }
Returns coresponding camera's serial number as an integer.
int TT_CameraSerial(int cameraIndex);
//== 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)); }
Returns a total number of centroids detected by a camera.
int TT_CameraMarkerCount(int cameraIndex);
for (int i = 0; i < TT_CameraCount(); i++) { int centroidcount = TT_CameraMarkerCount(i); printf("Camera #%d detected centroids: %d\n", i, centroidcount); }
Returns 2D location of the centroid as seen by a camera.
bool TT_CameraMarker(int cameraIndex, int markerIndex, float &x, float &y);
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); } }
Saves camera's pixel resolution.
bool TT_CameraPixelResolution(int cameraIndex, int &width, int&height);
//== 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); }
Saves predistorted 2D location of a centroid.
bool TT_CameraMarkerPredistorted(int cameraIndex, int markerIndex, float &x, float &y);
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); } }
Configures camera settings.
bool TT_SetCameraSettings(int cameraIndex, int videoType, int exposure, int threshold, int intensity);
//== 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)); }
Sets camera frame rate.
bool TT_SetCameraFrameRate(int cameraIndex, int framerate);
//== 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)); }
Gets configured frame rate of a camera.
int TT_CameraFrameRate(int cameraIndex);
//== 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)); }
Gets configured video type of a camera.
int TT_CameraVideoType(int cameraIndex);
#define NPVIDEOTYPE_SEGMENT 0 #define NPVIDEOTYPE_GRAYSCALE 1 #define NPVIDEOTYPE_OBJECT 2 #define NPVIDEOTYPE_PRECISION 4 #define NPVIDEOTYPE_MJPEG 6
//== 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"); } }
Gets exposure setting of a camera.
int TT_CameraExposure(int cameraIndex);
Gets configured threshold (THR) setting of a camera.
int TT_CameraThreshold(int cameraIndex);
Gets configured intensity (LED) setting of a camera.
int TT_CameraIntensity(int cameraIndex);
Measures image board temperature of a camera.
float TT_CameraTemperature(int cameraIndex);
//== 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"); }
Measures IR LED board temperature of a camera.
float TT_CameraRinglightTemperature(int cameraIndex);
Gets configured grayscale image frame rate decimation ratio of a camera.
int TT_CameraGrayscaleDecimation(int cameraIndex);
//== 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)); } }
Sets frame rate decimation ratio for processing grayscale images.
bool TT_SetCameraGrayscaleDecimation(int cameraIndex, int value);
//== 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)); } }
Enables or disables IR filter switch of a camera.
bool TT_SetCameraFilterSwitch(int cameraIndex, bool enableIRFilter);
//== 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); } }
Enables and disables automatic gain control.
bool TT_SetCameraAGC(int cameraIndex, bool enableIRFilter);
//== 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."); } }
Enables or disables automatic exposure control.
bool TT_SetCameraAEC(int cameraIndex, bool enabeledAutomaticExposureControl);
//== 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."); } }
Enables or disables the high power IR illumination mode.
bool TT_SetCameraHighPower(int cameraIndex, bool enableHighPowerMode);
//== Enabling high power mode ==// int totalCamera = TT_CameraCount(); for (int i = 0; i < totalCamera; i++) { TT_SetCameraHighPower(i, true); }
Sets compression quality of MJPEG images.
bool TT_SetCameraMJPEGHighQuality(int cameraIndex, int mjpegquality);
//== 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"); } } }
Gets configured imager gain setting of a camera.
int TT_CameraImagerGain(int cameraIndex);
//== for (int i = 0; i < TT_CameraCount(); i++) { printf("Camera #%d gain setting: %d\n",i, TT_CameraImagerGain(i)); }
Gets total number of gain levels available in a camera.
int TT_CameraImagerGainLevels(int cameraIndex);
//== 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)); }
Sets the imager gain level.
void TT_SetCameraImagerGain(int cameraIndex);
//== 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); }
Checks if the continuous IR mode is supported.
bool TT_IsContinuousIRAvailalbe(int cameraIndex);
//== 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"); } }
Checks if the continuous IR mode is enabled.
bool TT_ContinuousIR(int cameraIndex);
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"); } }
Enables/disables continuous IR.
void TT_SetContinuousIR(int cameraIndex, bool enable);
Clears masking from camera's 2D view.
bool TT_ClearCameraMask(int cameraIndex);
//== Clearing existing masks for all cameras ==// int totalCamera = TT_CameraCount(); for (int i = 0; i < totalCamera; i++) { TT_ClearCameraMask(i); }
bool TT_SetCameraMask( int cameraIndex, unsigned char* buffer, int bufferSize );
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 ); }
bool TT_CameraMask(int cameraIndex, unsigned char * buffer, int bufferSize);
bool TT_CameraMaskInfo(int cameraIndex, int &blockingMaskWidth, int &blockingMaskHeight, int &blockingMaskGrid);
Sets camera state of a camera.
bool TT_SetCameraState(int cameraIndex, eCameraStates state);
enum eCameraStates { Camera_Enabled = 0, Camera_Disabled_For_Reconstruction = 1, Camera_Disabled = 2, CameraStatesCount = 3 };
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); }
Checks camera states.
bool TT_CameraState(int cameraIndex, eCameraStates cameraState);
//== 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); } }
Returns the Camera ID.
int TT_CameraID(int cameraIndex);
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)); }
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);
// 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."); }
Saves image buffer of a camera into a BMP file.
bool TT_CameraFrameBufferSaveAsBMP(int cameraIndex, const char* filename);
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()); }
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);
//== 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); }
Removes lens distortion.
void TT_CameraUndistort2DPoint(int cameraIndex, float &x, float &y);
// 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);
Reapplies lens distortion model.
void TT_CameraDistort2DPoint(int cameraIndex, float &x, float &y);
// 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);
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);
//== 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);
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);
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);
Gets pointer to the camera object from Camera SDK.
CameraLibrary::Camera* TT_GetCamera(int cameraIndex);
CameraLibrary::Camera *cam = TT_GetCameraManager(); // cam is declared as a pointer to a camera object used in conjuction with the Camera SDK
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);
//== 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);
Attaches/detaches cCameraModule instance to a camera object.
void TT_AttachCameraModule(int cameraindex, CameraLibrary::cCameraModule *module);
void TT_DetachCameraModule(int cameraIndex, CameraLibrary::cCameraModule *module);
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 };
Attaches/detaches cRigidBodySolutionTest class to a rigid body.
void TT_AttachRigidBodySolutionTest(int rbIndex, cRigidBodySolutionTest* test);
void TT_DetachRigidBodySolutionTest(int rbIndex, cRigidBodySolutionTest* test);
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. } };
Attaches/detaches cTTAPIListener onto a TTAPI project.
void TT_AttachListener(cTTAPIListener* listener);
void TT_DetachListener(cTTAPIListener* listener);
int main() { //... //Within the main, attach the Listener myListener listener; TT_AttachListener(&listener); //... TT_DetachListener(&listener); } // Create a listener class that handles the callback. class myListener : public cTTAPIListener { public: // Create a function and call it TTAPIFrameAvailable void TTAPIFrameAvailable() { // When the Listener is attached. // This function will be executed each time a new frame is available. // Process frame } };
Returns plain text message that corresponds to a NPRESULT value.
const char* TT_GetResultString(NPRESULT result);
//== 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); } }
Checks whether there is another OptiTrack software using the devices.
NPRESULT TT_TestSoftwareMutex();