18 #include "../include/cob_camera_sensors/StdAfx.h" 25 #include "cob_common/cob_vision_utils/common/include/cob_vision_utils/VisionUtils.h" 26 #include "cob_vision/windows/src/extern/TinyXml/tinyxml.h" 70 return SR_GetDefaultCallback()(0,msg,param,data);
77 return SR_GetDefaultCallback()(0,msg,param,data);
96 std::cerr <<
"ERROR - Swissranger::Init:" << std::endl;
97 std::cerr <<
"\t ... Parsing xml configuration file failed." << std::endl;
109 std::string filename = directory +
"MatlabCalibrationData/PMD/ZCoeffsA0.xml";
110 CvMat* c_mat = (CvMat*)cvLoad(filename.c_str());
113 std::cerr <<
"ERROR - PMDCamCube::LoadParameters:" << std::endl;
114 std::cerr <<
"\t ... Error while loading " << directory +
"MatlabCalibrationData/ZcoeffsA0.txt" <<
"." << std::endl;
115 std::cerr <<
"\t ... Data is necessary for z-calibration of swissranger camera" << std::endl;
122 cvReleaseMat(&c_mat);
125 filename = directory +
"MatlabCalibrationData/PMD/ZCoeffsA1.xml";
126 c_mat = (CvMat*)cvLoad(filename.c_str());
129 std::cerr <<
"ERROR - PMDCamCube::LoadParameters:" << std::endl;
130 std::cerr <<
"\t ... Error while loading " << directory +
"MatlabCalibrationData/ZcoeffsA1.txt" <<
"." << std::endl;
131 std::cerr <<
"\t ... Data is necessary for z-calibration of swissranger camera" << std::endl;
138 cvReleaseMat(&c_mat);
141 filename = directory +
"MatlabCalibrationData/PMD/ZCoeffsA2.xml";
142 c_mat = (CvMat*)cvLoad(filename.c_str());
145 std::cerr <<
"ERROR - PMDCamCube::LoadParameters:" << std::endl;
146 std::cerr <<
"\t ... Error while loading " << directory +
"MatlabCalibrationData/ZcoeffsA2.txt" <<
"." << std::endl;
147 std::cerr <<
"\t ... Data is necessary for z-calibration of swissranger camera" << std::endl;
154 cvReleaseMat(&c_mat);
157 filename = directory +
"MatlabCalibrationData/PMD/ZCoeffsA3.xml";
158 c_mat = (CvMat*)cvLoad(filename.c_str());
161 std::cerr <<
"ERROR - PMDCamCube::LoadParameters:" << std::endl;
162 std::cerr <<
"\t ... Error while loading " << directory +
"MatlabCalibrationData/ZcoeffsA3.txt" <<
"." << std::endl;
163 std::cerr <<
"\t ... Data is necessary for z-calibration of swissranger camera" << std::endl;
170 cvReleaseMat(&c_mat);
173 filename = directory +
"MatlabCalibrationData/PMD/ZCoeffsA4.xml";
174 c_mat = (CvMat*)cvLoad(filename.c_str());
177 std::cerr <<
"ERROR - PMDCamCube::LoadParameters:" << std::endl;
178 std::cerr <<
"\t ... Error while loading " << directory +
"MatlabCalibrationData/ZcoeffsA4.txt" <<
"." << std::endl;
179 std::cerr <<
"\t ... Data is necessary for z-calibration of swissranger camera" << std::endl;
186 cvReleaseMat(&c_mat);
189 filename = directory +
"MatlabCalibrationData/PMD/ZCoeffsA5.xml";
190 c_mat = (CvMat*)cvLoad(filename.c_str());
193 std::cerr <<
"ERROR - PMDCamCube::LoadParameters:" << std::endl;
194 std::cerr <<
"\t ... Error while loading " << directory +
"MatlabCalibrationData/ZcoeffsA5.txt" <<
"." << std::endl;
195 std::cerr <<
"\t ... Data is necessary for z-calibration of swissranger camera" << std::endl;
202 cvReleaseMat(&c_mat);
205 filename = directory +
"MatlabCalibrationData/PMD/ZCoeffsA6.xml";
206 c_mat = (CvMat*)cvLoad(filename.c_str());
209 std::cerr <<
"ERROR - PMDCamCube::LoadParameters:" << std::endl;
210 std::cerr <<
"\t ... Error while loading " << directory +
"MatlabCalibrationData/ZcoeffsA6.txt" <<
"." << std::endl;
211 std::cerr <<
"\t ... Data is necessary for z-calibration of swissranger camera" << std::endl;
218 cvReleaseMat(&c_mat);
242 std::string sInterface =
"";
247 if (sInterface ==
"USB")
251 std::cerr <<
"ERROR - Swissranger::Open():" << std::endl;
252 std::cerr <<
"\t ... Could not open swissranger camera on USB port" << std::endl;
253 std::cerr <<
"\t ... Unplug and Replugin camera power cable.\n";
257 else if (sInterface ==
"ETHERNET")
259 std::string sIP =
"";
263 if(SR_OpenETH(&
m_SRCam, sIP.c_str())<=0)
265 std::cerr <<
"ERROR - Swissranger::Open():" << std::endl;
266 std::cerr <<
"\t ... Could not open swissranger camera on ETHERNET port" << std::endl;
267 std::cerr <<
"\t ... with ip '" << sIP <<
"'." << std::endl;
268 std::cerr <<
"\t ... Unplug and Replugin camera power cable to fix problem\n";
274 std::cerr <<
"ERROR - Swissranger::Open():" << std::endl;
275 std::cerr <<
"\t ... Unknown interface type '" << sInterface <<
"'" << std::endl;
286 std::cerr <<
"ERROR - AVTPikeCam::Open:" << std::endl;
287 std::cerr <<
"\t ... Could not set parameters" << std::endl;
291 std::cout <<
"**************************************************" << std::endl;
292 std::cout <<
"Swissranger::Open: Swissranger camera device OPEN" << std::endl;
293 std::cout <<
"**************************************************" << std::endl << std::endl;
309 std::cout <<
"ERROR - Swissranger::Close():" << std::endl;
310 std::cerr <<
"\t ... Could not close swissranger camera." << std::endl;
336 unsigned short val = 0;
337 err =SR_SetAmplitudeThreshold(
m_SRCam, val);
340 std::cerr <<
"ERROR - Swissranger::SetProperty:" << std::endl;
341 std::cerr <<
"\t ... Could not set amplitude threshold to AUTO mode" << std::endl;
351 std::cerr <<
"ERROR - Swissranger::SetProperty:" << std::endl;
352 std::cerr <<
"\t ... Special value 'VALUE_AUTO' or 'VALUE_DEFAULT' expected." << std::endl;
361 std::cerr <<
"ERROR - Swissranger::SetProperty:" << std::endl;
362 std::cerr <<
"\t ... Could not set amplitude threshold to AUTO mode" << std::endl;
368 std::cerr <<
"ERROR - Swissranger::SetProperty:" << std::endl;
369 std::cerr <<
"\t ... Wrong property type. '(TYPE_SHORT|TYPE_UNSIGNED)' or special value 'TYPE_SPECIAL' expected." << std::endl;
378 err = SR_SetAutoExposure(
m_SRCam, 1, 150, 5, 40);
381 std::cerr <<
"ERROR - Swissranger::SetProperty:" << std::endl;
382 std::cerr <<
"\t ... Could not set integration time to AUTO mode" << std::endl;
392 std::cerr <<
"ERROR - Swissranger::SetProperty:" << std::endl;
393 std::cerr <<
"\t ... Special value 'VALUE_AUTO' or 'VALUE_DEFAULT' expected." << std::endl;
399 err = SR_SetAutoExposure(
m_SRCam, 0xff, 150, 5, 70);
402 std::cerr <<
"ERROR - Swissranger::SetProperty:" << std::endl;
403 std::cerr <<
"\t ... Could not turn off auto exposure" << std::endl;
409 std::cerr <<
"ERROR - Swissranger::SetProperty:" << std::endl;
410 std::cerr <<
"\t ... Could not set amplitude threshold to '" << cameraProperty->
u_charData <<
"'" << std::endl;
416 std::cerr <<
"ERROR - Swissranger::SetProperty:" << std::endl;
417 std::cerr <<
"\t ... Wrong property type. '(TYPE_LONG|TYPE_UNSIGNED)' or special value 'TYPE_SPECIAL' expected." << std::endl;
426 err = SR_SetModulationFrequency(
m_SRCam, MF_LAST);
429 std::cerr <<
"ERROR - Swissranger::SetProperty:" << std::endl;
430 std::cerr <<
"\t ... Could not set modulation frequency to AUTO mode" << std::endl;
440 std::cerr <<
"ERROR - Swissranger::SetProperty:" << std::endl;
441 std::cerr <<
"\t ... Special value 'VALUE_AUTO' or 'VALUE_DEFAULT' expected." << std::endl;
459 err = SR_SetModulationFrequency(
m_SRCam, MF_40MHz);
461 else if (cameraProperty->
stringData ==
"MF_30MHz")
463 err = SR_SetModulationFrequency(
m_SRCam, MF_30MHz);
465 else if (cameraProperty->
stringData ==
"MF_21MHz")
467 err = SR_SetModulationFrequency(
m_SRCam, MF_21MHz);
469 else if (cameraProperty->
stringData ==
"MF_20MHz")
471 err = SR_SetModulationFrequency(
m_SRCam, MF_20MHz);
473 else if (cameraProperty->
stringData ==
"MF_19MHz")
475 err = SR_SetModulationFrequency(
m_SRCam, MF_19MHz);
477 else if (cameraProperty->
stringData ==
"MF_60MHz")
479 err = SR_SetModulationFrequency(
m_SRCam, MF_60MHz);
481 else if (cameraProperty->
stringData ==
"MF_15MHz")
483 err = SR_SetModulationFrequency(
m_SRCam, MF_15MHz);
485 else if (cameraProperty->
stringData ==
"MF_10MHz")
487 err = SR_SetModulationFrequency(
m_SRCam, MF_10MHz);
489 else if (cameraProperty->
stringData ==
"MF_29MHz")
491 err = SR_SetModulationFrequency(
m_SRCam, MF_29MHz);
493 else if (cameraProperty->
stringData ==
"MF_31MHz")
495 err = SR_SetModulationFrequency(
m_SRCam, MF_31MHz);
499 std::cerr <<
"ERROR - Swissranger::SetProperty:" << std::endl;
500 std::cerr <<
"\t ... Modulation frequency " << cameraProperty->
stringData <<
" unknown" << std::endl;
505 std::cerr <<
"ERROR - Swissranger::SetProperty:" << std::endl;
506 std::cerr <<
"\t ... Could not set modulation frequency " << cameraProperty->
stringData << std::endl;
513 std::cerr <<
"ERROR - Swissranger::SetProperty:" << std::endl;
514 std::cerr <<
"\t ... Wrong property type. '(TYPE_LONG|TYPE_UNSIGNED)' or special value 'TYPE_SPECIAL' expected." << std::endl;
524 std::cerr <<
"ERROR - Swissranger::SetProperty:" << std::endl;
525 std::cerr <<
"\t ... Could not set acquire mode" << std::endl;
531 std::cerr <<
"ERROR - Swissranger::SetProperty:" << std::endl;
532 std::cerr <<
"\t ... Wrong property type. 'TYPE_INTEGER' expected." << std::endl;
537 std::cout <<
"Swissranger::SetProperty: Property " << cameraProperty->
propertyID <<
" unspecified.\n";
612 std::cout <<
"ERROR - Swissranger::GetProperty:" << std::endl;
613 std::cout <<
"\t ... Property " << cameraProperty->
propertyID <<
" unspecified.";
628 char* rangeImageData = 0;
629 char* grayImageData = 0;
630 char* cartesianImageData = 0;
631 int widthStepRange = -1;
632 int widthStepGray = -1;
633 int widthStepCartesian = -1;
645 rangeImage->create(height, width, CV_32FC(1));
646 rangeImageData = rangeImage->ptr<
char>(0);
647 widthStepRange = rangeImage->step;
652 grayImage->create(height, width, CV_32FC(1));
653 grayImageData = grayImage->ptr<
char>(0);
654 widthStepGray = grayImage->step;
659 cartesianImage->create(height, width, CV_32FC(3));
660 cartesianImageData = cartesianImage->ptr<
char>(0);
661 widthStepCartesian = cartesianImage->step;
664 if (!rangeImage && !grayImage && !cartesianImage)
669 return AcquireImages(widthStepRange, widthStepGray, widthStepCartesian, rangeImageData, grayImageData, cartesianImageData, getLatestFrame, undistort, grayImageType);
674 unsigned long Swissranger::AcquireImages(
int widthStepRange,
int widthStepGray,
int widthStepCartesian,
char* rangeImageData,
char* grayImageData,
char* cartesianImageData,
682 std::cerr <<
"ERROR - Swissranger::AcquireImages:" << std::endl;
683 std::cerr <<
"t ... Camera not open." << std::endl;
700 unsigned int bytesRead = 0;
701 bytesRead = SR_Acquire(
m_SRCam);
704 std::cerr <<
"ERROR - Swissranger::AcquireImages:" << std::endl;
705 std::cerr <<
"\t ... Could not acquire image!" << std::endl;
709 if (getLatestFrame ==
true)
711 bytesRead = SR_Acquire(
m_SRCam);
714 std::cerr <<
"ERROR - Swissranger::AcquireImages:" << std::endl;
715 std::cerr <<
"\t ... Could not acquire image!" << std::endl;
719 WORD* pixels =(WORD*) SR_GetImage(
m_SRCam, 0);
729 for(
unsigned int row=0; row<(
unsigned int)height; row++)
731 imageStep = row*
width;
732 f_ptr = (
float*)(rangeImageData + row*widthStepRange);
734 for (
unsigned int col=0; col<(
unsigned int)width; col++)
736 f_ptr[col] = (float)(pixels[imageStep + col]);
742 cv::Mat undistortedData(height, width, CV_32FC(1), (
float*) rangeImageData);
743 cv::Mat distortedData;
757 if (grayImageType == ipa_CameraSensors::INTENSITY_32F1 &&
760 std::cout <<
"WARNING - Swissranger::AcquireImages:" << std::endl;
761 std::cout <<
"\t ... Intensity image for swissranger not available" << std::endl;
762 std::cout <<
"\t ... falling back to amplitude image" << std::endl;
766 int imageSize = width*
height;
770 for(
unsigned int row=0; row<(
unsigned int)height-1; row++)
772 imageStep = imageSize+row*
width;
773 f_ptr = (
float*)(grayImageData + row*widthStepGray);
775 for (
unsigned int col=0; col<(
unsigned int)width-1; col++)
777 f_ptr[col] = (float)(pixels[imageStep+col]);
783 cv::Mat undistortedData( height, width, CV_32FC1, (
float*) grayImageData);
784 cv::Mat distortedData;
795 if(cartesianImageData)
800 float* zCalibratedPtr = 0;
801 float zCalibrated = -1;
809 cv::Mat distortedData( height, width, CV_32FC1 );
810 for(
unsigned int row=0; row<(
unsigned int)height; row++)
812 f_ptr = distortedData.ptr<
float>(row);
813 for (
unsigned int col=0; col<(
unsigned int)width; col++)
815 zRaw = (float)(pixels[width*row + col]);
817 f_ptr[col] = zCalibrated;
830 cv::Mat undistortedData;
843 for(
unsigned int row=0; row<(
unsigned int)height; row++)
845 zCalibratedPtr = undistortedData.ptr<
float>(row);
846 f_ptr = (
float*)(cartesianImageData + row*widthStepCartesian);
848 for (
unsigned int col=0; col<(
unsigned int)width; col++)
850 int colTimes3 = 3*col;
853 f_ptr[colTimes3] = x;
854 f_ptr[colTimes3 + 1] = y;
855 f_ptr[colTimes3 + 2] = zCalibratedPtr[col];
861 std::cerr <<
"ERROR - Swissranger::AcquireImages: \n";
862 std::cerr <<
"\t ... At least one of m_CoeffsA0 ... m_CoeffsA6 not initialized.\n";
869 SR_CoordTrfFlt(
m_SRCam,
m_X,
m_Y,
m_Z,
sizeof(
float),
sizeof(
float),
sizeof(
float));
871 cv::Mat distortedData( height, width, CV_32FC1 );
872 for(
unsigned int row=0; row<(
unsigned int)height; row++)
874 f_ptr = distortedData.ptr<
float>(row);
875 for (
unsigned int col=0; col<(
unsigned int)width; col++)
878 f_ptr[col] = zCalibrated;
883 cv::Mat undistortedData;
888 for(
unsigned int row=0; row<(
unsigned int)height; row++)
890 zCalibratedPtr = undistortedData.ptr<
float>(row);
891 f_ptr = (
float*)(cartesianImageData + row*widthStepCartesian);
893 for (
unsigned int col=0; col<(
unsigned int)width; col++)
895 int colTimes3 = 3*col;
898 f_ptr[colTimes3] = x;
899 f_ptr[colTimes3 + 1] = y;
900 f_ptr[colTimes3 + 2] = zCalibratedPtr[col];
906 SR_CoordTrfFlt(
m_SRCam,
m_X,
m_Y,
m_Z,
sizeof(
float),
sizeof(
float),
sizeof(
float));
908 for(
unsigned int row=0; row<(
unsigned int)height; row++)
910 f_ptr = (
float*)(cartesianImageData + row*widthStepCartesian);
912 for (
unsigned int col=0; col<(
unsigned int)width; col++)
914 int colTimes3 = 3*col;
919 f_ptr[colTimes3] = x;
920 f_ptr[colTimes3 + 1] = y;
921 f_ptr[colTimes3 + 2] = zCalibrated;
927 std::cerr <<
"ERROR - Swissranger::AcquireImages:" << std::endl;
928 std::cerr <<
"\t ... Calibration method unknown.\n";
947 zCalibrated = (float) y;
955 zCalibrated = (float)
m_Z[v*width + u];
967 double fx, fy, cx, cy;
978 std::cerr <<
"ERROR - Swissranger::GetCalibratedXYZ:" << std::endl;
979 std::cerr <<
"\t ... fx is 0.\n";
982 x = (float) (z*(u-cx)/fx) ;
987 std::cerr <<
"ERROR - Swissranger::GetCalibratedXYZ:" << std::endl;
988 std::cerr <<
"\t ... fy is 0.\n";
991 y = (float) (z*(v-cy)/fy);
1003 int i = v*width + u;
1019 std::string sAmplitudeThreshold =
"";
1023 if (sAmplitudeThreshold ==
"AUTO")
1028 else if (sAmplitudeThreshold ==
"DEFAULT")
1043 std::cout <<
"WARNING - Swissranger::SetParameters:" << std::endl;
1044 std::cout <<
"\t ... Could not set amplitude threshold" << std::endl;
1051 std::string sIntegrationTime =
"";
1055 if (sIntegrationTime ==
"AUTO")
1060 else if (sIntegrationTime ==
"DEFAULT")
1067 std::string tempValue;
1072 cameraProperty.
u_charData = (
unsigned char)atoi(tempValue.c_str());
1077 std::cout <<
"WARNING - Swissranger::SetParameters:" << std::endl;
1078 std::cout <<
"\t ... Could not set integration time" << std::endl;
1085 std::string sModulationFrequency =
"";
1089 if (sModulationFrequency ==
"AUTO")
1094 else if (sModulationFrequency ==
"DEFAULT")
1107 if (
SetProperty(&cameraProperty) & ipa_CameraSensors::RET_FAILED)
1109 std::cout <<
"WARNING - Swissranger::SetParameters:" << std::endl;
1110 std::cout <<
"\t ... Could not set modulation frequency" << std::endl;
1121 if (
SetProperty(&cameraProperty) & ipa_CameraSensors::RET_FAILED)
1123 std::cout <<
"WARNING - Swissranger::SetParameters:" << std::endl;
1124 std::cout <<
"\t ... Could not set acquire mode" << std::endl;
1135 if (!p_configXmlDocument->LoadFile())
1137 std::cerr <<
"ERROR - Swissranger::LoadParameters:" << std::endl;
1138 std::cerr <<
"\t ... Error while loading xml configuration file \n";
1139 std::cerr <<
"\t ... (Check filename and syntax of the file):\n";
1140 std::cerr <<
"\t ... '" << filename <<
"'" << std::endl;
1143 std::cout <<
"INFO - Swissranger::LoadParameters:" << std::endl;
1144 std::cout <<
"\t ... Parsing xml configuration file:" << std::endl;
1145 std::cout <<
"\t ... '" << filename <<
"'" << std::endl;
1147 std::string tempString;
1148 if ( p_configXmlDocument )
1155 TiXmlElement *p_xmlElement_Root = NULL;
1156 p_xmlElement_Root = p_configXmlDocument->FirstChildElement(
"LibCameraSensors" );
1158 if ( p_xmlElement_Root )
1165 TiXmlElement *p_xmlElement_Root_SR31 = NULL;
1166 std::stringstream ss;
1167 ss <<
"Swissranger_" << cameraIndex;
1168 p_xmlElement_Root_SR31 = p_xmlElement_Root->FirstChildElement( ss.str() );
1169 if ( p_xmlElement_Root_SR31 )
1176 TiXmlElement* p_xmlElement_Child = NULL;
1177 p_xmlElement_Child = p_xmlElement_Root_SR31->FirstChildElement(
"Role" );
1178 if ( p_xmlElement_Child )
1181 if ( p_xmlElement_Child->QueryValueAttribute(
"value", &tempString ) != TIXML_SUCCESS)
1183 std::cerr <<
"ERROR - Swissranger::LoadParameters:" << std::endl;
1184 std::cerr <<
"\t ... Can't find attribute 'value' of tag 'Role'." << std::endl;
1192 std::cerr <<
"ERROR - Swissranger::LoadParameters:" << std::endl;
1193 std::cerr <<
"\t ... Role " << tempString <<
" unspecified." << std::endl;
1200 std::cerr <<
"ERROR - Swissranger::LoadParameters:" << std::endl;
1201 std::cerr <<
"\t ... Can't find tag 'Role'." << std::endl;
1209 p_xmlElement_Child = NULL;
1210 p_xmlElement_Child = p_xmlElement_Root_SR31->FirstChildElement(
"Interface" );
1211 std::string tempString;
1212 if ( p_xmlElement_Child )
1215 if ( p_xmlElement_Child->QueryValueAttribute(
"value", &tempString ) != TIXML_SUCCESS)
1217 std::cerr <<
"ERROR - Swissranger::LoadParameters:" << std::endl;
1218 std::cerr <<
"\t ... Can't find attribute 'value' of tag 'Interface'." << std::endl;
1221 if (tempString ==
"USB")
1227 else if (tempString ==
"ETHERNET")
1233 if ( p_xmlElement_Child->QueryValueAttribute(
"ip", &tempString ) != TIXML_SUCCESS)
1235 std::cerr <<
"ERROR - Swissranger::LoadParameters:" << std::endl;
1236 std::cerr <<
"\t ... Can't find attribute 'ip' of tag 'Interface'." << std::endl;
1245 std::cerr <<
"ERROR - Swissranger::LoadParameters:" << std::endl;
1246 std::cerr <<
"\t ... Interface " << tempString <<
" unspecified." << std::endl;
1252 std::cerr <<
"ERROR - Swissranger::LoadParameters:" << std::endl;
1253 std::cerr <<
"\t ... Can't find tag 'Interface'." << std::endl;
1261 p_xmlElement_Child = NULL;
1262 p_xmlElement_Child = p_xmlElement_Root_SR31->FirstChildElement(
"AmplitudeThreshold" );
1263 if ( p_xmlElement_Child )
1266 if ( p_xmlElement_Child->QueryValueAttribute(
"value", &tempString) != TIXML_SUCCESS)
1268 std::cerr <<
"ERROR - Swissranger::LoadParameters:" << std::endl;
1269 std::cerr <<
"\t ... Can't find attribute 'value' of tag 'AmplitudeThreshold'." << std::endl;
1281 std::cerr <<
"ERROR - Swissranger::LoadParameters:" << std::endl;
1282 std::cerr <<
"\t ... Can't find tag 'AmplitudeThreshold'." << std::endl;
1290 p_xmlElement_Child = NULL;
1291 p_xmlElement_Child = p_xmlElement_Root_SR31->FirstChildElement(
"IntegrationTime" );
1292 if ( p_xmlElement_Child )
1295 if ( p_xmlElement_Child->QueryValueAttribute(
"value", &tempString) != TIXML_SUCCESS)
1297 std::cerr <<
"ERROR - Swissranger::LoadParameters:" << std::endl;
1298 std::cerr <<
"\t ... Can't find attribute 'value' of tag 'IntegrationTime'." << std::endl;
1310 std::cerr <<
"ERROR - Swissranger::LoadParameters:" << std::endl;
1311 std::cerr <<
"\t ... Can't find tag 'IntegrationTime'." << std::endl;
1319 p_xmlElement_Child = NULL;
1320 p_xmlElement_Child = p_xmlElement_Root_SR31->FirstChildElement(
"Modulation" );
1321 if ( p_xmlElement_Child )
1324 if ( p_xmlElement_Child->QueryValueAttribute(
"frequency", &tempString) != TIXML_SUCCESS)
1326 std::cerr <<
"ERROR - Swissranger::LoadParameters:" << std::endl;
1327 std::cerr <<
"\t ... Can't find attribute 'frequency' of tag 'Modulation'." << std::endl;
1339 std::cerr <<
"ERROR - Swissranger::LoadParameters:" << std::endl;
1340 std::cerr <<
"\t ... Can't find tag 'Modulation'." << std::endl;
1348 p_xmlElement_Child = NULL;
1349 p_xmlElement_Child = p_xmlElement_Root_SR31->FirstChildElement(
"AcquireMode" );
1350 if ( p_xmlElement_Child )
1352 int acquireMode = 0;
1354 if ( p_xmlElement_Child->QueryValueAttribute(
"AM_COR_FIX_PTRN", &tempString) != TIXML_SUCCESS)
1356 std::cerr <<
"ERROR - Swissranger::LoadParameters:" << std::endl;
1357 std::cerr <<
"\t ... Can't find attribute 'AM_COR_FIX_PTRN' of tag 'AcquireMode'." << std::endl;
1362 if (tempString ==
"ON") acquireMode |= AM_COR_FIX_PTRN;
1365 if ( p_xmlElement_Child->QueryValueAttribute(
"AM_MEDIAN", &tempString) != TIXML_SUCCESS)
1367 std::cerr <<
"ERROR - Swissranger::LoadParameters:" << std::endl;
1368 std::cerr <<
"\t ... Can't find attribute 'AM_MEDIAN' of tag 'AcquireMode'." << std::endl;
1373 if (tempString ==
"ON") acquireMode |= AM_MEDIAN;
1376 if ( p_xmlElement_Child->QueryValueAttribute(
"AM_TOGGLE_FRQ", &tempString) != TIXML_SUCCESS)
1378 std::cerr <<
"ERROR - Swissranger::LoadParameters:" << std::endl;
1379 std::cerr <<
"\t ... Can't find attribute 'AM_TOGGLE_FRQ' of tag 'AcquireMode'." << std::endl;
1384 if (tempString ==
"ON") acquireMode |= AM_TOGGLE_FRQ;
1387 if ( p_xmlElement_Child->QueryValueAttribute(
"AM_CONV_GRAY", &tempString) != TIXML_SUCCESS)
1389 std::cerr <<
"ERROR - Swissranger::LoadParameters:" << std::endl;
1390 std::cerr <<
"\t ... Can't find attribute 'AM_CONV_GRAY' of tag 'AcquireMode'." << std::endl;
1395 if (tempString ==
"ON") acquireMode |= AM_CONV_GRAY;
1398 if ( p_xmlElement_Child->QueryValueAttribute(
"AM_SW_ANF", &tempString) != TIXML_SUCCESS)
1400 std::cerr <<
"ERROR - Swissranger::LoadParameters:" << std::endl;
1401 std::cerr <<
"\t ... Can't find attribute 'AM_SW_ANF' of tag 'AcquireMode'." << std::endl;
1406 if (tempString ==
"ON") acquireMode |= AM_SW_ANF;
1409 if ( p_xmlElement_Child->QueryValueAttribute(
"AM_SR3K_2TAP_PROC", &tempString) != TIXML_SUCCESS)
1411 std::cerr <<
"ERROR - Swissranger::LoadParameters:" << std::endl;
1412 std::cerr <<
"\t ... Can't find attribute 'AM_SR3K_2TAP_PROC' of tag 'AcquireMode'." << std::endl;
1420 if ( p_xmlElement_Child->QueryValueAttribute(
"AM_SHORT_RANGE", &tempString) != TIXML_SUCCESS)
1422 std::cerr <<
"ERROR - Swissranger::LoadParameters:" << std::endl;
1423 std::cerr <<
"\t ... Can't find attribute 'AM_SHORT_RANGE' of tag 'AcquireMode'." << std::endl;
1431 if ( p_xmlElement_Child->QueryValueAttribute(
"AM_CONF_MAP", &tempString) != TIXML_SUCCESS)
1433 std::cerr <<
"ERROR - Swissranger::LoadParameters:" << std::endl;
1434 std::cerr <<
"\t ... Can't find attribute 'AM_CONF_MAP' of tag 'AcquireMode'." << std::endl;
1439 if (tempString ==
"ON") acquireMode |= AM_CONF_MAP;
1442 if ( p_xmlElement_Child->QueryValueAttribute(
"AM_HW_TRIGGER", &tempString) != TIXML_SUCCESS)
1444 std::cerr <<
"ERROR - Swissranger::LoadParameters:" << std::endl;
1445 std::cerr <<
"\t ... Can't find attribute 'AM_HW_TRIGGER' of tag 'AcquireMode'." << std::endl;
1450 if (tempString ==
"ON") acquireMode |= AM_HW_TRIGGER;
1453 if ( p_xmlElement_Child->QueryValueAttribute(
"AM_SW_TRIGGER", &tempString) != TIXML_SUCCESS)
1455 std::cerr <<
"ERROR - Swissranger::LoadParameters:" << std::endl;
1456 std::cerr <<
"\t ... Can't find attribute 'AM_SW_TRIGGER' of tag 'AcquireMode'." << std::endl;
1461 if (tempString ==
"ON") acquireMode |= AM_SW_TRIGGER;
1464 if ( p_xmlElement_Child->QueryValueAttribute(
"AM_DENOISE_ANF", &tempString) != TIXML_SUCCESS)
1466 std::cerr <<
"ERROR - Swissranger::LoadParameters:" << std::endl;
1467 std::cerr <<
"\t ... Can't find attribute 'AM_DENOISE_ANF' of tag 'AcquireMode'." << std::endl;
1472 if (tempString ==
"ON") acquireMode |= AM_DENOISE_ANF;
1475 if ( p_xmlElement_Child->QueryValueAttribute(
"AM_MEDIANCROSS", &tempString) != TIXML_SUCCESS)
1477 std::cerr <<
"ERROR - Swissranger::LoadParameters:" << std::endl;
1478 std::cerr <<
"\t ... Can't find attribute 'AM_MEDIANCROSS' of tag 'AcquireMode'." << std::endl;
1483 if (tempString ==
"ON") acquireMode |= AM_MEDIANCROSS;
1492 std::cerr <<
"ERROR - Swissranger::LoadParameters:" << std::endl;
1493 std::cerr <<
"\t ... Can't find tag 'AcquireMode'." << std::endl;
1501 p_xmlElement_Child = NULL;
1502 p_xmlElement_Child = p_xmlElement_Root_SR31->FirstChildElement(
"CalibrationMethod" );
1503 if ( p_xmlElement_Child )
1506 if ( p_xmlElement_Child->QueryValueAttribute(
"name", &tempString ) != TIXML_SUCCESS)
1508 std::cerr <<
"ERROR - Swissranger::LoadParameters:" << std::endl;
1509 std::cerr <<
"\t ... Can't find attribute 'name' of tag 'CalibrationMethod'." << std::endl;
1517 std::cerr <<
"ERROR - Swissranger::LoadParameters:" << std::endl;
1518 std::cerr <<
"\t ... Calibration mode " << tempString <<
" unspecified." << std::endl;
1524 std::cerr <<
"ERROR - Swissranger::LoadParameters:" << std::endl;
1525 std::cerr <<
"\t ... Can't find tag 'CalibrationMethod'." << std::endl;
1535 std::cerr <<
"ERROR - Swissranger::LoadParameters:" << std::endl;
1536 std::cerr <<
"\t ... Can't find tag '" << ss.str() <<
"'" << std::endl;
1546 std::cerr <<
"ERROR - Swissranger::LoadParameters:" << std::endl;
1547 std::cerr <<
"\t ... Can't find tag 'LibCameraSensors'." << std::endl;
1553 std::cout <<
"INFO - Swissranger::LoadParameters:" << std::endl;
1554 std::cout <<
"\t ... Parsing xml calibration file: Done.\n";
PROP_MODULATION_FREQUENCY
bool m_CoeffsInitialized
True, when m_CoeffsAx have been initialized.
cv::Mat m_intrinsicMatrix
Intrinsic parameters [fx 0 cx; 0 fy cy; 0 0 1].
std::stringstream m_IntegrationTime
Integration time of the camera.
t_CalibrationMethod m_CalibrationMethod
Calibration method MATLAB, MATLAB_NO_Z or SWISSRANGER.
t_cameraResolution cameraResolution
unsigned long GetProperty(t_cameraProperty *cameraProperty)
RET_FUNCTION_NOT_IMPLEMENTED
std::stringstream m_IP
IP address of the camera.
cv::Mat m_CoeffsA1
a1 z-calibration parameters. One matrix entry corresponds to one pixel
cv::Mat m_CoeffsA2
a2 z-calibration parameters. One matrix entry corresponds to one pixel
unsigned long AcquireImages(int widthStepRange, int widthStepGray, int widthStepCartesian, char *RangeImage=NULL, char *IntensityImage=NULL, char *cartesianImage=NULL, bool getLatestFrame=true, bool undistort=true, ipa_CameraSensors::t_ToFGrayImageType grayImageType=ipa_CameraSensors::INTENSITY_32F1)
unsigned long SetProperty(t_cameraProperty *cameraProperty)
cv::Mat m_CoeffsA4
a4 z-calibration parameters. One matrix entry corresponds to one pixel
unsigned short u_shortData
ipa_CameraSensors::t_cameraRole m_CameraRole
Master or slave camera.
float m_Y[SWISSRANGER_COLUMNS *SWISSRANGER_ROWS]
unsigned long GetCalibratedZSwissranger(int u, int v, int width, float &zCalibrated)
unsigned long Init(std::string directory, int cameraIndex=0)
RET_CAMERA_NOT_INITIALIZED
bool m_GrayImageAcquireCalled
Is false, when acquiring gray image has not been called, yet.
unsigned long GetCalibratedZMatlab(int u, int v, float zRaw, float &zCalibrated)
float m_Z[SWISSRANGER_COLUMNS *SWISSRANGER_ROWS]
unsigned long LoadParameters(const char *filename, int cameraIndex)
unsigned long SetPropertyDefaults()
std::stringstream m_AmplitudeThreshold
their amplitude is lower than the amplitude threshold
cv::Mat m_CoeffsA5
a5 z-calibration parameters. One matrix entry corresponds to one pixel
unsigned long SetParameters()
t_cameraType m_CameraType
Camera Type.
SRCAM m_SRCam
Handle to USB SR3000 camera.
unsigned long SaveParameters(const char *filename)
t_specialValues specialValue
unsigned int m_BufferSize
Number of images, the camera buffers internally.
std::stringstream m_AcquireMode
Swissranger acquire mode.
cv::Mat m_CoeffsA0
a0 z-calibration parameters. One matrix entry corresponds to one pixel
RET_CAMERA_ALREADY_INITIALIZED
boost::shared_ptr< AbstractRangeImagingSensor > AbstractRangeImagingSensorPtr
cv::Mat m_undistortMapX
The output array of x coordinates for the undistortion map.
cv::Mat m_CoeffsA6
a6 z-calibration parameters. One matrix entry corresponds to one pixel
unsigned long GetCalibratedXYSwissranger(int u, int v, int width, float &x, float &y)
unsigned int u_integerData
t_cameraPropertyID propertyID
unsigned long EvaluatePolynomial(double x, int degree, double *coefficients, double *y)
cv::Mat m_undistortMapY
The output array of Y coordinates for the undistortion map.
cv::Mat m_CoeffsA3
a3 z-calibration parameters. One matrix entry corresponds to one pixel
bool m_initialized
True, when the camera has sucessfully been initialized.
std::stringstream m_ModulationFrequency
Modulation Frequency. The higher the frequency, the lower the measurable distance.
__DLL_LIBCAMERASENSORS__ AbstractRangeImagingSensorPtr CreateRangeImagingSensor_Swissranger()
t_RangeCameraParameters m_RangeCameraParameters
Storage for xml configuration file parmeters.
unsigned long propertyType
std::stringstream m_Interface
Interface, the camera is connected to (i.e. USB or ETHERNET)
ImgEntry * m_DataBuffer
Image array.
#define __DLL_LIBCAMERASENSORS__
float m_X[SWISSRANGER_COLUMNS *SWISSRANGER_ROWS]
unsigned long GetCalibratedXYMatlab(int u, int v, float z, float &x, float &y)
bool m_open
True, when the camera has sucessfully been opend.
int LibMesaCallback(SRCAM srCam, unsigned int msg, unsigned int param, void *data)