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;
497 if( camera->GetNumberCameras() > cam_id )
500 camera->GetNodeDescription(cam_id,buf,512);
501 std::cout <<
"Camera " << cam_id <<
": " << buf << std::endl ;
505 std::cout <<
"Camera " << cam_id <<
": camera not found" << std::endl ;
516 char vendor[256] , model[256] , buf[256];
519 camera->GetCameraName(model,
sizeof(model));
520 camera->GetCameraVendor(vendor,
sizeof(vendor));
521 camera->GetCameraUniqueID(&ID);
523 std::cout <<
"Vendor: " << vendor << std::endl;
524 std::cout <<
"Model: " << model << std::endl;
526 sprintf(buf,
"%08X%08X",ID.HighPart,ID.LowPart);
527 std::cout <<
"UniqueID: " << buf << std::endl;
579 if ((_format != -1) && (_mode != -1))
581 if (!camera->HasVideoMode(_format, _mode))
584 vpERROR_TRACE(
"vp1394CMUGrabber error: The image format is not supported by the IEEE 1394 camera number %i",index);
588 if (camera->IsAcquiring()) {
590 if (camera->StopImageAcquisition() != CAM_SUCCESS)
593 vpERROR_TRACE(
"vp1394CMUGrabber error: Can't stop image acquisition from IEEE 1394 camera number %i",index);
595 "Error while stopping image acquisition") );
599 if (camera->SetVideoFormat(_format) != CAM_SUCCESS)
602 vpERROR_TRACE(
"vp1394CMUGrabber error: Can't set video format of IEEE 1394 camera number %i",index);
606 if (camera->SetVideoMode(_mode) != CAM_SUCCESS)
609 vpERROR_TRACE(
"vp1394CMUGrabber error: Can't set video mode of IEEE 1394 camera number %i",index);
614 if (camera->StartImageAcquisition() != CAM_SUCCESS)
617 vpERROR_TRACE(
"vp1394CMUGrabber error: Can't start image acquisition from IEEE 1394 camera number %i",index);
619 "Error while starting image acquisition") );
624 camera->GetVideoFrameDimensions(&w, &h);
664 if (!camera->HasVideoFrameRate(_format,_mode,_fps))
667 vpERROR_TRACE(
"vp1394CMUGrabber error: The frame rate is not supported by the IEEE 1394 camera number %i for the selected image format",index);
671 if (camera->IsAcquiring()) {
673 if (camera->StopImageAcquisition() != CAM_SUCCESS)
676 vpERROR_TRACE(
"vp1394CMUGrabber error: Can't stop image acquisition from IEEE 1394 camera number %i",index);
678 "Error while stopping image acquisition") );
681 if (camera->SetVideoFrameRate(_fps) != CAM_SUCCESS)
684 vpERROR_TRACE(
"vp1394CMUGrabber error: Can't set video frame rate of IEEE 1394 camera number %i",index);
688 if (camera->StartImageAcquisition() != CAM_SUCCESS)
691 vpERROR_TRACE(
"vp1394CMUGrabber error: Can't start image acquisition from IEEE 1394 camera number %i",index);
693 "Error while starting image acquisition") );
723 int fps = camera->GetVideoFrameRate();
771 #elif !defined(VISP_BUILD_SHARED_LIBS)
773 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)
Firewire cameras video capture based on CMU 1394 Digital Camera SDK.
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)
vp1394CMUGrabber & operator>>(vpImage< unsigned char > &I)
void resize(const unsigned int h, const unsigned int w)
resize the image : Image initialization
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)