1 #define _CRT_SECURE_NO_WARNINGS 19 #pragma comment(lib, "IPHLPAPI.lib") 21 #include <arpa/inet.h> 27 inline void ToLower(std::string& str)
29 std::transform(str.begin(), str.end(), str.begin(), [](
int c)
31 return std::tolower(c);
35 inline void RemoveInvalidChars(std::string& str)
37 auto isInvalidChar = [](
int c) ->
int 42 return std::iscntrl(c) + std::isspace(c);
44 str.erase(std::remove_if(str.begin(), str.end(), isInvalidChar), str.end());
52 mpoRTPacket =
nullptr;
60 mpFileBuffer =
nullptr;
61 mDataBuffSize = 65535;
62 maDataBuff =
new char[mDataBuffSize];
77 mpoRTPacket =
nullptr;
82 bool CRTProtocol::Connect(
const char* pServerAddr,
unsigned short nPort,
unsigned short* pnUDPServerPort,
int nMajorVersion,
int nMinorVersion,
bool bBigEndian)
86 char pResponseStr[256];
88 mbBigEndian = bBigEndian;
92 if ((nMajorVersion == 1) && (nMinorVersion == 0))
113 mpoRTPacket =
new CRTPacket(nMajorVersion, nMinorVersion, bBigEndian);
115 if (mpoRTPacket ==
nullptr)
117 strcpy(maErrorStr,
"Could not allocate data packet.");
121 if (mpoNetwork->
Connect(pServerAddr, nPort))
123 if (pnUDPServerPort !=
nullptr)
127 sprintf(maErrorStr,
"CreateUDPSocket failed. %s", mpoNetwork->
GetErrorString());
145 const std::string welcomeMessage(
"QTM RT Interface connected");
146 if (strncmp(welcomeMessage.c_str(), mpoRTPacket->
GetCommandString(), welcomeMessage.size()) == 0)
154 if ((mnMajorVersion == 1) && (mnMinorVersion == 0))
158 strcpy(tTemp,
"ByteOrder BigEndian");
162 strcpy(tTemp,
"ByteOrder LittleEndian");
165 if (SendCommand(tTemp, pResponseStr))
171 strcpy(maErrorStr,
"Set byte order failed.");
188 if (mpoNetwork->
GetError() == 10061)
190 strcpy(maErrorStr,
"Check if QTM is running on target machine.");
219 mpoRTPacket =
nullptr;
234 char pResponseStr[256];
236 sprintf(tTemp,
"Version %u.%u", nMajorVersion, nMinorVersion);
238 if (SendCommand(tTemp, pResponseStr))
240 sprintf(tTemp,
"Version set to %u.%u", nMajorVersion, nMinorVersion);
242 if (strcmp(pResponseStr, tTemp) == 0)
244 mnMajorVersion = nMajorVersion;
245 mnMinorVersion = nMinorVersion;
246 mpoRTPacket->
SetVersion(mnMajorVersion, mnMinorVersion);
252 sprintf(maErrorStr,
"%s.", pResponseStr);
256 strcpy(maErrorStr,
"Set Version failed.");
261 strcpy(tTemp, maErrorStr);
262 sprintf(maErrorStr,
"Send Version failed. %s.", tTemp);
275 nMajorVersion = mnMajorVersion;
276 nMinorVersion = mnMinorVersion;
284 if (SendCommand(
"QTMVersion", pVersion, nVersionLen))
288 strcpy(maErrorStr,
"Get QTM Version failed.");
295 char pResponseStr[256];
297 if (SendCommand(
"ByteOrder", pResponseStr))
299 bBigEndian = (strcmp(pResponseStr,
"Byte order is big endian") == 0);
302 strcpy(maErrorStr,
"Get Byte order failed.");
310 char pResponseStr[256];
312 if (strlen(pLicenseCode) <= 85)
314 sprintf(tTemp,
"CheckLicense %s", pLicenseCode);
316 if (SendCommand(tTemp, pResponseStr))
318 if (strcmp(pResponseStr,
"License pass") == 0)
322 strcpy(maErrorStr,
"Wrong license code.");
326 strcpy(maErrorStr,
"CheckLicense failed.");
331 strcpy(maErrorStr,
"License code too long.");
342 if (mnBroadcastPort == 0)
349 mnBroadcastPort = nServerPort;
353 nServerPort = mnBroadcastPort;
356 *((
unsigned int*)pData) = (
unsigned int)10;
358 *((
unsigned short*)(pData + 8)) = htons(nServerPort);
362 mvsDiscoverResponseList.clear();
367 unsigned int nAddr = 0;
368 nReceived = mpoNetwork->
Receive(maDataBuff, mDataBuffSize,
false, 100000, &nAddr);
370 if (nReceived != -1 && nReceived > 8)
375 sResponse.
nAddr = nAddr;
378 if (response && (!bNoLocalResponses || !mpoNetwork->
IsLocalAddress(nAddr)))
380 strcpy(sResponse.
message, response);
381 mvsDiscoverResponseList.push_back(sResponse);
385 }
while (nReceived != -1 && nReceived > 8);
395 return (
int)mvsDiscoverResponseList.size();
401 if (nIndex < mvsDiscoverResponseList.size())
403 nAddr = mvsDiscoverResponseList[nIndex].nAddr;
404 nBasePort = mvsDiscoverResponseList[nIndex].nBasePort;
405 message = mvsDiscoverResponseList[nIndex].message;
414 char pCommandStr[256];
415 strcpy(pCommandStr,
"GetCurrentFrame ");
417 std::string::size_type nCommandStrSize = strlen(pCommandStr);
418 if (
GetComponentString(pCommandStr + (
int)nCommandStrSize, nComponentType, componentOptions))
420 if (SendCommand(pCommandStr))
424 strcpy(maErrorStr,
"GetCurrentFrame failed.");
428 strcpy(maErrorStr,
"DataComponent missing.");
437 char pCommandStr[256];
441 sprintf(pCommandStr,
"StreamFrames FrequencyDivisor:%d ", nRateArg);
445 sprintf(pCommandStr,
"StreamFrames Frequency:%d ", nRateArg);
449 sprintf(pCommandStr,
"StreamFrames AllFrames ");
453 strcpy(maErrorStr,
"No valid rate.");
459 if (pUDPAddr !=
nullptr && strlen(pUDPAddr) > 64)
461 strcpy(maErrorStr,
"UDP address string too long.");
464 sprintf(pCommandStr,
"%s UDP%s%s:%d ", pCommandStr, pUDPAddr !=
nullptr ?
":" :
"", pUDPAddr !=
nullptr ? pUDPAddr :
"", nUDPPort);
467 std::string::size_type nCommandStrSize = strlen(pCommandStr);
468 if (
GetComponentString(pCommandStr + (
int)nCommandStrSize, nComponentType, componentOptions))
470 if (SendCommand(pCommandStr))
474 strcpy(maErrorStr,
"StreamFrames failed.");
478 strcpy(maErrorStr,
"DataComponent missing.");
487 if (SendCommand(
"StreamFrames Stop"))
491 strcpy(maErrorStr,
"StreamFrames Stop failed.");
503 if (mnMajorVersion > 1 || mnMinorVersion > 9)
505 result = SendCommand(
"GetState");
509 result = SendCommand(
"GetLastEvent");
524 }
while (nReceived > 0);
526 strcpy(maErrorStr,
"GetLastEvent failed.");
540 char pResponseStr[256];
542 mpFileBuffer = fopen(pFileName,
"wb");
543 if (mpFileBuffer !=
nullptr)
548 if (SendCommand((mnMajorVersion > 1 || mnMinorVersion > 7) ?
"GetCaptureC3D" :
"GetCapture", pResponseStr))
550 if (strcmp(pResponseStr,
"Sending capture") == 0)
556 if (mpFileBuffer !=
nullptr)
558 fclose(mpFileBuffer);
561 strcpy(maErrorStr,
"Writing C3D file failed.");
565 strcpy(maErrorStr,
"Wrong packet type received.");
570 strcpy(maErrorStr,
"No packet received.");
575 sprintf(maErrorStr,
"%s failed.", (mnMajorVersion > 1 || mnMinorVersion > 7) ?
"GetCaptureC3D" :
"GetCapture");
580 sprintf(maErrorStr,
"%s failed.", (mnMajorVersion > 1 || mnMinorVersion > 7) ?
"GetCaptureC3D" :
"GetCapture");
586 if (SendCommand(
"GetCaptureQTM", pResponseStr))
588 if (strcmp(pResponseStr,
"Sending capture") == 0)
594 if (mpFileBuffer !=
nullptr)
596 fclose(mpFileBuffer);
599 strcpy(maErrorStr,
"Writing QTM file failed.");
603 strcpy(maErrorStr,
"Wrong packet type received.");
608 sprintf(maErrorStr,
"No packet received. %s.", maErrorStr);
613 strcpy(maErrorStr,
"GetCaptureQTM failed.");
618 strcpy(maErrorStr,
"GetCaptureQTM failed.");
624 fclose(mpFileBuffer);
633 char pResponseStr[256];
635 if (SendCommand(
"Trig", pResponseStr))
637 if (strcmp(pResponseStr,
"Trig ok") == 0)
644 sprintf(maErrorStr,
"%s.", pResponseStr);
648 strcpy(maErrorStr,
"Trig failed.");
657 char pResponseStr[256];
659 if (strlen(pLabel) <= 92)
661 sprintf(tTemp,
"%s %s", (mnMajorVersion > 1 || mnMinorVersion > 7) ?
"SetQTMEvent" :
"Event", pLabel);
663 if (SendCommand(tTemp, pResponseStr))
665 if (strcmp(pResponseStr,
"Event set") == 0)
672 sprintf(maErrorStr,
"%s.", pResponseStr);
676 sprintf(maErrorStr,
"%s failed.", (mnMajorVersion > 1 || mnMinorVersion > 7) ?
"SetQTMEvent" :
"Event");
681 strcpy(maErrorStr,
"Event label too long.");
689 char pResponseStr[256];
692 strcpy(pCmd,
"TakeControl");
693 if (pPassword !=
nullptr)
696 if (pPassword[0] != 0)
699 strcat(pCmd, pPassword);
702 if (SendCommand(pCmd, pResponseStr))
704 if (strcmp(
"You are now master", pResponseStr) == 0 ||
705 strcmp(
"You are already master", pResponseStr) == 0)
713 sprintf(maErrorStr,
"%s.", pResponseStr);
717 strcpy(maErrorStr,
"TakeControl failed.");
726 char pResponseStr[256];
728 if (SendCommand(
"ReleaseControl", pResponseStr))
730 if (strcmp(
"You are now a regular client", pResponseStr) == 0 ||
731 strcmp(
"You are already a regular client", pResponseStr) == 0)
739 sprintf(maErrorStr,
"%s.", pResponseStr);
743 strcpy(maErrorStr,
"ReleaseControl failed.");
757 char pResponseStr[256];
759 if (SendCommand(
"New", pResponseStr))
761 if (strcmp(pResponseStr,
"Creating new connection") == 0 ||
762 strcmp(pResponseStr,
"Already connected") == 0)
769 sprintf(maErrorStr,
"%s.", pResponseStr);
773 strcpy(maErrorStr,
"New failed.");
780 char pResponseStr[256];
782 if (SendCommand(
"Close", pResponseStr))
784 if (strcmp(pResponseStr,
"Closing connection") == 0 ||
785 strcmp(pResponseStr,
"File closed") == 0 ||
786 strcmp(pResponseStr,
"Closing file") == 0 ||
787 strcmp(pResponseStr,
"No connection to close") == 0)
794 sprintf(maErrorStr,
"%s.", pResponseStr);
798 strcpy(maErrorStr,
"Close failed.");
806 char pResponseStr[256];
808 if (SendCommand(
"Start", pResponseStr))
810 if (strcmp(pResponseStr,
"Starting measurement") == 0)
817 sprintf(maErrorStr,
"%s.", pResponseStr);
821 strcpy(maErrorStr,
"Start failed.");
829 char pResponseStr[256];
831 if (SendCommand(
"Start rtfromfile", pResponseStr))
833 if (strcmp(pResponseStr,
"Starting RT from file") == 0)
840 if (strcmp(pResponseStr,
"RT from file already running") == 0)
844 sprintf(maErrorStr,
"%s.", pResponseStr);
848 strcpy(maErrorStr,
"Starting RT from file failed.");
856 char pResponseStr[256];
858 if (SendCommand(
"Stop", pResponseStr))
860 if (strcmp(pResponseStr,
"Stopping measurement") == 0)
867 sprintf(maErrorStr,
"%s.", pResponseStr);
871 strcpy(maErrorStr,
"Stop failed.");
880 char pResponseStr[256];
882 if (strlen(pFileName) <= 94)
884 sprintf(tTemp,
"Load %s", pFileName);
886 if (SendCommand(tTemp, pResponseStr, 20000000))
888 if (strcmp(pResponseStr,
"Measurement loaded") == 0)
893 if (strlen(pResponseStr) > 0)
895 sprintf(maErrorStr,
"%s.", pResponseStr);
899 strcpy(maErrorStr,
"Load failed.");
904 strcpy(maErrorStr,
"File name too long.");
913 char pResponseStr[256];
914 char tNewFileNameTmp[300];
916 tNewFileNameTmp[0] = 0;
918 if (strlen(pFileName) <= 94)
920 sprintf(tTemp,
"Save %s%s", pFileName, bOverwrite ?
" Overwrite" :
"");
922 if (SendCommand(tTemp, pResponseStr))
924 if (strcmp(pResponseStr,
"Measurement saved") == 0)
926 if (pNewFileName && nSizeOfNewFileName > 0)
932 if (sscanf(pResponseStr,
"Measurement saved as '%[^']'", tNewFileNameTmp) == 1)
936 strcpy(pNewFileName, tNewFileNameTmp);
943 sprintf(maErrorStr,
"%s.", pResponseStr);
947 strcpy(maErrorStr,
"Save failed.");
952 strcpy(maErrorStr,
"File name too long.");
961 char pResponseStr[256];
963 if (strlen(pFileName) <= 94)
965 sprintf(tTemp,
"LoadProject %s", pFileName);
967 if (SendCommand(tTemp, pResponseStr))
969 if (strcmp(pResponseStr,
"Project loaded") == 0)
976 sprintf(maErrorStr,
"%s.", pResponseStr);
980 strcpy(maErrorStr,
"Load project failed.");
985 strcpy(maErrorStr,
"File name too long.");
993 char pResponseStr[256];
995 if (SendCommand(
"Reprocess", pResponseStr))
997 if (strcmp(pResponseStr,
"Reprocessing file") == 0)
1004 sprintf(maErrorStr,
"%s.", pResponseStr);
1008 strcpy(maErrorStr,
"Reprocess failed.");
1059 std::string rateString;
1061 rateString.assign(pRate);
1062 std::transform(rateString.begin(), rateString.end(), rateString.begin(), ::tolower);
1066 if (rateString.compare(0, 9,
"allframes", 9) == 0)
1070 else if (rateString.compare(0, 10,
"frequency:") == 0)
1072 nRateArg = atoi(rateString.substr(10).c_str());
1078 else if (rateString.compare(0, 17,
"frequencydivisor:") == 0)
1080 nRateArg = atoi(rateString.substr(17).c_str());
1093 std::string componentString;
1094 unsigned int componentTypes = 0;
1096 componentString.assign(pComponentType);
1098 std::transform(componentString.begin(), componentString.end(), componentString.begin(), ::tolower);
1100 if (componentString.find(
"2d") != std::string::npos)
1104 if (componentString.find(
"2dlin") != std::string::npos)
1108 if (componentString.find(
"3d") != std::string::npos)
1112 if (componentString.find(
"3dres") != std::string::npos)
1116 if (componentString.find(
"3dnolabels") != std::string::npos)
1120 if (componentString.find(
"3dnolabelsres") != std::string::npos)
1124 if (componentString.find(
"analog") != std::string::npos)
1128 if (componentString.find(
"analogsingle") != std::string::npos)
1132 if (componentString.find(
"force") != std::string::npos)
1136 if (componentString.find(
"forcesingle") != std::string::npos)
1140 if (componentString.find(
"6d") != std::string::npos)
1144 if (componentString.find(
"6dres") != std::string::npos)
1148 if (componentString.find(
"6deuler") != std::string::npos)
1152 if (componentString.find(
"6deulerres") != std::string::npos)
1156 if (componentString.find(
"image") != std::string::npos)
1160 if (componentString.find(
"gazevector") != std::string::npos)
1164 if (componentString.find(
"timecode") != std::string::npos)
1168 if (componentString.find(
"skeleton") != std::string::npos)
1172 return componentTypes;
1178 pComponentStr[0] = 0;
1182 strcat(pComponentStr,
"2D ");
1186 strcat(pComponentStr,
"2DLin ");
1190 strcat(pComponentStr,
"3D ");
1194 strcat(pComponentStr,
"3DRes ");
1198 strcat(pComponentStr,
"3DNoLabels ");
1202 strcat(pComponentStr,
"3DNoLabelsRes ");
1206 strcat(pComponentStr,
"6D ");
1210 strcat(pComponentStr,
"6DRes ");
1214 strcat(pComponentStr,
"6DEuler ");
1218 strcat(pComponentStr,
"6DEulerRes ");
1222 strcat(pComponentStr,
"Analog");
1226 strcat(pComponentStr,
":");
1230 strcat(pComponentStr,
" ");
1234 strcat(pComponentStr,
"AnalogSingle");
1238 strcat(pComponentStr,
":");
1242 strcat(pComponentStr,
" ");
1246 strcat(pComponentStr,
"Force ");
1250 strcat(pComponentStr,
"ForceSingle ");
1254 strcat(pComponentStr,
"GazeVector ");
1258 strcat(pComponentStr,
"Image ");
1262 strcat(pComponentStr,
"Timecode ");
1266 strcat(pComponentStr,
"Skeleton");
1270 strcat(pComponentStr,
":global");
1273 strcat(pComponentStr,
" ");
1276 return (pComponentStr[0] != 0);
1283 unsigned int nRecvedTotal = 0;
1284 unsigned int nFrameSize;
1293 nRecved = mpoNetwork->
Receive(maDataBuff, mDataBuffSize,
true, nTimeout);
1297 strcpy(maErrorStr,
"Data receive timeout.");
1300 if (nRecved < (
int)(
sizeof(
int) * 2))
1303 strcpy(maErrorStr,
"Couldn't read header bytes.");
1308 strcpy(maErrorStr,
"Socket Error.");
1311 nRecvedTotal += nRecved;
1313 bool bBigEndian = (mbBigEndian || (mnMajorVersion == 1 && mnMinorVersion == 0));
1314 nFrameSize = mpoRTPacket->
GetSize(maDataBuff, bBigEndian);
1315 eType = mpoRTPacket->
GetType(maDataBuff, bBigEndian);
1317 unsigned int nReadSize;
1321 if (mpFileBuffer !=
nullptr)
1323 rewind(mpFileBuffer);
1324 if (fwrite(maDataBuff +
sizeof(
int) * 2, 1, nRecvedTotal -
sizeof(
int) * 2, mpFileBuffer) !=
1325 nRecvedTotal -
sizeof(
int) * 2)
1327 strcpy(maErrorStr,
"Failed to write file to disk.");
1328 fclose(mpFileBuffer);
1329 mpFileBuffer =
nullptr;
1333 while (nRecvedTotal < nFrameSize)
1335 nReadSize = nFrameSize - nRecvedTotal;
1336 if (nFrameSize > mDataBuffSize)
1338 nReadSize = mDataBuffSize;
1341 nRecved = mpoNetwork->
Receive(&(maDataBuff[
sizeof(
int) * 2]), nReadSize,
false, nTimeout);
1344 strcpy(maErrorStr,
"Socket Error.");
1345 fclose(mpFileBuffer);
1346 mpFileBuffer =
nullptr;
1349 if (fwrite(maDataBuff +
sizeof(
int) * 2, 1, nRecved, mpFileBuffer) != (
size_t)nRecved)
1351 strcpy(maErrorStr,
"Failed to write file to disk.");
1352 fclose(mpFileBuffer);
1353 mpFileBuffer =
nullptr;
1356 nRecvedTotal += nRecved;
1361 strcpy(maErrorStr,
"Receive file buffer not opened.");
1364 fclose(mpFileBuffer);
1366 mpFileBuffer =
nullptr;
1372 if (nFrameSize > mDataBuffSize)
1374 char* buf =
new char[nFrameSize];
1375 memcpy(buf, maDataBuff, mDataBuffSize);
1378 mDataBuffSize = nFrameSize;
1382 while (nRecvedTotal < nFrameSize)
1385 nRecved = mpoNetwork->
Receive(&(maDataBuff[nRecvedTotal]), nFrameSize - nRecvedTotal,
false, nTimeout);
1388 strcpy(maErrorStr,
"Socket Error.");
1391 nRecvedTotal += nRecved;
1395 mpoRTPacket->
SetData(maDataBuff);
1396 if (mpoRTPacket->
GetEvent(meLastEvent))
1400 meState = meLastEvent;
1405 if (nRecvedTotal == nFrameSize)
1407 return nRecvedTotal;
1409 strcpy(maErrorStr,
"Packet truncated.");
1429 RemoveInvalidChars(str);
1436 else if (str ==
"false")
1455 msGeneralSettings.vsCameras.clear();
1457 if (!SendCommand(
"GetParameters General"))
1459 strcpy(maErrorStr,
"GetParameters General failed");
1469 strcat(maErrorStr,
" Expected XML packet.");
1482 sprintf(maErrorStr,
"GetParameters General returned wrong packet type. Got type %d expected type 2.", eType);
1500 msGeneralSettings.nCaptureFrequency = atoi(oXML.
GetChildData().c_str());
1506 msGeneralSettings.fCaptureTime = (float)atof(oXML.
GetChildData().c_str());
1509 if (!
ReadXmlBool(&oXML,
"Start_On_External_Trigger", msGeneralSettings.bStartOnExternalTrigger))
1513 if (mnMajorVersion > 1 || mnMinorVersion > 14)
1515 if (!
ReadXmlBool(&oXML,
"Start_On_Trigger_NO", msGeneralSettings.bStartOnTrigNO))
1519 if (!
ReadXmlBool(&oXML,
"Start_On_Trigger_NC", msGeneralSettings.bStartOnTrigNC))
1523 if (!
ReadXmlBool(&oXML,
"Start_On_Trigger_Software", msGeneralSettings.bStartOnTrigSoftware))
1541 std::transform(tStr.begin(), tStr.end(), tStr.begin(), ::tolower);
1542 msGeneralSettings.sExternalTimebase.bEnabled = (tStr ==
"true");
1549 std::transform(tStr.begin(), tStr.end(), tStr.begin(), ::tolower);
1550 if (tStr ==
"control port")
1554 else if (tStr ==
"ir receiver")
1558 else if (tStr ==
"smpte")
1560 msGeneralSettings.sExternalTimebase.eSignalSource =
SourceSMPTE;
1562 else if (tStr ==
"irig")
1564 msGeneralSettings.sExternalTimebase.eSignalSource =
SourceIRIG;
1566 else if (tStr ==
"video sync")
1580 std::transform(tStr.begin(), tStr.end(), tStr.begin(), ::tolower);
1581 if (tStr ==
"periodic")
1583 msGeneralSettings.sExternalTimebase.bSignalModePeriodic =
true;
1585 else if (tStr ==
"non-periodic")
1587 msGeneralSettings.sExternalTimebase.bSignalModePeriodic =
false;
1598 unsigned int nMultiplier;
1600 if (sscanf(tStr.c_str(),
"%u", &nMultiplier) == 1)
1602 msGeneralSettings.sExternalTimebase.nFreqMultiplier = nMultiplier;
1613 unsigned int nDivisor;
1615 if (sscanf(tStr.c_str(),
"%u", &nDivisor) == 1)
1617 msGeneralSettings.sExternalTimebase.nFreqDivisor = nDivisor;
1628 unsigned int nTolerance;
1630 if (sscanf(tStr.c_str(),
"%u", &nTolerance) == 1)
1632 msGeneralSettings.sExternalTimebase.nFreqTolerance = nTolerance;
1644 std::transform(tStr.begin(), tStr.end(), tStr.begin(), ::tolower);
1648 msGeneralSettings.sExternalTimebase.fNominalFrequency = -1;
1653 if (sscanf(tStr.c_str(),
"%f", &fFrequency) == 1)
1655 msGeneralSettings.sExternalTimebase.fNominalFrequency = fFrequency;
1668 std::transform(tStr.begin(), tStr.end(), tStr.begin(), ::tolower);
1669 if (tStr ==
"negative")
1671 msGeneralSettings.sExternalTimebase.bNegativeEdge =
true;
1673 else if (tStr ==
"positive")
1675 msGeneralSettings.sExternalTimebase.bNegativeEdge =
false;
1686 unsigned int nDelay;
1688 if (sscanf(tStr.c_str(),
"%u", &nDelay) == 1)
1690 msGeneralSettings.sExternalTimebase.nSignalShutterDelay = nDelay;
1703 if (sscanf(tStr.c_str(),
"%f", &fTimeout) == 1)
1705 msGeneralSettings.sExternalTimebase.fNonPeriodicTimeout = fTimeout;
1714 const char* processings[3] = {
"Processing_Actions",
"RealTime_Processing_Actions",
"Reprocessing_Actions" };
1717 &msGeneralSettings.eProcessingActions,
1718 &msGeneralSettings.eRtProcessingActions,
1719 &msGeneralSettings.eReprocessingActions
1721 auto actionsCount = (mnMajorVersion > 1 || mnMinorVersion > 13) ? 3 : 1;
1722 for (
auto i = 0; i < actionsCount; i++)
1733 if (mnMajorVersion > 1 || mnMinorVersion > 13)
1750 std::transform(tStr.begin(), tStr.end(), tStr.begin(), ::tolower);
1755 else if (tStr ==
"2d" && i != 1)
1808 if (mnMajorVersion > 1 || mnMinorVersion > 11)
1849 if (mnMajorVersion > 1 || mnMinorVersion > 11)
1866 msGeneralSettings.sCameraSystem.eType = ECameraSystemType::Unknown;
1872 if (CompareNoCase(tStr,
"oqus"))
1874 msGeneralSettings.sCameraSystem.eType = ECameraSystemType::Oqus;
1876 else if (CompareNoCase(tStr,
"miqus"))
1878 msGeneralSettings.sCameraSystem.eType = ECameraSystemType::Miqus;
1885 SSettingsGeneralCamera sCameraSettings;
1895 sCameraSettings.nID = atoi(oXML.
GetChildData().c_str());
1902 std::transform(tStr.begin(), tStr.end(), tStr.begin(), ::tolower);
1904 if (tStr ==
"macreflex")
1908 else if (tStr ==
"proreflex 120")
1912 else if (tStr ==
"proreflex 240")
1916 else if (tStr ==
"proreflex 500")
1920 else if (tStr ==
"proreflex 1000")
1924 else if (tStr ==
"oqus 100")
1928 else if (tStr ==
"oqus 200" || tStr ==
"oqus 200 c")
1932 else if (tStr ==
"oqus 300")
1936 else if (tStr ==
"oqus 300 plus")
1940 else if (tStr ==
"oqus 400")
1944 else if (tStr ==
"oqus 500")
1948 else if (tStr ==
"oqus 500 plus")
1952 else if (tStr ==
"oqus 700")
1956 else if (tStr ==
"oqus 700 plus")
1960 else if (tStr ==
"oqus 600 plus")
1964 else if (tStr ==
"miqus m1")
1968 else if (tStr ==
"miqus m3")
1972 else if (tStr ==
"miqus m5")
1976 else if (tStr ==
"miqus sync unit")
1980 else if (tStr ==
"miqus video")
1984 else if (tStr ==
"miqus video color")
1997 std::transform(tStr.begin(), tStr.end(), tStr.begin(), ::tolower);
1998 sCameraSettings.bUnderwater = (tStr ==
"true");
2004 std::transform(tStr.begin(), tStr.end(), tStr.begin(), ::tolower);
2005 sCameraSettings.bSupportsHwSync = (tStr ==
"true");
2012 sCameraSettings.nSerial = atoi(oXML.
GetChildData().c_str());
2020 std::transform(tStr.begin(), tStr.end(), tStr.begin(), ::tolower);
2021 if (tStr ==
"marker")
2025 else if (tStr ==
"marker intensity")
2029 else if (tStr ==
"video")
2038 if (mnMajorVersion > 1 || mnMinorVersion > 11)
2045 sCameraSettings.nVideoFrequency = atoi(oXML.
GetChildData().c_str());
2052 std::transform(tStr.begin(), tStr.end(), tStr.begin(), ::tolower);
2053 if (tStr ==
"1080p")
2057 else if (tStr ==
"720p")
2061 else if (tStr ==
"540p")
2065 else if (tStr ==
"480p")
2079 std::transform(tStr.begin(), tStr.end(), tStr.begin(), ::tolower);
2084 else if (tStr ==
"4x3")
2088 else if (tStr ==
"1x1")
2109 sCameraSettings.nVideoExposure = atoi(oXML.
GetChildData().c_str());
2115 sCameraSettings.nVideoExposureMin = atoi(oXML.
GetChildData().c_str());
2121 sCameraSettings.nVideoExposureMax = atoi(oXML.
GetChildData().c_str());
2135 sCameraSettings.nVideoFlashTime = atoi(oXML.
GetChildData().c_str());
2141 sCameraSettings.nVideoFlashTimeMin = atoi(oXML.
GetChildData().c_str());
2147 sCameraSettings.nVideoFlashTimeMax = atoi(oXML.
GetChildData().c_str());
2161 sCameraSettings.nMarkerExposure = atoi(oXML.
GetChildData().c_str());
2167 sCameraSettings.nMarkerExposureMin = atoi(oXML.
GetChildData().c_str());
2173 sCameraSettings.nMarkerExposureMax = atoi(oXML.
GetChildData().c_str());
2188 sCameraSettings.nMarkerThreshold = atoi(oXML.
GetChildData().c_str());
2194 sCameraSettings.nMarkerThresholdMin = atoi(oXML.
GetChildData().c_str());
2200 sCameraSettings.nMarkerThresholdMax = atoi(oXML.
GetChildData().c_str());
2215 sCameraSettings.fPositionX = (float)atoi(oXML.
GetChildData().c_str());
2221 sCameraSettings.fPositionY = (float)atoi(oXML.
GetChildData().c_str());
2227 sCameraSettings.fPositionZ = (float)atoi(oXML.
GetChildData().c_str());
2233 sCameraSettings.fPositionRotMatrix[0][0] = (float)atof(oXML.
GetChildData().c_str());
2239 sCameraSettings.fPositionRotMatrix[1][0] = (float)atof(oXML.
GetChildData().c_str());
2245 sCameraSettings.fPositionRotMatrix[2][0] = (float)atof(oXML.
GetChildData().c_str());
2251 sCameraSettings.fPositionRotMatrix[0][1] = (float)atof(oXML.
GetChildData().c_str());
2257 sCameraSettings.fPositionRotMatrix[1][1] = (float)atof(oXML.
GetChildData().c_str());
2263 sCameraSettings.fPositionRotMatrix[2][1] = (float)atof(oXML.
GetChildData().c_str());
2269 sCameraSettings.fPositionRotMatrix[0][2] = (float)atof(oXML.
GetChildData().c_str());
2275 sCameraSettings.fPositionRotMatrix[1][2] = (float)atof(oXML.
GetChildData().c_str());
2281 sCameraSettings.fPositionRotMatrix[2][2] = (float)atof(oXML.
GetChildData().c_str());
2290 sCameraSettings.nOrientation = atoi(oXML.
GetChildData().c_str());
2303 sCameraSettings.nMarkerResolutionWidth = atoi(oXML.
GetChildData().c_str());
2309 sCameraSettings.nMarkerResolutionHeight = atoi(oXML.
GetChildData().c_str());
2324 sCameraSettings.nVideoResolutionWidth = atoi(oXML.
GetChildData().c_str());
2330 sCameraSettings.nVideoResolutionHeight = atoi(oXML.
GetChildData().c_str());
2345 sCameraSettings.nMarkerFOVLeft = atoi(oXML.
GetChildData().c_str());
2351 sCameraSettings.nMarkerFOVTop = atoi(oXML.
GetChildData().c_str());
2357 sCameraSettings.nMarkerFOVRight = atoi(oXML.
GetChildData().c_str());
2363 sCameraSettings.nMarkerFOVBottom = atoi(oXML.
GetChildData().c_str());
2378 sCameraSettings.nVideoFOVLeft = atoi(oXML.
GetChildData().c_str());
2384 sCameraSettings.nVideoFOVTop = atoi(oXML.
GetChildData().c_str());
2390 sCameraSettings.nVideoFOVRight = atoi(oXML.
GetChildData().c_str());
2396 sCameraSettings.nVideoFOVBottom = atoi(oXML.
GetChildData().c_str());
2402 for (
int port = 0; port < 3; port++)
2404 char syncOutStr[16];
2405 sprintf(syncOutStr,
"Sync_Out%s", port == 0 ?
"" : (port == 1 ?
"2" :
"_MT"));
2417 std::transform(tStr.begin(), tStr.end(), tStr.begin(), ::tolower);
2418 if (tStr ==
"shutter out")
2422 else if (tStr ==
"multiplier")
2426 else if (tStr ==
"divisor")
2430 else if (tStr ==
"camera independent")
2434 else if (tStr ==
"measurement time")
2438 else if (tStr ==
"continuous 100hz")
2448 sCameraSettings.eSyncOutMode[port] ==
ModeDivisor ||
2455 sCameraSettings.nSyncOutValue[port] = atoi(oXML.
GetChildData().c_str());
2461 sCameraSettings.fSyncOutDutyCycle[port] = (float)atof(oXML.
GetChildData().c_str());
2473 sCameraSettings.bSyncOutNegativePolarity[port] =
true;
2477 sCameraSettings.bSyncOutNegativePolarity[port] =
false;
2485 sCameraSettings.nSyncOutValue[port] = 0;
2486 sCameraSettings.fSyncOutDutyCycle[port] = 0;
2487 sCameraSettings.bSyncOutNegativePolarity[port] =
false;
2498 if (sscanf(oXML.
GetAttrib(
"Value").c_str(),
"%f", &focus) == 1)
2500 sCameraSettings.fFocus = focus;
2508 if (sscanf(oXML.
GetAttrib(
"Value").c_str(),
"%f", &aperture) == 1)
2510 sCameraSettings.fAperture = aperture;
2518 sCameraSettings.fFocus = std::numeric_limits<float>::quiet_NaN();
2519 sCameraSettings.fAperture = std::numeric_limits<float>::quiet_NaN();
2525 if (CompareNoCase(oXML.
GetAttrib(
"Enabled"),
"true"))
2527 sCameraSettings.autoExposureEnabled =
true;
2529 float autoExposureCompensation;
2530 if (sscanf(oXML.
GetAttrib(
"Compensation").c_str(),
"%f", &autoExposureCompensation) == 1)
2532 sCameraSettings.autoExposureCompensation = autoExposureCompensation;
2538 sCameraSettings.autoExposureEnabled =
false;
2539 sCameraSettings.autoExposureCompensation = std::numeric_limits<float>::quiet_NaN();
2544 sCameraSettings.autoWhiteBalance = CompareNoCase(oXML.
GetChildData().c_str(),
"true") ? 1 : 0;
2548 sCameraSettings.autoWhiteBalance = -1;
2553 msGeneralSettings.vsCameras.push_back(sCameraSettings);
2565 bDataAvailable =
false;
2567 ms3DSettings.s3DLabels.clear();
2568 ms3DSettings.pCalibrationTime[0] = 0;
2570 if (!SendCommand(
"GetParameters 3D"))
2572 strcpy(maErrorStr,
"GetParameters 3D failed");
2582 strcat(maErrorStr,
" Expected XML packet.");
2595 sprintf(maErrorStr,
"GetParameters 3D returned wrong packet type. Got type %d expected type 2.", eType);
2614 std::transform(tStr.begin(), tStr.end(), tStr.begin(), ::tolower);
2618 ms3DSettings.eAxisUpwards =
XPos;
2620 else if (tStr ==
"-x")
2622 ms3DSettings.eAxisUpwards =
XNeg;
2624 else if (tStr ==
"+y")
2626 ms3DSettings.eAxisUpwards =
YPos;
2628 else if (tStr ==
"-y")
2630 ms3DSettings.eAxisUpwards =
YNeg;
2632 else if (tStr ==
"+z")
2634 ms3DSettings.eAxisUpwards =
ZPos;
2636 else if (tStr ==
"-z")
2638 ms3DSettings.eAxisUpwards =
ZNeg;
2650 strcpy(ms3DSettings.pCalibrationTime, tStr.c_str());
2656 unsigned int nNumberOfLabels = atoi(oXML.
GetChildData().c_str());
2658 ms3DSettings.s3DLabels.resize(nNumberOfLabels);
2659 SSettings3DLabel sLabel;
2661 for (
unsigned int iLabel = 0; iLabel < nNumberOfLabels; iLabel++)
2673 ms3DSettings.s3DLabels[iLabel] = sLabel;
2683 ms3DSettings.sBones.clear();
2690 SSettingsBone bone = { };
2691 bone.fromName = oXML.
GetAttrib(
"From").c_str();
2692 bone.toName = oXML.
GetAttrib(
"To").c_str();
2694 auto colorString = oXML.
GetAttrib(
"Color");
2695 if (!colorString.empty())
2697 bone.color = atoi(colorString.c_str());
2699 ms3DSettings.sBones.push_back(bone);
2705 bDataAvailable =
true;
2714 bDataAvailable =
false;
2716 mvs6DOFSettings.bodySettings.clear();
2718 if (!SendCommand(
"GetParameters 6D"))
2720 strcpy(maErrorStr,
"GetParameters 6D failed");
2730 strcat(maErrorStr,
" Expected XML packet.");
2743 sprintf(maErrorStr,
"GetParameters 6D returned wrong packet type. Got type %d expected type 2.", eType);
2764 SSettings6DOFBody s6DOFBodySettings;
2767 for (
int iBody = 0; iBody < nBodies; iBody++)
2785 s6DOFBodySettings.vsPoints.clear();
2786 s6DOFBodySettings.nRGBColor = atoi(oXML.
GetChildData().c_str());
2810 s6DOFBodySettings.vsPoints.push_back(sPoint);
2812 mvs6DOFSettings.bodySettings.push_back(s6DOFBodySettings);
2816 if (mnMajorVersion > 1 || mnMinorVersion > 15)
2840 bDataAvailable =
true;
2849 bDataAvailable =
false;
2851 mvsGazeVectorSettings.clear();
2853 if (!SendCommand(
"GetParameters GazeVector"))
2855 strcpy(maErrorStr,
"GetParameters GazeVector failed");
2865 strcat(maErrorStr,
" Expected XML packet.");
2878 sprintf(maErrorStr,
"GetParameters GazeVector returned wrong packet type. Got type %d expected type 2.", eType);
2894 std::string tGazeVectorName;
2896 int nGazeVectorCount = 0;
2908 float frequency = 0;
2914 mvsGazeVectorSettings.push_back({ tGazeVectorName, frequency });
2919 bDataAvailable =
true;
2928 bDataAvailable =
false;
2929 mvsAnalogDeviceSettings.clear();
2931 if (!SendCommand(
"GetParameters Analog"))
2933 strcpy(maErrorStr,
"GetParameters Analog failed");
2943 strcat(maErrorStr,
" Expected XML packet.");
2956 sprintf(maErrorStr,
"GetParameters Analog returned wrong packet type. Got type %d expected type 2.", eType);
2969 SAnalogDevice sAnalogDevice;
2973 if (mnMajorVersion == 1 && mnMinorVersion == 0)
2975 sAnalogDevice.nDeviceID = 1;
2976 sAnalogDevice.oName =
"AnalogDevice";
2981 sAnalogDevice.nChannels = atoi(oXML.
GetChildData().c_str());
2986 sAnalogDevice.nFrequency = atoi(oXML.
GetChildData().c_str());
3001 sAnalogDevice.fMinRange = (float)atof(oXML.
GetChildData().c_str());
3006 sAnalogDevice.fMaxRange = (float)atof(oXML.
GetChildData().c_str());
3007 mvsAnalogDeviceSettings.push_back(sAnalogDevice);
3008 bDataAvailable =
true;
3015 sAnalogDevice.voLabels.clear();
3016 sAnalogDevice.voUnits.clear();
3023 sAnalogDevice.nDeviceID = atoi(oXML.
GetChildData().c_str());
3037 sAnalogDevice.nChannels = atoi(oXML.
GetChildData().c_str());
3044 sAnalogDevice.nFrequency = atoi(oXML.
GetChildData().c_str());
3046 if (mnMajorVersion == 1 && mnMinorVersion < 11)
3068 sAnalogDevice.fMinRange = (float)atof(oXML.
GetChildData().c_str());
3076 sAnalogDevice.fMaxRange = (float)atof(oXML.
GetChildData().c_str());
3079 if (mnMajorVersion == 1 && mnMinorVersion < 11)
3081 for (
unsigned int i = 0; i < sAnalogDevice.nChannels; i++)
3088 if (sAnalogDevice.voLabels.size() != sAnalogDevice.nChannels)
3109 if (sAnalogDevice.voLabels.size() != sAnalogDevice.nChannels ||
3110 sAnalogDevice.voUnits.size() != sAnalogDevice.nChannels)
3117 mvsAnalogDeviceSettings.push_back(sAnalogDevice);
3118 bDataAvailable =
true;
3130 bDataAvailable =
false;
3132 msForceSettings.vsForcePlates.clear();
3134 if (!SendCommand(
"GetParameters Force"))
3136 strcpy(maErrorStr,
"GetParameters Force failed");
3146 strcat(maErrorStr,
" Expected XML packet.");
3159 sprintf(maErrorStr,
"GetParameters Force returned wrong packet type. Got type %d expected type 2.", eType);
3175 SForcePlate sForcePlate;
3176 sForcePlate.bValidCalibrationMatrix =
false;
3177 sForcePlate.nCalibrationMatrixRows = 6;
3178 sForcePlate.nCalibrationMatrixColumns = 6;
3214 sForcePlate.nAnalogDeviceID = atoi(oXML.
GetChildData().c_str());
3218 sForcePlate.nAnalogDeviceID = 0;
3225 sForcePlate.nFrequency = atoi(oXML.
GetChildData().c_str());
3233 sForcePlate.oType =
"unknown";
3247 sForcePlate.fLength = (float)atof(oXML.
GetChildData().c_str());
3251 sForcePlate.fWidth = (float)atof(oXML.
GetChildData().c_str());
3262 sForcePlate.asCorner[0].fX = (float)atof(oXML.
GetChildData().c_str());
3266 sForcePlate.asCorner[0].fY = (float)atof(oXML.
GetChildData().c_str());
3270 sForcePlate.asCorner[0].fZ = (float)atof(oXML.
GetChildData().c_str());
3279 sForcePlate.asCorner[1].fX = (float)atof(oXML.
GetChildData().c_str());
3283 sForcePlate.asCorner[1].fY = (float)atof(oXML.
GetChildData().c_str());
3287 sForcePlate.asCorner[1].fZ = (float)atof(oXML.
GetChildData().c_str());
3296 sForcePlate.asCorner[2].fX = (float)atof(oXML.
GetChildData().c_str());
3300 sForcePlate.asCorner[2].fY = (float)atof(oXML.
GetChildData().c_str());
3304 sForcePlate.asCorner[2].fZ = (float)atof(oXML.
GetChildData().c_str());
3313 sForcePlate.asCorner[3].fX = (float)atof(oXML.
GetChildData().c_str());
3317 sForcePlate.asCorner[3].fY = (float)atof(oXML.
GetChildData().c_str());
3321 sForcePlate.asCorner[3].fZ = (float)atof(oXML.
GetChildData().c_str());
3333 sForcePlate.sOrigin.fX = (float)atof(oXML.
GetChildData().c_str());
3337 sForcePlate.sOrigin.fY = (float)atof(oXML.
GetChildData().c_str());
3341 sForcePlate.sOrigin.fZ = (float)atof(oXML.
GetChildData().c_str());
3346 sForcePlate.vChannels.clear();
3350 SForceChannel sForceChannel;
3356 sForceChannel.nChannelNumber = atoi(oXML.
GetChildData().c_str());
3360 sForceChannel.fConversionFactor = (float)atof(oXML.
GetChildData().c_str());
3362 sForcePlate.vChannels.push_back(sForceChannel);
3373 if (mnMajorVersion == 1 && mnMinorVersion < 12)
3377 sprintf(strRow,
"Row%d", nRow + 1);
3382 sprintf(strCol,
"Col%d", nCol + 1);
3385 sForcePlate.afCalibrationMatrix[nRow][nCol] = (float)atof(oXML.
GetChildData().c_str());
3387 sprintf(strCol,
"Col%d", nCol + 1);
3389 sForcePlate.nCalibrationMatrixColumns = nCol;
3392 sprintf(strRow,
"Row%d", nRow + 1);
3415 sForcePlate.afCalibrationMatrix[nRow][nCol] = (float)atof(oXML.
GetChildData().c_str());
3418 sForcePlate.nCalibrationMatrixColumns = nCol;
3428 sForcePlate.nCalibrationMatrixRows = nRow;
3429 sForcePlate.bValidCalibrationMatrix =
true;
3435 bDataAvailable =
true;
3436 msForceSettings.vsForcePlates.push_back(sForcePlate);
3447 bDataAvailable =
false;
3449 mvsImageSettings.clear();
3451 if (!SendCommand(
"GetParameters Image"))
3453 strcpy(maErrorStr,
"GetParameters Image failed");
3463 strcat(maErrorStr,
" Expected XML packet.");
3476 sprintf(maErrorStr,
"GetParameters Image returned wrong packet type. Got type %d expected type 2.", eType);
3495 SImageCamera sImageCamera;
3509 std::transform(tStr.begin(), tStr.end(), tStr.begin(), ::tolower);
3513 sImageCamera.bEnabled =
true;
3517 sImageCamera.bEnabled =
false;
3525 std::transform(tStr.begin(), tStr.end(), tStr.begin(), ::tolower);
3527 if (tStr ==
"rawgrayscale")
3531 else if (tStr ==
"rawbgr")
3535 else if (tStr ==
"jpg")
3539 else if (tStr ==
"png")
3552 sImageCamera.nWidth = atoi(oXML.
GetChildData().c_str());
3558 sImageCamera.nHeight = atoi(oXML.
GetChildData().c_str());
3564 sImageCamera.fCropLeft = (float)atof(oXML.
GetChildData().c_str());
3570 sImageCamera.fCropTop = (float)atof(oXML.
GetChildData().c_str());
3576 sImageCamera.fCropRight = (float)atof(oXML.
GetChildData().c_str());
3582 sImageCamera.fCropBottom = (float)atof(oXML.
GetChildData().c_str());
3586 mvsImageSettings.push_back(sImageCamera);
3587 bDataAvailable =
true;
3599 bDataAvailable =
false;
3601 mSkeletonSettings.clear();
3603 std::string cmd(
"GetParameters Skeleton");
3604 if (skeletonGlobalData)
3608 if (!SendCommand(cmd.c_str()))
3610 strcpy(maErrorStr,
"GetParameters Skeleton failed");
3620 strcat(maErrorStr,
" Expected XML packet.");
3633 sprintf(maErrorStr,
"GetParameters Skeleton returned wrong packet type. Got type %d expected type 2.", eType);
3646 std::string skeletonName;
3648 std::map<int, int> segmentIdIndexMap;
3665 if (segment.
name.size() == 0 || sscanf(oXML.
GetAttrib(
"ID").c_str(),
"%u", &segment.
id) != 1)
3670 segmentIdIndexMap[segment.
id] = segmentIndex++;
3673 if (sscanf(oXML.
GetAttrib(
"Parent_ID").c_str(),
"%d", &parentId) != 1)
3678 else if (segmentIdIndexMap.count(parentId) > 0)
3681 segment.
parentIndex = segmentIdIndexMap[parentId];
3688 if (sscanf(oXML.
GetAttrib(
"X").c_str(),
"%f", &x) == 1)
3692 if (sscanf(oXML.
GetAttrib(
"Y").c_str(),
"%f", &y) == 1)
3696 if (sscanf(oXML.
GetAttrib(
"Z").c_str(),
"%f", &z) == 1)
3707 if (sscanf(oXML.
GetAttrib(
"X").c_str(),
"%f", &x) == 1)
3711 if (sscanf(oXML.
GetAttrib(
"Y").c_str(),
"%f", &y) == 1)
3715 if (sscanf(oXML.
GetAttrib(
"Z").c_str(),
"%f", &z) == 1)
3719 if (sscanf(oXML.
GetAttrib(
"W").c_str(),
"%f", &w) == 1)
3726 skeleton.
segments.push_back(segment);
3731 mSkeletonSettings.push_back(skeleton);
3738 bDataAvailable =
true;
3744 unsigned int &nCaptureFrequency,
float &fCaptureTime,
3745 bool& bStartOnExtTrig,
bool& startOnTrigNO,
bool& startOnTrigNC,
bool& startOnTrigSoftware,
3748 nCaptureFrequency = msGeneralSettings.nCaptureFrequency;
3749 fCaptureTime = msGeneralSettings.fCaptureTime;
3750 bStartOnExtTrig = msGeneralSettings.bStartOnExternalTrigger;
3751 startOnTrigNO = msGeneralSettings.bStartOnTrigNO;
3752 startOnTrigNC = msGeneralSettings.bStartOnTrigNC;
3753 startOnTrigSoftware = msGeneralSettings.bStartOnTrigSoftware;
3754 eProcessingActions = msGeneralSettings.eProcessingActions;
3755 eRtProcessingActions = msGeneralSettings.eRtProcessingActions;
3756 eReprocessingActions = msGeneralSettings.eReprocessingActions;
3763 bool &bSignalModePeriodic,
unsigned int &nFreqMultiplier,
3764 unsigned int &nFreqDivisor,
unsigned int &nFreqTolerance,
3765 float &fNominalFrequency,
bool &bNegativeEdge,
3766 unsigned int &nSignalShutterDelay,
float &fNonPeriodicTimeout)
const 3768 bEnabled = msGeneralSettings.sExternalTimebase.bEnabled;
3769 eSignalSource = msGeneralSettings.sExternalTimebase.eSignalSource;
3770 bSignalModePeriodic = msGeneralSettings.sExternalTimebase.bSignalModePeriodic;
3771 nFreqMultiplier = msGeneralSettings.sExternalTimebase.nFreqMultiplier;
3772 nFreqDivisor = msGeneralSettings.sExternalTimebase.nFreqDivisor;
3773 nFreqTolerance = msGeneralSettings.sExternalTimebase.nFreqTolerance;
3774 fNominalFrequency = msGeneralSettings.sExternalTimebase.fNominalFrequency;
3775 bNegativeEdge = msGeneralSettings.sExternalTimebase.bNegativeEdge;
3776 nSignalShutterDelay = msGeneralSettings.sExternalTimebase.nSignalShutterDelay;
3777 fNonPeriodicTimeout = msGeneralSettings.sExternalTimebase.fNonPeriodicTimeout;
3783 return (
unsigned int)msGeneralSettings.vsCameras.size();
3788 unsigned int nCameraIndex,
unsigned int &nID,
ECameraModel &eModel,
3789 bool &bUnderwater,
bool &bSupportsHwSync,
unsigned int &nSerial,
ECameraMode &eMode)
const 3791 if (nCameraIndex < msGeneralSettings.vsCameras.size())
3793 nID = msGeneralSettings.vsCameras[nCameraIndex].nID;
3794 eModel = msGeneralSettings.vsCameras[nCameraIndex].eModel;
3795 bUnderwater = msGeneralSettings.vsCameras[nCameraIndex].bUnderwater;
3796 bSupportsHwSync = msGeneralSettings.vsCameras[nCameraIndex].bSupportsHwSync;
3797 nSerial = msGeneralSettings.vsCameras[nCameraIndex].nSerial;
3798 eMode = msGeneralSettings.vsCameras[nCameraIndex].eMode;
3806 unsigned int nCameraIndex,
unsigned int &nCurrentExposure,
unsigned int &nMinExposure,
3807 unsigned int &nMaxExposure,
unsigned int &nCurrentThreshold,
3808 unsigned int &nMinThreshold,
unsigned int &nMaxThreshold)
const 3810 if (nCameraIndex < msGeneralSettings.vsCameras.size())
3812 nCurrentExposure = msGeneralSettings.vsCameras[nCameraIndex].nMarkerExposure;
3813 nMinExposure = msGeneralSettings.vsCameras[nCameraIndex].nMarkerExposureMin;
3814 nMaxExposure = msGeneralSettings.vsCameras[nCameraIndex].nMarkerExposureMax;
3815 nCurrentThreshold = msGeneralSettings.vsCameras[nCameraIndex].nMarkerThreshold;
3816 nMinThreshold = msGeneralSettings.vsCameras[nCameraIndex].nMarkerThresholdMin;
3817 nMaxThreshold = msGeneralSettings.vsCameras[nCameraIndex].nMarkerThresholdMax;
3827 unsigned int &nCurrentExposure,
unsigned int &nMinExposure,
3828 unsigned int &nMaxExposure,
unsigned int &nCurrentFlashTime,
3829 unsigned int &nMinFlashTime,
unsigned int &nMaxFlashTime)
const 3831 if (nCameraIndex < msGeneralSettings.vsCameras.size())
3833 eVideoResolution = msGeneralSettings.vsCameras[nCameraIndex].eVideoResolution;
3834 eVideoAspectRatio = msGeneralSettings.vsCameras[nCameraIndex].eVideoAspectRatio;
3835 nVideoFrequency = msGeneralSettings.vsCameras[nCameraIndex].nVideoFrequency;
3836 nCurrentExposure = msGeneralSettings.vsCameras[nCameraIndex].nVideoExposure;
3837 nMinExposure = msGeneralSettings.vsCameras[nCameraIndex].nVideoExposureMin;
3838 nMaxExposure = msGeneralSettings.vsCameras[nCameraIndex].nVideoExposureMax;
3839 nCurrentFlashTime = msGeneralSettings.vsCameras[nCameraIndex].nVideoFlashTime;
3840 nMinFlashTime = msGeneralSettings.vsCameras[nCameraIndex].nVideoFlashTimeMin;
3841 nMaxFlashTime = msGeneralSettings.vsCameras[nCameraIndex].nVideoFlashTimeMax;
3849 unsigned int nCameraIndex,
unsigned int portNumber,
ESyncOutFreqMode &eSyncOutMode,
3850 unsigned int &nSyncOutValue,
float &fSyncOutDutyCycle,
3851 bool &bSyncOutNegativePolarity)
const 3853 if (nCameraIndex < msGeneralSettings.vsCameras.size())
3855 if (portNumber == 1 || portNumber == 2)
3857 eSyncOutMode = msGeneralSettings.vsCameras[nCameraIndex].eSyncOutMode[portNumber - 1];
3858 nSyncOutValue = msGeneralSettings.vsCameras[nCameraIndex].nSyncOutValue[portNumber - 1];
3859 fSyncOutDutyCycle = msGeneralSettings.vsCameras[nCameraIndex].fSyncOutDutyCycle[portNumber - 1];
3861 if (portNumber > 0 && portNumber < 4)
3863 bSyncOutNegativePolarity = msGeneralSettings.vsCameras[nCameraIndex].bSyncOutNegativePolarity[portNumber - 1];
3876 unsigned int nCameraIndex,
SPoint &sPoint,
float fvRotationMatrix[3][3])
const 3878 if (nCameraIndex < msGeneralSettings.vsCameras.size())
3880 sPoint.
fX = msGeneralSettings.vsCameras[nCameraIndex].fPositionX;
3881 sPoint.
fY = msGeneralSettings.vsCameras[nCameraIndex].fPositionY;
3882 sPoint.
fZ = msGeneralSettings.vsCameras[nCameraIndex].fPositionZ;
3883 memcpy(fvRotationMatrix, msGeneralSettings.vsCameras[nCameraIndex].fPositionRotMatrix, 9 *
sizeof(
float));
3891 unsigned int nCameraIndex,
int &nOrientation)
const 3893 if (nCameraIndex < msGeneralSettings.vsCameras.size())
3895 nOrientation = msGeneralSettings.vsCameras[nCameraIndex].nOrientation;
3902 unsigned int nCameraIndex,
unsigned int &nMarkerWidth,
unsigned int &nMarkerHeight,
3903 unsigned int &nVideoWidth,
unsigned int &nVideoHeight)
const 3905 if (nCameraIndex < msGeneralSettings.vsCameras.size())
3907 nMarkerWidth = msGeneralSettings.vsCameras[nCameraIndex].nMarkerResolutionWidth;
3908 nMarkerHeight = msGeneralSettings.vsCameras[nCameraIndex].nMarkerResolutionHeight;
3909 nVideoWidth = msGeneralSettings.vsCameras[nCameraIndex].nVideoResolutionWidth;
3910 nVideoHeight = msGeneralSettings.vsCameras[nCameraIndex].nVideoResolutionHeight;
3917 unsigned int nCameraIndex,
unsigned int &nMarkerLeft,
unsigned int &nMarkerTop,
3918 unsigned int &nMarkerRight,
unsigned int &nMarkerBottom,
3919 unsigned int &nVideoLeft,
unsigned int &nVideoTop,
3920 unsigned int &nVideoRight,
unsigned int &nVideoBottom)
const 3922 if (nCameraIndex < msGeneralSettings.vsCameras.size())
3924 nMarkerLeft = msGeneralSettings.vsCameras[nCameraIndex].nMarkerFOVLeft;
3925 nMarkerTop = msGeneralSettings.vsCameras[nCameraIndex].nMarkerFOVTop;
3926 nMarkerRight = msGeneralSettings.vsCameras[nCameraIndex].nMarkerFOVRight;
3927 nMarkerBottom = msGeneralSettings.vsCameras[nCameraIndex].nMarkerFOVBottom;
3928 nVideoLeft = msGeneralSettings.vsCameras[nCameraIndex].nVideoFOVLeft;
3929 nVideoTop = msGeneralSettings.vsCameras[nCameraIndex].nVideoFOVTop;
3930 nVideoRight = msGeneralSettings.vsCameras[nCameraIndex].nVideoFOVRight;
3931 nVideoBottom = msGeneralSettings.vsCameras[nCameraIndex].nVideoFOVBottom;
3939 if (nCameraIndex < msGeneralSettings.vsCameras.size())
3941 *focus = msGeneralSettings.vsCameras[nCameraIndex].fFocus;
3942 if (std::isnan(*focus))
3944 *aperture = msGeneralSettings.vsCameras[nCameraIndex].fAperture;
3952 if (nCameraIndex < msGeneralSettings.vsCameras.size())
3954 *autoExposureCompensation = msGeneralSettings.vsCameras[nCameraIndex].autoExposureCompensation;
3955 if (std::isnan(*autoExposureCompensation))
3957 *autoExposureEnabled = msGeneralSettings.vsCameras[nCameraIndex].autoExposureEnabled;
3965 if (nCameraIndex < msGeneralSettings.vsCameras.size() && msGeneralSettings.vsCameras[nCameraIndex].autoWhiteBalance >= 0)
3967 *autoWhiteBalanceEnabled = msGeneralSettings.vsCameras[nCameraIndex].autoWhiteBalance == 1;
3975 return ms3DSettings.eAxisUpwards;
3980 return ms3DSettings.pCalibrationTime;
3985 return (
unsigned int)ms3DSettings.s3DLabels.size();
3990 if (nMarkerIndex < ms3DSettings.s3DLabels.size())
3992 return ms3DSettings.s3DLabels[nMarkerIndex].oName.c_str();
3999 if (nMarkerIndex < ms3DSettings.s3DLabels.size())
4001 return ms3DSettings.s3DLabels[nMarkerIndex].nRGBColor;
4009 return (
unsigned int)ms3DSettings.sBones.size();
4014 if (boneIndex < ms3DSettings.sBones.size())
4016 return ms3DSettings.sBones[boneIndex].fromName.c_str();
4023 if (boneIndex < ms3DSettings.sBones.size())
4025 return ms3DSettings.sBones[boneIndex].toName.c_str();
4032 first = mvs6DOFSettings.eulerFirst;
4033 second = mvs6DOFSettings.eulerSecond;
4034 third = mvs6DOFSettings.eulerThird;
4040 return (
unsigned int)mvs6DOFSettings.bodySettings.size();
4046 if (nBodyIndex < mvs6DOFSettings.bodySettings.size())
4048 return mvs6DOFSettings.bodySettings[nBodyIndex].oName.c_str();
4056 if (nBodyIndex < mvs6DOFSettings.bodySettings.size())
4058 return mvs6DOFSettings.bodySettings[nBodyIndex].nRGBColor;
4066 if (nBodyIndex < mvs6DOFSettings.bodySettings.size())
4068 return (
unsigned int)mvs6DOFSettings.bodySettings.at(nBodyIndex).vsPoints.size();
4076 if (nBodyIndex < mvs6DOFSettings.bodySettings.size())
4078 if (nMarkerIndex < mvs6DOFSettings.bodySettings.at(nBodyIndex).vsPoints.size())
4080 sPoint.
fX = mvs6DOFSettings.bodySettings.at(nBodyIndex).vsPoints[nMarkerIndex].fX;
4081 sPoint.
fY = mvs6DOFSettings.bodySettings.at(nBodyIndex).vsPoints[nMarkerIndex].fY;
4082 sPoint.
fZ = mvs6DOFSettings.bodySettings.at(nBodyIndex).vsPoints[nMarkerIndex].fZ;
4092 return (
unsigned int)mvsGazeVectorSettings.size();
4098 if (nGazeVectorIndex < mvsGazeVectorSettings.size())
4100 return mvsGazeVectorSettings[nGazeVectorIndex].name.c_str();
4107 if (nGazeVectorIndex < mvsGazeVectorSettings.size())
4109 return mvsGazeVectorSettings[nGazeVectorIndex].frequency;
4117 return (
unsigned int)mvsAnalogDeviceSettings.size();
4122 char* &pName,
unsigned int &nFrequency,
char* &pUnit,
4123 float &fMinRange,
float &fMaxRange)
const 4125 if (nDeviceIndex < mvsAnalogDeviceSettings.size())
4127 nDeviceID = mvsAnalogDeviceSettings.at(nDeviceIndex).nDeviceID;
4128 pName = (
char*)mvsAnalogDeviceSettings.at(nDeviceIndex).oName.c_str();
4129 nChannels = mvsAnalogDeviceSettings.at(nDeviceIndex).nChannels;
4130 nFrequency = mvsAnalogDeviceSettings.at(nDeviceIndex).nFrequency;
4131 pUnit = (
char*)mvsAnalogDeviceSettings.at(nDeviceIndex).oUnit.c_str();
4132 fMinRange = mvsAnalogDeviceSettings.at(nDeviceIndex).fMinRange;
4133 fMaxRange = mvsAnalogDeviceSettings.at(nDeviceIndex).fMaxRange;
4143 if (nDeviceIndex < mvsAnalogDeviceSettings.size())
4145 if (nChannelIndex < mvsAnalogDeviceSettings.at(nDeviceIndex).voLabels.size())
4147 return mvsAnalogDeviceSettings.at(nDeviceIndex).voLabels.at(nChannelIndex).c_str();
4156 if (nDeviceIndex < mvsAnalogDeviceSettings.size())
4158 if (nChannelIndex < mvsAnalogDeviceSettings.at(nDeviceIndex).voUnits.size())
4160 return mvsAnalogDeviceSettings.at(nDeviceIndex).voUnits.at(nChannelIndex).c_str();
4169 pLength = (
char*)msForceSettings.oUnitLength.c_str();
4170 pForce = (
char*)msForceSettings.oUnitForce.c_str();
4176 return (
unsigned int)msForceSettings.vsForcePlates.size();
4181 unsigned int &nFrequency,
char* &pType,
char* &pName,
float &fLength,
float &fWidth)
const 4183 if (nPlateIndex < msForceSettings.vsForcePlates.size())
4185 nID = msForceSettings.vsForcePlates[nPlateIndex].nID;
4186 nAnalogDeviceID = msForceSettings.vsForcePlates[nPlateIndex].nAnalogDeviceID;
4187 nFrequency = msForceSettings.vsForcePlates[nPlateIndex].nFrequency;
4188 pType = (
char*)msForceSettings.vsForcePlates[nPlateIndex].oType.c_str();
4189 pName = (
char*)msForceSettings.vsForcePlates[nPlateIndex].oName.c_str();
4190 fLength = msForceSettings.vsForcePlates[nPlateIndex].fLength;
4191 fWidth = msForceSettings.vsForcePlates[nPlateIndex].fWidth;
4200 if (nPlateIndex < msForceSettings.vsForcePlates.size())
4202 memcpy(sCorner, msForceSettings.vsForcePlates[nPlateIndex].asCorner, 3 * 4 *
sizeof(
float));
4211 if (nPlateIndex < msForceSettings.vsForcePlates.size())
4213 sOrigin = msForceSettings.vsForcePlates[nPlateIndex].sOrigin;
4222 if (nPlateIndex < msForceSettings.vsForcePlates.size())
4224 return (
unsigned int)msForceSettings.vsForcePlates[nPlateIndex].vChannels.size();
4231 unsigned int &nChannelNumber,
float &fConversionFactor)
const 4233 if (nPlateIndex < msForceSettings.vsForcePlates.size())
4235 if (nChannelIndex < msForceSettings.vsForcePlates[nPlateIndex].vChannels.size())
4237 nChannelNumber = msForceSettings.vsForcePlates[nPlateIndex].vChannels[nChannelIndex].nChannelNumber;
4238 fConversionFactor = msForceSettings.vsForcePlates[nPlateIndex].vChannels[nChannelIndex].fConversionFactor;
4248 if (nPlateIndex < msForceSettings.vsForcePlates.size())
4250 if (msForceSettings.vsForcePlates[nPlateIndex].bValidCalibrationMatrix)
4252 *rows = msForceSettings.vsForcePlates[nPlateIndex].nCalibrationMatrixRows;
4253 *columns = msForceSettings.vsForcePlates[nPlateIndex].nCalibrationMatrixColumns;
4256 msForceSettings.vsForcePlates[nPlateIndex].afCalibrationMatrix,
4257 msForceSettings.vsForcePlates[nPlateIndex].nCalibrationMatrixRows * msForceSettings.vsForcePlates[nPlateIndex].nCalibrationMatrixColumns *
sizeof(
float));
4267 return (
unsigned int)mvsImageSettings.size();
4273 float &fCropLeft,
float &fCropTop,
float &fCropRight,
float &fCropBottom)
const 4275 if (nCameraIndex < mvsImageSettings.size())
4277 nCameraID = mvsImageSettings[nCameraIndex].nID;
4278 bEnabled = mvsImageSettings[nCameraIndex].bEnabled;
4279 eFormat = mvsImageSettings[nCameraIndex].eFormat;
4280 nWidth = mvsImageSettings[nCameraIndex].nWidth;
4281 nHeight = mvsImageSettings[nCameraIndex].nHeight;
4282 fCropLeft = mvsImageSettings[nCameraIndex].fCropLeft;
4283 fCropTop = mvsImageSettings[nCameraIndex].fCropTop;
4284 fCropRight = mvsImageSettings[nCameraIndex].fCropRight;
4285 fCropBottom = mvsImageSettings[nCameraIndex].fCropBottom;
4293 return (
unsigned int)mSkeletonSettings.size();
4299 if (skeletonIndex < mSkeletonSettings.size())
4301 return (
char*)mSkeletonSettings[skeletonIndex].name.c_str();
4309 if (skeletonIndex < mSkeletonSettings.size())
4311 return static_cast<long unsigned>(mSkeletonSettings[skeletonIndex].segments.size());
4318 if (skeleton ==
nullptr)
4321 if (skeletonIndex < mSkeletonSettings.size())
4323 *skeleton = mSkeletonSettings[skeletonIndex];
4331 if (segment ==
nullptr)
4334 if (skeletonIndex < mSkeletonSettings.size())
4336 if (segmentIndex < mSkeletonSettings[skeletonIndex].segments.size())
4338 *segment = mSkeletonSettings[skeletonIndex].segments[segmentIndex];
4348 return msGeneralSettings.sCameraSystem.eType;
4353 const unsigned int* pnCaptureFrequency,
const float* pfCaptureTime,
4354 const bool* pbStartOnExtTrig,
const bool* startOnTrigNO,
const bool* startOnTrigNC,
const bool* startOnTrigSoftware,
4364 if (pnCaptureFrequency)
4366 AddXMLElementUnsignedInt(&oXML,
"Frequency", pnCaptureFrequency);
4370 AddXMLElementFloat(&oXML,
"Capture_Time", pfCaptureTime, 3);
4372 if (pbStartOnExtTrig)
4374 AddXMLElementBool(&oXML,
"Start_On_External_Trigger", pbStartOnExtTrig);
4375 if (mnMajorVersion > 1 || mnMinorVersion > 14)
4377 AddXMLElementBool(&oXML,
"Start_On_Trigger_NO", startOnTrigNO);
4378 AddXMLElementBool(&oXML,
"Start_On_Trigger_NC", startOnTrigNC);
4379 AddXMLElementBool(&oXML,
"Start_On_Trigger_Software", startOnTrigSoftware);
4383 const char* processings[3] = {
"Processing_Actions",
"RealTime_Processing_Actions",
"Reprocessing_Actions" };
4384 const EProcessingActions* processingActions[3] = { peProcessingActions, peRtProcessingActions, peReprocessingActions };
4386 auto actionsCount = (mnMajorVersion > 1 || mnMinorVersion > 13) ? 3 : 1;
4388 for (
auto i = 0; i < actionsCount; i++)
4390 if (processingActions[i])
4395 if (mnMajorVersion > 1 || mnMinorVersion > 13)
4401 oXML.
AddElem(
"Tracking",
"2D");
4405 oXML.
AddElem(
"Tracking",
"3D");
4409 oXML.
AddElem(
"Tracking",
"False");
4416 AddXMLElementBool(&oXML,
"AIM", (*processingActions[i] &
ProcessingAIM) != 0);
4418 AddXMLElementBool(&oXML,
"ForceData", (*processingActions[i] &
ProcessingForceData) != 0);
4422 AddXMLElementBool(&oXML,
"ExportTSV", (*processingActions[i] &
ProcessingExportTSV) != 0);
4423 AddXMLElementBool(&oXML,
"ExportC3D", (*processingActions[i] &
ProcessingExportC3D) != 0);
4433 if (SendXML(oXML.
GetDoc().c_str()))
4444 const bool* pbSignalModePeriodic,
const unsigned int* pnFreqMultiplier,
4445 const unsigned int* pnFreqDivisor,
const unsigned int* pnFreqTolerance,
4446 const float* pfNominalFrequency,
const bool* pbNegativeEdge,
4447 const unsigned int* pnSignalShutterDelay,
const float* pfNonPeriodicTimeout)
4455 oXML.
AddElem(
"External_Time_Base");
4458 AddXMLElementBool(&oXML,
"Enabled", pbEnabled);
4462 switch (*peSignalSource)
4465 oXML.
AddElem(
"Signal_Source",
"Control port");
4468 oXML.
AddElem(
"Signal_Source",
"IR receiver");
4471 oXML.
AddElem(
"Signal_Source",
"SMPTE");
4474 oXML.
AddElem(
"Signal_Source",
"Video sync");
4477 oXML.
AddElem(
"Signal_Source",
"IRIG");
4482 AddXMLElementBool(&oXML,
"Signal_Mode", pbSignalModePeriodic,
"Periodic",
"Non-periodic");
4483 AddXMLElementUnsignedInt(&oXML,
"Frequency_Multiplier", pnFreqMultiplier);
4484 AddXMLElementUnsignedInt(&oXML,
"Frequency_Divisor", pnFreqDivisor);
4485 AddXMLElementUnsignedInt(&oXML,
"Frequency_Tolerance", pnFreqTolerance);
4487 if (pfNominalFrequency)
4489 if (*pfNominalFrequency < 0)
4491 oXML.
AddElem(
"Nominal_Frequency",
"None");
4495 AddXMLElementFloat(&oXML,
"Nominal_Frequency", pfNominalFrequency, 3);
4499 AddXMLElementBool(&oXML,
"Signal_Edge", pbNegativeEdge,
"Negative",
"Positive");
4500 AddXMLElementUnsignedInt(&oXML,
"Signal_Shutter_Delay", pnSignalShutterDelay);
4501 AddXMLElementFloat(&oXML,
"Non_Periodic_Timeout", pfNonPeriodicTimeout, 3);
4507 if (SendXML(oXML.
GetDoc().c_str()))
4518 const unsigned int nCameraID,
const ECameraMode* peMode,
4519 const float* pfMarkerExposure,
const float* pfMarkerThreshold,
4520 const int* pnOrientation)
4532 AddXMLElementUnsignedInt(&oXML,
"ID", &nCameraID);
4539 oXML.
AddElem(
"Mode",
"Marker");
4542 oXML.
AddElem(
"Mode",
"Marker Intensity");
4545 oXML.
AddElem(
"Mode",
"Video");
4549 AddXMLElementFloat(&oXML,
"Marker_Exposure", pfMarkerExposure);
4550 AddXMLElementFloat(&oXML,
"Marker_Threshold", pfMarkerThreshold);
4551 AddXMLElementInt(&oXML,
"Orientation", pnOrientation);
4557 if (SendXML(oXML.
GetDoc().c_str()))
4569 const EVideoAspectRatio* eVideoAspectRatio,
const unsigned int* pnVideoFrequency,
4570 const float* pfVideoExposure,
const float* pfVideoFlashTime)
4582 AddXMLElementUnsignedInt(&oXML,
"ID", &nCameraID);
4583 if (eVideoResolution)
4585 switch (*eVideoResolution)
4588 oXML.
AddElem(
"Video_Resolution",
"1080p");
4591 oXML.
AddElem(
"Video_Resolution",
"720p");
4594 oXML.
AddElem(
"Video_Resolution",
"540p");
4597 oXML.
AddElem(
"Video_Resolution",
"480p");
4603 if (eVideoAspectRatio)
4605 switch (*eVideoAspectRatio)
4608 oXML.
AddElem(
"Video_Aspect_Ratio",
"16x9");
4611 oXML.
AddElem(
"Video_Aspect_Ratio",
"4x3");
4614 oXML.
AddElem(
"Video_Aspect_Ratio",
"1x1");
4620 AddXMLElementUnsignedInt(&oXML,
"Video_Frequency", pnVideoFrequency);
4621 AddXMLElementFloat(&oXML,
"Video_Exposure", pfVideoExposure);
4622 AddXMLElementFloat(&oXML,
"Video_Flash_Time", pfVideoFlashTime);
4628 if (SendXML(oXML.
GetDoc().c_str()))
4639 const unsigned int nCameraID,
const unsigned int portNumber,
const ESyncOutFreqMode* peSyncOutMode,
4640 const unsigned int* pnSyncOutValue,
const float* pfSyncOutDutyCycle,
4641 const bool* pbSyncOutNegativePolarity)
4653 AddXMLElementUnsignedInt(&oXML,
"ID", &nCameraID);
4655 int port = portNumber - 1;
4656 if (((port == 0 || port == 1) && peSyncOutMode) || (port == 2))
4658 oXML.
AddElem(port == 0 ?
"Sync_Out" : (port == 1 ?
"Sync_Out2" :
"Sync_Out_MT"));
4661 if (port == 0 || port == 1)
4663 switch (*peSyncOutMode)
4666 oXML.
AddElem(
"Mode",
"Shutter out");
4669 oXML.
AddElem(
"Mode",
"Multiplier");
4672 oXML.
AddElem(
"Mode",
"Divisor");
4675 oXML.
AddElem(
"Mode",
"Camera independent");
4678 oXML.
AddElem(
"Mode",
"Measurement time");
4681 oXML.
AddElem(
"Mode",
"Continuous 100Hz");
4693 AddXMLElementUnsignedInt(&oXML,
"Value", pnSyncOutValue);
4695 if (pfSyncOutDutyCycle)
4697 AddXMLElementFloat(&oXML,
"Duty_Cycle", pfSyncOutDutyCycle, 3);
4701 if (pbSyncOutNegativePolarity && (port == 2 ||
4704 AddXMLElementBool(&oXML,
"Signal_Polarity", pbSyncOutNegativePolarity,
"Negative",
"Positive");
4712 if (SendXML(oXML.
GetDoc().c_str()))
4734 AddXMLElementUnsignedInt(&oXML,
"ID", &nCameraID);
4749 if (SendXML(oXML.
GetDoc().c_str()))
4770 AddXMLElementUnsignedInt(&oXML,
"ID", &nCameraID);
4776 oXML.
AddAttrib(
"Enabled", autoExposure ?
"true" :
"false");
4784 if (SendXML(oXML.
GetDoc().c_str()))
4805 AddXMLElementUnsignedInt(&oXML,
"ID", &nCameraID);
4807 oXML.
AddElem(
"AutoWhiteBalance", enable ?
"true" :
"false");
4813 if (SendXML(oXML.
GetDoc().c_str()))
4824 const unsigned int* pnWidth,
const unsigned int* pnHeight,
const float* pfLeftCrop,
4825 const float* pfTopCrop,
const float* pfRightCrop,
const float* pfBottomCrop)
4837 AddXMLElementUnsignedInt(&oXML,
"ID", &nCameraID);
4839 AddXMLElementBool(&oXML,
"Enabled", pbEnable);
4846 oXML.
AddElem(
"Format",
"RAWGrayscale");
4849 oXML.
AddElem(
"Format",
"RAWBGR");
4852 oXML.
AddElem(
"Format",
"JPG");
4855 oXML.
AddElem(
"Format",
"PNG");
4859 AddXMLElementUnsignedInt(&oXML,
"Width", pnWidth);
4860 AddXMLElementUnsignedInt(&oXML,
"Height", pnHeight);
4861 AddXMLElementFloat(&oXML,
"Left_Crop", pfLeftCrop);
4862 AddXMLElementFloat(&oXML,
"Top_Crop", pfTopCrop);
4863 AddXMLElementFloat(&oXML,
"Right_Crop", pfRightCrop);
4864 AddXMLElementFloat(&oXML,
"Bottom_Crop", pfBottomCrop);
4870 if (SendXML(oXML.
GetDoc().c_str()))
4880 const unsigned int nPlateID,
const SPoint* psCorner1,
const SPoint* psCorner2,
4895 if (mnMajorVersion > 1 || mnMinorVersion > 7)
4897 AddXMLElementUnsignedInt(&oXML,
"Plate_ID", &nPlateID);
4901 AddXMLElementUnsignedInt(&oXML,
"Force_Plate_Index", &nPlateID);
4907 AddXMLElementFloat(&oXML,
"X", &(psCorner1->
fX));
4908 AddXMLElementFloat(&oXML,
"Y", &(psCorner1->
fY));
4909 AddXMLElementFloat(&oXML,
"Z", &(psCorner1->
fZ));
4916 AddXMLElementFloat(&oXML,
"X", &(psCorner2->
fX));
4917 AddXMLElementFloat(&oXML,
"Y", &(psCorner2->
fY));
4918 AddXMLElementFloat(&oXML,
"Z", &(psCorner2->
fZ));
4925 AddXMLElementFloat(&oXML,
"X", &(psCorner3->
fX));
4926 AddXMLElementFloat(&oXML,
"Y", &(psCorner3->
fY));
4927 AddXMLElementFloat(&oXML,
"Z", &(psCorner3->
fZ));
4934 AddXMLElementFloat(&oXML,
"X", &(psCorner4->
fX));
4935 AddXMLElementFloat(&oXML,
"Y", &(psCorner4->
fY));
4936 AddXMLElementFloat(&oXML,
"Z", &(psCorner4->
fZ));
4944 if (SendXML(oXML.
GetDoc().c_str()))
4951 sprintf(maErrorStr,
"Illegal force plate id: %d.", nPlateID);
4963 bool CRTProtocol::SendString(
const char* pCmdStr,
int nType)
4965 auto nCmdStrLen = strlen(pCmdStr);
4966 static char aSendBuffer[5000];
4968 if (nCmdStrLen >
sizeof(aSendBuffer))
4970 strcpy(maErrorStr,
"String is larger than send buffer.");
4977 unsigned int nSize = 8 + (
unsigned int)nCmdStrLen + 1;
4979 memcpy(aSendBuffer + 8, pCmdStr, nCmdStrLen + 1);
4981 if ((mnMajorVersion == 1 && mnMinorVersion == 0) || mbBigEndian)
4983 *((
unsigned int*)aSendBuffer) = htonl(nSize);
4984 *((
unsigned int*)(aSendBuffer + 4)) = htonl(nType);
4988 *((
unsigned int*)aSendBuffer) = nSize;
4989 *((
unsigned int*)(aSendBuffer + 4)) = nType;
4992 if (mpoNetwork->
Send(aSendBuffer, nSize) ==
false)
5002 bool CRTProtocol::SendCommand(
const char* pCmdStr)
5008 bool CRTProtocol::SendCommand(
const char* pCmdStr,
char* pCommandResponseStr,
unsigned int timeout)
5031 strcpy(pTmpStr, maErrorStr);
5032 sprintf(maErrorStr,
"\'%s\' command failed. %s", pCmdStr, pTmpStr);
5034 pCommandResponseStr[0] = 0;
5039 bool CRTProtocol::SendXML(
const char* pCmdStr)
5049 if (strcmp(mpoRTPacket->
GetCommandString(),
"Setting parameters succeeded") == 0)
5056 "Expected command response \"Setting parameters succeeded\". Got \"%s\".",
5062 sprintf(maErrorStr,
"Expected command response packet. Got packet type %d.", (
int)eType);
5067 strcpy(maErrorStr,
"Missing command response packet.");
5073 strcpy(pTmpStr, maErrorStr);
5074 sprintf(maErrorStr,
"Failed to send XML string. %s", pTmpStr);
5080 void CRTProtocol::AddXMLElementBool(
CMarkup* oXML,
const char* tTag,
const bool* pbValue,
const char* tTrue,
const char* tFalse)
5084 oXML->
AddElem(tTag, *pbValue ? tTrue : tFalse);
5089 void CRTProtocol::AddXMLElementBool(
CMarkup* oXML,
const char* tTag,
const bool pbValue,
const char* tTrue,
const char* tFalse)
5091 oXML->
AddElem(tTag, pbValue ? tTrue : tFalse);
5095 void CRTProtocol::AddXMLElementInt(
CMarkup* oXML,
const char* tTag,
const int* pnValue)
5102 oXML->
AddElem(tTag, tVal.c_str());
5107 void CRTProtocol::AddXMLElementUnsignedInt(
CMarkup* oXML,
const char* tTag,
const unsigned int* pnValue)
5114 oXML->
AddElem(tTag, tVal.c_str());
5118 void CRTProtocol::AddXMLElementFloat(
CMarkup* oXML,
const char* tTag,
const float* pfValue,
unsigned int pnDecimals)
5125 sprintf(fFormat,
"%%.%df", pnDecimals);
5127 oXML->
AddElem(tTag, tVal.c_str());
5131 bool CRTProtocol::CompareNoCase(std::string tStr1,
const char* tStr2)
const 5133 std::transform(tStr1.begin(), tStr1.end(), tStr1.begin(), ::tolower);
5134 return tStr1.compare(tStr2) == 0;
void Get6DOFEulerNames(std::string &first, std::string &second, std::string &third) const
int Receive(char *rtDataBuff, int nDataBufSize, bool bHeader, int nTimeout, unsigned int *ipAddr=nullptr)
bool GetDiscoverResponse(unsigned int nIndex, unsigned int &nAddr, unsigned short &nBasePort, std::string &message)
static const unsigned int cComponentImage
bool GetCameraMarkerSettings(unsigned int nCameraIndex, unsigned int &nCurrentExposure, unsigned int &nMinExposure, unsigned int &nMaxExposure, unsigned int &nCurrentThreshold, unsigned int &nMinThreshold, unsigned int &nMaxThreshold) const
bool AddElem(const char *szName, const char *szData=NULL)
bool GetForcePlateLocation(unsigned int nPlateIndex, SPoint sCorner[4]) const
const char * GetAnalogUnit(unsigned int nDeviceIndex, unsigned int nChannelIndex) const
unsigned short GetUdpServerPort()
const char * Get6DOFBodyName(unsigned int nBodyIndex) const
bool LoadProject(const char *pFileName)
static const unsigned int cComponent2d
bool SetVersion(int nMajorVersion, int nMinorVersion)
unsigned short GetUdpServerPort()
bool SetForceSettings(const unsigned int nPlateID, const SPoint *psCorner1, const SPoint *psCorner2, const SPoint *psCorner3, const SPoint *psCorner4)
unsigned int GetSkeletonCount() const
std::vector< SSettingsSkeletonSegment > segments
void GetForceUnits(char *&pLength, char *&pForce) const
void GetSystemSettings(unsigned int &nCaptureFrequency, float &fCaptureTime, bool &bStartOnExtTrig, bool &trigNO, bool &trigNC, bool &trigSoftware, EProcessingActions &eProcessingActions, EProcessingActions &eRtProcessingActions, EProcessingActions &eReprocessingActions) const
bool CreateUDPSocket(unsigned short &nUDPPort, bool bBroadcast=false)
bool GetCurrentFrame(unsigned int nComponentType, const SComponentOptions &componentOptions={ })
bool GetCameraFOV(unsigned int nCameraIndex, unsigned int &nMarkerLeft, unsigned int &nMarkerTop, unsigned int &nMarkerRight, unsigned int &nMarkerBottom, unsigned int &nVideoLeft, unsigned int &nVideoTop, unsigned int &nVideoRight, unsigned int &nVideoBottom) const
const char * Get3DBoneToName(unsigned int boneIndex) const
CRTPacket * GetRTPacket()
bool SetCameraVideoSettings(const unsigned int nCameraID, const EVideoResolution *eVideoResolution, const EVideoAspectRatio *eVideoAspectRatio, const unsigned int *pnVideoFrequency, const float *pfVideoExposure, const float *pfVideoFlashTime)
const char * Get3DLabelName(unsigned int nMarkerIndex) const
bool GetCameraLensControlSettings(const unsigned int nCameraIndex, float *focus, float *aperture) const
void GetExtTimeBaseSettings(bool &bEnabled, ESignalSource &eSignalSource, bool &bSignalModePeriodic, unsigned int &nFreqMultiplier, unsigned int &nFreqDivisor, unsigned int &nFreqTolerance, float &fNominalFrequency, bool &bNegativeEdge, unsigned int &nSignalShutterDelay, float &fNonPeriodicTimeout) const
static const unsigned int cComponent6d
std::string GetAttrib(const char *szAttrib) const
bool SetDoc(const char *szDoc)
bool LoadCapture(const char *pFileName)
bool SetCameraLensControlSettings(const unsigned int nCameraID, const float focus, const float aperture)
unsigned int Get6DOFBodyPointCount(unsigned int nBodyIndex) const
static const unsigned int cComponent3dRes
bool GetCapture(const char *pFileName, bool bC3D)
bool GetCameraSettings(unsigned int nCameraIndex, unsigned int &nID, ECameraModel &eModel, bool &bUnderwater, bool &bSupportsHwSync, unsigned int &nSerial, ECameraMode &eMode) const
bool GetForcePlate(unsigned int nPlateIndex, unsigned int &nID, unsigned int &nAnalogDeviceID, unsigned int &nFrequency, char *&pType, char *&pName, float &fLength, float &fWidth) const
static const unsigned int cComponentForceSingle
float GetGazeVectorFrequency(unsigned int nGazeVectorIndex) const
bool ReadSkeletonSettings(bool &bDataAvailable, bool skeletonGlobalData=false)
unsigned int Get6DOFBodyCount() const
unsigned int GetForcePlateCount() const
bool Get6DOFBodyPoint(unsigned int nBodyIndex, unsigned int nMarkerIndex, SPoint &sPoint) const
const char * Get3DCalibrated() const
static bool GetComponentString(char *pComponentStr, unsigned int nComponentType, const SComponentOptions &options=SComponentOptions())
unsigned int GetImageCameraCount() const
char * GetCommandString()
static const unsigned int cComponent6dEulerRes
bool SetCameraAutoWhiteBalance(const unsigned int nCameraID, const bool enable)
const char * GetGazeVectorName(unsigned int nGazeVectorIndex) const
unsigned int GetCameraCount() const
bool SetQTMEvent(const char *pLabel)
static const unsigned int cComponentAnalogSingle
unsigned int Get3DLabelColor(unsigned int nMarkerIndex) const
unsigned int Get3DLabeledMarkerCount() const
bool ReadAnalogSettings(bool &bDataAvailable)
bool ReadImageSettings(bool &bDataAvailable)
unsigned int GetForcePlateChannelCount(unsigned int nPlateIndex) const
bool GetCameraAutoExposureSettings(const unsigned int nCameraIndex, bool *autoExposureEnabled, float *autoExposureCompensation) const
bool ReadXmlBool(CMarkup *xml, const std::string &element, bool &value) const
ECameraSystemType GetCameraSystemType() const
bool SetCameraSettings(const unsigned int nCameraID, const ECameraMode *peMode, const float *pfMarkerExposure, const float *pfMarkerThreshold, const int *pnOrientation)
static const unsigned int cComponent2dLin
static std::string Format(const char *fmt,...)
bool Read3DSettings(bool &bDataAvailable)
static const unsigned int cComponentTimecode
bool CheckLicense(const char *pLicenseCode)
unsigned int GetAnalogDeviceCount() const
bool GetForcePlateChannel(unsigned int nPlateIndex, unsigned int nChannelIndex, unsigned int &nChannelNumber, float &fConversionFactor) const
EAxis Get3DUpwardAxis() const
static bool ConvertRateString(const char *pRate, EStreamRate &eRate, unsigned int &nRateArg)
bool ReadCameraSystemSettings()
bool GetSkeletonSegment(unsigned int skeletonIndex, unsigned int segmentIndex, SSettingsSkeletonSegment *segment)
const char * GetAnalogLabel(unsigned int nDeviceIndex, unsigned int nChannelIndex) const
bool GetCameraOrientation(unsigned int nCameraIndex, int &nOrientation) const
bool GetByteOrder(bool &bBigEndian)
bool GetCameraAutoWhiteBalance(const unsigned int nCameraIndex, bool *autoWhiteBalanceEnabled) const
bool GetCameraResolution(unsigned int nCameraIndex, unsigned int &nMarkerWidth, unsigned int &nMarkerHeight, unsigned int &nVideoWidth, unsigned int &nVideoHeight) const
bool Read6DOFSettings(bool &bDataAvailable)
bool DiscoverRTServer(unsigned short nServerPort, bool bNoLocalResponses, unsigned short nDiscoverPort=DEFAULT_AUTO_DESCOVER_PORT)
static bool GetEventString(CRTPacket::EEvent eEvent, char *pStr)
bool Send(const char *pSendBuf, int nSize)
bool TakeControl(const char *pPassword=nullptr)
std::string GetDoc() const
bool SetSystemSettings(const unsigned int *pnCaptureFrequency, const float *pfCaptureTime, const bool *pbStartOnExtTrig, const bool *trigNO, const bool *trigNC, const bool *trigSoftware, const EProcessingActions *peProcessingActions, const EProcessingActions *peRtProcessingActions, const EProcessingActions *peReprocessingActions)
short GetDiscoverResponseBasePort()
static const unsigned int cComponentSkeleton
bool GetSkeleton(unsigned int skeletonIndex, SSettingsSkeleton *skeleton)
unsigned int Get6DOFBodyColor(unsigned int nBodyIndex) const
bool GetCameraVideoSettings(unsigned int nCameraIndex, EVideoResolution &eVideoResolution, EVideoAspectRatio &eVideoAspectRatio, unsigned int &nVideoFrequency, unsigned int &nCurrentExposure, unsigned int &nMinExposure, unsigned int &nMaxExposure, unsigned int &nCurrentFlashTime, unsigned int &nMinFlashTime, unsigned int &nMaxFlashTime) const
bool ReadForceSettings(bool &bDataAvailable)
bool GetForcePlateCalibrationMatrix(unsigned int nPlateIndex, float fvCalMatrix[12][12], unsigned int *rows, unsigned int *columns) const
bool SetExtTimeBaseSettings(const bool *pbEnabled, const ESignalSource *peSignalSource, const bool *pbSignalModePeriodic, const unsigned int *pnFreqMultiplier, const unsigned int *pnFreqDivisor, const unsigned int *pnFreqTolerance, const float *pfNominalFrequency, const bool *pbNegativeEdge, const unsigned int *pnSignalShutterDelay, const float *pfNonPeriodicTimeout)
bool FindChildElem(const char *szName=NULL)
bool SendUDPBroadcast(const char *pSendBuf, int nSize, short nPort, unsigned int nFilterAddr=0)
bool GetCameraSyncOutSettings(unsigned int nCameraIndex, unsigned int portNumber, ESyncOutFreqMode &eSyncOutMode, unsigned int &nSyncOutValue, float &fSyncOutDutyCycle, bool &bSyncOutNegativePolarity) const
bool Connect(const char *pServerAddr, unsigned short nPort, unsigned short *pnUDPServerPort=nullptr, int nMajorVersion=MAJOR_VERSION, int nMinorVersion=MINOR_VERSION, bool bBigEndian=false)
bool GetQTMVersion(char *pVersion, unsigned int nVersionLen)
static const unsigned int cComponent3dNoLabelsRes
static unsigned int ConvertComponentString(const char *pComponentType)
std::string GetChildData() const
bool ReadGazeVectorSettings(bool &bDataAvailable)
void SetVersion(unsigned int nMajorVersion, unsigned int nMinorVersion)
bool AddAttrib(const char *szAttrib, const char *szValue)
bool GetState(CRTPacket::EEvent &eEvent, bool bUpdate=true, int nTimeout=WAIT_FOR_DATA_TIMEOUT)
static const unsigned int cComponent3d
bool Connect(const char *pServerAddr, unsigned short nPort)
bool GetCameraPosition(unsigned int nCameraIndex, SPoint &sPoint, float fvRotationMatrix[3][3]) const
bool SetCameraAutoExposureSettings(const unsigned int nCameraID, const bool autoExposure, const float compensation)
bool IsLocalAddress(unsigned int nAddr) const
unsigned int Get3DBoneCount() const
bool StreamFrames(EStreamRate eRate, unsigned int nRateArg, unsigned short nUDPPort, const char *pUDPAddr, unsigned int nComponentType, const SComponentOptions &componentOptions={ })
bool SetImageSettings(const unsigned int nCameraID, const bool *pbEnable, const CRTPacket::EImageFormat *peFormat, const unsigned int *pnWidth, const unsigned int *pnHeight, const float *pfLeftCrop, const float *pfTopCrop, const float *pfRightCrop, const float *pfBottomCrop)
bool SaveCapture(const char *pFileName, bool bOverwrite, char *pNewFileName=nullptr, int nSizeOfNewFileName=0)
unsigned int GetGazeVectorCount() const
bool GetImageCamera(unsigned int nCameraIndex, unsigned int &nCameraID, bool &bEnabled, CRTPacket::EImageFormat &eFormat, unsigned int &nWidth, unsigned int &nHeight, float &fCropLeft, float &fCropTop, float &fCropRight, float &fCropBottom) const
const char * Get3DBoneFromName(unsigned int boneIndex) const
int GetNumberOfDiscoverResponses()
int ReceiveRTPacket(CRTPacket::EPacketType &eType, bool bSkipEvents=true, int nTimeout=WAIT_FOR_DATA_TIMEOUT)
static const unsigned int cComponent6dEuler
static const unsigned int cComponent3dNoLabels
bool GetForcePlateOrigin(unsigned int nPlateIndex, SPoint &sOrigin) const
bool GetAnalogDevice(unsigned int nDeviceIndex, unsigned int &nDeviceID, unsigned int &nChannels, char *&pName, unsigned int &nFrequency, char *&pUnit, float &fMinRange, float &fMaxRange) const
bool GetVersion(unsigned int &nMajorVersion, unsigned int &nMinorVersion)
static const unsigned int cComponent6dRes
static const unsigned int cComponentGazeVector
static const unsigned int cComponentAnalog
unsigned int GetSkeletonSegmentCount(unsigned int skeletonIndex)
const char * GetSkeletonName(unsigned int skeletonIndex)
bool GetEvent(EEvent &eEvent)
static const unsigned int cComponentForce
bool SetCameraSyncOutSettings(const unsigned int nCameraID, const unsigned int portNumber, const ESyncOutFreqMode *peSyncOutMode, const unsigned int *pnSyncOutValue, const float *pfSyncOutDutyCycle, const bool *pbSyncOutNegativePolarity)