/*! Disable auto shutter and set the shutter to the requested value. \sa setAutoShutter() */ void vp1394CMUGrabber::setShutter(unsigned short shutter) { initCamera(); _shutter = shutter; unsigned short min,max; C1394CameraControl *Control; Control = camera->GetCameraControl(FEATURE_SHUTTER); Control->Inquire(); Control->GetRange(&min,&max); if (_shutter < min) { _shutter = min; std::cout << "vp1394CMUGrabber warning: Desired exposure time register value of IEEE 1394 camera number " << index << " can't be less than " << _shutter << std::endl; } else if (_shutter > max) { _shutter = max; std::cout << "vp1394CMUGrabber warning: Desired exposure time register value of IEEE 1394 camera number " << index << " can't be greater than " << _shutter << std::endl; } Control->SetAutoMode(false); if(Control->SetValue(_shutter) != CAM_SUCCESS) { std::cout << "vp1394CMUGrabber warning: Can't set exposure time register value of IEEE 1394 camera number " << index << std::endl; } }
/*! Disable auto gain and set the gain to the requested value. \sa setAutoGain() */ void vp1394CMUGrabber::setGain(unsigned short gain) { initCamera(); _gain = gain; unsigned short min,max; C1394CameraControl *Control; Control = camera->GetCameraControl(FEATURE_GAIN); Control->Inquire(); Control->GetRange(&min,&max); if (_gain < min) { _gain = min; std::cout << "vp1394CMUGrabber warning: Desired gain register value of IEEE 1394 camera number " << index << " can't be less than " << _gain << std::endl; } else if (_gain > max) { _gain = max; std::cout << "vp1394CMUGrabber warning: Desired gain register value of IEEE 1394 camera number " << index << " can't be greater than " << _gain << std::endl; } Control->SetAutoMode(false); if(Control->SetValue(_gain) != CAM_SUCCESS) { std::cout << "vp1394CMUGrabber warning: Can't set gain register value of IEEE 1394 camera number " << index << std::endl; } }
/*! Get the shutter min and max values. \sa setAutoShutter(), setShutter() */ void vp1394CMUGrabber::getShutterMinMax(unsigned short &min, unsigned short &max) { initCamera(); C1394CameraControl *Control; Control = camera->GetCameraControl(FEATURE_SHUTTER); Control->Inquire(); Control->GetRange(&min, &max); }
/*! Init the selected camera. */ void vp1394CMUGrabber::initCamera() { int camerror; unsigned long width, height; if (camera->CheckLink() != CAM_SUCCESS) { vpERROR_TRACE("C1394Camera error: Found no cameras on the 1394 bus"); throw (vpFrameGrabberException(vpFrameGrabberException::initializationError,"The is no detected camera") ); } camerror = camera->InitCamera(); if ( camerror != CAM_SUCCESS ) { switch (camerror) { case CAM_ERROR_NOT_INITIALIZED: vpERROR_TRACE("vp1394CMUGrabber error: No camera selected",index); throw (vpFrameGrabberException(vpFrameGrabberException::initializationError,"The is no selected camera") ); break; case CAM_ERROR_BUSY: vpERROR_TRACE("vp1394CMUGrabber error: The camera %i is busy",index); throw (vpFrameGrabberException(vpFrameGrabberException::initializationError,"The required camera is in use by other application") ); break; case CAM_ERROR: vpERROR_TRACE("vp1394CMUGrabber error: General I/O error when selecting camera number %i",index); throw (vpFrameGrabberException(vpFrameGrabberException::initializationError,"Resolve camera can not be used") ); break; } close(); } if (camera->Has1394b()) camera->Set1394b(TRUE); // Set format and mode if ((_format != -1) && (_mode != -1)) { if (!camera->HasVideoMode(_format, _mode)) { close(); vpERROR_TRACE("vp1394CMUGrabber error: The image format is not supported by the IEEE 1394 camera number %i",index); throw (vpFrameGrabberException(vpFrameGrabberException::settingError,"Video mode not supported") ); } if (camera->SetVideoFormat(_format) != CAM_SUCCESS) { close(); vpERROR_TRACE("vp1394CMUGrabber error: Can't set video format of IEEE 1394 camera number %i",index); throw (vpFrameGrabberException(vpFrameGrabberException::settingError,"Can't set video format") ); } if (camera->SetVideoMode(_mode) != CAM_SUCCESS) { close(); vpERROR_TRACE("vp1394CMUGrabber error: Can't set video mode of IEEE 1394 camera number %i",index); throw (vpFrameGrabberException(vpFrameGrabberException::settingError,"Can't set video mode") ); } } else { // Get the current format and mode _format = camera->GetVideoFormat(); _mode = camera->GetVideoMode(); } // Update the color coding _color = getVideoColorCoding(); //std::cout << "color coding: " << _color << std::endl; // Set fps if (_fps!=-1) { if (!camera->HasVideoFrameRate(_format,_mode,_fps)) { close(); vpERROR_TRACE("vp1394CMUGrabber error: The frame rate is not supported by the IEEE 1394 camera number %i for the selected image format",index); throw (vpFrameGrabberException(vpFrameGrabberException::settingError,"The frame rate is not supported") ); } if (camera->SetVideoFrameRate(_fps) != CAM_SUCCESS) { close(); vpERROR_TRACE("vp1394CMUGrabber error: Can't set video frame rate of IEEE 1394 camera number %i",index); throw (vpFrameGrabberException(vpFrameGrabberException::settingError,"Can't set video frame rate") ); } } // Set shutter and gain if ( _modeauto == false ) { unsigned short min,max; C1394CameraControl *Control; Control = camera->GetCameraControl(FEATURE_GAIN); Control->Inquire(); Control->GetRange(&min,&max); if (_gain<min) { _gain = min; std::cout << "vp1394CMUGrabber warning: Desired gain register value of IEEE 1394 camera number " << index << " can't be less than " << _gain << std::endl; } else if (_gain>max) { _gain = max; std::cout << "vp1394CMUGrabber warning: Desired gain register value of IEEE 1394 camera number " << index << " can't be greater than " << _gain << std::endl; } Control->SetAutoMode(false); if(Control->SetValue(_gain) != CAM_SUCCESS) { std::cout << "vp1394CMUGrabber warning: Can't set gain register value of IEEE 1394 camera number " << index << std::endl; } Control = camera->GetCameraControl(FEATURE_SHUTTER); Control->Inquire(); Control->GetRange(&min,&max); if (_shutter<min) { _shutter = min; std::cout << "vp1394CMUGrabber warning: Desired exposure time register value of IEEE 1394 camera number " << index << " can't be less than " << _shutter << std::endl; } else if (_shutter>max) { _shutter = max; std::cout << "vp1394CMUGrabber warning: Desired exposure time register value of IEEE 1394 camera number " << index << " can't be greater than " << _shutter << std::endl; } Control->SetAutoMode(false); if(Control->SetValue(_shutter) != CAM_SUCCESS) { std::cout << "vp1394CMUGrabber warning: Can't set exposure time register value of IEEE 1394 camera number " << index << std::endl; } } else { camera->GetCameraControl(FEATURE_SHUTTER)->SetAutoMode(true); camera->GetCameraControl(FEATURE_GAIN)->SetAutoMode(true); } // Set trigger off camera->GetCameraControlTrigger()->SetOnOff(false); camera->GetVideoFrameDimensions(&width,&height); this->height = height; this->width = width; init = true; } // end camera init