36 #include <visp3/core/vpConfig.h>
38 #ifdef VISP_HAVE_CMU1394
42 #include <visp3/core/vpDebug.h>
43 #include <visp3/core/vpImageConvert.h>
44 #include <visp3/sensor/vp1394CMUGrabber.h>
53 _format(-1), _mode(-1), _fps(-1), _modeauto(true), _gain(0), _shutter(0), _color(
vp1394CMUGrabber::UNKNOWN)
62 camera =
new C1394Camera;
88 camerror = camera->SelectCamera(index);
89 if (camerror != CAM_SUCCESS) {
91 case CAM_ERROR_PARAM_OUT_OF_RANGE:
92 vpERROR_TRACE(
"vp1394CMUGrabber error: Found no camera number %i", index);
97 vpERROR_TRACE(
"vp1394CMUGrabber error: The camera %i is busy", index);
99 "The required camera is in use by other application"));
102 vpERROR_TRACE(
"vp1394CMUGrabber error: General I/O error when "
103 "selecting camera number %i",
115 void vp1394CMUGrabber::initCamera()
120 if (camera->CheckLink() != CAM_SUCCESS) {
121 vpERROR_TRACE(
"C1394Camera error: Found no cameras on the 1394 bus");
125 camerror = camera->InitCamera();
126 if (camerror != CAM_SUCCESS) {
128 case CAM_ERROR_NOT_INITIALIZED:
129 vpERROR_TRACE(
"vp1394CMUGrabber error: No camera selected", index);
133 vpERROR_TRACE(
"vp1394CMUGrabber error: The camera %i is busy", index);
135 "The required camera is in use by other application"));
138 vpERROR_TRACE(
"vp1394CMUGrabber error: General I/O error when "
139 "selecting camera number %i",
147 if (camera->Has1394b())
148 camera->Set1394b(TRUE);
151 _format = camera->GetVideoFormat();
152 _mode = camera->GetVideoMode();
159 camera->GetCameraControlTrigger()->SetOnOff(
false);
162 camera->GetVideoFrameDimensions(&w, &h);
167 if (camera->StartImageAcquisition() != CAM_SUCCESS) {
169 vpERROR_TRACE(
"vp1394CMUGrabber error: Can't start image acquisition "
170 "from IEEE 1394 camera number %i",
210 unsigned long length;
211 unsigned char *rawdata =
nullptr;
217 camera->AcquireImageEx(TRUE, &dropped);
218 rawdata = camera->GetRawData(&length);
223 memcpy(I.
bitmap, (
unsigned char *)rawdata, size);
247 vpERROR_TRACE(
"Format conversion not implemented. Acquisition failed.");
249 "Acquisition failed."));
272 unsigned long length;
273 unsigned char *rawdata =
nullptr;
279 camera->AcquireImageEx(TRUE, &dropped);
280 rawdata = camera->GetRawData(&length);
311 vpERROR_TRACE(
"Format conversion not implemented. Acquisition failed.");
313 "Acquisition failed."));
324 if (camera->IsAcquiring()) {
326 if (camera->StopImageAcquisition() != CAM_SUCCESS) {
328 vpERROR_TRACE(
"vp1394CMUGrabber error: Can't stop image acquisition "
329 "from IEEE 1394 camera number %i",
353 int n_cam = camera->RefreshCameraList();
367 C1394CameraControl *Control;
368 Control = camera->GetCameraControl(FEATURE_GAIN);
370 Control->GetRange(&min, &max);
380 camera->GetCameraControl(FEATURE_GAIN)->SetAutoMode(
true);
392 unsigned short min, max;
393 C1394CameraControl *Control;
395 Control = camera->GetCameraControl(FEATURE_GAIN);
397 Control->GetRange(&min, &max);
401 std::cout <<
"vp1394CMUGrabber warning: Desired gain register value of "
402 "IEEE 1394 camera number "
403 << index <<
" can't be less than " << _gain << std::endl;
405 else if (_gain > max) {
407 std::cout <<
"vp1394CMUGrabber warning: Desired gain register value of "
408 "IEEE 1394 camera number "
409 << index <<
" can't be greater than " << _gain << std::endl;
412 Control->SetAutoMode(
false);
413 if (Control->SetValue(_gain) != CAM_SUCCESS) {
414 std::cout <<
"vp1394CMUGrabber warning: Can't set gain register value of "
415 "IEEE 1394 camera number "
416 << index << std::endl;
429 C1394CameraControl *Control;
430 Control = camera->GetCameraControl(FEATURE_SHUTTER);
432 Control->GetRange(&min, &max);
443 camera->GetCameraControl(FEATURE_SHUTTER)->SetAutoMode(
true);
456 unsigned short min, max;
457 C1394CameraControl *Control;
459 Control = camera->GetCameraControl(FEATURE_SHUTTER);
461 Control->GetRange(&min, &max);
463 if (_shutter < min) {
465 std::cout <<
"vp1394CMUGrabber warning: Desired exposure time register "
466 "value of IEEE 1394 camera number "
467 << index <<
" can't be less than " << _shutter << std::endl;
469 else if (_shutter > max) {
471 std::cout <<
"vp1394CMUGrabber warning: Desired exposure time register "
472 "value of IEEE 1394 camera number "
473 << index <<
" can't be greater than " << _shutter << std::endl;
475 Control->SetAutoMode(
false);
476 if (Control->SetValue(_shutter) != CAM_SUCCESS) {
477 std::cout <<
"vp1394CMUGrabber warning: Can't set exposure time register "
478 "value of IEEE 1394 camera number "
479 << index << std::endl;
488 if (camera->GetNumberCameras() > cam_id) {
490 camera->GetNodeDescription(cam_id, buf, 512);
491 std::cout <<
"Camera " << cam_id <<
": " << buf << std::endl;
495 std::cout <<
"Camera " << cam_id <<
": camera not found" << std::endl;
504 char vendor[256], model[256], buf[256];
507 camera->GetCameraName(model,
sizeof(model));
508 camera->GetCameraVendor(vendor,
sizeof(vendor));
509 camera->GetCameraUniqueID(&ID);
511 std::cout <<
"Vendor: " << vendor << std::endl;
512 std::cout <<
"Model: " << model << std::endl;
514 snprintf(buf, 256,
"%08X%08X", ID.HighPart, ID.LowPart);
515 std::cout <<
"UniqueID: " << buf << std::endl;
565 if ((_format != -1) && (_mode != -1)) {
566 if (!camera->HasVideoMode(_format, _mode)) {
568 vpERROR_TRACE(
"vp1394CMUGrabber error: The image format is not "
569 "supported by the IEEE 1394 camera number %i",
574 if (camera->IsAcquiring()) {
576 if (camera->StopImageAcquisition() != CAM_SUCCESS) {
578 vpERROR_TRACE(
"vp1394CMUGrabber error: Can't stop image acquisition "
579 "from IEEE 1394 camera number %i",
585 if (camera->SetVideoFormat(_format) != CAM_SUCCESS) {
587 vpERROR_TRACE(
"vp1394CMUGrabber error: Can't set video format of IEEE "
588 "1394 camera number %i",
593 if (camera->SetVideoMode(_mode) != CAM_SUCCESS) {
595 vpERROR_TRACE(
"vp1394CMUGrabber error: Can't set video mode of IEEE "
596 "1394 camera number %i",
602 if (camera->StartImageAcquisition() != CAM_SUCCESS) {
604 vpERROR_TRACE(
"vp1394CMUGrabber error: Can't start image acquisition "
605 "from IEEE 1394 camera number %i",
612 camera->GetVideoFrameDimensions(&w, &h);
650 if (!camera->HasVideoFrameRate(_format, _mode, _fps)) {
652 vpERROR_TRACE(
"vp1394CMUGrabber error: The frame rate is not supported "
653 "by the IEEE 1394 camera number %i for the selected "
659 if (camera->IsAcquiring()) {
661 if (camera->StopImageAcquisition() != CAM_SUCCESS) {
663 vpERROR_TRACE(
"vp1394CMUGrabber error: Can't stop image acquisition "
664 "from IEEE 1394 camera number %i",
669 if (camera->SetVideoFrameRate(_fps) != CAM_SUCCESS) {
671 vpERROR_TRACE(
"vp1394CMUGrabber error: Can't set video frame rate of "
672 "IEEE 1394 camera number %i",
677 if (camera->StartImageAcquisition() != CAM_SUCCESS) {
679 vpERROR_TRACE(
"vp1394CMUGrabber error: Can't start image acquisition "
680 "from IEEE 1394 camera number %i",
710 int fps = camera->GetVideoFrameRate();
766 #elif !defined(VISP_BUILD_SHARED_LIBS)
769 void dummy_vp1394CMUGrabber() { };
Firewire cameras video capture based on CMU 1394 Digital Camera SDK.
void displayCameraModel()
void setControl(unsigned short gain, unsigned short shutter)
virtual ~vp1394CMUGrabber()
void displayCameraDescription(int cam_id)
vpColorCodingType getVideoColorCoding() const
Get the video color coding format.
void getGainMinMax(unsigned short &min, unsigned short &max)
void setVideoMode(unsigned long format, unsigned long mode)
vp1394CMUGrabber & operator>>(vpImage< unsigned char > &I)
void acquire(vpImage< unsigned char > &I)
void setFramerate(unsigned long fps)
void getShutterMinMax(unsigned short &min, unsigned short &max)
int getNumberOfConnectedCameras() const
void setGain(unsigned short gain)
void open(vpImage< unsigned char > &I)
void selectCamera(int cam_id)
void setShutter(unsigned short shutter)
Error that can be emitted by the vpFrameGrabber class and its derivates.
@ settingError
Grabber settings error.
@ initializationError
Grabber initialization error.
@ otherError
Grabber returned an other error.
unsigned int height
Number of rows in the image.
bool init
Set to true if the frame grabber has been initialized.
unsigned int width
Number of columns in the image.
static void YUV411ToGrey(unsigned char *yuv, unsigned char *grey, unsigned int size)
static void MONO16ToGrey(unsigned char *grey16, unsigned char *grey, unsigned int size)
static void YUV422ToGrey(unsigned char *yuv, unsigned char *grey, unsigned int size)
static void YUV411ToRGBa(unsigned char *yuv, unsigned char *rgba, unsigned int size)
static void GreyToRGBa(unsigned char *grey, unsigned char *rgba, unsigned int width, unsigned int height)
static void MONO16ToRGBa(unsigned char *grey16, unsigned char *rgba, unsigned int size)
static void RGBToGrey(unsigned char *rgb, unsigned char *grey, unsigned int width, unsigned int height, bool flip=false)
static void RGBToRGBa(unsigned char *rgb, unsigned char *rgba, unsigned int size)
static void YUV422ToRGBa(unsigned char *yuv, unsigned char *rgba, unsigned int size)
static void YUV444ToRGBa(unsigned char *yuv, unsigned char *rgba, unsigned int size)
static void YUV444ToGrey(unsigned char *yuv, unsigned char *grey, unsigned int size)
unsigned int getWidth() const
void resize(unsigned int h, unsigned int w)
resize the image : Image initialization
unsigned int getSize() const
Type * bitmap
points toward the bitmap
unsigned int getHeight() const