/*! Init the selected camera. */ void vp1394CMUGrabber::initCamera() { if (init == false) { int camerror; 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); // Get the current settings _format = camera->GetVideoFormat(); _mode = camera->GetVideoMode(); _color = getVideoColorCoding(); //std::cout << "format: " << _format << std::endl; //std::cout << "mode: " << _mode << std::endl; //std::cout << "color coding: " << _color << std::endl; // Set trigger off camera->GetCameraControlTrigger()->SetOnOff(false); unsigned long w, h; camera->GetVideoFrameDimensions(&w, &h); this->width = w; this->height = h; // start acquisition if (camera->StartImageAcquisition() != CAM_SUCCESS) { close(); vpERROR_TRACE("vp1394CMUGrabber error: Can't start image acquisition from IEEE 1394 camera number %i",index); throw (vpFrameGrabberException(vpFrameGrabberException::otherError, "Error while starting image acquisition") ); } init = true; } } // end camera init
/*! Set the camera format and video mode. This method has to be called before open(). \param format : Camera video format. \param mode : Camera video mode. See the following table for the correspondances between the input format and mode and the resulting video color coding. <TABLE BORDER="1"> <TR><TH> Format </TH><TH> Mode </TH><TH> (H) x (W) </TH><TH> Color </TH></TR> <TR><TD> 0 </TD><TD> 0 </TD><TD> 160 x 120 </TD><TD> YUV444 </TD></TR> <TR><TD> 0 </TD><TD> 1 </TD><TD> 320 x 240 </TD><TD> YUV422 </TD></TR> <TR><TD> 0 </TD><TD> 2 </TD><TD> 640 x 480 </TD><TD> YUV411 </TD></TR> <TR><TD> 0 </TD><TD> 3 </TD><TD> 640 x 480 </TD><TD> YUV422 </TD></TR> <TR><TD> 0 </TD><TD> 4 </TD><TD> 640 x 480 </TD><TD> RGB8 </TD></TR> <TR><TD> 0 </TD><TD> 5 </TD><TD> 640 x 480 </TD><TD> MONO8 </TD></TR> <TR><TD> 0 </TD><TD> 6 </TD><TD> 640 x 480 </TD><TD> MONO16 </TD></TR> <TR><TD> 1 </TD><TD> 0 </TD><TD> 800 x 600 </TD><TD> YUV422 </TD></TR> <TR><TD> 1 </TD><TD> 1 </TD><TD> 800 x 600 </TD><TD> RGB8 </TD></TR> <TR><TD> 1 </TD><TD> 2 </TD><TD> 800 x 600 </TD><TD> MONO8 </TD></TR> <TR><TD> 1 </TD><TD> 3 </TD><TD>1024 x 768 </TD><TD> YUV422 </TD></TR> <TR><TD> 1 </TD><TD> 4 </TD><TD>1024 x 768 </TD><TD> RGB8 </TD></TR> <TR><TD> 1 </TD><TD> 5 </TD><TD>1024 x 768 </TD><TD> MONO8 </TD></TR> <TR><TD> 1 </TD><TD> 6 </TD><TD> 800 x 600 </TD><TD> MONO16 </TD></TR> <TR><TD> 1 </TD><TD> 7 </TD><TD>1024 x 768 </TD><TD> MONO16 </TD></TR> <TR><TD> 2 </TD><TD> 0 </TD><TD>1280 x 960 </TD><TD> YUV422 </TD></TR> <TR><TD> 2 </TD><TD> 1 </TD><TD>1280 x 960 </TD><TD> RGB8 </TD></TR> <TR><TD> 2 </TD><TD> 2 </TD><TD>1280 x 960 </TD><TD> MONO8 </TD></TR> <TR><TD> 2 </TD><TD> 3 </TD><TD>1600 x 1200</TD><TD> YUV422 </TD></TR> <TR><TD> 2 </TD><TD> 4 </TD><TD>1600 x 1200</TD><TD> RGB8 </TD></TR> <TR><TD> 2 </TD><TD> 5 </TD><TD>1600 x 1200</TD><TD> MONO8 </TD></TR> <TR><TD> 2 </TD><TD> 6 </TD><TD>1280 x 960 </TD><TD> MONO16 </TD></TR> <TR><TD> 2 </TD><TD> 7 </TD><TD>1600 x 1200</TD><TD> MONO16 </TD></TR> </TABLE> */ void vp1394CMUGrabber::setVideoMode( unsigned long format, unsigned long mode ) { initCamera(); _format = format ; _mode = mode ; // 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->IsAcquiring()) { // stop acquisition if (camera->StopImageAcquisition() != CAM_SUCCESS) { close(); vpERROR_TRACE("vp1394CMUGrabber error: Can't stop image acquisition from IEEE 1394 camera number %i",index); throw (vpFrameGrabberException(vpFrameGrabberException::otherError, "Error while stopping image acquisition") ); } } 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") ); } // start acquisition if (camera->StartImageAcquisition() != CAM_SUCCESS) { close(); vpERROR_TRACE("vp1394CMUGrabber error: Can't start image acquisition from IEEE 1394 camera number %i",index); throw (vpFrameGrabberException(vpFrameGrabberException::otherError, "Error while starting image acquisition") ); } // Update Image dimension unsigned long w, h; camera->GetVideoFrameDimensions(&w, &h); this->width = w; this->height = h; // Update the color coding _color = getVideoColorCoding(); } }
/*! 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