44 #include <visp/vpConfig.h>
46 #ifdef VISP_HAVE_CMU1394
50 #include <visp/vpImageIo.h>
51 #include <visp/vpImageConvert.h>
52 #include <visp/vp1394CMUGrabber.h>
66 camera =
new C1394Camera;
68 _format = _mode = _fps = -1;
96 camerror = camera->SelectCamera(index);
97 if ( camerror!= CAM_SUCCESS)
101 case CAM_ERROR_PARAM_OUT_OF_RANGE:
102 vpERROR_TRACE(
"vp1394CMUGrabber error: Found no camera number %i",index);
106 vpERROR_TRACE(
"vp1394CMUGrabber error: The camera %i is busy",index);
110 vpERROR_TRACE(
"vp1394CMUGrabber error: General I/O error when selecting camera number %i",index);
122 vp1394CMUGrabber::initCamera()
128 if (camera->CheckLink() != CAM_SUCCESS)
130 vpERROR_TRACE(
"C1394Camera error: Found no cameras on the 1394 bus");
134 camerror = camera->InitCamera();
135 if ( camerror != CAM_SUCCESS )
139 case CAM_ERROR_NOT_INITIALIZED:
140 vpERROR_TRACE(
"vp1394CMUGrabber error: No camera selected",index);
144 vpERROR_TRACE(
"vp1394CMUGrabber error: The camera %i is busy",index);
148 vpERROR_TRACE(
"vp1394CMUGrabber error: General I/O error when selecting camera number %i",index);
155 if (camera->Has1394b())
156 camera->Set1394b(TRUE);
159 _format = camera->GetVideoFormat();
160 _mode = camera->GetVideoMode();
167 camera->GetCameraControlTrigger()->SetOnOff(
false);
170 camera->GetVideoFrameDimensions(&w, &h);
175 if (camera->StartImageAcquisition() != CAM_SUCCESS)
178 vpERROR_TRACE(
"vp1394CMUGrabber error: Can't start image acquisition from IEEE 1394 camera number %i",index);
180 "Error while starting image acquisition") );
222 unsigned long length;
223 unsigned char *rawdata = NULL ;
229 camera->AcquireImageEx(TRUE,&dropped);
230 rawdata = camera->GetRawData(&length);
235 memcpy(I.
bitmap, (
unsigned char *) rawdata, size);
259 vpERROR_TRACE(
"Format conversion not implemented. Acquisition failed.");
261 "Format conversion not implemented. "
262 "Acquisition failed.") );
287 unsigned long length;
288 unsigned char *rawdata = NULL;
294 camera->AcquireImageEx(TRUE,&dropped);
295 rawdata = camera->GetRawData(&length);
326 vpERROR_TRACE(
"Format conversion not implemented. Acquisition failed.");
328 "Format conversion not implemented. "
329 "Acquisition failed.") );
341 if (camera->IsAcquiring()) {
343 if (camera->StopImageAcquisition() != CAM_SUCCESS)
346 vpERROR_TRACE(
"vp1394CMUGrabber error: Can't stop image acquisition from IEEE 1394 camera number %i",index);
348 "Error while stopping image acquisition") );
372 int n_cam = camera->RefreshCameraList();
386 C1394CameraControl *Control;
387 Control = camera->GetCameraControl(FEATURE_GAIN);
389 Control->GetRange(&min, &max);
399 camera->GetCameraControl(FEATURE_GAIN)->SetAutoMode(
true);
411 unsigned short min,max;
412 C1394CameraControl *Control;
414 Control = camera->GetCameraControl(FEATURE_GAIN);
416 Control->GetRange(&min,&max);
421 std::cout <<
"vp1394CMUGrabber warning: Desired gain register value of IEEE 1394 camera number " << index <<
" can't be less than " << _gain << std::endl;
423 else if (_gain > max)
426 std::cout <<
"vp1394CMUGrabber warning: Desired gain register value of IEEE 1394 camera number " << index <<
" can't be greater than " << _gain << std::endl;
429 Control->SetAutoMode(
false);
430 if(Control->SetValue(_gain) != CAM_SUCCESS)
432 std::cout <<
"vp1394CMUGrabber warning: Can't set gain register value of IEEE 1394 camera number " << index << std::endl;
445 C1394CameraControl *Control;
446 Control = camera->GetCameraControl(FEATURE_SHUTTER);
448 Control->GetRange(&min, &max);
459 camera->GetCameraControl(FEATURE_SHUTTER)->SetAutoMode(
true);
472 unsigned short min,max;
473 C1394CameraControl *Control;
475 Control = camera->GetCameraControl(FEATURE_SHUTTER);
477 Control->GetRange(&min,&max);
482 std::cout <<
"vp1394CMUGrabber warning: Desired exposure time register value of IEEE 1394 camera number " << index <<
" can't be less than " << _shutter << std::endl;
484 else if (_shutter > max)
487 std::cout <<
"vp1394CMUGrabber warning: Desired exposure time register value of IEEE 1394 camera number " << index <<
" can't be greater than " << _shutter << std::endl;
489 Control->SetAutoMode(
false);
490 if(Control->SetValue(_shutter) != CAM_SUCCESS)
492 std::cout <<
"vp1394CMUGrabber warning: Can't set exposure time register value of IEEE 1394 camera number " << index << std::endl;
504 if( camera->GetNumberCameras() > cam_id )
506 camera->GetNodeDescription(cam_id,buf,512);
507 std::cout <<
"Camera " << cam_id <<
": " << buf << std::endl ;
511 std::cout <<
"Camera " << cam_id <<
": camera not found" << std::endl ;
522 char vendor[256] , model[256] , buf[256];
525 camera->GetCameraName(model,
sizeof(model));
526 camera->GetCameraVendor(vendor,
sizeof(vendor));
527 camera->GetCameraUniqueID(&ID);
529 std::cout <<
"Vendor: " << vendor << std::endl;
530 std::cout <<
"Model: " << model << std::endl;
532 sprintf(buf,
"%08X%08X",ID.HighPart,ID.LowPart);
533 std::cout <<
"UniqueID: " << buf << std::endl;
585 if ((_format != -1) && (_mode != -1))
587 if (!camera->HasVideoMode(_format, _mode))
590 vpERROR_TRACE(
"vp1394CMUGrabber error: The image format is not supported by the IEEE 1394 camera number %i",index);
594 if (camera->IsAcquiring()) {
596 if (camera->StopImageAcquisition() != CAM_SUCCESS)
599 vpERROR_TRACE(
"vp1394CMUGrabber error: Can't stop image acquisition from IEEE 1394 camera number %i",index);
601 "Error while stopping image acquisition") );
605 if (camera->SetVideoFormat(_format) != CAM_SUCCESS)
608 vpERROR_TRACE(
"vp1394CMUGrabber error: Can't set video format of IEEE 1394 camera number %i",index);
612 if (camera->SetVideoMode(_mode) != CAM_SUCCESS)
615 vpERROR_TRACE(
"vp1394CMUGrabber error: Can't set video mode of IEEE 1394 camera number %i",index);
620 if (camera->StartImageAcquisition() != CAM_SUCCESS)
623 vpERROR_TRACE(
"vp1394CMUGrabber error: Can't start image acquisition from IEEE 1394 camera number %i",index);
625 "Error while starting image acquisition") );
630 camera->GetVideoFrameDimensions(&w, &h);
670 if (!camera->HasVideoFrameRate(_format,_mode,_fps))
673 vpERROR_TRACE(
"vp1394CMUGrabber error: The frame rate is not supported by the IEEE 1394 camera number %i for the selected image format",index);
677 if (camera->IsAcquiring()) {
679 if (camera->StopImageAcquisition() != CAM_SUCCESS)
682 vpERROR_TRACE(
"vp1394CMUGrabber error: Can't stop image acquisition from IEEE 1394 camera number %i",index);
684 "Error while stopping image acquisition") );
687 if (camera->SetVideoFrameRate(_fps) != CAM_SUCCESS)
690 vpERROR_TRACE(
"vp1394CMUGrabber error: Can't set video frame rate of IEEE 1394 camera number %i",index);
694 if (camera->StartImageAcquisition() != CAM_SUCCESS)
697 vpERROR_TRACE(
"vp1394CMUGrabber error: Can't start image acquisition from IEEE 1394 camera number %i",index);
699 "Error while starting image acquisition") );
729 int fps = camera->GetVideoFrameRate();
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
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)