40 #include <visp3/core/vpConfig.h>
42 #ifdef VISP_HAVE_CMU1394
46 #include <visp3/core/vpImageConvert.h>
47 #include <visp3/sensor/vp1394CMUGrabber.h>
61 camera =
new C1394Camera;
63 _format = _mode = _fps = -1;
91 camerror = camera->SelectCamera(index);
92 if ( camerror!= CAM_SUCCESS)
96 case CAM_ERROR_PARAM_OUT_OF_RANGE:
97 vpERROR_TRACE(
"vp1394CMUGrabber error: Found no camera number %i",index);
101 vpERROR_TRACE(
"vp1394CMUGrabber error: The camera %i is busy",index);
105 vpERROR_TRACE(
"vp1394CMUGrabber error: General I/O error when selecting camera number %i",index);
117 vp1394CMUGrabber::initCamera()
123 if (camera->CheckLink() != CAM_SUCCESS)
125 vpERROR_TRACE(
"C1394Camera error: Found no cameras on the 1394 bus");
129 camerror = camera->InitCamera();
130 if ( camerror != CAM_SUCCESS )
134 case CAM_ERROR_NOT_INITIALIZED:
135 vpERROR_TRACE(
"vp1394CMUGrabber error: No camera selected",index);
139 vpERROR_TRACE(
"vp1394CMUGrabber error: The camera %i is busy",index);
143 vpERROR_TRACE(
"vp1394CMUGrabber error: General I/O error when selecting camera number %i",index);
150 if (camera->Has1394b())
151 camera->Set1394b(TRUE);
154 _format = camera->GetVideoFormat();
155 _mode = camera->GetVideoMode();
162 camera->GetCameraControlTrigger()->SetOnOff(
false);
165 camera->GetVideoFrameDimensions(&w, &h);
170 if (camera->StartImageAcquisition() != CAM_SUCCESS)
173 vpERROR_TRACE(
"vp1394CMUGrabber error: Can't start image acquisition from IEEE 1394 camera number %i",index);
175 "Error while starting image acquisition") );
217 unsigned long length;
218 unsigned char *rawdata = NULL ;
224 camera->AcquireImageEx(TRUE,&dropped);
225 rawdata = camera->GetRawData(&length);
230 memcpy(I.
bitmap, (
unsigned char *) rawdata, size);
254 vpERROR_TRACE(
"Format conversion not implemented. Acquisition failed.");
256 "Format conversion not implemented. "
257 "Acquisition failed.") );
282 unsigned long length;
283 unsigned char *rawdata = NULL;
289 camera->AcquireImageEx(TRUE,&dropped);
290 rawdata = camera->GetRawData(&length);
321 vpERROR_TRACE(
"Format conversion not implemented. Acquisition failed.");
323 "Format conversion not implemented. "
324 "Acquisition failed.") );
336 if (camera->IsAcquiring()) {
338 if (camera->StopImageAcquisition() != CAM_SUCCESS)
341 vpERROR_TRACE(
"vp1394CMUGrabber error: Can't stop image acquisition from IEEE 1394 camera number %i",index);
343 "Error while stopping image acquisition") );
367 int n_cam = camera->RefreshCameraList();
381 C1394CameraControl *Control;
382 Control = camera->GetCameraControl(FEATURE_GAIN);
384 Control->GetRange(&min, &max);
394 camera->GetCameraControl(FEATURE_GAIN)->SetAutoMode(
true);
406 unsigned short min,max;
407 C1394CameraControl *Control;
409 Control = camera->GetCameraControl(FEATURE_GAIN);
411 Control->GetRange(&min,&max);
416 std::cout <<
"vp1394CMUGrabber warning: Desired gain register value of IEEE 1394 camera number " << index <<
" can't be less than " << _gain << std::endl;
418 else if (_gain > max)
421 std::cout <<
"vp1394CMUGrabber warning: Desired gain register value of IEEE 1394 camera number " << index <<
" can't be greater than " << _gain << std::endl;
424 Control->SetAutoMode(
false);
425 if(Control->SetValue(_gain) != CAM_SUCCESS)
427 std::cout <<
"vp1394CMUGrabber warning: Can't set gain register value of IEEE 1394 camera number " << index << std::endl;
440 C1394CameraControl *Control;
441 Control = camera->GetCameraControl(FEATURE_SHUTTER);
443 Control->GetRange(&min, &max);
454 camera->GetCameraControl(FEATURE_SHUTTER)->SetAutoMode(
true);
467 unsigned short min,max;
468 C1394CameraControl *Control;
470 Control = camera->GetCameraControl(FEATURE_SHUTTER);
472 Control->GetRange(&min,&max);
477 std::cout <<
"vp1394CMUGrabber warning: Desired exposure time register value of IEEE 1394 camera number " << index <<
" can't be less than " << _shutter << std::endl;
479 else if (_shutter > max)
482 std::cout <<
"vp1394CMUGrabber warning: Desired exposure time register value of IEEE 1394 camera number " << index <<
" can't be greater than " << _shutter << std::endl;
484 Control->SetAutoMode(
false);
485 if(Control->SetValue(_shutter) != CAM_SUCCESS)
487 std::cout <<
"vp1394CMUGrabber warning: Can't set exposure time register value of IEEE 1394 camera number " << index << std::endl;
499 if( camera->GetNumberCameras() > cam_id )
501 camera->GetNodeDescription(cam_id,buf,512);
502 std::cout <<
"Camera " << cam_id <<
": " << buf << std::endl ;
506 std::cout <<
"Camera " << cam_id <<
": camera not found" << std::endl ;
517 char vendor[256] , model[256] , buf[256];
520 camera->GetCameraName(model,
sizeof(model));
521 camera->GetCameraVendor(vendor,
sizeof(vendor));
522 camera->GetCameraUniqueID(&ID);
524 std::cout <<
"Vendor: " << vendor << std::endl;
525 std::cout <<
"Model: " << model << std::endl;
527 sprintf(buf,
"%08X%08X",ID.HighPart,ID.LowPart);
528 std::cout <<
"UniqueID: " << buf << std::endl;
580 if ((_format != -1) && (_mode != -1))
582 if (!camera->HasVideoMode(_format, _mode))
585 vpERROR_TRACE(
"vp1394CMUGrabber error: The image format is not supported by the IEEE 1394 camera number %i",index);
589 if (camera->IsAcquiring()) {
591 if (camera->StopImageAcquisition() != CAM_SUCCESS)
594 vpERROR_TRACE(
"vp1394CMUGrabber error: Can't stop image acquisition from IEEE 1394 camera number %i",index);
596 "Error while stopping image acquisition") );
600 if (camera->SetVideoFormat(_format) != CAM_SUCCESS)
603 vpERROR_TRACE(
"vp1394CMUGrabber error: Can't set video format of IEEE 1394 camera number %i",index);
607 if (camera->SetVideoMode(_mode) != CAM_SUCCESS)
610 vpERROR_TRACE(
"vp1394CMUGrabber error: Can't set video mode of IEEE 1394 camera number %i",index);
615 if (camera->StartImageAcquisition() != CAM_SUCCESS)
618 vpERROR_TRACE(
"vp1394CMUGrabber error: Can't start image acquisition from IEEE 1394 camera number %i",index);
620 "Error while starting image acquisition") );
625 camera->GetVideoFrameDimensions(&w, &h);
665 if (!camera->HasVideoFrameRate(_format,_mode,_fps))
668 vpERROR_TRACE(
"vp1394CMUGrabber error: The frame rate is not supported by the IEEE 1394 camera number %i for the selected image format",index);
672 if (camera->IsAcquiring()) {
674 if (camera->StopImageAcquisition() != CAM_SUCCESS)
677 vpERROR_TRACE(
"vp1394CMUGrabber error: Can't stop image acquisition from IEEE 1394 camera number %i",index);
679 "Error while stopping image acquisition") );
682 if (camera->SetVideoFrameRate(_fps) != CAM_SUCCESS)
685 vpERROR_TRACE(
"vp1394CMUGrabber error: Can't set video frame rate of IEEE 1394 camera number %i",index);
689 if (camera->StartImageAcquisition() != CAM_SUCCESS)
692 vpERROR_TRACE(
"vp1394CMUGrabber error: Can't start image acquisition from IEEE 1394 camera number %i",index);
694 "Error while starting image acquisition") );
724 int fps = camera->GetVideoFrameRate();
728 #elif !defined(VISP_BUILD_SHARED_LIBS)
730 void dummy_vp1394CMUGrabber() {};
int getNumberOfConnectedCameras() const
void setVideoMode(unsigned long format, unsigned long mode)
static void RGBToGrey(unsigned char *rgb, unsigned char *grey, unsigned int size)
void setGain(unsigned short gain)
unsigned int getWidth() const
void open(vpImage< unsigned char > &I)
static void RGBToRGBa(unsigned char *rgb, unsigned char *rgba, unsigned int size)
Type * bitmap
points toward the bitmap
static void MONO16ToGrey(unsigned char *grey16, unsigned char *grey, unsigned int size)
vpColorCodingType getVideoColorCoding() const
Get the video color coding format.
static void GreyToRGBa(unsigned char *grey, unsigned char *rgba, unsigned int size)
static void YUV422ToRGBa(unsigned char *yuv, unsigned char *rgba, unsigned int size)
void displayCameraModel()
Error that can be emited by the vpFrameGrabber class and its derivates.
void setShutter(unsigned short shutter)
void displayCameraDescription(int cam_id)
static void YUV444ToRGBa(unsigned char *yuv, unsigned char *rgba, unsigned int size)
static void YUV422ToGrey(unsigned char *yuv, unsigned char *grey, unsigned int size)
virtual ~vp1394CMUGrabber()
void getGainMinMax(unsigned short &min, unsigned short &max)
void setFramerate(unsigned long fps)
unsigned int getSize() const
void acquire(vpImage< unsigned char > &I)
unsigned int height
Number of rows in the image.
static void MONO16ToRGBa(unsigned char *grey16, unsigned char *rgba, unsigned int size)
void resize(const unsigned int h, const unsigned int w)
set the size of the image without initializing it.
bool init
Set to true if the frame grabber has been initialized.
static void YUV444ToGrey(unsigned char *yuv, unsigned char *grey, unsigned int size)
void getShutterMinMax(unsigned short &min, unsigned short &max)
static void YUV411ToRGBa(unsigned char *yuv, unsigned char *rgba, unsigned int size)
unsigned int getHeight() const
static void YUV411ToGrey(unsigned char *yuv, unsigned char *grey, unsigned int size)
unsigned int width
Number of columns in the image.
void setControl(unsigned short gain, unsigned short shutter)
void selectCamera(int cam_id)