00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054 #ifdef __LINUX__
00055 #include "cob_camera_sensors/AVTPikeCam.h"
00056 #else
00057 #include "cob_driver/cob_camera_sensors/common/include/cob_camera_sensors/AVTPikeCam.h"
00058 #endif
00059
00060 using namespace std;
00061 using namespace ipa_CameraSensors;
00062
00063 bool AVTPikeCam::m_OpenExecuted = false;
00064 AVTPikeCam::AVTPikeCamDeleter AVTPikeCam::m_Deleter;
00065
00066 __DLL_LIBCAMERASENSORS__ AbstractColorCameraPtr ipa_CameraSensors::CreateColorCamera_AVTPikeCam()
00067 {
00068 return AbstractColorCameraPtr(new AVTPikeCam());
00069 }
00070
00071 AVTPikeCam::AVTPikeCam()
00072 {
00073 m_initialized = false;
00074 m_open = false;
00075 m_BufferSize = 3;
00076
00077 #ifdef __LINUX__
00078 m_cam = 0;
00079 m_IEEE1394Cameras = 0;
00080 m_IEEE1394Info = 0;
00081 m_Frame = 0;
00082 #endif
00083 #ifndef __LINUX__
00084 m_Frame.pData = 0;
00085 #endif
00086
00087 }
00088
00089 AVTPikeCam::~AVTPikeCam()
00090 {
00091 if (isOpen())
00092 {
00093 Close();
00094 }
00095
00096 #ifdef __LINUX__
00097 if (m_IEEE1394Info != 0)
00098 {
00099 dc1394_free(m_IEEE1394Info);
00100 m_IEEE1394Info = 0;
00101 }
00102 #endif
00103 }
00104
00105
00106 unsigned long AVTPikeCam::Init(std::string directory, int cameraIndex)
00107 {
00108 if (isInitialized())
00109 {
00110 return (RET_OK | RET_CAMERA_ALREADY_INITIALIZED);
00111 }
00112 m_initialized = false;
00113 m_CameraType = ipa_CameraSensors::CAM_AVTPIKE;
00114
00115 #ifdef __LINUX__
00116
00117
00118 std::string iniFileNameAndPath = directory + "cameraSensorsIni.xml";
00119 if (LoadParameters(iniFileNameAndPath.c_str(), cameraIndex) & RET_FAILED)
00120 {
00121 return (RET_FAILED | RET_INIT_CAMERA_FAILED);
00122 }
00123
00124
00125
00126 if (m_IEEE1394Info == 0)
00127 {
00128 m_IEEE1394Info = dc1394_new();
00129 }
00130 dc1394error_t err = dc1394_camera_enumerate(m_IEEE1394Info, &m_IEEE1394Cameras);
00131 if (err!=DC1394_SUCCESS)
00132 {
00133 std::cerr << "ERROR - AVTPikeCam::Init:" << std::endl;
00134 std::cerr << "\t ... Failed to enumerate cameras" << std::endl;
00135 std::cerr << "\t ... " << dc1394_error_get_string(err) << std::endl;
00136 return RET_FAILED;
00137 }
00138
00139 if (m_IEEE1394Cameras->num == 0)
00140 {
00141 std::cerr << "ERROR - AVTPikeCam::Init:" << std::endl;
00142 std::cerr << "\t ... No cameras found" << std::endl;
00143 return RET_FAILED;
00144 }
00145
00146 m_initialized = true;
00147 return RET_OK;
00148
00149 #else
00150
00151 std::string iniFileNameAndPath = directory + "cameraSensorsIni.xml";
00152 if (LoadParameters(iniFileNameAndPath.c_str(), cameraIndex) & RET_FAILED)
00153 {
00154 return (RET_FAILED | RET_INIT_CAMERA_FAILED);
00155 }
00156
00157 UINT32 err;
00158
00159
00160 if (m_OpenExecuted == false)
00161 {
00162 m_OpenExecuted = true;
00163 UINT32 err = FGInitModule(NULL);
00164 if(err!=FCE_NOERROR)
00165 {
00166 std::cerr << "ERROR - AVTPikeCam::Init:" << std::endl;
00167 std::cerr << "\t ... Initialization of FireGrab library failed. ( error " << err << " )" << std::endl;
00168 return RET_FAILED;
00169 }
00170 }
00171
00172
00173
00174 m_NodeCnt = 0;
00175 err=FGGetNodeList(m_nodeInfo, 5, &m_NodeCnt);
00176 if(err!=FCE_NOERROR)
00177 {
00178 std::cerr << "ERROR - AVTPikeCam::Init:" << std::endl;
00179 std::cerr << "\t ... Retrival of connected IEEE1394 nodes failed. ( error " << err << " )" << std::endl;
00180 return RET_FAILED;
00181 }
00182
00183 if (m_NodeCnt <= 0)
00184 {
00185 std::cout << "ERROR - AVTPikeCam::Init:" << std::endl;
00186 std::cerr << "\t ... No cameras found." << std::endl;
00187 return RET_FAILED;
00188 }
00189 else
00190 {
00191 std::cout << "INFO - AVTPikeCam::Init:" << std::endl;
00192 std::cout << "\t ... Detected '" << m_NodeCnt << "' IEEE1394 node(s)" << std::endl;
00193 for(unsigned int i=0; i < m_NodeCnt; i++)
00194 {
00195 printf ("\t ... GUID of node '%i' is %-#08lX %-#08lX \n", i+1, m_nodeInfo[i].Guid.High, m_nodeInfo[i].Guid.Low);
00196 }
00197 }
00198
00199 m_initialized = true;
00200 return RET_OK;
00201
00202 #endif
00203 }
00204
00205
00206 unsigned long AVTPikeCam::Open()
00207 {
00208 if (!isInitialized())
00209 {
00210 std::cerr << "ERROR - AVTPikeCam::Open:" << std::endl;
00211 std::cerr << "\t ... Camera not initialized." << std::endl;
00212 return (RET_FAILED);
00213 }
00214 m_open = false;
00215
00216
00217 #ifdef __LINUX__
00218 dc1394error_t err;
00219
00220
00221 unsigned int i=0;
00222 for(; i<m_IEEE1394Cameras->num; i++)
00223 {
00224 uint64_t high = m_GUID.High;
00225 uint64_t low = m_GUID.Low;
00226 uint64_t guid = (high << 32) + low;
00227 if (m_IEEE1394Cameras->ids[i].guid == guid) break;
00228 }
00229
00230 if (i == m_IEEE1394Cameras->num)
00231 {
00232 printf ("ERROR - AVTPikeCam::Open: \n\t ... Could not detect specified camera GUID %#08lX %#08lX on IEEE1394 bus\n", m_GUID.High, m_GUID.Low);
00233 return RET_FAILED;
00234 }
00235
00236 m_cam = dc1394_camera_new(m_IEEE1394Info, m_IEEE1394Cameras->ids[i].guid);
00237 if (m_cam == 0)
00238 {
00239 m_open = false;
00240 return RET_FAILED;
00241 }
00242
00243 dc1394_camera_free_list(m_IEEE1394Cameras);
00244
00245
00246 if (SetParameters() & ipa_CameraSensors::RET_FAILED)
00247 {
00248 std::cerr << "ERROR - AVTPikeCam::Open:" << std::endl;
00249 std::cerr << "\t... Error while setting parameters" << std::endl;
00250 return RET_FAILED;
00251 }
00252
00253 err = dc1394_capture_setup(m_cam, m_BufferSize, DC1394_CAPTURE_FLAGS_DEFAULT);
00254
00255 if (err!=DC1394_SUCCESS)
00256 {
00257 std::cout << "INFO - AVTPikeCam::Open:" << std::endl;
00258 std::cout << "\t ... Releasing bandwdith and retrying to setup DMA capture" << std::endl;
00259 uint32_t bandwidth = -1;
00260 err = dc1394_video_get_bandwidth_usage(m_cam, &bandwidth);
00261 if (err!=DC1394_SUCCESS)
00262 {
00263 std::cerr << "ERROR - AVTPikeCam::Open:" << std::endl;
00264 std::cerr << "\t ... Failed to get bandwith usage of camera device" << std::endl;
00265 std::cerr << "\t ... " << dc1394_error_get_string(err) << std::endl;
00266 return RET_FAILED;
00267 }
00268 dc1394_iso_release_bandwidth(m_cam, bandwidth);
00269 if (err!=DC1394_SUCCESS)
00270 {
00271 std::cerr << "ERROR - AVTPikeCam::Open:" << std::endl;
00272 std::cerr << "\t ... Failed to relase requested bandwidth '" << bandwidth << "'" << std::endl;
00273 std::cerr << "\t ... " << dc1394_error_get_string(err) << std::endl;
00274 return RET_FAILED;
00275 }
00276 err = dc1394_capture_setup(m_cam, m_BufferSize, DC1394_CAPTURE_FLAGS_DEFAULT);
00277 if (err!=DC1394_SUCCESS)
00278 {
00279 std::cerr << "ERROR - AVTPikeCam::Open:" << std::endl;
00280 std::cerr << "\t ... Failed to setup cameras device" << std::endl;
00281 std::cerr << "\t ... " << dc1394_error_get_string(err) << std::endl;
00282 return RET_FAILED;
00283 }
00284 }
00285
00286
00287
00288 err=dc1394_video_set_transmission(m_cam, DC1394_ON);
00289 if (err!=DC1394_SUCCESS)
00290 {
00291 std::cerr << "ERROR - AVTPikeCam::Open:" << std::endl;
00292 std::cerr << "\t ... 'dc1394_video_set_transmission' failed." << std::endl;
00293 std::cerr << "\t ... " << dc1394_error_get_string(err) << std::endl;
00294 return RET_FAILED;
00295 }
00296
00297 #else
00298
00299 UINT32 err;
00300
00301
00302 unsigned int i=0;
00303 for(; i<m_NodeCnt; i++)
00304 {
00305 if (m_nodeInfo[i].Guid.Low - m_GUID.Low == 0 &&
00306 m_nodeInfo[i].Guid.High - m_GUID.High == 0) break;
00307 }
00308
00309 if (i == m_NodeCnt)
00310 {
00311 printf ("ERROR - AVTPikeCam::Open: \n\t ... Could not detect specified camera GUID %#08lX %#08lX on IEEE1394 bus\n", m_GUID.High, m_GUID.Low);
00312 return RET_FAILED;
00313 }
00314
00315 err=m_cam.Connect(&m_GUID);
00316 if(err!=FCE_NOERROR)
00317 {
00318 std::cerr << "ERROR - AVTPikeCam::Open:" << std::endl;
00319 std::cerr << "\t ... Could not connect to camera. ( error " << err << " )" << std::endl;
00320 return RET_FAILED;
00321 }
00322
00323 if (SetParameters() & ipa_CameraSensors::RET_FAILED)
00324 {
00325 std::cerr << "ERROR - AVTPikeCam::Open:" << std::endl;
00326 std::cerr << "\t ... Could not set parameters. ( error " << err << " )" << std::endl;
00327 return RET_FAILED;
00328 }
00329
00330 err = m_cam.SetParameter(FGP_FRAMEBUFFERCOUNT, m_BufferSize);
00331 if(err!=FCE_NOERROR)
00332 {
00333 std::cerr << "ERROR - AVTPikeCam::Open:" << std::endl;
00334 std::cerr << "\t ... Could not set DMA buffer size to '"<< m_BufferSize
00335 << "' ( error " << err << " )" << std::endl;
00336 return RET_FAILED;
00337 }
00338
00339
00340 err=m_cam.OpenCapture();
00341 if(err!=FCE_NOERROR)
00342 {
00343 std::cerr << "ERROR - AVTPikeCam::Open:" << std::endl;
00344 std::cerr << "\t ... Could not start DMA logic ( error " << err << " )" << std::endl;
00345 return RET_FAILED;
00346 }
00347
00348
00349 err=m_cam.StartDevice();
00350 if(err!=FCE_NOERROR)
00351 {
00352 std::cerr << "ERROR - AVTPikeCam::Open:" << std::endl;
00353 std::cerr << "\t ... Could not start camera device ( error " << err << " )" << std::endl;
00354 return RET_FAILED;
00355 }
00356
00357 #endif
00358 std::cout << "**************************************************" << std::endl;
00359 std::cout << "AVTPikeCam::Open: AVT Pike 145C camera device OPEN" << std::endl;
00360 std::cout << "**************************************************" << std::endl << std::endl;
00361 m_open = true;
00362 return RET_OK;
00363 }
00364
00365
00366 unsigned long AVTPikeCam::SaveParameters(const char* filename)
00367 {
00368 return RET_FAILED;
00369 }
00370
00371
00372
00373
00374
00375 unsigned long AVTPikeCam::Close()
00376 {
00377 if (!isOpen())
00378 {
00379 return (RET_OK);
00380 }
00381
00382 #ifdef __LINUX__
00383 if (m_cam != 0)
00384 {
00385
00386 dc1394error_t err;
00387 err=dc1394_video_set_transmission(m_cam, DC1394_OFF);
00388 if (err!=DC1394_SUCCESS)
00389 {
00390 std::cerr << "ERROR - AVTPikeCam::Close:" << std::endl;
00391 std::cerr << "\t ... 'dc1394_video_set_transmission' failed." << std::endl;
00392 std::cerr << "\t ... " << dc1394_error_get_string(err) << std::endl;
00393 return RET_FAILED;
00394 }
00395 dc1394_capture_stop(m_cam);
00396 dc1394_camera_free(m_cam);
00397 m_cam = 0;
00398 }
00399 #else
00400
00401 UINT32 err;
00402 err=m_cam.StopDevice();
00403 if(err!=FCE_NOERROR)
00404 {
00405 std::cerr << "ERROR - AVTPikeCam::Close:" << std::endl;
00406 std::cerr << "\t ... Could not stop camera device ( error " << err << " )" << std::endl;
00407 }
00408
00409
00410
00411 err=m_cam.CloseCapture();
00412 if(err!=FCE_NOERROR)
00413 {
00414 std::cerr << "ERROR - AVTPikeCam::Close:" << std::endl;
00415 std::cerr << "\t ... Could not close capture logic. ( error " << err << " )" << std::endl; return RET_FAILED;
00416 }
00417
00418
00419 err=m_cam.Disconnect();
00420 if(err!=FCE_NOERROR)
00421 {
00422 std::cerr << "ERROR - AVTPikeCam::Close:" << std::endl;
00423 std::cerr << "\t ... Could not disconnect camera. ( error " << err << " )" << std::endl; return RET_FAILED;
00424 }
00425
00426
00427 #endif
00428
00429 m_open = false;
00430 return RET_OK;
00431 }
00432
00433
00434
00435 unsigned long AVTPikeCam::SetPropertyDefaults()
00436 {
00437 return RET_FUNCTION_NOT_IMPLEMENTED;
00438 }
00439
00440 unsigned long AVTPikeCam::GetProperty(t_cameraProperty* cameraProperty)
00441 {
00442 #ifdef __LINUX__
00443 dc1394error_t err;
00444 switch (cameraProperty->propertyID)
00445 {
00446 case PROP_DMA_BUFFER_SIZE:
00447 cameraProperty->u_integerData = m_BufferSize;
00448 return RET_OK;
00449 break;
00450 case PROP_CAMERA_RESOLUTION:
00451 if (isOpen())
00452 {
00453 uint32_t imageWidth = -1;
00454 uint32_t imageHeight = -1;
00455 dc1394video_mode_t videoMode;
00456 err=dc1394_video_get_mode(m_cam, &videoMode);
00457 if (err!=DC1394_SUCCESS)
00458 {
00459 std::cerr << "ERROR - AVTPikeCam::GetProperty:" << std::endl;
00460 std::cerr << "\t ... Failed to get video mode." << std::endl;
00461 std::cerr << "\t ... " << dc1394_error_get_string(err) << std::endl;
00462 return RET_FAILED;
00463 }
00464
00465 err = dc1394_get_image_size_from_video_mode(m_cam, videoMode, &imageWidth, &imageHeight);
00466 if (err!=DC1394_SUCCESS)
00467 {
00468 std::cerr << "ERROR - AVTPikeCam::GetProperty:" << std::endl;
00469 std::cerr << "\t ... Failed to get image size." << std::endl;
00470 std::cerr << "\t ... " << dc1394_error_get_string(err) << std::endl;
00471 return RET_FAILED;
00472 }
00473 cameraProperty->cameraResolution.xResolution = (int) imageWidth;
00474 cameraProperty->cameraResolution.yResolution = (int) imageHeight;
00475 }
00476 else
00477 {
00478 std::cout << "WARNING - AVTPikeCam::GetProperty:" << std::endl;
00479 std::cout << "\t ... Camera not open" << std::endl;
00480 std::cout << "\t ... Resetting width and height to '1388'x'1038'" << std::endl;
00481 cameraProperty->cameraResolution.xResolution = 1388;
00482 cameraProperty->cameraResolution.yResolution = 1038;
00483 cameraProperty->propertyType = TYPE_CAMERA_RESOLUTION;
00484 }
00485
00486 return RET_OK;
00487 break;
00488 default:
00489 std::cerr << "ERROR - AVTPikeCam::GetProperty:" << std::endl;
00490 std::cerr << "\t ... Property " << cameraProperty->propertyID << " unspecified" << std::endl;
00491 return RET_FAILED;
00492 break;
00493 }
00494 return RET_OK;
00495 #endif
00496 #ifndef __LINUX__
00497 UINT32 err;
00498 switch (cameraProperty->propertyID)
00499 {
00500 case PROP_BRIGHTNESS:
00501
00502 break;
00503 case PROP_EXPOSURE_TIME:
00504
00505 break;
00506 case PROP_WHITE_BALANCE_U:
00507
00508 break;
00509 case PROP_WHITE_BALANCE_V:
00510
00511 break;
00512 case PROP_HUE:
00513
00514 break;
00515 case PROP_SATURATION:
00516
00517 break;
00518 case PROP_GAMMA:
00519
00520 break;
00521 case PROP_GAIN:
00522
00523 break;
00524 case PROP_CAMERA_RESOLUTION:
00525 if (isOpen())
00526 {
00527 UINT32 x;
00528 UINT32 y;
00529
00530 err = m_cam.GetParameter(FGP_XSIZE, &x);
00531 if(err!=FCE_NOERROR)
00532 {
00533 std::cerr << "ERROR - AVTPikeCam::GetProperty:" << std::endl;
00534 std::cerr << "\t ... Could not read image width ( error " << err << " )" << std::endl;
00535 return RET_FAILED;
00536 }
00537 m_cam.GetParameter(FGP_YSIZE, &y);
00538 if(err!=FCE_NOERROR)
00539 {
00540 std::cerr << "ERROR - AVTPikeCam::GetProperty:" << std::endl;
00541 std::cerr << "\t ... Could not read image height ( error " << err << " )" << std::endl;
00542 return RET_FAILED;
00543 }
00544 cameraProperty->cameraResolution.xResolution = x;
00545 cameraProperty->cameraResolution.yResolution = y;
00546 }
00547 else
00548 {
00549 std::cout << "WARNING - AVTPikeCam::GetProperty:" << std::endl;
00550 std::cout << "\t ... Camera not open" << std::endl;
00551 std::cout << "\t ... Resetting width and height to '1388'x'1038'" << std::endl;
00552 cameraProperty->cameraResolution.xResolution = 1388;
00553 cameraProperty->cameraResolution.yResolution = 1038;
00554 cameraProperty->propertyType = TYPE_CAMERA_RESOLUTION;
00555 }
00556
00557 return RET_OK;
00558 break;
00559 case PROP_FW_OPERATION_MODE:
00560 cameraProperty->propertyType = TYPE_STRING;
00561 if (m_operationMode_B == false) cameraProperty->stringData == "A";
00562 else if (m_operationMode_B == true) cameraProperty->stringData == "B";
00563 break;
00564 case PROP_DMA_BUFFER_SIZE:
00565 cameraProperty->u_integerData = m_BufferSize;
00566 return RET_OK;
00567 break;
00568 case PROP_ISO_SPEED:
00569
00570 break;
00571 default:
00572 std::cerr << "ERROR - AVTPikeCam::GetProperty:" << std::endl;
00573 std::cerr << "\t ... Property " << cameraProperty->propertyID << " unspecified";
00574 return RET_FAILED;
00575 break;
00576
00577 }
00578
00579 return RET_OK;
00580 #endif
00581 }
00582
00583
00584 unsigned long AVTPikeCam::GetColorImage(char* colorImageData, bool getLatestFrame)
00585 {
00586 if (!isOpen())
00587 {
00588 std::cerr << "ERROR - AVTPikeCam::GetColorImage:" << std::endl;
00589 std::cerr << "\t ... Color camera not open." << std::endl;
00590 return (RET_FAILED | RET_CAMERA_NOT_OPEN);
00591 }
00592 #ifdef __LINUX__
00593
00594 dc1394error_t err;
00595
00596 if (m_Frame)
00597 {
00598
00599 err=dc1394_capture_enqueue(m_cam, m_Frame);
00600 if (err!=DC1394_SUCCESS)
00601 {
00602 std::cerr << "AVTPikeCam::GetColorImage:" << std::endl;
00603 std::cerr << "\t ... 'dc1394_capture_enqueue' failed." << std::endl;
00604 std::cerr << "\t ... " << dc1394_error_get_string(err) << std::endl;
00605 return RET_FAILED;
00606 }
00607 }
00608
00609
00610
00611
00612 if (getLatestFrame)
00613 {
00614
00615 do
00616 {
00617 m_Frame = 0;
00618 err=dc1394_capture_dequeue(m_cam, DC1394_CAPTURE_POLICY_POLL, &m_Frame);
00619 if (err!=DC1394_SUCCESS)
00620 {
00621 std::cerr << "ERROR - AVTPikeCam::GetColorImage:" << std::endl;
00622 std::cerr << "\t ... 'dc1394_capture_dequeue' failed." << std::endl;
00623 std::cerr << "\t ... " << dc1394_error_get_string(err) << std::endl;
00624 return RET_FAILED;
00625 }
00626
00627 if (m_Frame == 0)
00628 {
00629 break;
00630 }
00631
00632 err=dc1394_capture_enqueue(m_cam, m_Frame);
00633 if (err!=DC1394_SUCCESS)
00634 {
00635 std::cerr << "ERROR - AVTPikeCam::GetColorImage:" << std::endl;
00636 std::cerr << "\t ... 'dc1394_capture_enqueue' failed." << std::endl;
00637 std::cerr << "\t ... " << dc1394_error_get_string(err) << std::endl;
00638 return RET_FAILED;
00639 }
00640 }
00641 while (true);
00642 }
00643
00644
00645
00646
00647
00648 err=dc1394_capture_dequeue(m_cam, DC1394_CAPTURE_POLICY_WAIT, &m_Frame);
00649 if (err!=DC1394_SUCCESS)
00650 {
00651 std::cerr << "ERROR - AVTPikeCam::GetColorImage:" << std::endl;
00652 std::cerr << "\t ... 'dc1394_capture_dequeue' failed." << std::endl;
00653 std::cerr << "\t ... " << dc1394_error_get_string(err) << std::endl;
00654 return RET_FAILED;
00655 }
00656 unsigned char * src = (unsigned char *)m_Frame->image;
00657 unsigned char * dst = (unsigned char *)colorImageData;
00658
00659
00660 int width;
00661 int height;
00662 ipa_CameraSensors::t_cameraProperty cameraProperty;
00663 cameraProperty.propertyID = PROP_CAMERA_RESOLUTION;
00664 if (GetProperty(&cameraProperty) & RET_FAILED) return RET_FAILED;
00665 width = cameraProperty.cameraResolution.xResolution;
00666 height = cameraProperty.cameraResolution.yResolution;
00667
00668 for (int i=0;i<width*height*3;i+=6)
00669 {
00670 dst[i] = src[i+2];
00671 dst[i+1] = src[i+1];
00672 dst[i+2] = src[i];
00673 dst[i+3] = src[i+5];
00674 dst[i+4] = src[i+4];
00675 dst[i+5] = src[i+3];
00676 }
00677
00678 return RET_OK;
00679
00680 #else
00681
00682 UINT32 err;
00683
00684
00685 if (m_Frame.pData != 0)
00686 {
00687
00688 err=m_cam.PutFrame(&m_Frame);
00689 if(err!=FCE_NOERROR)
00690 {
00691 std::cerr << "ERROR - AVTPikeCam::GetColorImage:" << std::endl;
00692 std::cerr << "\t ... Could not release image buffer ( error " << err << " )" << std::endl;
00693 return RET_FAILED;
00694 }
00695 }
00696
00697 if (getLatestFrame)
00698 {
00699
00700
00701 err = m_cam.DiscardFrames();
00702 if(err!=FCE_NOERROR)
00703 {
00704 std::cerr << "ERROR - AVTPikeCam::GetColorImage:" << std::endl;
00705 std::cerr << "\t ... Could not reset image buffers ( error " << err << " )" << std::endl;
00706 return RET_FAILED;
00707 }
00708 }
00709
00710
00711
00712 err = m_cam.GetFrame(&m_Frame);
00713 if(err!=FCE_NOERROR)
00714 {
00715 std::cerr << "AVTPikeCam::GetColorImage:" << std::endl;
00716 std::cerr << "\t ... Could not acquire image ( error " << err << " )" << std::endl;
00717 return RET_FAILED;
00718 }
00719
00720 unsigned char * src = (unsigned char *)m_Frame.pData;
00721 unsigned char * dst = (unsigned char *)colorImageData;
00722
00723
00724 int width;
00725 int height;
00726 ipa_CameraSensors::t_cameraProperty cameraProperty;
00727 cameraProperty.propertyID = PROP_CAMERA_RESOLUTION;
00728 if (GetProperty(&cameraProperty) & RET_FAILED) return RET_FAILED;
00729 width = cameraProperty.cameraResolution.xResolution;
00730 height = cameraProperty.cameraResolution.yResolution;
00731
00732 for (int i=0; i<width*height*3; i+=6)
00733 {
00734 dst[i] = src[i+2];
00735 dst[i+1] = src[i+1];
00736 dst[i+2] = src[i];
00737 dst[i+3] = src[i+5];
00738 dst[i+4] = src[i+4];
00739 dst[i+5] = src[i+3];
00740 }
00741
00742 return RET_OK;
00743
00744 #endif
00745 }
00746
00747 unsigned long AVTPikeCam::GetColorImage(cv::Mat* colorImage, bool getLatestFrame)
00748 {
00749 if (!isOpen())
00750 {
00751 std::cerr << "ERROR - AVTPikeCam::GetColorImage:" << std::endl;
00752 std::cerr << "\t ... Color camera not open." << std::endl;
00753 return (RET_FAILED | RET_CAMERA_NOT_OPEN);
00754 }
00755
00756 CV_Assert(colorImage != 0);
00757
00758 int width;
00759 int height;
00760 ipa_CameraSensors::t_cameraProperty cameraProperty;
00761 cameraProperty.propertyID = PROP_CAMERA_RESOLUTION;
00762 if (GetProperty(&cameraProperty) & RET_FAILED) return RET_FAILED;
00763 width = cameraProperty.cameraResolution.xResolution;
00764 height = cameraProperty.cameraResolution.yResolution;
00765
00766
00767 colorImage->create(height, width, CV_8UC3);
00768 return GetColorImage(colorImage->ptr<char>(0), getLatestFrame);
00769 }
00770
00771 unsigned long AVTPikeCam::PrintCameraInformation()
00772 {
00773 #ifndef __LINUX__
00774 FGPINFO info;
00775 string parameterName;
00776 std::cout << "INFO - AVTPikeCam::PrintCameraInformation:" << std::endl;
00777
00778 for (int ID = FGP_BRIGHTNESS; ID <= FGP_BRIGHTNESS+10; ID++)
00779 {
00780 switch (ID)
00781 {
00782 case 0: parameterName = "FGP_IMAGEFORMAT"; break;
00783 case 1: parameterName = "FGP_ENUMIMAGEFORMAT"; break;
00784 case 2: parameterName = "FGP_BRIGHTNESS"; break;
00785 case 3: parameterName = "FGP_AUTOEXPOSURE"; break;
00786 case 4: parameterName = "FGP_SHARPNESS"; break;
00787 case 5: parameterName = "FGP_WHITEBALCB"; break;
00788 case 6: parameterName = "FGP_WHITEBALCR"; break;
00789 case 7: parameterName = "FGP_HUE"; break;
00790 case 8: parameterName = "FGP_SATURATION"; break;
00791 case 9: parameterName = "FGP_GAMMA"; break;
00792 case 10: parameterName = "FGP_SHUTTER"; break;
00793 case 11: parameterName = "FGP_GAIN"; break;
00794 case 12: parameterName = "FGP_IRIS"; break;
00795 case 13: parameterName = "FGP_FOCUS"; break;
00796 case 14: parameterName = "FGP_TEMPERATURE"; break;
00797 case 15: parameterName = "FGP_TRIGGER"; break;
00798 case 16: parameterName = "FGP_TRIGGERDLY"; break;
00799 case 17: parameterName = "FGP_WHITESHD"; break;
00800 case 18: parameterName = "FGP_FRAMERATE"; break;
00801 case 19: parameterName = "FGP_ZOOM"; break;
00802 case 20: parameterName = "FGP_PAN"; break;
00803 case 21: parameterName = "FGP_TILT"; break;
00804 case 22: parameterName = "FGP_OPTICALFILTER"; break;
00805 case 23: parameterName = "FGP_CAPTURESIZE"; break;
00806 case 24: parameterName = "FGP_CAPTUREQUALITY"; break;
00807 case 25: parameterName = "FGP_PHYSPEED"; break;
00808 case 26: parameterName = "FGP_XSIZE"; break;
00809 case 27: parameterName = "FGP_YSIZE"; break;
00810 case 28: parameterName = "FGP_XPOSITION"; break;
00811 case 29: parameterName = "FGP_YPOSITION"; break;
00812 case 30: parameterName = "FGP_PACKETSIZE"; break;
00813 case 31: parameterName = "FGP_DMAMODE"; break;
00814 case 32: parameterName = "FGP_BURSTCOUNT"; break;
00815 case 33: parameterName = "FGP_FRAMEBUFFERCOUNT"; break;
00816 case 34: parameterName = "FGP_USEIRMFORBW"; break;
00817 case 35: parameterName = "FGP_ADJUSTPARAMETERS"; break;
00818 case 36: parameterName = "FGP_STARTIMMEDIATELY"; break;
00819 case 37: parameterName = "FGP_FRAMEMEMORYSIZE"; break;
00820 case 38: parameterName = "FGP_COLORFORMAT"; break;
00821 case 39: parameterName = "FGP_IRMFREEBW"; break;
00822 case 40: parameterName = "FGP_DO_FASTTRIGGER"; break;
00823 case 41: parameterName = "FGP_DO_BUSTRIGGER"; break;
00824 case 42: parameterName = "FGP_RESIZE"; break;
00825 case 43: parameterName = "FGP_USEIRMFORCHN"; break;
00826 case 44: parameterName = "FGP_CAMACCEPTDELAY"; break;
00827 case 45: parameterName = "FGP_ISOCHANNEL"; break;
00828 case 46: parameterName = "FGP_CYCLETIME"; break;
00829 case 47: parameterName = "FGP_DORESET"; break;
00830 case 48: parameterName = "FGP_DMAFLAGS"; break;
00831 case 49: parameterName = "FGP_R0C"; break;
00832 case 50: parameterName = "FGP_BUSADDRESS"; break;
00833 case 51: parameterName = "FGP_CMDTIMEOUT"; break;
00834 case 52: parameterName = "FGP_CARD"; break;
00835 case 53: parameterName = "FGP_LICENSEINFO"; break;
00836 case 54: parameterName = "FGP_PACKETCOUNT"; break;
00837 case 55: parameterName = "FGP_DO_MULTIBUSTRIGGER"; break;
00838 case 56: parameterName = "FGP_LAST"; break;
00839
00840 default: parameterName = "Unknown parameter";
00841 }
00842
00843 m_cam.GetParameterInfo(ID, &info);
00844 std::cout << parameterName << std::endl;
00845 std::cout << "\t ... Value: " << info.IsValue << std::endl;
00846 std::cout << "\t ... Max: " << info.MaxValue << std::endl;
00847 std::cout << "\t ... Min: " << info.MinValue << std::endl;
00848 std::cout << "\t ... Unit: " << info.Unit << std::endl;
00849 if (info.Specific.Data.FeatureInfo.AutoCap)
00850 std::cout << "\t ... Auto state: " << (bool) info.Specific.Data.FeatureInfo.AutoState << std::endl;
00851 std::cout << "\n" << std::endl;
00852 }
00853 #endif
00854 return RET_OK;
00855 }
00856
00857 unsigned long AVTPikeCam::TestCamera(const char* filename)
00858 {
00859 if (AbstractColorCamera::TestCamera(filename) & RET_FAILED)
00860 {
00861 return RET_FAILED;
00862 }
00863
00864 return RET_OK;
00865 }
00866
00867
00868 unsigned long AVTPikeCam::SetProperty(t_cameraProperty* cameraProperty)
00869
00870 {
00871 #ifdef __LINUX__
00872 dc1394error_t err;
00873 #else
00874 UINT32 err;
00875 FGPINFO info;
00876 #endif
00877
00878 switch (cameraProperty->propertyID)
00879 {
00881
00883 case PROP_AMPLITUDE_THRESHOLD:
00884 case PROP_INTEGRATION_TIME:
00885 case PROP_VIDEO_MODE:
00886 case PROP_COLOR_MODE:
00887 case PROP_VIDEO_FORMAT:
00888 case PROP_CAMERA_RESOLUTION:
00889 case PROP_TIMEOUT:
00890 case PROP_REGISTER:
00891 case PROP_OPTICAL_FILTER:
00892 case PROP_SHARPNESS:
00893 case PROP_MODULATION_FREQUENCY:
00894
00895 break;
00896 case PROP_SHUTTER:
00897 if (cameraProperty->propertyType & ipa_CameraSensors::TYPE_SPECIAL)
00898 {
00899 if(cameraProperty->specialValue == ipa_CameraSensors::VALUE_AUTO)
00900 {
00901 #ifdef __LINUX__
00902 err=dc1394_feature_set_mode(m_cam, DC1394_FEATURE_SHUTTER, DC1394_FEATURE_MODE_AUTO);
00903 if (err!=DC1394_SUCCESS)
00904 {
00905 std::cerr << "ERROR - AVTPikeCam::SetProperty:" << std::endl;
00906 std::cerr << "\t ... Failed to set shutter to AUTO mode." << std::endl;
00907 std::cerr << "\t ... " << dc1394_error_get_string(err) << std::endl;
00908 return RET_FAILED;
00909 }
00910 #else
00911 err = m_cam.SetParameter(FGP_SHUTTER, PVAL_AUTO);
00912 if(err!=FCE_NOERROR)
00913 {
00914 std::cerr << "ERROR - AVTPikeCam::SetProperty:" << std::endl;
00915 std::cerr << "\t ... Could not set shutter time to AUTO mode ( error " << err << " )" << std::endl;
00916 return RET_FAILED;
00917 }
00918 #endif
00919 }
00920 else if(cameraProperty->specialValue == ipa_CameraSensors::VALUE_DEFAULT)
00921 {
00922
00923 }
00924 else
00925 {
00926 std::cerr << "ERROR - AVTPikeCam::SetProperty:" << std::endl;
00927 std::cerr << "\t ... Special value 'VALUE_AUTO' or 'VALUE_DEFAULT' expected." << std::endl;
00928 return RET_FAILED;
00929 }
00930 }
00931 else if (cameraProperty->propertyType & (ipa_CameraSensors::TYPE_LONG | ipa_CameraSensors::TYPE_UNSIGNED))
00932 {
00933 #ifdef __LINUX__
00934 uint32_t min;
00935 uint32_t max;
00936 dc1394_feature_get_boundaries(m_cam, DC1394_FEATURE_SHUTTER, &min, &max);
00937 if ((cameraProperty->u_longData < min) | (cameraProperty->u_longData > max))
00938 {
00939 std::cerr << "ERROR - AVTPikeCam::SetProperty:" << std::endl;
00940 std::cerr << "\t ... Shutter time " << cameraProperty->u_longData
00941 << " has to be a value between " << min << " and " << max << "." << std::endl;
00942 return RET_FAILED;
00943 }
00944 else
00945 {
00946 err=dc1394_feature_set_value(m_cam, DC1394_FEATURE_SHUTTER, (uint32_t) cameraProperty->u_longData);
00947 if (err!=DC1394_SUCCESS)
00948 {
00949 std::cerr << "ERROR - AVTPikeCam::SetProperty:" << std::endl;
00950 std::cerr << "\t ... Could not set shutter time "
00951 << cameraProperty->u_longData << " ( error " << err << " )" << std::endl;
00952 std::cerr << "\t ... " << dc1394_error_get_string(err) << std::endl;
00953 return RET_FAILED;
00954 }
00955 }
00956 #else
00957 m_cam.GetParameterInfo(FGP_SHUTTER, &info);
00958 if ((cameraProperty->u_longData < info.MinValue) | (cameraProperty->u_longData > info.MaxValue))
00959 {
00960 std::cerr << "ERROR - AVTPikeCam::SetProperty:" << std::endl;
00961 std::cerr << "\t ... Shutter time " << cameraProperty->u_longData
00962 << " has to be a value between " << info.MinValue << " and " << info.MaxValue << "." << std::endl;
00963 return RET_FAILED;
00964 }
00965 else
00966 {
00967 err = m_cam.SetParameter(FGP_SHUTTER, cameraProperty->u_longData);
00968 if(err!=FCE_NOERROR)
00969 {
00970 std::cerr << "ERROR - AVTPikeCam::SetProperty:" << std::endl;
00971 std::cerr << "\t ... Could not set shutter time "
00972 << cameraProperty->u_longData << " ( error " << err << " )" << std::endl;
00973 return RET_FAILED;
00974 }
00975 }
00976 #endif
00977 }
00978 else
00979 {
00980 std::cerr << "ERROR - AVTPikeCam::SetProperty:" << std::endl;
00981 std::cerr << "\t ... Wrong property type. '(TYPE_LONG|TYPE_UNSIGNED)' or special value 'TYPE_SPECIAL' expected." << std::endl;
00982 return RET_FAILED;
00983 }
00984 break;
00986
00988 case PROP_BRIGHTNESS:
00989 if (cameraProperty->propertyType & ipa_CameraSensors::TYPE_SPECIAL)
00990 {
00991 if(cameraProperty->specialValue == ipa_CameraSensors::VALUE_AUTO)
00992 {
00993 #ifdef __LINUX__
00994 err=dc1394_feature_set_mode(m_cam, DC1394_FEATURE_BRIGHTNESS, DC1394_FEATURE_MODE_AUTO);
00995 if (err!=DC1394_SUCCESS)
00996 {
00997 std::cerr << "ERROR - AVTPikeCam::SetProperty:" << std::endl;
00998 std::cerr << "\t ... Failed to set brightness to AUTO mode." << std::endl;
00999 std::cerr << "\t ... " << dc1394_error_get_string(err) << std::endl;
01000 return RET_FAILED;
01001 }
01002 #else
01003 err = m_cam.SetParameter(FGP_BRIGHTNESS, PVAL_AUTO);
01004 if(err!=FCE_NOERROR)
01005 {
01006 std::cerr << "ERROR - AVTPikeCam::SetProperty:" << std::endl;
01007 std::cerr << "\t ... Could not set brightness time to AUTO mode ( error " << err << " )" << std::endl;
01008 return RET_FAILED;
01009 }
01010 #endif
01011 }
01012 else if(cameraProperty->specialValue == ipa_CameraSensors::VALUE_DEFAULT)
01013 {
01014
01015 }
01016 else
01017 {
01018 std::cerr << "ERROR - AVTPikeCam::SetProperty:" << std::endl;
01019 std::cerr << "\t ... Special value 'VALUE_AUTO' or 'VALUE_DEFAULT' expected." << std::endl;
01020 return RET_FAILED;
01021 }
01022 }
01023 else if (cameraProperty->propertyType & (ipa_CameraSensors::TYPE_LONG | ipa_CameraSensors::TYPE_UNSIGNED))
01024 {
01025 #ifdef __LINUX__
01026 uint32_t min;
01027 uint32_t max;
01028 dc1394_feature_get_boundaries(m_cam, DC1394_FEATURE_BRIGHTNESS, &min, &max);
01029 if ((cameraProperty->u_longData < min) | (cameraProperty->u_longData > max))
01030 {
01031 std::cerr << "ERROR - AVTPikeCam::SetProperty:" << std::endl;
01032 std::cerr << "\t ... Brighness " << cameraProperty->u_longData
01033 << " has to be a value between " << min << " and " << max << "." << std::endl;
01034 return RET_FAILED;
01035 }
01036 else
01037 {
01038 err=dc1394_feature_set_value(m_cam, DC1394_FEATURE_BRIGHTNESS, (uint32_t) cameraProperty->u_longData);
01039 if (err!=DC1394_SUCCESS)
01040 {
01041 std::cerr << "ERROR - AVTPikeCam::SetProperty:" << std::endl;
01042 std::cerr << "\t ... Could not set brighness "
01043 << cameraProperty->u_longData << " ( error " << err << " )" << std::endl;
01044 std::cerr << "\t ... " << dc1394_error_get_string(err) << std::endl;
01045 return RET_FAILED;
01046 }
01047 }
01048 #else
01049 m_cam.GetParameterInfo(FGP_BRIGHTNESS, &info);
01050 if ((cameraProperty->u_longData < info.MinValue) | (cameraProperty->u_longData > info.MaxValue))
01051 {
01052 std::cerr << "ERROR - AVTPikeCam::SetProperty:" << std::endl;
01053 std::cerr << "\t ... Brigthness " << cameraProperty->u_longData << " has to be a value between " << info.MinValue << " and " << info.MaxValue << "." << std::endl;
01054 return RET_FAILED;
01055 }
01056 else
01057 {
01058 err = m_cam.SetParameter(FGP_BRIGHTNESS, cameraProperty->u_longData);
01059 if(err!=FCE_NOERROR)
01060 {
01061 std::cerr << "ERROR - AVTPikeCam::SetProperty:" << std::endl;
01062 std::cerr << "\t ... Could not set brightness ( error " << err << " )" << std::endl;
01063 return RET_FAILED;
01064 }
01065 }
01066 #endif
01067 }
01068 else
01069 {
01070 std::cerr << "ERROR - AVTPikeCam::SetProperty:" << std::endl;
01071 std::cerr << "\t ... Wrong property type. '(TYPE_LONG|TYPE_UNSIGNED)' or special value 'TYPE_SPECIAL' expected." << std::endl;
01072 return RET_FAILED;
01073 }
01074 break;
01076
01078 case PROP_EXPOSURE_TIME:
01079 if (cameraProperty->propertyType & ipa_CameraSensors::TYPE_SPECIAL)
01080 {
01081 if(cameraProperty->specialValue == ipa_CameraSensors::VALUE_AUTO)
01082 {
01083 #ifdef __LINUX__
01084 err=dc1394_feature_set_mode(m_cam, DC1394_FEATURE_EXPOSURE, DC1394_FEATURE_MODE_AUTO);
01085 if (err!=DC1394_SUCCESS)
01086 {
01087 std::cerr << "ERROR - AVTPikeCam::SetProperty:" << std::endl;
01088 std::cerr << "\t ... Failed to set exposure time to AUTO mode." << std::endl;
01089 std::cerr << "\t ... " << dc1394_error_get_string(err) << std::endl;
01090 return RET_FAILED;
01091 }
01092 #else
01093 err = m_cam.SetParameter(FGP_AUTOEXPOSURE, PVAL_AUTO);
01094 if(err!=FCE_NOERROR)
01095 {
01096 std::cerr << "ERROR - AVTPikeCam::SetProperty:" << std::endl;
01097 std::cerr << "\t ... Could not set exposure time to AUTO mode ( error " << err << " )" << std::endl;
01098 return RET_FAILED;
01099 }
01100 #endif
01101 }
01102 else if(cameraProperty->specialValue == ipa_CameraSensors::VALUE_DEFAULT)
01103 {
01104
01105 }
01106 else
01107 {
01108 std::cerr << "ERROR - AVTPikeCam::SetProperty:" << std::endl;
01109 std::cerr << "\t ... Special value 'VALUE_AUTO' or 'VALUE_DEFAULT' expected." << std::endl;
01110 return RET_FAILED;
01111 }
01112 }
01113 else if (cameraProperty->propertyType & (ipa_CameraSensors::TYPE_LONG | ipa_CameraSensors::TYPE_UNSIGNED))
01114 {
01115 #ifdef __LINUX__
01116 uint32_t min;
01117 uint32_t max;
01118 dc1394_feature_get_boundaries(m_cam, DC1394_FEATURE_EXPOSURE, &min, &max);
01119 if ((cameraProperty->u_longData < min) | (cameraProperty->u_longData > max))
01120 {
01121 std::cerr << "ERROR - AVTPikeCam::SetProperty:" << std::endl;
01122 std::cerr << "\t ... Exposure time " << cameraProperty->u_longData
01123 << " has to be a value between " << min << " and " << max << "." << std::endl;
01124 return RET_FAILED;
01125 }
01126 else
01127 {
01128 err=dc1394_feature_set_value(m_cam, DC1394_FEATURE_EXPOSURE, (uint32_t) cameraProperty->u_longData);
01129 if (err!=DC1394_SUCCESS)
01130 {
01131 std::cerr << "ERROR - AVTPikeCam::SetProperty:" << std::endl;
01132 std::cerr << "\t ... Could not set exposure time "
01133 << cameraProperty->u_longData << " ( error " << err << " )" << std::endl;
01134 std::cerr << "\t ... " << dc1394_error_get_string(err) << std::endl;
01135 return RET_FAILED;
01136 }
01137 }
01138 #else
01139 m_cam.GetParameterInfo(FGP_AUTOEXPOSURE, &info);
01140 if ((cameraProperty->u_longData < info.MinValue) | (cameraProperty->u_longData > info.MaxValue))
01141 {
01142 std::cerr << "ERROR - AVTPikeCam::SetProperty:" << std::endl;
01143 std::cerr << "\t ... Exposure time " << cameraProperty->u_longData
01144 << " has to be a value between " << info.MinValue << " and " << info.MaxValue << "." << std::endl;
01145 return RET_FAILED;
01146 }
01147 else
01148 {
01149 err = m_cam.SetParameter(FGP_AUTOEXPOSURE, cameraProperty->u_longData);
01150 if(err!=FCE_NOERROR)
01151 {
01152 std::cerr << "ERROR - AVTPikeCam::SetProperty:" << std::endl;
01153 std::cerr << "\t ... Could not set exposure time ( error " << err << " )" << std::endl;
01154 return RET_FAILED;
01155 }
01156 }
01157 #endif
01158 }
01159 else
01160 {
01161 std::cerr << "ERROR - AVTPikeCam::SetProperty:" << std::endl;
01162 std::cerr << "\t ... Wrong property type. '(TYPE_LONG|TYPE_UNSIGNED)' or special value 'TYPE_SPECIAL' expected." << std::endl;
01163 return RET_FAILED;
01164 }
01165 break;
01167
01169 case PROP_WHITE_BALANCE_U:
01170 if (cameraProperty->propertyType & ipa_CameraSensors::TYPE_SPECIAL)
01171 {
01172 if(cameraProperty->specialValue == ipa_CameraSensors::VALUE_AUTO)
01173 {
01174 #ifdef __LINUX__
01175 err=dc1394_feature_set_mode(m_cam, DC1394_FEATURE_WHITE_BALANCE, DC1394_FEATURE_MODE_AUTO);
01176 if (err!=DC1394_SUCCESS)
01177 {
01178 std::cerr << "ERROR - AVTPikeCam::SetProperty:" << std::endl;
01179 std::cerr << "\t ... Failed to set white balance U to AUTO mode." << std::endl;
01180 std::cerr << "\t ... " << dc1394_error_get_string(err) << std::endl;
01181 return RET_FAILED;
01182 }
01183 #else
01184 err = m_cam.SetParameter(FGP_WHITEBALCB, PVAL_AUTO);
01185 if(err!=FCE_NOERROR)
01186 {
01187 std::cerr << "ERROR - AVTPikeCam::SetProperty:" << std::endl;
01188 std::cerr << "\t ... Could not set white balance U to AUTO mode ( error " << err << " )" << std::endl;
01189 return RET_FAILED;
01190 }
01191 #endif
01192 }
01193 else if(cameraProperty->specialValue == ipa_CameraSensors::VALUE_DEFAULT)
01194 {
01195
01196 }
01197 else
01198 {
01199 std::cerr << "ERROR - AVTPikeCam::SetProperty:" << std::endl;
01200 std::cerr << "\t ... Special value 'VALUE_AUTO' or 'VALUE_DEFAULT' expected." << std::endl;
01201 return RET_FAILED;
01202 }
01203 }
01204 else if (cameraProperty->propertyType & (ipa_CameraSensors::TYPE_LONG | ipa_CameraSensors::TYPE_UNSIGNED))
01205 {
01206 #ifdef __LINUX__
01207 uint32_t min;
01208 uint32_t max;
01209 dc1394_feature_get_boundaries(m_cam, DC1394_FEATURE_WHITE_BALANCE, &min, &max);
01210 if ((cameraProperty->u_longData < min) | (cameraProperty->u_longData > max))
01211 {
01212 std::cerr << "ERROR - AVTPikeCam::SetProperty:" << std::endl;
01213 std::cerr << "\t ... White balance U " << cameraProperty->u_longData
01214 << " has to be a value between " << min << " and " << max << "." << std::endl;
01215 return RET_FAILED;
01216 }
01217 else
01218 {
01219 uint32_t whiteU;
01220 uint32_t whiteV;
01221 dc1394_feature_whitebalance_get_value(m_cam, &whiteU, &whiteV);
01222 err=dc1394_feature_whitebalance_set_value(m_cam, (uint32_t) cameraProperty->u_longData, whiteV);
01223 if (err!=DC1394_SUCCESS)
01224 {
01225 std::cerr << "ERROR - AVTPikeCam::SetProperty:" << std::endl;
01226 std::cerr << "\t ... Could not set white balance U "
01227 << cameraProperty->u_longData << " ( error " << err << " )" << std::endl;
01228 std::cerr << "\t ... " << dc1394_error_get_string(err) << std::endl;
01229 return RET_FAILED;
01230 }
01231 }
01232 #else
01233 m_cam.GetParameterInfo(FGP_WHITEBALCB, &info);
01234 if ((cameraProperty->u_longData < info.MinValue) | (cameraProperty->u_longData > info.MaxValue))
01235 {
01236 std::cerr << "ERROR - AVTPikeCam::SetProperty:" << std::endl;
01237 std::cerr << "\t ... White balance U value " << cameraProperty->u_longData
01238 << " has to be a value between " << info.MinValue << " and " << info.MaxValue << "." << std::endl;
01239 return RET_FAILED;
01240 }
01241 else
01242 {
01243 err = m_cam.SetParameter(FGP_WHITEBALCB, cameraProperty->u_longData);
01244 if(err!=FCE_NOERROR)
01245 {
01246 std::cerr << "ERROR - AVTPikeCam::SetProperty:" << std::endl;
01247 std::cerr << "\t ... Could not set white balance U value ( error " << err << " )" << std::endl;
01248 return RET_FAILED;
01249 }
01250 }
01251 #endif
01252 }
01253 else
01254 {
01255 std::cerr << "ERROR - AVTPikeCam::SetProperty:" << std::endl;
01256 std::cerr << "\t ... Wrong property type. '(TYPE_LONG|TYPE_UNSIGNED)' or special value 'TYPE_SPECIAL' expected." << std::endl;
01257 return RET_FAILED;
01258 }
01259 break;
01261
01263 case PROP_WHITE_BALANCE_V:
01264 if (cameraProperty->propertyType & ipa_CameraSensors::TYPE_SPECIAL)
01265 {
01266 if(cameraProperty->specialValue == ipa_CameraSensors::VALUE_AUTO)
01267 {
01268 #ifdef __LINUX__
01269 err=dc1394_feature_set_mode(m_cam, DC1394_FEATURE_WHITE_BALANCE, DC1394_FEATURE_MODE_AUTO);
01270 if (err!=DC1394_SUCCESS)
01271 {
01272 std::cerr << "ERROR - AVTPikeCam::SetProperty:" << std::endl;
01273 std::cerr << "\t ... Failed to set white balance V to AUTO mode." << std::endl;
01274 std::cerr << "\t ... " << dc1394_error_get_string(err) << std::endl;
01275 return RET_FAILED;
01276 }
01277 #else
01278 err = m_cam.SetParameter(FGP_WHITEBALCR, PVAL_AUTO);
01279 if(err!=FCE_NOERROR)
01280 {
01281 std::cerr << "ERROR - AVTPikeCam::SetProperty:" << std::endl;
01282 std::cerr << "\t ... Could not set white balance V to AUTO mode ( error " << err << " )" << std::endl;
01283 return RET_FAILED;
01284 }
01285 #endif
01286 }
01287 else if(cameraProperty->specialValue == ipa_CameraSensors::VALUE_DEFAULT)
01288 {
01289
01290 }
01291 else
01292 {
01293 std::cerr << "ERROR - AVTPikeCam::SetProperty:" << std::endl;
01294 std::cerr << "\t ... Special value 'VALUE_AUTO' or 'VALUE_DEFAULT' expected." << std::endl;
01295 return RET_FAILED;
01296 }
01297 }
01298 else if (cameraProperty->propertyType & (ipa_CameraSensors::TYPE_LONG | ipa_CameraSensors::TYPE_UNSIGNED))
01299 {
01300 #ifdef __LINUX__
01301 uint32_t min;
01302 uint32_t max;
01303 dc1394_feature_get_boundaries(m_cam, DC1394_FEATURE_WHITE_BALANCE, &min, &max);
01304 if ((cameraProperty->u_longData < min) | (cameraProperty->u_longData > max))
01305 {
01306 std::cerr << "ERROR - AVTPikeCam::SetProperty:" << std::endl;
01307 std::cerr << "\t ... white balance V " << cameraProperty->u_longData
01308 << " has to be a value between " << min << " and " << max << "." << std::endl;
01309 return RET_FAILED;
01310 }
01311 else
01312 {
01313 uint32_t whiteU;
01314 uint32_t whiteV;
01315 dc1394_feature_whitebalance_get_value(m_cam, &whiteU, &whiteV);
01316 err=dc1394_feature_whitebalance_set_value(m_cam, whiteU, (uint32_t) cameraProperty->u_longData);
01317 if (err!=DC1394_SUCCESS)
01318 {
01319 std::cerr << "ERROR - AVTPikeCam::SetProperty:" << std::endl;
01320 std::cerr << "\t ... Could not set white balance V "
01321 << cameraProperty->u_longData << " ( error " << err << " )" << std::endl;
01322 std::cerr << "\t ... " << dc1394_error_get_string(err) << std::endl;
01323 return RET_FAILED;
01324 }
01325 }
01326 #else
01327 m_cam.GetParameterInfo(FGP_WHITEBALCR, &info);
01328 if ((cameraProperty->u_longData < info.MinValue) | (cameraProperty->u_longData > info.MaxValue))
01329 {
01330 std::cerr << "ERROR - AVTPikeCam::SetProperty:" << std::endl;
01331 std::cerr << "\t ... White balance V value " << cameraProperty->u_longData
01332 << " has to be a value between " << info.MinValue << " and " << info.MaxValue << "." << std::endl;
01333 return RET_FAILED;
01334 }
01335 else
01336 {
01337 err = m_cam.SetParameter(FGP_WHITEBALCR, cameraProperty->u_longData);
01338 if(err!=FCE_NOERROR)
01339 {
01340 std::cerr << "ERROR - AVTPikeCam::SetProperty:" << std::endl;
01341 std::cerr << "\t ... Could not set white balance V value ( error " << err << " )" << std::endl;
01342 return RET_FAILED;
01343 }
01344 }
01345 #endif
01346 }
01347 else
01348 {
01349 std::cerr << "ERROR - AVTPikeCam::SetProperty:" << std::endl;
01350 std::cerr << "\t ... Wrong property type. 'unsigned int' or special value 'TYPE_SPECIAL' expected." << std::endl;
01351 return RET_FAILED;
01352 }
01353 break;
01355
01357 case PROP_HUE:
01358 if (cameraProperty->propertyType & ipa_CameraSensors::TYPE_SPECIAL)
01359 {
01360 if(cameraProperty->specialValue == ipa_CameraSensors::VALUE_AUTO)
01361 {
01362 #ifdef __LINUX__
01363 err=dc1394_feature_set_mode(m_cam, DC1394_FEATURE_HUE, DC1394_FEATURE_MODE_AUTO);
01364 if (err!=DC1394_SUCCESS)
01365 {
01366 std::cerr << "ERROR - AVTPikeCam::SetProperty:" << std::endl;
01367 std::cerr << "\t ... Failed to set hue to AUTO mode." << std::endl;
01368 std::cerr << "\t ... " << dc1394_error_get_string(err) << std::endl;
01369 return RET_FAILED;
01370 }
01371 #else
01372 err = m_cam.SetParameter(FGP_HUE, PVAL_AUTO);
01373 if(err!=FCE_NOERROR)
01374 {
01375 std::cerr << "ERROR - AVTPikeCam::SetProperty:" << std::endl;
01376 std::cerr << "\t ... Could not set image hue to AUTO ( error " << err << " )" << std::endl;
01377 return RET_FAILED;
01378 }
01379 #endif
01380 }
01381 else if(cameraProperty->specialValue == ipa_CameraSensors::VALUE_DEFAULT)
01382 {
01383
01384 }
01385 else
01386 {
01387 std::cerr << "ERROR - AVTPikeCam::SetProperty:" << std::endl;
01388 std::cerr << "\t ... Special value 'VALUE_AUTO' or 'VALUE_DEFAULT' expected." << std::endl;
01389 return RET_FAILED;
01390 }
01391 }
01392 else if (cameraProperty->propertyType & (ipa_CameraSensors::TYPE_LONG | ipa_CameraSensors::TYPE_UNSIGNED))
01393 {
01394 #ifdef __LINUX__
01395 uint32_t min;
01396 uint32_t max;
01397 dc1394_feature_get_boundaries(m_cam, DC1394_FEATURE_HUE, &min, &max);
01398 if ((cameraProperty->u_longData < min) | (cameraProperty->u_longData > max))
01399 {
01400 std::cerr << "ERROR - AVTPikeCam::SetProperty:" << std::endl;
01401 std::cerr << "\t ... Hue " << cameraProperty->u_longData
01402 << " has to be a value between " << min << " and " << max << "." << std::endl;
01403 return RET_FAILED;
01404 }
01405 else
01406 {
01407 err=dc1394_feature_set_value(m_cam, DC1394_FEATURE_HUE, (uint32_t) cameraProperty->u_longData);
01408 if (err!=DC1394_SUCCESS)
01409 {
01410 std::cerr << "ERROR - AVTPikeCam::SetProperty:" << std::endl;
01411 std::cerr << "\t ... Could not set hue "
01412 << cameraProperty->u_longData << " ( error " << err << " )" << std::endl;
01413 std::cerr << "\t ... " << dc1394_error_get_string(err) << std::endl;
01414 return RET_FAILED;
01415 }
01416 }
01417 #else
01418 m_cam.GetParameterInfo(FGP_HUE, &info);
01419 if ((cameraProperty->u_longData < info.MinValue) | (cameraProperty->u_longData > info.MaxValue))
01420 {
01421 std::cerr << "ERROR - AVTPikeCam::SetProperty:" << std::endl;
01422 std::cerr << "\t ... Hue " << cameraProperty->u_longData
01423 << " has to be a value between " << info.MinValue << " and " << info.MaxValue << "." << std::endl;
01424 }
01425 else
01426 {
01427 err = m_cam.SetParameter(FGP_HUE, cameraProperty->u_longData);
01428 if(err!=FCE_NOERROR)
01429 {
01430 std::cerr << "ERROR - AVTPikeCam::SetProperty:" << std::endl;
01431 std::cerr << "\t ... Could not set image hue to " << cameraProperty->u_longData
01432 << " ( error " << err << " )" << std::endl;
01433 return RET_FAILED;
01434 }
01435 }
01436 #endif
01437 }
01438 else
01439 {
01440 std::cerr << "ERROR - AVTPikeCam::SetProperty:" << std::endl;
01441 std::cerr << "\t ... Wrong property type. '(TYPE_LONG|TYPE_UNSIGNED)' or special value 'TYPE_SPECIAL' expected." << std::endl;
01442 return RET_FAILED;
01443 }
01444 break;
01446
01448 case PROP_SATURATION:
01449 if (cameraProperty->propertyType & ipa_CameraSensors::TYPE_SPECIAL)
01450 {
01451 if(cameraProperty->specialValue == ipa_CameraSensors::VALUE_AUTO)
01452 {
01453 #ifdef __LINUX__
01454 err=dc1394_feature_set_mode(m_cam, DC1394_FEATURE_SATURATION, DC1394_FEATURE_MODE_AUTO);
01455 if (err!=DC1394_SUCCESS)
01456 {
01457 std::cerr << "ERROR - AVTPikeCam::SetProperty:" << std::endl;
01458 std::cerr << "\t ... Failed to set saturation to AUTO mode." << std::endl;
01459 std::cerr << "\t ... " << dc1394_error_get_string(err) << std::endl;
01460 return RET_FAILED;
01461 }
01462 #else
01463 err = m_cam.SetParameter(FGP_SATURATION, PVAL_AUTO);
01464 if(err!=FCE_NOERROR)
01465 {
01466 std::cerr << "ERROR - AVTPikeCam::SetProperty:" << std::endl;
01467 std::cerr << "\t ... << Could not set saturation to AUTO ( error " << err << " )" << std::endl;
01468 return RET_FAILED;
01469 }
01470 #endif
01471 }
01472 else if(cameraProperty->specialValue == ipa_CameraSensors::VALUE_DEFAULT)
01473 {
01474
01475 }
01476 else
01477 {
01478 std::cerr << "ERROR - AVTPikeCam::SetProperty:" << std::endl;
01479 std::cerr << "\t ... Special value 'VALUE_AUTO' or 'VALUE_DEFAULT' expected." << std::endl;
01480 return RET_FAILED;
01481 }
01482 }
01483 else if (cameraProperty->propertyType & (ipa_CameraSensors::TYPE_LONG | ipa_CameraSensors::TYPE_UNSIGNED))
01484 {
01485 #ifdef __LINUX__
01486 uint32_t min;
01487 uint32_t max;
01488 dc1394_feature_get_boundaries(m_cam, DC1394_FEATURE_SATURATION, &min, &max);
01489 if ((cameraProperty->u_longData < min) | (cameraProperty->u_longData > max))
01490 {
01491 std::cerr << "ERROR - AVTPikeCam::SetProperty:" << std::endl;
01492 std::cerr << "\t ... Saturation " << cameraProperty->u_longData
01493 << " has to be a value between " << min << " and " << max << "." << std::endl;
01494 return RET_FAILED;
01495 }
01496 else
01497 {
01498 err=dc1394_feature_set_value(m_cam, DC1394_FEATURE_SATURATION, (uint32_t) cameraProperty->u_longData);
01499 if (err!=DC1394_SUCCESS)
01500 {
01501 std::cerr << "ERROR - AVTPikeCam::SetProperty:" << std::endl;
01502 std::cerr << "\t ... Could not set saturation "
01503 << cameraProperty->u_longData << " ( error " << err << " )" << std::endl;
01504 std::cerr << "\t ... " << dc1394_error_get_string(err) << std::endl;
01505 return RET_FAILED;
01506 }
01507 }
01508 #else
01509 m_cam.GetParameterInfo(FGP_SATURATION, &info);
01510 if ((cameraProperty->u_longData < info.MinValue) | (cameraProperty->u_longData > info.MaxValue))
01511 {
01512 std::cerr << "ERROR - AVTPikeCam::SetProperty:" << std::endl;
01513 std::cerr << "\t ... Saturation has to be a value between " << info.MinValue << " and " << info.MaxValue << "." << std::endl;
01514 }
01515 else
01516 {
01517 err = m_cam.SetParameter(FGP_SATURATION, cameraProperty->u_longData);
01518 if(err!=FCE_NOERROR)
01519 {
01520 std::cerr << "ERROR - AVTPikeCam::SetProperty:" << std::endl;
01521 std::cerr << "\t ... Could not set saturation ( error " << err << " )" << std::endl;
01522 return RET_FAILED;
01523 }
01524 }
01525 #endif
01526 }
01527 else
01528 {
01529 std::cerr << "ERROR - AVTPikeCam::SetProperty:" << std::endl;
01530 std::cerr << "\t ... Wrong property type. '(TYPE_LONG|TYPE_UNSIGNED)' or special value 'TYPE_SPECIAL' expected." << std::endl;
01531 return RET_FAILED;
01532 }
01533 break;
01535
01537 case PROP_GAMMA:
01538 if (cameraProperty->propertyType & ipa_CameraSensors::TYPE_SPECIAL)
01539 {
01540 if(cameraProperty->specialValue == ipa_CameraSensors::VALUE_AUTO)
01541 {
01542 #ifdef __LINUX__
01543 err=dc1394_feature_set_mode(m_cam, DC1394_FEATURE_GAMMA, DC1394_FEATURE_MODE_AUTO);
01544 if (err!=DC1394_SUCCESS)
01545 {
01546 std::cerr << "ERROR - AVTPikeCam::SetProperty:" << std::endl;
01547 std::cerr << "\t ... Failed to set gamma to AUTO mode." << std::endl;
01548 std::cerr << "\t ... " << dc1394_error_get_string(err) << std::endl;
01549 return RET_FAILED;
01550 }
01551 #else
01552 err = m_cam.SetParameter(FGP_GAMMA, PVAL_AUTO);
01553 if(err!=FCE_NOERROR)
01554 {
01555 std::cerr << "ERROR - AVTPikeCam::SetProperty:" << std::endl;
01556 std::cerr << "\t ... << Could not set gamma to AUTO ( error " << err << " )" << std::endl;
01557 return RET_FAILED;
01558 }
01559 #endif
01560 }
01561 else if(cameraProperty->specialValue == ipa_CameraSensors::VALUE_DEFAULT)
01562 {
01563
01564 }
01565 else
01566 {
01567 std::cerr << "ERROR - AVTPikeCam::SetProperty:" << std::endl;
01568 std::cerr << "\t ... Special value 'VALUE_AUTO' or 'VALUE_DEFAULT' expected." << std::endl;
01569 return RET_FAILED;
01570 }
01571 }
01572 else if (cameraProperty->propertyType & (ipa_CameraSensors::TYPE_LONG | ipa_CameraSensors::TYPE_UNSIGNED))
01573 {
01574 #ifdef __LINUX__
01575 uint32_t min;
01576 uint32_t max;
01577 dc1394_feature_get_boundaries(m_cam, DC1394_FEATURE_GAMMA, &min, &max);
01578 if ((cameraProperty->u_longData < min) | (cameraProperty->u_longData > max))
01579 {
01580 std::cerr << "ERROR - AVTPikeCam::SetProperty:" << std::endl;
01581 std::cerr << "\t ... Gamma " << cameraProperty->u_longData
01582 << " has to be a value between " << min << " and " << max << "." << std::endl;
01583 return RET_FAILED;
01584 }
01585 else
01586 {
01587 err=dc1394_feature_set_value(m_cam, DC1394_FEATURE_GAMMA, (uint32_t) cameraProperty->u_longData);
01588 if (err!=DC1394_SUCCESS)
01589 {
01590 std::cerr << "ERROR - AVTPikeCam::SetProperty:" << std::endl;
01591 std::cerr << "\t ... Could not set gamma "
01592 << cameraProperty->u_longData << " ( error " << err << " )" << std::endl;
01593 std::cerr << "\t ... " << dc1394_error_get_string(err) << std::endl;
01594 return RET_FAILED;
01595 }
01596 }
01597 #else
01598 m_cam.GetParameterInfo(FGP_GAMMA, &info);
01599 if ((cameraProperty->u_longData < info.MinValue) | (cameraProperty->u_longData > info.MaxValue))
01600 {
01601 std::cerr << "ERROR - AVTPikeCam::SetProperty:" << std::endl;
01602 std::cerr << "\t ... Gamma has to be a value between " << info.MinValue << " and " << info.MaxValue << "." << std::endl;
01603 return RET_FAILED;
01604 }
01605 else
01606 {
01607 err = m_cam.SetParameter(FGP_GAMMA, cameraProperty->u_longData);
01608 if(err!=FCE_NOERROR)
01609 {
01610 std::cerr << "ERROR - AVTPikeCam::SetProperty:" << std::endl;
01611 std::cerr << "\t ... << Could not set gamma to " << cameraProperty->u_longData << " ( error " << err << " )" << std::endl;
01612 return RET_FAILED;
01613 }
01614 }
01615 #endif
01616 }
01617 else
01618 {
01619 std::cerr << "ERROR - AVTPikeCam::SetProperty:" << std::endl;
01620 std::cerr << "\t ... Wrong property type. '(TYPE_LONG|TYPE_UNSIGNED)' or special value 'TYPE_SPECIAL' expected." << std::endl;
01621 return RET_FAILED;
01622 }
01623 break;
01625
01627 case PROP_GAIN:
01628 if (cameraProperty->propertyType & ipa_CameraSensors::TYPE_SPECIAL)
01629 {
01630 if(cameraProperty->specialValue == ipa_CameraSensors::VALUE_AUTO)
01631 {
01632 #ifdef __LINUX__
01633 err=dc1394_feature_set_mode(m_cam, DC1394_FEATURE_GAIN, DC1394_FEATURE_MODE_AUTO);
01634 if (err!=DC1394_SUCCESS)
01635 {
01636 std::cerr << "ERROR - AVTPikeCam::SetProperty:" << std::endl;
01637 std::cerr << "\t ... Failed to set gamma to AUTO mode." << std::endl;
01638 std::cerr << "\t ... " << dc1394_error_get_string(err) << std::endl;
01639 return RET_FAILED;
01640 }
01641 #else
01642 err = m_cam.SetParameter(FGP_GAIN, PVAL_AUTO);
01643 if(err!=FCE_NOERROR)
01644 {
01645 std::cerr << "ERROR - AVTPikeCam::SetProperty:" << std::endl;
01646 std::cerr << "\t ... Could not set gain (on auto mode) ( error " << err << " )" << std::endl;
01647 return RET_FAILED;
01648 }
01649 #endif
01650 }
01651 else if(cameraProperty->specialValue == ipa_CameraSensors::VALUE_DEFAULT)
01652 {
01653
01654 }
01655 else
01656 {
01657 std::cerr << "ERROR - AVTPikeCam::SetProperty:" << std::endl;
01658 std::cerr << "\t ... Special value 'VALUE_AUTO' or 'VALUE_DEFAULT' expected." << std::endl;
01659 return RET_FAILED;
01660 }
01661 }
01662 else if (cameraProperty->propertyType & (ipa_CameraSensors::TYPE_LONG | ipa_CameraSensors::TYPE_UNSIGNED))
01663 {
01664 #ifdef __LINUX__
01665 uint32_t min;
01666 uint32_t max;
01667 dc1394_feature_get_boundaries(m_cam, DC1394_FEATURE_GAIN, &min, &max);
01668 if ((cameraProperty->u_longData < min) | (cameraProperty->u_longData > max))
01669 {
01670 std::cerr << "ERROR - AVTPikeCam::SetProperty:" << std::endl;
01671 std::cerr << "\t ... Gamma " << cameraProperty->u_longData
01672 << " has to be a value between " << min << " and " << max << "." << std::endl;
01673 return RET_FAILED;
01674 }
01675 else
01676 {
01677 err=dc1394_feature_set_value(m_cam, DC1394_FEATURE_GAIN, (uint32_t) cameraProperty->u_longData);
01678 if (err!=DC1394_SUCCESS)
01679 {
01680 std::cerr << "ERROR - AVTPikeCam::SetProperty:" << std::endl;
01681 std::cerr << "\t ... Could not set gamma "
01682 << cameraProperty->u_longData << " ( error " << err << " )" << std::endl;
01683 std::cerr << "\t ... " << dc1394_error_get_string(err) << std::endl;
01684 return RET_FAILED;
01685 }
01686 }
01687 #else
01688 m_cam.GetParameterInfo(FGP_GAIN, &info);
01689 if ((cameraProperty->u_longData < info.MinValue) | (cameraProperty->u_longData > info.MaxValue))
01690 {
01691 std::cerr << "ERROR - AVTPikeCam::SetProperty: " << std::endl;
01692 std::cerr << "\t ... Gain has to be a value between " << info.MinValue << " and " << info.MaxValue << "." << std::endl;
01693 return RET_FAILED;
01694 }
01695 else
01696 {
01697 err = m_cam.SetParameter(FGP_GAIN, cameraProperty->u_longData);
01698 if(err!=FCE_NOERROR)
01699 {
01700 std::cerr << "ERROR - AVTPikeCam::SetProperty: " << std::endl;
01701 std::cerr << "\t ... Could not set gain to value " << cameraProperty->u_longData << " ( error " << err << " )" << std::endl;
01702 return RET_FAILED;
01703 }
01704 }
01705 #endif
01706 }
01707 else
01708 {
01709 std::cerr << "ERROR - AVTPikeCam::SetProperty:" << std::endl;
01710 std::cerr << "\t ... Wrong property type. '(TYPE_LONG|TYPE_UNSIGNED)' or special value 'TYPE_SPECIAL' expected." << std::endl;
01711 return RET_FAILED;
01712 }
01713 break;
01715
01717 case PROP_VIDEO_ALL:
01718 if (cameraProperty->propertyType ==
01719 (ipa_CameraSensors::TYPE_VIDEO_FORMAT |
01720 ipa_CameraSensors::TYPE_VIDEO_MODE |
01721 ipa_CameraSensors::TYPE_COLOR_MODE))
01722 {
01723 #ifdef __LINUX__
01724 dc1394color_coding_t colorMode;
01725 dc1394video_mode_t videoMode;
01726 switch(cameraProperty->videoFormat)
01727 {
01728 case FORMAT_0:
01729 switch(cameraProperty->videoMode)
01730 {
01731 case MODE_1:
01732 videoMode = DC1394_VIDEO_MODE_320x240_YUV422;
01733 break;
01734 case MODE_2:
01735 videoMode = DC1394_VIDEO_MODE_640x480_YUV411;
01736 break;
01737 case MODE_3:
01738 videoMode = DC1394_VIDEO_MODE_640x480_YUV422;
01739 break;
01740 case MODE_4:
01741 case MODE_DEFAULT:
01742 videoMode = DC1394_VIDEO_MODE_640x480_RGB8;
01743 break;
01744 case MODE_5:
01745 videoMode = DC1394_VIDEO_MODE_640x480_MONO8;
01746 break;
01747 default:
01748 std::cerr << "ERROR - AVTPikeCam::SetProperty:" << std::endl;
01749 std::cerr << "\t ... Specified video mode unknown." << std::endl;
01750 return RET_FAILED;
01751 }
01752
01753 err=dc1394_video_set_mode(m_cam, videoMode);
01754 if (err!=DC1394_SUCCESS)
01755 {
01756 std::cerr << "ERROR - AVTPikeCam::SetProperty:" << std::endl;
01757 std::cerr << "\t ... Failed to setup video mode for format 0" << std::endl;
01758 std::cerr << "\t ... " << dc1394_error_get_string(err) << std::endl;
01759 return RET_FAILED;
01760 }
01761
01762 break;
01763 case FORMAT_1:
01764 switch(cameraProperty->videoMode)
01765 {
01766 case MODE_0:
01767 videoMode = DC1394_VIDEO_MODE_800x600_YUV422;
01768 break;
01769 case MODE_1:
01770 videoMode = DC1394_VIDEO_MODE_800x600_RGB8;
01771 break;
01772 case MODE_2:
01773 videoMode = DC1394_VIDEO_MODE_800x600_MONO8;
01774 break;
01775 case MODE_3:
01776 videoMode = DC1394_VIDEO_MODE_1024x768_YUV422;
01777 break;
01778 case MODE_4:
01779 case MODE_DEFAULT:
01780 videoMode = DC1394_VIDEO_MODE_1024x768_RGB8;
01781 break;
01782 case MODE_5:
01783 videoMode = DC1394_VIDEO_MODE_1024x768_MONO8;
01784 break;
01785 default:
01786 std::cerr << "ERROR - AVTPikeCam::SetProperty:" << std::endl;
01787 std::cerr << "\t ... Specified video mode not supported." << std::endl;
01788 return RET_FAILED;
01789 }
01790
01791 err=dc1394_video_set_mode(m_cam, videoMode);
01792 if (err!=DC1394_SUCCESS)
01793 {
01794 std::cerr << "ERROR - AVTPikeCam::SetProperty:" << std::endl;
01795 std::cerr << "\t ... Failed to setup video for format 1" << std::endl;
01796 std::cerr << "\t ... " << dc1394_error_get_string(err) << std::endl;
01797 return RET_FAILED;
01798 }
01799
01800 break;
01801 case FORMAT_2:
01802 switch(cameraProperty->videoMode)
01803 {
01804 case MODE_0:
01805 videoMode = DC1394_VIDEO_MODE_1280x960_YUV422;
01806 break;
01807 case MODE_1:
01808 case MODE_DEFAULT:
01809 videoMode = DC1394_VIDEO_MODE_1280x960_RGB8;
01810 break;
01811 case MODE_2:
01812 videoMode = DC1394_VIDEO_MODE_1280x960_MONO8;
01813 break;
01814 default:
01815 std::cerr << "ERROR - AVTPikeCam::SetProperty:" << std::endl;
01816 std::cerr << "\t ... Specified video mode not supported." << std::endl;
01817 return RET_FAILED;
01818 }
01819
01820 err=dc1394_video_set_mode(m_cam, videoMode);
01821 if (err!=DC1394_SUCCESS)
01822 {
01823 std::cerr << "ERROR - AVTPikeCam::SetProperty:" << std::endl;
01824 std::cerr << "\t ... Failed to setup video for format 1" << std::endl;
01825 std::cerr << "\t ... " << dc1394_error_get_string(err) << std::endl;
01826 return RET_FAILED;
01827 }
01828
01829 break;
01830 case FORMAT_DEFAULT:
01831 case FORMAT_7:
01832 switch(cameraProperty->colorMode)
01833 {
01834 case COLOR_YUV411:
01835 colorMode = DC1394_COLOR_CODING_YUV411;
01836 break;
01837 case COLOR_YUV422:
01838 colorMode = DC1394_COLOR_CODING_YUV422;
01839 break;
01840 case COLOR_YUV444:
01841 colorMode = DC1394_COLOR_CODING_YUV444;
01842 break;
01843 case COLOR_DEFAULT:
01844 case COLOR_RGB8:
01845 colorMode = DC1394_COLOR_CODING_RGB8;
01846 break;
01847 case COLOR_RGB16S:
01848 colorMode = DC1394_COLOR_CODING_RGB16S;
01849 break;
01850 case COLOR_RGB16:
01851 colorMode = DC1394_COLOR_CODING_RGB16;
01852 break;
01853 case COLOR_MONO8:
01854 colorMode = DC1394_COLOR_CODING_MONO8;
01855 break;
01856 case COLOR_MONO16S:
01857 colorMode = DC1394_COLOR_CODING_MONO16S;
01858 break;
01859 case COLOR_MONO16:
01860 colorMode = DC1394_COLOR_CODING_MONO16;
01861 break;
01862 case COLOR_RAW8:
01863 colorMode = DC1394_COLOR_CODING_RAW8;
01864 break;
01865 case COLOR_RAW16:
01866 colorMode = DC1394_COLOR_CODING_RAW16;
01867 break;
01868 default:
01869 std::cerr << "ERROR - AVTPikeCam::SetProperty:" << std::endl;
01870 std::cerr << "\t ... Specified color mode not supported." << std::endl;
01871 return RET_FAILED;
01872 }
01873
01874
01875 switch(cameraProperty->videoMode)
01876 {
01877 case MODE_DEFAULT:
01878 case MODE_0:
01879 videoMode = DC1394_VIDEO_MODE_FORMAT7_0;
01880 break;
01881 case MODE_4:
01882 videoMode = DC1394_VIDEO_MODE_FORMAT7_4;
01883 break;
01884 case MODE_5:
01885 videoMode = DC1394_VIDEO_MODE_FORMAT7_5;
01886 break;
01887 case MODE_6:
01888 videoMode = DC1394_VIDEO_MODE_FORMAT7_6;
01889 break;
01890 default:
01891 std::cerr << "ERROR - AVTPikeCam::SetProperty:" << std::endl;
01892 std::cerr << "\t ... Specified video mode not supported." << std::endl;
01893 return RET_FAILED;
01894 }
01895
01896
01897 err = dc1394_video_set_mode(m_cam, videoMode);
01898 if (err!=DC1394_SUCCESS)
01899 {
01900 std::cerr << "ERROR - AVTPikeCam::SetProperty:" << std::endl;
01901 std::cerr << "\t ... Failed to setup video mode." << std::endl;
01902 std::cerr << "\t ... " << dc1394_error_get_string(err) << std::endl;
01903 return RET_FAILED;
01904 }
01905 err = dc1394_format7_set_color_coding(m_cam, videoMode, colorMode);
01906 if (err!=DC1394_SUCCESS)
01907 {
01908 std::cerr << "ERROR - AVTPikeCam::SetProperty:" << std::endl;
01909 std::cerr << "\t ... Failed to setup color coding." << std::endl;
01910 std::cerr << "\t ... " << dc1394_error_get_string(err) << std::endl;
01911 return RET_FAILED;
01912 }
01913
01914 break;
01915 default:
01916 std::cerr << "ERROR - AVTPikeCam::SetProperty:" << std::endl;
01917 std::cerr << "\t ... Specified video format unknown." << std::endl;
01918 return RET_FAILED;
01919 }
01920 #else
01921
01922 FG_RESOLUTION resolution;
01923 FG_COLORMODE colorMode;
01924 int videoMode = -1;
01925 switch(cameraProperty->videoFormat)
01926 {
01927 case FORMAT_0:
01928 switch(cameraProperty->videoMode)
01929 {
01930 case MODE_1:
01931 resolution = RES_320_240;
01932 colorMode = CM_YUV422;
01933 break;
01934 case MODE_2:
01935 resolution = RES_640_480;
01936 colorMode = CM_YUV411;
01937 break;
01938 case MODE_3:
01939 resolution = RES_640_480;
01940 colorMode = CM_YUV422;
01941 break;
01942 case MODE_4:
01943 case MODE_DEFAULT:
01944 resolution = RES_640_480;
01945 colorMode = CM_RGB8;
01946 break;
01947 case MODE_5:
01948 resolution = RES_640_480;
01949 colorMode = CM_Y8;
01950 break;
01951 default:
01952 std::cerr << "ERROR - AVTPikeCam::SetProperty:" << std::endl;
01953 std::cerr << "\t ... Specified video mode unknown." << std::endl;
01954 return RET_FAILED;
01955 }
01956
01957 err = m_cam.SetParameter(FGP_IMAGEFORMAT, MAKEIMAGEFORMAT(resolution, colorMode, FR_30));
01958 if(err!=FCE_NOERROR)
01959 {
01960 std::cerr << "ERROR - AVTPikeCam::SetProperty:" << std::endl;
01961 std::cerr << "\t ... Could not set video format and mode ( error " << err << " )" << std::endl;
01962 return RET_FAILED;
01963 }
01964
01965 break;
01966 case FORMAT_1:
01967 switch(cameraProperty->videoMode)
01968 {
01969 case MODE_0:
01970 resolution = RES_800_600;
01971 colorMode = CM_YUV422;
01972 break;
01973 case MODE_1:
01974 resolution = RES_800_600;
01975 colorMode = CM_RGB8;
01976 break;
01977 case MODE_2:
01978 resolution = RES_800_600;
01979 colorMode = CM_Y8;
01980 break;
01981 case MODE_3:
01982 resolution = RES_1024_768;
01983 colorMode = CM_YUV422;
01984 break;
01985 case MODE_4:
01986 case MODE_DEFAULT:
01987 resolution = RES_1024_768;
01988 colorMode = CM_RGB8;
01989 break;
01990 case MODE_5:
01991 resolution = RES_1024_768;
01992 colorMode = CM_Y8;
01993 break;
01994 default:
01995 std::cerr << "ERROR - AVTPikeCam::SetProperty:" << std::endl;
01996 std::cerr << "\t ... Specified video mode not supported." << std::endl;
01997 return RET_FAILED;
01998 }
01999
02000 err = m_cam.SetParameter(FGP_IMAGEFORMAT, MAKEIMAGEFORMAT(resolution, colorMode, FR_15));
02001 if(err!=FCE_NOERROR)
02002 {
02003 std::cerr << "ERROR - AVTPikeCam::SetProperty:" << std::endl;
02004 std::cerr << "\t ... Could not set video format and mode ( error " << err << " )" << std::endl;
02005 return RET_FAILED;
02006 }
02007
02008 break;
02009 case FORMAT_2:
02010 switch(cameraProperty->videoMode)
02011 {
02012 case MODE_0:
02013 resolution = RES_1280_960;
02014 colorMode = CM_YUV422;
02015 break;
02016 case MODE_1:
02017 case MODE_DEFAULT:
02018 resolution = RES_1280_960;
02019 colorMode = CM_RGB8;
02020 break;
02021 case MODE_2:
02022 resolution = RES_1280_960;
02023 colorMode = CM_Y8;
02024 break;
02025 default:
02026 std::cerr << "ERROR - AVTPikeCam::SetProperty:" << std::endl;
02027 std::cerr << "\t ... Specified video mode not supported." << std::endl;
02028 return RET_FAILED;
02029 }
02030
02031 err = m_cam.SetParameter(FGP_IMAGEFORMAT, MAKEIMAGEFORMAT(resolution, colorMode, FR_15));
02032 if(err!=FCE_NOERROR)
02033 {
02034 std::cerr << "ERROR - AVTPikeCam::SetProperty:" << std::endl;
02035 std::cerr << "\t ... Could not set video format and mode ( error " << err << " )" << std::endl;
02036 return RET_FAILED;
02037 }
02038
02039 break;
02040 case FORMAT_DEFAULT:
02041 case FORMAT_7:
02042 switch(cameraProperty->colorMode)
02043 {
02044 case COLOR_YUV444:
02045 colorMode = CM_YUV444;
02046 break;
02047 case COLOR_YUV422:
02048 colorMode = CM_YUV422;
02049 break;
02050 case COLOR_YUV411:
02051 colorMode = CM_YUV411;
02052 break;
02053 case COLOR_DEFAULT:
02054 case COLOR_RGB8:
02055 colorMode = CM_RGB8;
02056 break;
02057 case COLOR_RGB16S:
02058 colorMode = CM_SRGB16;
02059 break;
02060 case COLOR_RGB16:
02061 colorMode = CM_RGB16;
02062 break;
02063 case COLOR_MONO8:
02064 colorMode = CM_Y8;
02065 break;
02066 case COLOR_MONO16S:
02067 colorMode = CM_SY16;
02068 break;
02069 case COLOR_MONO16:
02070 colorMode = CM_Y16;
02071 break;
02072 case COLOR_RAW8:
02073 colorMode = CM_RAW8;
02074 break;
02075 case COLOR_RAW16:
02076 colorMode = CM_RAW16;
02077 break;
02078 default:
02079 std::cerr << "ERROR - AVTPikeCam::SetProperty:" << std::endl;
02080 std::cerr << "\t ... Specified color mode not supported." << std::endl;
02081 return RET_FAILED;
02082 }
02083
02084 switch(cameraProperty->videoMode)
02085 {
02086 case MODE_0:
02087 case COLOR_DEFAULT:
02088 videoMode = 0;
02089 break;
02090 case MODE_4:
02091 videoMode = 4;
02092 break;
02093 case MODE_5:
02094 videoMode = 5;
02095 break;
02096 case MODE_6:
02097 videoMode = 6;
02098 break;
02099 default:
02100 std::cerr << "ERROR - AVTPikeCam::SetProperty:" << std::endl;
02101 std::cerr << "\t ... Specified video mode not supported." << std::endl;
02102 return RET_FAILED;
02103 }
02104
02105 err = m_cam.SetParameter(FGP_IMAGEFORMAT, MAKEDCAMFORMAT(RES_SCALABLE, videoMode, colorMode));
02106 if(err!=FCE_NOERROR)
02107 {
02108 std::cerr << "ERROR - AVTPikeCam::SetProperty:" << std::endl;
02109 std::cerr << "\t ... Could not set video format and mode ( error " << err << " )" << std::endl;
02110 return RET_FAILED;
02111 }
02112
02113 break;
02114 default:
02115 std::cerr << "ERROR - AVTPikeCam::SetProperty:" << std::endl;
02116 std::cerr << "\t ... Specified video format not supported." << std::endl;
02117 return RET_FAILED;
02118 }
02119 #endif
02120 }
02121 else
02122 {
02123 std::cerr << "ERROR - AVTPikeCam::SetProperty:" << std::endl;
02124 std::cerr << "\t ... Wrong property type. 'TYPE_VIDEO_MODE' or special value 'TYPE_SPECIAL' expected." << std::endl;
02125 return RET_FAILED;
02126 }
02127 break;
02128
02130
02132 case PROP_FRAME_RATE:
02133 #ifdef __LINUX__
02134 dc1394video_mode_t videoMode;
02135 err=dc1394_video_get_mode(m_cam, &videoMode);
02136 if(err!=DC1394_SUCCESS)
02137 {
02138 std::cerr << "ERROR - AVTPikeCam::SetProperty:" << std::endl;
02139 std::cerr << "\t ... Could not get video mode ( error " << err << " )" << std::endl;
02140 std::cerr << "\t ... " << dc1394_error_get_string(err) << std::endl;
02141 return RET_FAILED;
02142 }
02143
02144
02145
02146 if (videoMode==DC1394_VIDEO_MODE_FORMAT7_0 ||
02147 videoMode==DC1394_VIDEO_MODE_FORMAT7_1 ||
02148 videoMode==DC1394_VIDEO_MODE_FORMAT7_2 ||
02149 videoMode==DC1394_VIDEO_MODE_FORMAT7_3 ||
02150 videoMode==DC1394_VIDEO_MODE_FORMAT7_4 ||
02151 videoMode==DC1394_VIDEO_MODE_FORMAT7_5 ||
02152 videoMode==DC1394_VIDEO_MODE_FORMAT7_6 ||
02153 videoMode==DC1394_VIDEO_MODE_FORMAT7_7)
02154 {
02155 #else
02156 UINT32 imageFormat;
02157 FGPINFO packetSizeInfo;
02158 err = m_cam.GetParameter(FGP_IMAGEFORMAT, &imageFormat);
02159 if(err!=FCE_NOERROR)
02160 {
02161 std::cout << "ERROR - AVTPikeCam::SetProperty:" << std::endl;
02162 std::cerr << "\t ... Could not read image format ( error " << err << " )" << std::endl;
02163 return RET_FAILED;
02164 }
02165
02166
02167
02168 if (IMGRES(imageFormat)==RES_SCALABLE)
02169 {
02170 #endif
02171 if (cameraProperty->propertyType & ipa_CameraSensors::TYPE_SPECIAL)
02172 {
02173 if(cameraProperty->specialValue == ipa_CameraSensors::VALUE_AUTO ||
02174 cameraProperty->specialValue == ipa_CameraSensors::VALUE_DEFAULT)
02175 {
02176
02177 }
02178 }
02179 else if (cameraProperty->propertyType & ipa_CameraSensors::TYPE_FLOAT)
02180 {
02181 #ifdef __LINUX__
02182 uint64_t bytesPerFrame;
02183
02184 err = dc1394_format7_get_total_bytes(m_cam, videoMode, &bytesPerFrame);
02185 if (err!=DC1394_SUCCESS)
02186 {
02187 std::cerr << "ERROR - AVTPikeCam::SetProperty:" << std::endl;
02188 std::cerr << "\t ... Could not get bytes per image ( error " << err << " )" << std::endl;
02189 std::cerr << "\t ... " << dc1394_error_get_string(err) << std::endl;
02190 return RET_FAILED;
02191 }
02192
02193 if (cameraProperty->floatData > 0 && cameraProperty->floatData <= 60)
02194 {
02195 double fps = cameraProperty->floatData;
02196 uint32_t min = 0;
02197 uint32_t max = 0;
02198 uint64_t bytesPerFrame = 0;
02199 uint32_t bytesPerPacket = 0;
02200 unsigned long packetsPerFrame = 0;
02201 double busPeriodInSeconds = 0;
02202 dc1394speed_t isoSpeed;
02203
02204 err = dc1394_format7_get_packet_parameters(m_cam, videoMode, &min, &max);
02205 if (err!=DC1394_SUCCESS)
02206 {
02207 std::cerr << "ERROR - AVTPikeCam::SetProperty:" << std::endl;
02208 std::cerr << "\t ... Could not get min/max bytes per packet ( error " << err << " )" << std::endl;
02209 std::cerr << "\t ... " << dc1394_error_get_string(err) << std::endl;
02210 return RET_FAILED;
02211 }
02212 err = dc1394_format7_get_total_bytes(m_cam, videoMode, &bytesPerFrame);
02213 if (err!=DC1394_SUCCESS)
02214 {
02215 std::cerr << "ERROR - AVTPikeCam::SetProperty:" << std::endl;
02216 std::cerr << "\t ... Could not get total bytes per frame ( error " << err << " )" << std::endl;
02217 std::cerr << "\t ... " << dc1394_error_get_string(err) << std::endl;
02218 return RET_FAILED;
02219 }
02220
02221 err = dc1394_video_get_iso_speed(m_cam, &isoSpeed);
02222 if (err!=DC1394_SUCCESS)
02223 {
02224 std::cerr << "ERROR - AVTPikeCam::SetProperty:" << std::endl;
02225 std::cerr << "\t ... Could not get iso speed ( error " << err << " )" << std::endl;
02226 std::cerr << "\t ... " << dc1394_error_get_string(err) << std::endl;
02227 return RET_FAILED;
02228 }
02229
02230 if (isoSpeed == DC1394_ISO_SPEED_100)
02231 {
02232 busPeriodInSeconds = 500.0/1000000.0;
02233 }
02234 else if(isoSpeed == DC1394_ISO_SPEED_200)
02235 {
02236 busPeriodInSeconds = 250.0/1000000.0;
02237 }
02238 else if(isoSpeed == DC1394_ISO_SPEED_400)
02239 {
02240 busPeriodInSeconds = 125.0/1000000.0;
02241 }
02242 else
02243 {
02244 busPeriodInSeconds = 62.5/1000000.0;
02245 }
02246
02247 packetsPerFrame = (int) (1.0/(busPeriodInSeconds*fps) + 0.5);
02248 bytesPerPacket = (uint32_t) ((bytesPerFrame + packetsPerFrame - 1)/(packetsPerFrame));
02249
02250 if (bytesPerPacket < min || bytesPerPacket > max)
02251 {
02252 std::cout << "WARNING - AVTPikeCam::SetProperty:" << std::endl;
02253 std::cout << "\t ... Desired packet size out of bounds. Resetting packet size to max value" << std::endl;
02254 bytesPerPacket = max;
02255 }
02256
02257
02258 bytesPerPacket = ((int)(bytesPerPacket/min))*min;
02259
02260 err = dc1394_format7_set_packet_size(m_cam, videoMode, bytesPerPacket);
02261 if (err!=DC1394_SUCCESS)
02262 {
02263 std::cerr << "ERROR - AVTPikeCam::SetProperty:" << std::endl;
02264 std::cerr << "\t ... Could not set packet size " << bytesPerPacket << " ( error " << err << " )" << std::endl;
02265 return RET_FAILED;
02266 }
02267 }
02268 #else
02269 UINT32 bytesPerImage = 0;
02270 UINT32 isoSpeed = 0;
02271 double busPeriodInSeconds = 0;
02272 err = m_cam.GetParameter(FGP_FRAMEMEMORYSIZE, &bytesPerImage);
02273 if(err!=FCE_NOERROR)
02274 {
02275 std::cout << "ERROR - AVTPikeCam::SetProperty:" << std::endl;
02276 std::cerr << "\t ... Could not read image size ( error " << err << " )" << std::endl;
02277 return RET_FAILED;
02278 }
02279
02280 err = m_cam.GetParameter(FGP_PHYSPEED, &isoSpeed);
02281 if (err!=FCE_NOERROR)
02282 {
02283 std::cerr << "ERROR - AVTPikeCam::SetProperty:" << std::endl;
02284 std::cerr << "\t ... Could not read iso speed info ( error " << err << " )" << std::endl;
02285 return RET_FAILED;
02286 }
02287
02288 if (isoSpeed == PS_100MBIT)
02289 {
02290 busPeriodInSeconds = 500.0/1000000.0;
02291 }
02292 else if(isoSpeed == PS_200MBIT)
02293 {
02294 busPeriodInSeconds = 250.0/1000000.0;
02295 }
02296 else if(isoSpeed == PS_400MBIT)
02297 {
02298 busPeriodInSeconds = 125.0/1000000.0;
02299 }
02300 else
02301 {
02302 busPeriodInSeconds = 62.5/1000000.0;
02303 }
02304
02305 if (cameraProperty->floatData > 0 && cameraProperty->floatData <= 60)
02306 {
02307 double fps = cameraProperty->floatData;
02308 UINT32 bytesPerPacket = (UINT32) (fps * busPeriodInSeconds * (double)bytesPerImage);
02309
02310 err = m_cam.GetParameterInfo(FGP_PACKETSIZE, &packetSizeInfo);
02311 if(err!=FCE_NOERROR)
02312 {
02313 std::cerr << "ERROR - AVTPikeCam::SetProperty:" << std::endl;
02314 std::cerr << "\t ... Could not read packet size info ( error " << err << " )" << std::endl;
02315 return RET_FAILED;
02316 }
02317
02318 if (bytesPerPacket < packetSizeInfo.MinValue || bytesPerPacket > packetSizeInfo.MaxValue)
02319 {
02320 std::cout << "WARNING - AVTPikeCam::SetProperty:" << std::endl;
02321 std::cout << "\t ... Desired packet size out of bounds. Resetting packet size to max value" << std::endl;
02322 bytesPerPacket = packetSizeInfo.MaxValue;
02323 }
02324
02325
02326 bytesPerPacket = ((int)(bytesPerPacket/packetSizeInfo.MinValue))*packetSizeInfo.MinValue;
02327
02328 err = m_cam.SetParameter(FGP_PACKETSIZE, bytesPerPacket);
02329 if(err!=FCE_NOERROR)
02330 {
02331 std::cerr << "ERROR - AVTPikeCam::SetProperty:" << std::endl;
02332 std::cerr << "\t ... Could not set packet size " << bytesPerPacket << " ( error " << err << " )" << std::endl;
02333 return RET_FAILED;
02334 }
02335 }
02336 #endif
02337
02338 else
02339 {
02340 std::cerr << "ERROR - AVTPikeCam::SetProperty:" << std::endl;
02341 std::cerr << "\t ... Specified framerate out of range ( error " << err << " )" << std::endl;
02342 return RET_FAILED;
02343 }
02344 }
02345 else
02346 {
02347 std::cerr << "ERROR - AVTPikeCam::SetProperty:" << std::endl;
02348 std::cerr << "\t ... Wrong property type. 'TYPE_FLOAT' or special values 'TYPE_SPECIAL' expected." << std::endl;
02349 return RET_FAILED;
02350 }
02351 }
02352
02353 else
02354 {
02355 if (cameraProperty->propertyType & ipa_CameraSensors::TYPE_SPECIAL)
02356 {
02357 if(cameraProperty->specialValue == ipa_CameraSensors::VALUE_AUTO)
02358 {
02359 #ifdef __LINUX__
02360 err=dc1394_video_set_framerate(m_cam, DC1394_FRAMERATE_7_5);
02361 if (err!=DC1394_SUCCESS)
02362 {
02363 std::cerr << "ERROR - AVTPikeCam::SetProperty:" << std::endl;
02364 std::cerr << "\t ... Failed to set framerate to AUTO mode." << std::endl;
02365 std::cerr << "\t ... " << dc1394_error_get_string(err) << std::endl;
02366 return RET_FAILED;
02367 }
02368 #else
02369 err = m_cam.SetParameter(FGP_FRAMERATE, PVAL_AUTO);
02370 if(err!=FCE_NOERROR)
02371 {
02372 std::cout << "ERROR - AVTPikeCam::SetProperty:" << std::endl;
02373 std::cerr << "\t ... Could not set framerate to AUTO ( error " << err << " )" << std::endl;
02374 return RET_FAILED;
02375 }
02376 #endif
02377 }
02378 if(cameraProperty->specialValue == ipa_CameraSensors::VALUE_DEFAULT)
02379 {
02380
02381 }
02382 else
02383 {
02384 std::cerr << "ERROR - AVTPikeCam::SetProperty:" << std::endl;
02385 std::cerr << "\t ... Special value 'VALUE_AUTO' or 'VALUE_DEFAULT' expected." << std::endl;
02386 return RET_FAILED;
02387 }
02388 }
02389 else if (cameraProperty->propertyType & ipa_CameraSensors::TYPE_FLOAT)
02390 {
02391 #ifdef __LINUX__
02392 dc1394framerate_t framerate;
02393 if (cameraProperty->floatData <= 1.875)
02394 {
02395 framerate = DC1394_FRAMERATE_1_875;
02396 }
02397 else if (cameraProperty->floatData <= 3.75)
02398 {
02399 framerate = DC1394_FRAMERATE_3_75;
02400 }
02401 else if (cameraProperty->floatData <= 7.5)
02402 {
02403 framerate = DC1394_FRAMERATE_7_5;
02404 }
02405 else if (cameraProperty->floatData <= 15)
02406 {
02407 framerate = DC1394_FRAMERATE_15;
02408 }
02409 else if (cameraProperty->floatData <= 30)
02410 {
02411 framerate = DC1394_FRAMERATE_30;
02412 }
02413 else if (cameraProperty->floatData <= 60)
02414 {
02415 framerate = DC1394_FRAMERATE_60;
02416 }
02417 else
02418 {
02419 std::cerr << "ERROR - AVTPikeCam::SetProperty:" << std::endl;
02420 std::cerr << "\t ... Specified framerate " << cameraProperty->floatData << " out of range ( error " << err << " )" << std::endl;
02421 return RET_FAILED;
02422 }
02423 err=dc1394_video_set_framerate(m_cam, framerate);
02424 if (err!=DC1394_SUCCESS)
02425 {
02426 std::cerr << "ERROR - AVTPikeCam::SetProperty:" << std::endl;
02427 std::cerr << "\t ... Could not set specified framerate " << cameraProperty->floatData << " ( error " << err << " )" << std::endl;
02428 return RET_FAILED;
02429 }
02430 #else
02431 UINT32 framerate;
02432 if (cameraProperty->floatData <= 1.875)
02433 {
02434 framerate = FR_1_875;
02435 }
02436 else if (cameraProperty->floatData <= 3.75)
02437 {
02438 framerate = FR_3_75;
02439 }
02440 else if (cameraProperty->floatData <= 7.5)
02441 {
02442 framerate = FR_7_5;
02443 }
02444 else if (cameraProperty->floatData <= 15)
02445 {
02446 framerate = FR_15;
02447 }
02448 else if (cameraProperty->floatData <= 30)
02449 {
02450 framerate = FR_30;
02451 }
02452 else if (cameraProperty->floatData <= 60)
02453 {
02454 framerate = FR_60;
02455 }
02456 else
02457 {
02458 std::cerr << "ERROR - AVTPikeCam::SetProperty:" << std::endl;
02459 std::cerr << "\t ... Specified framerate " << cameraProperty->floatData << " out of range ( error " << err << " )" << std::endl;
02460 return RET_FAILED;
02461 }
02462 err = m_cam.SetParameter(FGP_FRAMERATE, framerate);
02463 if(err!=FCE_NOERROR)
02464 {
02465 std::cerr << "ERROR - AVTPikeCam::SetProperty:" << std::endl;
02466 std::cerr << "\t ... Could not set specified framerate " << cameraProperty->floatData << " ( error " << err << " )" << std::endl;
02467 return RET_FAILED;
02468 }
02469 #endif
02470 }
02471 else
02472 {
02473 std::cerr << "ERROR - AVTPikeCam::SetProperty:" << std::endl;
02474 std::cerr << "\t ... Wrong property type. 'TYPE_FLOAT' or special values 'TYPE_SPECIAL' expected." << std::endl;
02475 return RET_FAILED;
02476 }
02477 }
02478 return RET_OK;
02479 break;
02481
02483 case PROP_FW_OPERATION_MODE:
02484 if (cameraProperty->propertyType & ipa_CameraSensors::TYPE_SPECIAL)
02485 {
02486 if(cameraProperty->specialValue == ipa_CameraSensors::VALUE_AUTO)
02487 {
02488 m_operationMode_B = false;
02489 return RET_OK;
02490 }
02491 else if(cameraProperty->specialValue == ipa_CameraSensors::VALUE_DEFAULT)
02492 {
02493 m_operationMode_B = false;
02494 return RET_OK;
02495 }
02496 else
02497 {
02498 std::cerr << "ERROR - AVTPikeCam::SetProperty:" << std::endl;
02499 std::cerr << "\t ... Special value 'VALUE_AUTO' or 'VALUE_DEFAULT' expected." << std::endl;
02500 return RET_FAILED;
02501 }
02502
02503 }
02504 else if (cameraProperty->propertyType & TYPE_STRING)
02505 {
02506 if (cameraProperty->stringData == "A")
02507 {
02508 m_operationMode_B = false;
02509 return RET_OK;
02510 }
02511 else if (cameraProperty->stringData == "B")
02512 {
02513 m_operationMode_B = true;
02514 return RET_OK;
02515 }
02516 else
02517 {
02518 std::cerr << "ERROR - AVTPikeCam::SetProperty:" << std::endl;
02519 std::cerr << "\t ... FireWire operation mode " << cameraProperty->stringData << " unknown." << std::endl;
02520 return RET_FAILED;
02521 }
02522 }
02523 else
02524 {
02525 std::cerr << "ERROR - AVTPikeCam::SetProperty:" << std::endl;
02526 std::cerr << "\t ... Wrong property type. 'TYPE_STRING' or special values 'TYPE_SPECIAL' expected." << std::endl;
02527 return RET_FAILED;
02528 }
02529 break;
02531
02533 case PROP_ISO_SPEED:
02534 if (cameraProperty->propertyType & ipa_CameraSensors::TYPE_SPECIAL)
02535 {
02536 if(cameraProperty->specialValue == ipa_CameraSensors::VALUE_AUTO)
02537 {
02538 #ifdef __LINUX__
02539 err=dc1394_video_set_iso_speed(m_cam, DC1394_ISO_SPEED_400);
02540 if (err!=DC1394_SUCCESS)
02541 {
02542 std::cerr << "ERROR - AVTPikeCam::SetProperty:" << std::endl;
02543 std::cerr << "\t ... Failed to setup iso speed." << std::endl;
02544 std::cerr << "\t ... " << dc1394_error_get_string(err) << std::endl;
02545 return RET_FAILED;
02546 }
02547 #else
02548 err = m_cam.SetParameter(FGP_PHYSPEED, PS_AUTO);
02549 if(err!=FCE_NOERROR)
02550 {
02551 std::cerr<< "ERROR - AVTPikeCam::SetProperty:" << std::endl;
02552 std::cerr << "\t ... Could not set iso speed to AUTO mode ( error " << err << " )" << std::endl;
02553 return RET_FAILED;
02554 }
02555 #endif
02556 }
02557 else if(cameraProperty->specialValue == ipa_CameraSensors::VALUE_DEFAULT)
02558 {
02559 #ifdef __LINUX__
02560 #else
02561 err = m_cam.SetParameter(FGP_PHYSPEED, PS_LAST);
02562 if(err!=FCE_NOERROR)
02563 {
02564 std::cerr << "ERROR - AVTPikeCam::SetProperty:" << std::endl;
02565 std::cerr << "\t ... Could not set iso speed to DEFAULT mode ( error " << err << " )" << std::endl;
02566 return RET_FAILED;
02567 }
02568 #endif
02569 }
02570 else
02571 {
02572 std::cerr << "ERROR - AVTPikeCam::SetProperty:" << std::endl;
02573 std::cerr << "\t ... Special value 'VALUE_AUTO' or 'VALUE_DEFAULT' expected." << std::endl;
02574 return RET_FAILED;
02575 }
02576 }
02577 else if (cameraProperty->propertyType & (ipa_CameraSensors::TYPE_LONG | ipa_CameraSensors::TYPE_UNSIGNED))
02578 {
02579 #ifdef __LINUX__
02580 err = DC1394_FAILURE;
02581 if (cameraProperty->u_longData <= 100)
02582 {
02583 err=dc1394_video_set_iso_speed(m_cam, DC1394_ISO_SPEED_100);
02584 }
02585 else if (cameraProperty->u_longData <= 200)
02586 {
02587 err=dc1394_video_set_iso_speed(m_cam, DC1394_ISO_SPEED_200);
02588 }
02589 else if (cameraProperty->u_longData <= 400)
02590 {
02591 err=dc1394_video_set_iso_speed(m_cam, DC1394_ISO_SPEED_400);
02592 }
02593 else if (cameraProperty->u_longData <= 800)
02594 {
02595 err=dc1394_video_set_iso_speed(m_cam, DC1394_ISO_SPEED_800);
02596 }
02597 if (err!=DC1394_SUCCESS)
02598 {
02599 std::cerr << "ERROR - AVTPikeCam::SetProperty:" << std::endl;
02600 std::cerr << "\t ... Failed to setup iso speed " << cameraProperty->u_longData << std::endl;
02601 std::cerr << "\t ... " << dc1394_error_get_string(err) << std::endl;
02602 return RET_FAILED;
02603 }
02604 #else
02605 err = 1;
02606 if (cameraProperty->u_longData <= 100)
02607 {
02608 err = m_cam.SetParameter(FGP_PHYSPEED, PS_100MBIT);
02609 }
02610 else if (cameraProperty->u_longData <= 200)
02611 {
02612 err = m_cam.SetParameter(FGP_PHYSPEED, PS_200MBIT);
02613 }
02614 else if (cameraProperty->u_longData <= 400)
02615 {
02616 err = m_cam.SetParameter(FGP_PHYSPEED, PS_400MBIT);
02617 }
02618 else if (cameraProperty->u_longData <= 800)
02619 {
02620 err = m_cam.SetParameter(FGP_PHYSPEED, PS_800MBIT);
02621 }
02622 if(err!=FCE_NOERROR)
02623 {
02624 std::cerr << "ERROR - AVTPikeCam::SetProperty:" << std::endl;
02625 std::cerr << "\t ... Could not set iso speed to " <<
02626 cameraProperty->u_longData << " ( error " << err << " )" << std::endl;
02627 return RET_FAILED;
02628 }
02629 #endif
02630 }
02631 else
02632 {
02633 std::cerr << "ERROR - AVTPikeCam::SetProperty:" << std::endl;
02634 std::cerr << "\t ... Wrong property type. '(TYPE_LONG|TYPE_UNSIGNED)' or 'TYPE_SPECIAL' expected." << std::endl;
02635 return RET_FAILED;
02636 }
02637 break;
02639
02641 case PROP_RESOLUTION:
02642 if (cameraProperty->propertyType & ipa_CameraSensors::TYPE_SPECIAL)
02643 {
02644 if(cameraProperty->specialValue == ipa_CameraSensors::VALUE_AUTO)
02645 {
02646 #ifdef __LINUX__
02647 #else
02648 err = m_cam.SetParameter(FGP_XSIZE, PVAL_AUTO);
02649 if(err!=FCE_NOERROR)
02650 {
02651 std::cerr << "ERROR - AVTPikeCam::SetProperty:" << std::endl;
02652 std::cerr << "\t ... Could not set x resolution to AUTO mode ( error " << err << " )" << std::endl;
02653 return RET_FAILED;
02654 }
02655 err = m_cam.SetParameter(FGP_YSIZE, PVAL_AUTO);
02656 if(err!=FCE_NOERROR)
02657 {
02658 std::cerr << "ERROR - AVTPikeCam::SetProperty:" << std::endl;
02659 std::cerr << "\t ... Could not set y resolution to AUTO mode ( error " << err << " )" << std::endl;
02660 return RET_FAILED;
02661 }
02662 #endif
02663 }
02664 else if(cameraProperty->specialValue == ipa_CameraSensors::VALUE_DEFAULT)
02665 {
02666
02667 }
02668 else
02669 {
02670 std::cerr << "ERROR - AVTPikeCam::SetProperty:" << std::endl;
02671 std::cerr << "\t ... Special value 'VALUE_AUTO' or 'VALUE_DEFAULT' expected." << std::endl;
02672 return RET_FAILED;
02673 }
02674 }
02675 else if (cameraProperty->propertyType & ipa_CameraSensors::TYPE_CAMERA_RESOLUTION)
02676 {
02677 #ifdef __LINUX__
02678 #else
02679 m_cam.GetParameterInfo(FGP_XSIZE, &info);
02680 if (((unsigned int) cameraProperty->cameraResolution.xResolution < info.MinValue) ||
02681 ((unsigned int) cameraProperty->cameraResolution.xResolution > info.MaxValue))
02682 {
02683 std::cout << "WARNING - AVTPikeCam::SetProperty:" << std::endl;
02684 std::cout << "\t ... x resolution " << cameraProperty->cameraResolution.xResolution
02685 << " has to be a value between " << info.MinValue << " and " << info.MaxValue << "." << std::endl;
02686 std::cout << "\t ... Setting maximal x resolution" << std::endl;
02687 }
02688 m_cam.GetParameterInfo(FGP_YSIZE, &info);
02689 if (((unsigned int) cameraProperty->cameraResolution.yResolution < info.MinValue) ||
02690 ((unsigned int) cameraProperty->cameraResolution.yResolution > info.MaxValue))
02691 {
02692 std::cout << "WARNING - AVTPikeCam::SetProperty:" << std::endl;
02693 std::cout << "\t ... y resolution " << cameraProperty->cameraResolution.yResolution
02694 << " has to be a value between " << info.MinValue << " and " << info.MaxValue << "." << std::endl;
02695 std::cout << "\t ... Setting maximal y resolution" << std::endl;
02696 }
02697
02698
02699
02700 err = m_cam.SetParameter(FGP_XSIZE, cameraProperty->cameraResolution.xResolution);
02701 if(err!=FCE_NOERROR)
02702 {
02703 std::cout << "WARNING - AVTPikeCam::SetProperty:" << std::endl;
02704 std::cout << "\t ... Could not set image width ( error " << err << " )" << std::endl;
02705 }
02706
02707 err = m_cam.SetParameter(FGP_YSIZE, cameraProperty->cameraResolution.yResolution);
02708 if(err!=FCE_NOERROR)
02709 {
02710 std::cout << "WARNING - AVTPikeCam::SetProperty:" << std::endl;
02711 std::cout << "\t ... Could not set image height ( error " << err << " )" << std::endl;
02712 }
02713 #endif
02714
02715 }
02716 else
02717 {
02718 std::cerr << "ERROR - AVTPikeCam::SetProperty:" << std::endl;
02719 std::cerr << "\t ... Wrong property type. 'TYPE_CAMERA_RESOLUTION' or 'TYPE_SPECIAL' expected." << std::endl;
02720 return RET_FAILED;
02721 }
02722 break;
02724
02726 default:
02727 std::cerr << "ERROR - VTPikeCam::SetProperty:" << std::endl;
02728 std::cerr << "\t ... Property " << cameraProperty->propertyID << " unspecified." << std::endl;
02729 return RET_FAILED;
02730 break;
02731 }
02732
02733 return RET_OK;
02734 }
02735
02736 unsigned long AVTPikeCam::SetParameters()
02737 {
02738 ipa_CameraSensors::t_cameraProperty cameraProperty;
02739
02740
02741
02742
02743 if (m_ColorCameraParameters.m_CameraRole == MASTER)
02744 {
02745 std::cout << "Info - AVTPikeCam::SetProperty:" << std::endl;
02746 std::cout << "\t ... Setting camera in MASTER mode." << std::endl;
02747 #ifdef __LINUX__
02748
02749
02750 dc1394error_t err;
02751 err = dc1394_external_trigger_set_power(m_cam, DC1394_OFF);
02752 if (err!=DC1394_SUCCESS)
02753 {
02754 std::cerr << "ERROR - AVTPikeCam::SetProperty:" << std::endl;
02755 std::cerr << "\t ... Failed to deactivate external trigger." << std::endl;
02756 std::cerr << "\t ... " << dc1394_error_get_string(err) << std::endl;
02757 return RET_FAILED;
02758 }
02759 err = dc1394_external_trigger_set_mode(m_cam, DC1394_TRIGGER_MODE_3);
02760 if (err!=DC1394_SUCCESS)
02761 {
02762 std::cerr << "ERROR - AVTPikeCam::SetProperty:" << std::endl;
02763 std::cerr << "\t ... Failed to set trigger mode." << std::endl;
02764 std::cerr << "\t ... " << dc1394_error_get_string(err) << std::endl;
02765 return RET_FAILED;
02766 }
02767 #else
02768 UINT32 err;
02769
02770 UINT32 triggerValue;
02771 triggerValue=MAKETRIGGER(0, 0, 0, 0, 0);
02772 err = m_cam.SetParameter(FGP_TRIGGER,triggerValue);
02773 if(err!=FCE_NOERROR)
02774 {
02775 std::cerr << "ERROR - AVTPikeCam::SetProperty:" << std::endl;
02776 std::cerr << "\t ... Could not set Slave trigger mode ( error " << err << " )" << std::endl;
02777 return RET_FAILED;
02778 }
02779 #endif
02780 }
02781 else if (m_ColorCameraParameters.m_CameraRole == SLAVE)
02782 {
02783 std::cout << "Info - AVTPikeCam::SetProperty:" << std::endl;
02784 std::cout << "\t ... Setting camera in SLAVE mode." << std::endl;
02785 #ifdef __LINUX__
02786
02787 dc1394error_t err;
02788 err = dc1394_external_trigger_set_power(m_cam, DC1394_ON);
02789 if (err!=DC1394_SUCCESS)
02790 {
02791 std::cerr << "ERROR - AVTPikeCam::SetProperty:" << std::endl;
02792 std::cerr << "\t ... Failed to activate external trigger." << std::endl;
02793 std::cerr << "\t ... " << dc1394_error_get_string(err) << std::endl;
02794 return RET_FAILED;
02795 }
02796
02797 err = dc1394_external_trigger_set_polarity(m_cam, DC1394_TRIGGER_ACTIVE_HIGH);
02798 if (err!=DC1394_SUCCESS)
02799 {
02800 std::cerr << "ERROR - AVTPikeCam::SetProperty:" << std::endl;
02801 std::cerr << "\t ... Failed to set trigger polarity." << std::endl;
02802 std::cerr << "\t ... " << dc1394_error_get_string(err) << std::endl;
02803 return RET_FAILED;
02804 }
02805
02806 err = dc1394_external_trigger_set_mode(m_cam, DC1394_TRIGGER_MODE_0);
02807 if (err!=DC1394_SUCCESS)
02808 {
02809 std::cerr << "ERROR - AVTPikeCam::SetProperty:" << std::endl;
02810 std::cerr << "\t ... Failed to set trigger mode." << std::endl;
02811 std::cerr << "\t ... " << dc1394_error_get_string(err) << std::endl;
02812 return RET_FAILED;
02813 }
02814 #else
02815 UINT32 err;
02816 UINT32 nOn=1;
02817 UINT32 nPolarity=1;
02818 UINT32 nSrc=0;
02819 UINT32 nMode=0;
02820 UINT32 nParm=0;
02821 UINT32 triggerValue;
02822 triggerValue=MAKETRIGGER(nOn, nPolarity, nSrc, nMode, nParm);
02823 err = m_cam.SetParameter(FGP_TRIGGER,triggerValue);
02824 if(err!=FCE_NOERROR)
02825 {
02826 std::cerr << "ERROR - AVTPikeCam::SetProperty:" << std::endl;
02827 std::cerr << "\t ... Could not set Slave trigger mode ( error " << err << " )" << std::endl;
02828 return RET_FAILED;
02829 }
02830 #endif
02831 }
02832
02833
02834
02835
02836 cameraProperty.propertyID = ipa_CameraSensors::PROP_ISO_SPEED;
02837 std::string sIsoSpeed = "";
02838 m_ColorCameraParameters.m_IsoSpeed.clear();
02839 m_ColorCameraParameters.m_IsoSpeed.seekg(0);
02840 m_ColorCameraParameters.m_IsoSpeed >> sIsoSpeed;
02841 if (sIsoSpeed == "AUTO")
02842 {
02843 cameraProperty.propertyType = ipa_CameraSensors::TYPE_SPECIAL;
02844 cameraProperty.specialValue = VALUE_AUTO;
02845 }
02846 else if (sIsoSpeed == "DEFAULT")
02847 {
02848 cameraProperty.propertyType = ipa_CameraSensors::TYPE_SPECIAL;
02849 cameraProperty.specialValue = VALUE_DEFAULT;
02850 }
02851 else
02852 {
02853 cameraProperty.propertyType = (ipa_CameraSensors::TYPE_UNSIGNED | ipa_CameraSensors::TYPE_LONG);
02854 m_ColorCameraParameters.m_IsoSpeed.clear();
02855 m_ColorCameraParameters.m_IsoSpeed.seekg(0);
02856 m_ColorCameraParameters.m_IsoSpeed >> cameraProperty.u_longData;
02857 }
02858
02859 if (SetProperty(&cameraProperty) & ipa_CameraSensors::RET_FAILED)
02860 {
02861 std::cout << "WARNING - AVTPikeCam::SetParameters:" << std::endl;
02862 std::cout << "\t ... Could not set ISO speed." << std::endl;
02863 }
02864
02865
02866
02867
02868 cameraProperty.propertyID = ipa_CameraSensors::PROP_VIDEO_ALL;
02869 cameraProperty.propertyType = (ipa_CameraSensors::TYPE_VIDEO_FORMAT |
02870 ipa_CameraSensors::TYPE_VIDEO_MODE |
02871 ipa_CameraSensors::TYPE_COLOR_MODE);
02872 std::string sVideoFormat = "";
02873 std::string sVideoMode = "";
02874 std::string sColorMode = "";
02875
02876 m_ColorCameraParameters.m_VideoFormat.clear();
02877 m_ColorCameraParameters.m_VideoFormat.seekg(0);
02878 m_ColorCameraParameters.m_VideoFormat >> sVideoFormat;
02879 if (sVideoFormat == "FORMAT_DEFAULT")
02880 {
02881 cameraProperty.videoFormat = FORMAT_DEFAULT;
02882 }
02883 else if (sVideoFormat == "FORMAT_0")
02884 {
02885 cameraProperty.videoFormat = FORMAT_0;
02886 }
02887 else if (sVideoFormat == "FORMAT_1")
02888 {
02889 cameraProperty.videoFormat = FORMAT_1;
02890 }
02891 else if (sVideoFormat == "FORMAT_2")
02892 {
02893 cameraProperty.videoFormat = FORMAT_2;
02894 }
02895 else if (sVideoFormat == "FORMAT_7")
02896 {
02897 cameraProperty.videoFormat = FORMAT_7;
02898 }
02899
02900 m_ColorCameraParameters.m_VideoMode.clear();
02901 m_ColorCameraParameters.m_VideoMode.seekg(0);
02902 m_ColorCameraParameters.m_VideoMode >> sVideoMode;
02903 if (sVideoMode == "MODE_DEFAULT")
02904 {
02905 cameraProperty.videoMode = MODE_DEFAULT;
02906 }
02907 else if (sVideoMode == "MODE_0")
02908 {
02909 cameraProperty.videoMode = MODE_0;
02910 }
02911 else if (sVideoMode == "MODE_1")
02912 {
02913 cameraProperty.videoMode = MODE_1;
02914 }
02915 else if (sVideoMode == "MODE_2")
02916 {
02917 cameraProperty.videoMode = MODE_2;
02918 }
02919 else if (sVideoMode == "MODE_3")
02920 {
02921 cameraProperty.videoMode = MODE_3;
02922 }
02923 else if (sVideoMode == "MODE_4")
02924 {
02925 cameraProperty.videoMode = MODE_4;
02926 }
02927 else if (sVideoMode == "MODE_5")
02928 {
02929 cameraProperty.videoMode = MODE_5;
02930 }
02931 else if (sVideoMode == "MODE_6")
02932 {
02933 cameraProperty.videoMode = MODE_6;
02934 }
02935 else if (sVideoMode == "MODE_7")
02936 {
02937 cameraProperty.videoMode = MODE_7;
02938 }
02939
02940 m_ColorCameraParameters.m_ColorMode.clear();
02941 m_ColorCameraParameters.m_ColorMode.seekg(0);
02942 m_ColorCameraParameters.m_ColorMode >> sColorMode;
02943 if (sColorMode == "COLOR_DEFAULT")
02944 {
02945 cameraProperty.colorMode = COLOR_DEFAULT;
02946 }
02947 else if (sColorMode == "COLOR_YUV422")
02948 {
02949 cameraProperty.colorMode = COLOR_YUV422;
02950 }
02951 else if (sColorMode == "COLOR_YUV411")
02952 {
02953 cameraProperty.colorMode = COLOR_YUV411;
02954 }
02955 else if (sColorMode == "COLOR_RGB8")
02956 {
02957 cameraProperty.colorMode = COLOR_RGB8;
02958 }
02959 else if (sColorMode == "COLOR_RGB16S")
02960 {
02961 cameraProperty.colorMode = COLOR_RGB16S;
02962 }
02963 else if (sColorMode == "COLOR_RGB16")
02964 {
02965 cameraProperty.colorMode = COLOR_RGB16;
02966 }
02967 else if (sColorMode == "COLOR_MONO8")
02968 {
02969 cameraProperty.colorMode = COLOR_MONO8;
02970 }
02971 else if (sColorMode == "COLOR_MONO16")
02972 {
02973 cameraProperty.colorMode = COLOR_MONO16;
02974 }
02975 else if (sColorMode == "COLOR_MONO16S")
02976 {
02977 cameraProperty.colorMode = COLOR_MONO16S;
02978 }
02979 else if (sColorMode == "COLOR_RAW8")
02980 {
02981 cameraProperty.colorMode = COLOR_RAW8;
02982 }
02983 else if (sColorMode == "COLOR_RAW16")
02984 {
02985 cameraProperty.colorMode = COLOR_RAW16;
02986 }
02987
02988 if (SetProperty(&cameraProperty) & ipa_CameraSensors::RET_FAILED)
02989 {
02990 std::cout << "WARNING - AVTPikeCam::SetParameters:" << std::endl;
02991 std::cout << "\t ... Could not set video format, video mode and color mode" << std::endl;
02992 }
02993
02994
02995
02996
02997
02998 cameraProperty.propertyID = ipa_CameraSensors::PROP_RESOLUTION;
02999 std::string sImageWidth = "";
03000 std::string sImageHeight = "";
03001 int iImageWidth = -1;
03002 int iImageHeight = -1;
03003
03004 m_ColorCameraParameters.m_ImageWidth.clear();
03005 m_ColorCameraParameters.m_ImageWidth.seekg(0);
03006 m_ColorCameraParameters.m_ImageWidth >> sImageWidth;
03007 m_ColorCameraParameters.m_ImageHeight.clear();
03008 m_ColorCameraParameters.m_ImageHeight.seekg(0);
03009 m_ColorCameraParameters.m_ImageHeight >> sImageHeight;
03010
03011 if (sImageWidth == "AUTO" || sImageHeight == "Auto")
03012 {
03013 cameraProperty.propertyType = ipa_CameraSensors::TYPE_SPECIAL;
03014 cameraProperty.specialValue = VALUE_AUTO;
03015 }
03016 else if (sImageWidth == "DEFAULT" || sImageHeight == "DEFAULT")
03017 {
03018 cameraProperty.propertyType = ipa_CameraSensors::TYPE_SPECIAL;
03019 cameraProperty.specialValue = VALUE_DEFAULT;
03020 }
03021 else
03022 {
03023 cameraProperty.propertyType = (ipa_CameraSensors::TYPE_UNSIGNED | ipa_CameraSensors::TYPE_LONG);
03024 m_ColorCameraParameters.m_ImageWidth.clear();
03025 m_ColorCameraParameters.m_ImageWidth.seekg(0);
03026 m_ColorCameraParameters.m_ImageWidth >> iImageWidth;
03027 m_ColorCameraParameters.m_ImageHeight.clear();
03028 m_ColorCameraParameters.m_ImageHeight.seekg(0);
03029 m_ColorCameraParameters.m_ImageHeight >> iImageHeight;
03030 }
03031
03032 if (SetProperty(&cameraProperty) & ipa_CameraSensors::RET_FAILED)
03033 {
03034 std::cout << "WARNING - AVTPikeCam::SetParameters:" << std::endl;
03035 std::cout << "\t ... Could not set resolution." << std::endl;
03036 }
03037
03038
03039
03040
03041
03042 cameraProperty.propertyID = ipa_CameraSensors::PROP_EXPOSURE_TIME;
03043 std::string sExposureTime = "";
03044
03045 m_ColorCameraParameters.m_ExposureTime.clear();
03046 m_ColorCameraParameters.m_ExposureTime.seekg(0);
03047 m_ColorCameraParameters.m_ExposureTime >> sExposureTime;
03048
03049 if (sExposureTime == "AUTO")
03050 {
03051 cameraProperty.propertyType = ipa_CameraSensors::TYPE_SPECIAL;
03052 cameraProperty.specialValue = VALUE_AUTO;
03053 }
03054 else if (sExposureTime == "DEFAULT")
03055 {
03056 cameraProperty.propertyType = ipa_CameraSensors::TYPE_SPECIAL;
03057 cameraProperty.specialValue = VALUE_DEFAULT;
03058 }
03059 else
03060 {
03061 cameraProperty.propertyType = (ipa_CameraSensors::TYPE_UNSIGNED | ipa_CameraSensors::TYPE_LONG);
03062 m_ColorCameraParameters.m_ExposureTime.clear();
03063 m_ColorCameraParameters.m_ExposureTime.seekg(0);
03064 m_ColorCameraParameters.m_ExposureTime >> cameraProperty.u_longData;
03065 }
03066
03067 if (SetProperty(&cameraProperty) & ipa_CameraSensors::RET_FAILED)
03068 {
03069 std::cout << "WARNING - AVTPikeCam::SetParameters:" << std::endl;
03070 std::cout << "\t ... Could not set auto exposure." << std::endl;
03071 }
03072
03073
03074
03075
03076 cameraProperty.propertyID = ipa_CameraSensors::PROP_FRAME_RATE;
03077 std::string sFrameRate = "";
03078
03079 m_ColorCameraParameters.m_FrameRate.clear();
03080 m_ColorCameraParameters.m_FrameRate.seekg(0);
03081 m_ColorCameraParameters.m_FrameRate >> sFrameRate;
03082
03083 if (sFrameRate == "AUTO")
03084 {
03085 cameraProperty.propertyType = ipa_CameraSensors::TYPE_SPECIAL;
03086 cameraProperty.specialValue = VALUE_AUTO;
03087 }
03088 else if (sFrameRate == "DEFAULT")
03089 {
03090 cameraProperty.propertyType = ipa_CameraSensors::TYPE_SPECIAL;
03091 cameraProperty.specialValue = VALUE_DEFAULT;
03092 }
03093 else
03094 {
03095 cameraProperty.propertyType = ipa_CameraSensors::TYPE_FLOAT;
03096 m_ColorCameraParameters.m_FrameRate.clear();
03097 m_ColorCameraParameters.m_FrameRate.seekg(0);
03098 m_ColorCameraParameters.m_FrameRate >> cameraProperty.floatData;
03099 }
03100
03101 if (SetProperty(&cameraProperty) & ipa_CameraSensors::RET_FAILED)
03102 {
03103 std::cout << "WARNING - AVTPikeCam::SetParameters:" << std::endl;
03104 std::cout << "\t ... Could not set frame rate." << std::endl;
03105 }
03106
03107
03108
03109
03110
03111 cameraProperty.propertyID = ipa_CameraSensors::PROP_SHUTTER;
03112 std::string sShutter = "";
03113
03114 m_ColorCameraParameters.m_Shutter.clear();
03115 m_ColorCameraParameters.m_Shutter.seekg(0);
03116 m_ColorCameraParameters.m_Shutter >> sShutter;
03117
03118 if (sShutter == "AUTO")
03119 {
03120 cameraProperty.propertyType = ipa_CameraSensors::TYPE_SPECIAL;
03121 cameraProperty.specialValue = VALUE_AUTO;
03122 }
03123 else if (sShutter == "DEFAULT")
03124 {
03125 cameraProperty.propertyType = ipa_CameraSensors::TYPE_SPECIAL;
03126 cameraProperty.specialValue = VALUE_DEFAULT;
03127 }
03128 else
03129 {
03130 cameraProperty.propertyType = (ipa_CameraSensors::TYPE_UNSIGNED | ipa_CameraSensors::TYPE_LONG);
03131 m_ColorCameraParameters.m_Shutter.clear();
03132 m_ColorCameraParameters.m_Shutter.seekg(0);
03133 m_ColorCameraParameters.m_Shutter >> cameraProperty.u_longData;
03134 }
03135
03136 if (SetProperty(&cameraProperty) & ipa_CameraSensors::RET_FAILED)
03137 {
03138 std::cout << "WARNING - AVTPikeCam::SetParameters:" << std::endl;
03139 std::cout << "\t ... Could not set shutter." << std::endl;
03140 }
03141
03142
03143
03144
03145 cameraProperty.propertyID = ipa_CameraSensors::PROP_BRIGHTNESS;
03146 std::string sBrightness = "";
03147
03148 m_ColorCameraParameters.m_Brightness.clear();
03149 m_ColorCameraParameters.m_Brightness.seekg(0);
03150 m_ColorCameraParameters.m_Brightness >> sBrightness;
03151
03152 if (sBrightness == "AUTO")
03153 {
03154 cameraProperty.propertyType = ipa_CameraSensors::TYPE_SPECIAL;
03155 cameraProperty.specialValue = VALUE_AUTO;
03156 }
03157 else if (sBrightness == "DEFAULT")
03158 {
03159 cameraProperty.propertyType = ipa_CameraSensors::TYPE_SPECIAL;
03160 cameraProperty.specialValue = VALUE_DEFAULT;
03161 }
03162 else
03163 {
03164 cameraProperty.propertyType = (ipa_CameraSensors::TYPE_UNSIGNED | ipa_CameraSensors::TYPE_LONG);
03165 m_ColorCameraParameters.m_Brightness.clear();
03166 m_ColorCameraParameters.m_Brightness.seekg(0);
03167 m_ColorCameraParameters.m_Brightness >> cameraProperty.u_longData;
03168 }
03169
03170 if (SetProperty(&cameraProperty) & ipa_CameraSensors::RET_FAILED)
03171 {
03172 std::cout << "WARNING - AVTPikeCam::SetParameters:" << std::endl;
03173 std::cout << "\t ... Could not set brightness." << std::endl;
03174 }
03175
03176
03177
03178
03179 cameraProperty.propertyID = ipa_CameraSensors::PROP_GAIN;
03180 std::string sGain = "";
03181
03182 m_ColorCameraParameters.m_Gain.clear();
03183 m_ColorCameraParameters.m_Gain.seekg(0);
03184 m_ColorCameraParameters.m_Gain >> sGain;
03185
03186 if (sGain == "AUTO")
03187 {
03188 cameraProperty.propertyType = ipa_CameraSensors::TYPE_SPECIAL;
03189 cameraProperty.specialValue = VALUE_AUTO;
03190 }
03191 else if (sGain == "DEFAULT")
03192 {
03193 cameraProperty.propertyType = ipa_CameraSensors::TYPE_SPECIAL;
03194 cameraProperty.specialValue = VALUE_DEFAULT;
03195 }
03196 else
03197 {
03198 cameraProperty.propertyType = (ipa_CameraSensors::TYPE_UNSIGNED | ipa_CameraSensors::TYPE_LONG);
03199 m_ColorCameraParameters.m_Gain.clear();
03200 m_ColorCameraParameters.m_Gain.seekg(0);
03201 m_ColorCameraParameters.m_Gain >> cameraProperty.u_longData;
03202 }
03203
03204 if (SetProperty(&cameraProperty) & ipa_CameraSensors::RET_FAILED)
03205 {
03206 std::cout << "WARNING - AVTPikeCam::SetParameters:" << std::endl;
03207 std::cout << "\t ... Could not set gain." << std::endl;
03208 }
03209
03210
03211
03212
03213 cameraProperty.propertyID = ipa_CameraSensors::PROP_GAMMA;
03214 std::string sGamma = "";
03215
03216 m_ColorCameraParameters.m_Gamma.clear();
03217 m_ColorCameraParameters.m_Gamma.seekg(0);
03218 m_ColorCameraParameters.m_Gamma >> sGamma;
03219
03220 if (sGamma == "AUTO")
03221 {
03222 cameraProperty.propertyType = ipa_CameraSensors::TYPE_SPECIAL;
03223 cameraProperty.specialValue = VALUE_AUTO;
03224 }
03225 else if (sGamma == "DEFAULT")
03226 {
03227 cameraProperty.propertyType = ipa_CameraSensors::TYPE_SPECIAL;
03228 cameraProperty.specialValue = VALUE_DEFAULT;
03229 }
03230 else
03231 {
03232 cameraProperty.propertyType = (ipa_CameraSensors::TYPE_UNSIGNED | ipa_CameraSensors::TYPE_LONG);
03233 m_ColorCameraParameters.m_Gamma.clear();
03234 m_ColorCameraParameters.m_Gamma.seekg(0);
03235 m_ColorCameraParameters.m_Gamma >> cameraProperty.u_longData;
03236 }
03237
03238 if (SetProperty(&cameraProperty) & ipa_CameraSensors::RET_FAILED)
03239 {
03240 std::cout << "WARNING - AVTPikeCam::SetParameters:" << std::endl;
03241 std::cout << "\t ... Could not set gamma." << std::endl;
03242 }
03243
03244
03245
03246
03247 cameraProperty.propertyID = ipa_CameraSensors::PROP_HUE;
03248 std::string sHue = "";
03249
03250 m_ColorCameraParameters.m_Hue.clear();
03251 m_ColorCameraParameters.m_Hue.seekg(0);
03252 m_ColorCameraParameters.m_Hue >> sHue;
03253
03254 if (sHue == "AUTO")
03255 {
03256 cameraProperty.propertyType = ipa_CameraSensors::TYPE_SPECIAL;
03257 cameraProperty.specialValue = VALUE_AUTO;
03258 }
03259 else if (sHue == "DEFAULT")
03260 {
03261 cameraProperty.propertyType = ipa_CameraSensors::TYPE_SPECIAL;
03262 cameraProperty.specialValue = VALUE_DEFAULT;
03263 }
03264 else
03265 {
03266 cameraProperty.propertyType = (ipa_CameraSensors::TYPE_UNSIGNED | ipa_CameraSensors::TYPE_LONG);
03267 m_ColorCameraParameters.m_Hue.clear();
03268 m_ColorCameraParameters.m_Hue.seekg(0);
03269 m_ColorCameraParameters.m_Hue >> cameraProperty.u_longData;
03270 }
03271
03272 if (SetProperty(&cameraProperty) & ipa_CameraSensors::RET_FAILED)
03273 {
03274 std::cout << "WARNING - AVTPikeCam::SetParameters:" << std::endl;
03275 std::cout << "\t ... Could not set hue." << std::endl;
03276 }
03277
03278
03279
03280
03281 cameraProperty.propertyID = ipa_CameraSensors::PROP_SATURATION;
03282 std::string sSaturation = "";
03283
03284 m_ColorCameraParameters.m_Saturation.clear();
03285 m_ColorCameraParameters.m_Saturation.seekg(0);
03286 m_ColorCameraParameters.m_Saturation >> sSaturation;
03287
03288 if (sSaturation == "AUTO")
03289 {
03290 cameraProperty.propertyType = ipa_CameraSensors::TYPE_SPECIAL;
03291 cameraProperty.specialValue = VALUE_AUTO;
03292 }
03293 else if (sSaturation == "DEFAULT")
03294 {
03295 cameraProperty.propertyType = ipa_CameraSensors::TYPE_SPECIAL;
03296 cameraProperty.specialValue = VALUE_DEFAULT;
03297 }
03298 else
03299 {
03300 cameraProperty.propertyType = (ipa_CameraSensors::TYPE_UNSIGNED | ipa_CameraSensors::TYPE_LONG);
03301 m_ColorCameraParameters.m_Saturation.clear();
03302 m_ColorCameraParameters.m_Saturation.seekg(0);
03303 m_ColorCameraParameters.m_Saturation >> cameraProperty.u_longData;
03304 }
03305
03306 if (SetProperty(&cameraProperty) & ipa_CameraSensors::RET_FAILED)
03307 {
03308 std::cout << "WARNING - AVTPikeCam::SetParameters:" << std::endl;
03309 std::cout << "\t ... Could not set saturation." << std::endl;
03310 }
03311
03312
03313
03314
03315 cameraProperty.propertyID = ipa_CameraSensors::PROP_WHITE_BALANCE_U;
03316 std::string sWhiteBalanceU = "";
03317
03318 m_ColorCameraParameters.m_WhiteBalanceU.clear();
03319 m_ColorCameraParameters.m_WhiteBalanceU.seekg(0);
03320 m_ColorCameraParameters.m_WhiteBalanceU >> sWhiteBalanceU;
03321
03322 if (sWhiteBalanceU == "AUTO")
03323 {
03324 cameraProperty.propertyType = ipa_CameraSensors::TYPE_SPECIAL;
03325 cameraProperty.specialValue = VALUE_AUTO;
03326 }
03327 else if (sWhiteBalanceU == "DEFAULT")
03328 {
03329 cameraProperty.propertyType = ipa_CameraSensors::TYPE_SPECIAL;
03330 cameraProperty.specialValue = VALUE_DEFAULT;
03331 }
03332 else
03333 {
03334 cameraProperty.propertyType = (ipa_CameraSensors::TYPE_UNSIGNED | ipa_CameraSensors::TYPE_LONG);
03335 m_ColorCameraParameters.m_WhiteBalanceU.clear();
03336 m_ColorCameraParameters.m_WhiteBalanceU.seekg(0);
03337 m_ColorCameraParameters.m_WhiteBalanceU >> cameraProperty.u_longData;
03338 }
03339
03340 if (SetProperty(&cameraProperty) & ipa_CameraSensors::RET_FAILED)
03341 {
03342 std::cout << "WARNING - AVTPikeCam::SetParameters:" << std::endl;
03343 std::cout << "\t ... Could not set white balance U." << std::endl;
03344 }
03345
03346
03347
03348
03349 cameraProperty.propertyID = ipa_CameraSensors::PROP_WHITE_BALANCE_V;
03350 std::string sWhiteBalanceV = "";
03351
03352 m_ColorCameraParameters.m_WhiteBalanceV.clear();
03353 m_ColorCameraParameters.m_WhiteBalanceV.seekg(0);
03354 m_ColorCameraParameters.m_WhiteBalanceV >> sWhiteBalanceV;
03355
03356 if (sWhiteBalanceV == "AUTO")
03357 {
03358 cameraProperty.propertyType = ipa_CameraSensors::TYPE_SPECIAL;
03359 cameraProperty.specialValue = VALUE_AUTO;
03360 }
03361 else if (sWhiteBalanceV == "DEFAULT")
03362 {
03363 cameraProperty.propertyType = ipa_CameraSensors::TYPE_SPECIAL;
03364 cameraProperty.specialValue = VALUE_DEFAULT;
03365 }
03366 else
03367 {
03368 cameraProperty.propertyType = (ipa_CameraSensors::TYPE_UNSIGNED | ipa_CameraSensors::TYPE_LONG);
03369 m_ColorCameraParameters.m_WhiteBalanceV.clear();
03370 m_ColorCameraParameters.m_WhiteBalanceV.seekg(0);
03371 m_ColorCameraParameters.m_WhiteBalanceV >> cameraProperty.u_longData;
03372 }
03373
03374 if (SetProperty(&cameraProperty) & ipa_CameraSensors::RET_FAILED)
03375 {
03376 std::cout << "WARNING - AVTPikeCam::SetParameters:" << std::endl;
03377 std::cout << "\t ... Could not set white balance V." << std::endl;
03378 }
03379 return RET_OK;
03380 }
03381
03382 unsigned long AVTPikeCam::LoadParameters(const char* filename, int cameraIndex)
03383 {
03384 boost::shared_ptr<TiXmlDocument> p_configXmlDocument (new TiXmlDocument( filename ));
03385
03386 if (!p_configXmlDocument->LoadFile())
03387 {
03388 std::cerr << "ERROR - AVTPikeCam::LoadParameters:" << std::endl;
03389 std::cerr << "\t ... Error while loading xml configuration file (Check filename and syntax of the file):\n";
03390 std::cerr << "\t ... '" << filename << "'" << std::endl;
03391 return (RET_FAILED | RET_FAILED_OPEN_FILE);
03392 }
03393 std::cout << "INFO - AVTPikeCam::LoadParameters:" << std::endl;
03394 std::cout << "\t ... Parsing xml configuration file:" << std::endl;
03395 std::cout << "\t ... '" << filename << "'" << std::endl;
03396
03397 if ( p_configXmlDocument )
03398 {
03399
03400
03401
03402
03403
03404 TiXmlElement *p_xmlElement_Root = NULL;
03405 p_xmlElement_Root = p_configXmlDocument->FirstChildElement( "LibCameraSensors" );
03406 if ( p_xmlElement_Root )
03407 {
03408
03409
03410
03411
03412
03413 TiXmlElement *p_xmlElement_Root_AVTPikeCam = NULL;
03414 std::stringstream ss;
03415 ss << "AVTPikeCam_" << cameraIndex;
03416 p_xmlElement_Root_AVTPikeCam = p_xmlElement_Root->FirstChildElement( ss.str() );
03417 if ( p_xmlElement_Root_AVTPikeCam )
03418 {
03419
03420
03421
03422
03423
03424 TiXmlElement *p_xmlElement_Child = NULL;
03425 std::string tempString;
03426 p_xmlElement_Child = p_xmlElement_Root_AVTPikeCam->FirstChildElement( "GUID" );
03427 if ( p_xmlElement_Child )
03428 {
03429
03430 if ( p_xmlElement_Child->QueryValueAttribute( "high", &tempString ) != TIXML_SUCCESS)
03431 {
03432 std::cerr << "ERROR - AVTPikeCam::LoadParameters:" << std::endl;
03433 std::cerr << "\t ... Can't find attribute 'high' of tag 'GUID'." << std::endl;
03434 return (RET_FAILED | RET_XML_ATTR_NOT_FOUND);
03435 }
03436 m_GUID.High = strtoul(tempString.c_str(),NULL,16);
03437
03438
03439 if ( p_xmlElement_Child->QueryValueAttribute( "low", &tempString ) != TIXML_SUCCESS)
03440 {
03441 std::cerr << "ERROR - AVTPikeCam::LoadParameters:" << std::endl;
03442 std::cerr << "\t ... Can't find attribute 'low' of tag 'GUID'." << std::endl;
03443 return (RET_FAILED | RET_XML_ATTR_NOT_FOUND);
03444 }
03445 m_GUID.Low = strtoul(tempString.c_str(),NULL,16);
03446 }
03447 else
03448 {
03449 std::cerr << "ERROR - AVTPikeCam::LoadParameters:" << std::endl;
03450 std::cerr << "\t ... Can't find tag 'GUID'." << std::endl;
03451 return (RET_FAILED | RET_XML_TAG_NOT_FOUND);
03452 }
03453
03454
03455
03456
03457 p_xmlElement_Child = NULL;
03458 p_xmlElement_Child = p_xmlElement_Root_AVTPikeCam->FirstChildElement( "Role" );
03459 if ( p_xmlElement_Child )
03460 {
03461
03462 if ( p_xmlElement_Child->QueryValueAttribute( "value", &tempString ) != TIXML_SUCCESS)
03463 {
03464 std::cerr << "ERROR - AVTPikeCam::LoadParameters:" << std::endl;
03465 std::cerr << "\t ... Can't find attribute 'value' of tag 'Role'." << std::endl;
03466 return (RET_FAILED | RET_XML_ATTR_NOT_FOUND);
03467 }
03468
03469 if (tempString == "MASTER") m_ColorCameraParameters.m_CameraRole = MASTER;
03470 else if (tempString == "SLAVE") m_ColorCameraParameters.m_CameraRole = SLAVE;
03471 else
03472 {
03473 std::cerr << "ERROR - AVTPikeCam::LoadParameters:" << std::endl;
03474 std::cerr << "\t ... Role " << tempString << " unspecified." << std::endl;
03475 return (RET_FAILED);
03476 }
03477
03478 }
03479 else
03480 {
03481 std::cerr << "ERROR - AVTPikeCam::LoadParameters:" << std::endl;
03482 std::cerr << "\t ... Can't find tag 'Role'." << std::endl;
03483 return (RET_FAILED | RET_XML_TAG_NOT_FOUND);
03484 }
03485
03486
03487
03488
03489
03490 p_xmlElement_Child = NULL;
03491 p_xmlElement_Child = p_xmlElement_Root_AVTPikeCam->FirstChildElement( "VideoFormat" );
03492 if ( p_xmlElement_Child )
03493 {
03494
03495 if ( p_xmlElement_Child->QueryValueAttribute( "type", &tempString) != TIXML_SUCCESS)
03496 {
03497 std::cerr << "ERROR - AVTPikeCam::LoadParameters:" << std::endl;
03498 std::cerr << "\t ... Can't find attribute 'type' of tag 'VideoFormat'." << std::endl;
03499 return (RET_FAILED | RET_XML_ATTR_NOT_FOUND);
03500 }
03501 else
03502 {
03503 m_ColorCameraParameters.m_VideoFormat.str( " " );
03504 m_ColorCameraParameters.m_VideoFormat.clear();
03505 m_ColorCameraParameters.m_VideoFormat << tempString;
03506 }
03507 }
03508 else
03509 {
03510 std::cerr << "ERROR - AVTPikeCam::LoadParameters:" << std::endl;
03511 std::cerr << "\t ... Can't find tag 'VideoFormat'." << std::endl;
03512 return (RET_FAILED | RET_XML_TAG_NOT_FOUND);
03513 }
03514
03515
03516
03517
03518
03519 p_xmlElement_Child = NULL;
03520 p_xmlElement_Child = p_xmlElement_Root_AVTPikeCam->FirstChildElement( "VideoMode" );
03521 if ( p_xmlElement_Child )
03522 {
03523
03524 if ( p_xmlElement_Child->QueryValueAttribute( "type", &tempString ) != TIXML_SUCCESS)
03525 {
03526 std::cerr << "ERROR - AVTPikeCam::LoadParameters:" << std::endl;
03527 std::cerr << "\t ... Can't find attribute 'type' of tag 'VideoMode'." << std::endl;
03528 return (RET_FAILED | RET_XML_ATTR_NOT_FOUND);
03529 }
03530 else
03531 {
03532 m_ColorCameraParameters.m_VideoMode.str( " " );
03533 m_ColorCameraParameters.m_VideoMode.clear();
03534 m_ColorCameraParameters.m_VideoMode << tempString;
03535 }
03536
03537 }
03538 else
03539 {
03540 std::cerr << "ERROR - AVTPikeCam::LoadParameters:" << std::endl;
03541 std::cerr << "\t ... Can't find tag 'VideoMode'." << std::endl;
03542 return (RET_FAILED | RET_XML_TAG_NOT_FOUND);
03543 }
03544
03545
03546
03547
03548
03549 p_xmlElement_Child = NULL;
03550 p_xmlElement_Child = p_xmlElement_Root_AVTPikeCam->FirstChildElement( "Resolution" );
03551 if ( p_xmlElement_Child )
03552 {
03553
03554 if ( p_xmlElement_Child->QueryValueAttribute("width", &tempString) != TIXML_SUCCESS)
03555 {
03556 std::cerr << "ERROR - AVTPikeCam::LoadParameters:" << std::endl;
03557 std::cerr << "\t ... Can't find attribute 'width' of tag 'Resolution'." << std::endl;
03558 return (RET_FAILED | RET_XML_ATTR_NOT_FOUND);
03559 }
03560 else
03561 {
03562 m_ColorCameraParameters.m_ImageWidth.str( " " );
03563 m_ColorCameraParameters.m_ImageWidth.clear();
03564 m_ColorCameraParameters.m_ImageWidth << tempString;
03565 }
03566
03567 if ( p_xmlElement_Child->QueryValueAttribute("height", &tempString) != TIXML_SUCCESS)
03568 {
03569 std::cerr << "ERROR - AVTPikeCam::LoadParameters:" << std::endl;
03570 std::cerr << "\t ... Can't find attribute 'height' of tag 'Resolution'." << std::endl;
03571 return (RET_FAILED | RET_XML_ATTR_NOT_FOUND);
03572 }
03573 else
03574 {
03575 m_ColorCameraParameters.m_ImageHeight.str( " " );
03576 m_ColorCameraParameters.m_ImageHeight.clear();
03577 m_ColorCameraParameters.m_ImageHeight << tempString;
03578 }
03579 }
03580 else
03581 {
03582 std::cerr << "ERROR - AVTPikeCam::LoadParameters:" << std::endl;
03583 std::cerr << "\t ... Can't find tag 'Resolution'." << std::endl;
03584 return (RET_FAILED | RET_XML_TAG_NOT_FOUND);
03585 }
03586
03587
03588
03589
03590
03591 p_xmlElement_Child = NULL;
03592 p_xmlElement_Child = p_xmlElement_Root_AVTPikeCam->FirstChildElement( "FrameRate" );
03593 if ( p_xmlElement_Child )
03594 {
03595
03596 if ( p_xmlElement_Child->QueryValueAttribute("fps", &tempString) != TIXML_SUCCESS)
03597 {
03598 std::cerr << "ERROR - AVTPikeCam::LoadParameters:" << std::endl;
03599 std::cerr << "\t ... Can't find attribute 'fps' of tag 'FrameRate'." << std::endl;
03600 return (RET_FAILED | RET_XML_ATTR_NOT_FOUND);
03601 }
03602 else
03603 {
03604 m_ColorCameraParameters.m_FrameRate.str( " " );
03605 m_ColorCameraParameters.m_FrameRate.clear();
03606 m_ColorCameraParameters.m_FrameRate << tempString;
03607 }
03608
03609 }
03610 else
03611 {
03612 std::cerr << "ERROR - AVTPikeCam::LoadParameters:" << std::endl;
03613 std::cerr << "\t ... Can't find tag 'FrameRate'." << std::endl;
03614 return (RET_FAILED | RET_XML_TAG_NOT_FOUND);
03615 }
03616
03617
03618
03619
03620
03621
03622 p_xmlElement_Child = NULL;
03623 p_xmlElement_Child = p_xmlElement_Root_AVTPikeCam->FirstChildElement( "ColorMode" );
03624 if ( p_xmlElement_Child )
03625 {
03626
03627 if ( p_xmlElement_Child->QueryValueAttribute( "type", &tempString ) != TIXML_SUCCESS)
03628 {
03629 std::cerr << "ERROR - AVTPikeCam::LoadParameters:" << std::endl;
03630 std::cerr << "\t ... Can't find attribute 'type' of tag 'ColorMode'." << std::endl;
03631 return (RET_FAILED | RET_XML_ATTR_NOT_FOUND);
03632 }
03633 else
03634 {
03635 m_ColorCameraParameters.m_ColorMode.str( " " );
03636 m_ColorCameraParameters.m_ColorMode.clear();
03637 m_ColorCameraParameters.m_ColorMode << tempString;
03638 }
03639
03640 }
03641 else
03642 {
03643 std::cerr << "ERROR - AVTPikeCam::LoadParameters:" << std::endl;
03644 std::cerr << "\t ... Can't find tag 'ColorMode'." << std::endl;
03645 return (RET_FAILED | RET_XML_TAG_NOT_FOUND);
03646 }
03647
03648
03649
03650
03651
03652 p_xmlElement_Child = NULL;
03653 p_xmlElement_Child = p_xmlElement_Root_AVTPikeCam->FirstChildElement( "IsoSpeed" );
03654 if ( p_xmlElement_Child )
03655 {
03656
03657 if ( p_xmlElement_Child->QueryValueAttribute( "speed", &tempString ) != TIXML_SUCCESS)
03658 {
03659 std::cerr << "ERROR - AVTPikeCam::LoadParameters:" << std::endl;
03660 std::cerr << "\t ... Can't find attribute 'speed' of tag 'IsoSpeed'." << std::endl;
03661 return (RET_FAILED | RET_XML_ATTR_NOT_FOUND);
03662 }
03663 else
03664 {
03665 m_ColorCameraParameters.m_IsoSpeed.str( " " );
03666 m_ColorCameraParameters.m_IsoSpeed.clear();
03667 m_ColorCameraParameters.m_IsoSpeed << tempString;
03668 }
03669
03670 }
03671 else
03672 {
03673 std::cerr << "ERROR - AVTPikeCam::LoadParameters:" << std::endl;
03674 std::cerr << "\t ... Can't find tag 'IsoSpeed'." << std::endl;
03675 return (RET_FAILED | RET_XML_TAG_NOT_FOUND);
03676 }
03677
03678
03679
03680
03681
03682 p_xmlElement_Child = NULL;
03683 p_xmlElement_Child = p_xmlElement_Root_AVTPikeCam->FirstChildElement( "OperationMode" );
03684 if ( p_xmlElement_Child )
03685 {
03686
03687 if ( p_xmlElement_Child->QueryValueAttribute( "value", &tempString ) != TIXML_SUCCESS)
03688 {
03689 std::cerr << "ERROR - AVTPikeCam::LoadParameters:" << std::endl;
03690 std::cerr << "\t ... Can't find attribute 'value' of tag 'OperationMode'." << std::endl;
03691 return (RET_FAILED | RET_XML_ATTR_NOT_FOUND);
03692 }
03693 if (tempString == "A") m_operationMode_B = false;
03694 else if (tempString == "B") m_operationMode_B = true;
03695 else
03696 {
03697 std::cerr << "ERROR - AVTPikeCam::LoadParameters:" << std::endl;
03698 std::cerr << "\t ... FireWire operation mode " << tempString << " unspecified." << std::endl;
03699 return (RET_FAILED);
03700 }
03701 }
03702 else
03703 {
03704 std::cerr << "ERROR - AVTPikeCam::LoadParameters:" << std::endl;
03705 std::cerr << "\t ... Can't find tag 'OperationMode'." << std::endl;
03706 return (RET_FAILED | RET_XML_TAG_NOT_FOUND);
03707 }
03708
03709
03710
03711
03712
03713 p_xmlElement_Child = NULL;
03714 p_xmlElement_Child = p_xmlElement_Root_AVTPikeCam->FirstChildElement( "PROP_SHUTTER" );
03715 if ( p_xmlElement_Child )
03716 {
03717
03718 if ( p_xmlElement_Child->QueryValueAttribute( "value", &tempString) != TIXML_SUCCESS)
03719 {
03720 std::cerr << "ERROR - AVTPikeCam::LoadParameters:" << std::endl;
03721 std::cerr << "\t ... Can't find attribute 'value' of tag 'PROP_SHUTTER'." << std::endl;
03722 return (RET_FAILED | RET_XML_ATTR_NOT_FOUND);
03723 }
03724 else
03725 {
03726 m_ColorCameraParameters.m_Shutter.str( " " );
03727 m_ColorCameraParameters.m_Shutter.clear();
03728 m_ColorCameraParameters.m_Shutter << tempString;
03729 }
03730 }
03731 else
03732 {
03733 std::cerr << "ERROR - AVTPikeCam::LoadParameters:" << std::endl;
03734 std::cerr << "\t ... Can't find tag 'PROP_SHUTTER'." << std::endl;
03735 return (RET_FAILED | RET_XML_TAG_NOT_FOUND);
03736 }
03737
03738
03739
03740
03741
03742 p_xmlElement_Child = NULL;
03743 p_xmlElement_Child = p_xmlElement_Root_AVTPikeCam->FirstChildElement( "PROP_BRIGHTNESS" );
03744 if ( p_xmlElement_Child )
03745 {
03746
03747 if ( p_xmlElement_Child->QueryValueAttribute( "value", &tempString) != TIXML_SUCCESS)
03748 {
03749 std::cerr << "ERROR - AVTPikeCam::LoadParameters:" << std::endl;
03750 std::cerr << "\t ... Can't find attribute 'value' of tag 'PROP_BRIGHTNESS'." << std::endl;
03751 return (RET_FAILED | RET_XML_ATTR_NOT_FOUND);
03752 }
03753 else
03754 {
03755 m_ColorCameraParameters.m_Brightness.str( " " );
03756 m_ColorCameraParameters.m_Brightness.clear();
03757 m_ColorCameraParameters.m_Brightness << tempString;
03758 }
03759
03760 }
03761 else
03762 {
03763 std::cerr << "ERROR - AVTPikeCam::LoadParameters:" << std::endl;
03764 std::cerr << "\t ... Can't find tag 'PROP_BRIGHTNES'." << std::endl;
03765 return (RET_FAILED | RET_XML_TAG_NOT_FOUND);
03766 }
03767
03768
03769
03770
03771
03772 p_xmlElement_Child = NULL;
03773 p_xmlElement_Child = p_xmlElement_Root_AVTPikeCam->FirstChildElement( "PROP_EXPOSURE_TIME" );
03774 if ( p_xmlElement_Child )
03775 {
03776
03777 if ( p_xmlElement_Child->QueryValueAttribute( "value", &tempString) != TIXML_SUCCESS)
03778 {
03779 std::cerr << "ERROR - AVTPikeCam::LoadParameters:" << std::endl;
03780 std::cerr << "\t ... Can't find attribute 'value' of tag 'PROP_EXPOSURE_TIME'." << std::endl;
03781 return (RET_FAILED | RET_XML_ATTR_NOT_FOUND);
03782 }
03783 else
03784 {
03785 m_ColorCameraParameters.m_ExposureTime.str( " " );
03786 m_ColorCameraParameters.m_ExposureTime.clear();
03787 m_ColorCameraParameters.m_ExposureTime << tempString;
03788 }
03789
03790 }
03791 else
03792 {
03793 std::cerr << "ERROR - AVTPikeCam::LoadParameters:" << std::endl;
03794 std::cerr << "\t ... Can't find tag 'PROP_EXPOSURE_TIME'." << std::endl;
03795 return (RET_FAILED | RET_XML_TAG_NOT_FOUND);
03796 }
03797
03798
03799
03800
03801
03802 p_xmlElement_Child = NULL;
03803 p_xmlElement_Child = p_xmlElement_Root_AVTPikeCam->FirstChildElement("PROP_WHITE_BALANCE_U");
03804 if ( p_xmlElement_Child )
03805 {
03806
03807 if ( p_xmlElement_Child->QueryValueAttribute("value", &tempString) != TIXML_SUCCESS)
03808 {
03809 std::cerr << "ERROR - AVTPikeCam::LoadParameters:" << std::endl;
03810 std::cerr << "\t ... Can't find attribute 'value' of tag 'PROP_WHITE_BALANCE_U'." << std::endl;
03811 return (RET_FAILED | RET_XML_ATTR_NOT_FOUND);
03812 }
03813 else
03814 {
03815 m_ColorCameraParameters.m_WhiteBalanceU.str( " " );
03816 m_ColorCameraParameters.m_WhiteBalanceU.clear();
03817 m_ColorCameraParameters.m_WhiteBalanceU << tempString;
03818 }
03819 }
03820 else
03821 {
03822 std::cerr << "ERROR - AVTPikeCam::LoadParameters:" << std::endl;
03823 std::cerr << "\t ... Can't find tag 'PROP_WHITE_BALANCE_U'." << std::endl;
03824 return (RET_FAILED | RET_XML_TAG_NOT_FOUND);
03825 }
03826
03827
03828
03829
03830
03831 p_xmlElement_Child = NULL;
03832 p_xmlElement_Child = p_xmlElement_Root_AVTPikeCam->FirstChildElement( "PROP_WHITE_BALANCE_V" );
03833 if ( p_xmlElement_Child )
03834 {
03835
03836 if ( p_xmlElement_Child->QueryValueAttribute( "value", &tempString) != TIXML_SUCCESS)
03837 {
03838 std::cerr << "ERROR - AVTPikeCam::LoadParameters:" << std::endl;
03839 std::cerr << "\t ... Can't find attribute 'value' of tag 'PROP_WHITE_BALANCE_V'." << std::endl;
03840 return (RET_FAILED | RET_XML_ATTR_NOT_FOUND);
03841 }
03842 else
03843 {
03844 m_ColorCameraParameters.m_WhiteBalanceV.str( " " );
03845 m_ColorCameraParameters.m_WhiteBalanceV.clear();
03846 m_ColorCameraParameters.m_WhiteBalanceV << tempString;
03847 }
03848 }
03849 else
03850 {
03851 std::cerr << "ERROR - AVTPikeCam::LoadParameters:" << std::endl;
03852 std::cerr << "\t ... Can't find tag 'PROP_WHITE_BALANCE_V'." << std::endl;
03853 return (RET_FAILED | RET_XML_TAG_NOT_FOUND);
03854 }
03855
03856
03857
03858
03859
03860 p_xmlElement_Child = NULL;
03861 p_xmlElement_Child = p_xmlElement_Root_AVTPikeCam->FirstChildElement( "PROP_HUE" );
03862 if ( p_xmlElement_Child )
03863 {
03864
03865 if ( p_xmlElement_Child->QueryValueAttribute( "value", &tempString) != TIXML_SUCCESS)
03866 {
03867 std::cerr << "ERROR - AVTPikeCam::LoadParameters:" << std::endl;
03868 std::cerr << "\t ... Can't find attribute 'value' of tag 'PROP_HUE'." << std::endl;
03869 return (RET_FAILED | RET_XML_ATTR_NOT_FOUND);
03870 }
03871 else
03872 {
03873 m_ColorCameraParameters.m_Hue.str( " " );
03874 m_ColorCameraParameters.m_Hue.clear();
03875 m_ColorCameraParameters.m_Hue << tempString;
03876 }
03877 }
03878 else
03879 {
03880 std::cerr << "ERROR - AVTPikeCam::LoadParameters:" << std::endl;
03881 std::cerr << "\t ... Can't find tag 'PROP_HUE'." << std::endl;
03882 return (RET_FAILED | RET_XML_TAG_NOT_FOUND);
03883 }
03884
03885
03886
03887
03888
03889 p_xmlElement_Child = NULL;
03890 p_xmlElement_Child = p_xmlElement_Root_AVTPikeCam->FirstChildElement( "PROP_SATURATION" );
03891 if ( p_xmlElement_Child )
03892 {
03893
03894 if ( p_xmlElement_Child->QueryValueAttribute( "value", &tempString) != TIXML_SUCCESS)
03895 {
03896 std::cerr << "ERROR - AVTPikeCam::LoadParameters:" << std::endl;
03897 std::cerr << "\t ... Can't find attribute 'value' of tag 'PROP_SATURATION'." << std::endl;
03898 return (RET_FAILED | RET_XML_ATTR_NOT_FOUND);
03899 }
03900 else
03901 {
03902 m_ColorCameraParameters.m_Saturation.str( " " );
03903 m_ColorCameraParameters.m_Saturation.clear();
03904 m_ColorCameraParameters.m_Saturation << tempString;
03905 }
03906 }
03907 else
03908 {
03909 std::cerr << "ERROR - AVTPikeCam::LoadParameters:" << std::endl;
03910 std::cerr << "\t ... Can't find tag 'PROP_SATURATION'." << std::endl;
03911 return (RET_FAILED | RET_XML_TAG_NOT_FOUND);
03912 }
03913
03914
03915
03916
03917
03918 p_xmlElement_Child = NULL;
03919 p_xmlElement_Child = p_xmlElement_Root_AVTPikeCam->FirstChildElement( "PROP_GAMMA" );
03920 if ( p_xmlElement_Child )
03921 {
03922
03923 if ( p_xmlElement_Child->QueryValueAttribute( "value", &tempString) != TIXML_SUCCESS)
03924 {
03925 std::cerr << "AVTPikeCam::LoadParameters:" << std::endl;
03926 std::cerr << "\t ... Can't find attribute 'value' of tag 'PROP_GAMMA'." << std::endl;
03927 return (RET_FAILED | RET_XML_ATTR_NOT_FOUND);
03928 }
03929 else
03930 {
03931 m_ColorCameraParameters.m_Gamma.str( " " );
03932 m_ColorCameraParameters.m_Gamma.clear();
03933 m_ColorCameraParameters.m_Gamma << tempString;
03934 }
03935 }
03936 else
03937 {
03938 std::cerr << "AVTPikeCam::LoadParameters:" << std::endl;
03939 std::cerr << "\t ... Can't find tag 'PROP_GAMMA'." << std::endl;
03940 return (RET_FAILED | RET_XML_TAG_NOT_FOUND);
03941 }
03942
03943
03944
03945
03946
03947 p_xmlElement_Child = NULL;
03948 p_xmlElement_Child = p_xmlElement_Root_AVTPikeCam->FirstChildElement( "PROP_GAIN" );
03949 if ( p_xmlElement_Child )
03950 {
03951
03952 if ( p_xmlElement_Child->QueryValueAttribute( "value", &tempString) != TIXML_SUCCESS)
03953 {
03954 std::cerr << "ERROR - AVTPikeCam::LoadParameters:" << std::endl;
03955 std::cerr << "\t ... Can't find attribute 'value' of tag 'PROP_GAIN '." << std::endl;
03956 return (RET_FAILED | RET_XML_ATTR_NOT_FOUND);
03957 }
03958 else
03959 {
03960 m_ColorCameraParameters.m_Gain.str( " " );
03961 m_ColorCameraParameters.m_Gain.clear();
03962 m_ColorCameraParameters.m_Gain << tempString;
03963 }
03964 }
03965 else
03966 {
03967 std::cerr << "ERROR - AVTPikeCam::LoadParameters:" << std::endl;
03968 std::cerr << "\t ... Can't find tag 'PROP_EXPOSURE_TIME'." << std::endl;
03969 return (RET_FAILED | RET_XML_TAG_NOT_FOUND);
03970 }
03971 }
03972
03973
03974
03975
03976 else
03977 {
03978 std::cerr << "ERROR - AVTPikeCam::LoadParameters:" << std::endl;
03979 std::cerr << "\t ... Can't find tag '" << ss.str() << "'" << std::endl;
03980 return (RET_FAILED | RET_XML_TAG_NOT_FOUND);
03981 }
03982 }
03983
03984
03985
03986
03987 else
03988 {
03989 std::cerr << "ERROR - AVTPikeCam::LoadParameters:" << std::endl;
03990 std::cerr << "\t ... Can't find tag 'LibCameraSensors'." << std::endl;
03991 return (RET_FAILED | RET_XML_TAG_NOT_FOUND);
03992 }
03993 }
03994
03995
03996
03997 return RET_OK;
03998 }
03999