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