41 #include <visp3/core/vpConfig.h> 43 #ifdef VISP_HAVE_CMU1394 47 #include <visp3/core/vpImageConvert.h> 48 #include <visp3/sensor/vp1394CMUGrabber.h> 56 _format(-1), _mode(-1), _fps(-1), _modeauto(true), _gain(0), _shutter(0), _color(
vp1394CMUGrabber::UNKNOWN)
65 camera =
new C1394Camera;
91 camerror = camera->SelectCamera(index);
92 if (camerror != CAM_SUCCESS) {
94 case CAM_ERROR_PARAM_OUT_OF_RANGE:
95 vpERROR_TRACE(
"vp1394CMUGrabber error: Found no camera number %i", index);
100 vpERROR_TRACE(
"vp1394CMUGrabber error: The camera %i is busy", index);
102 "The required camera is in use by other application"));
105 vpERROR_TRACE(
"vp1394CMUGrabber error: General I/O error when " 106 "selecting camera number %i",
118 void vp1394CMUGrabber::initCamera()
123 if (camera->CheckLink() != CAM_SUCCESS) {
124 vpERROR_TRACE(
"C1394Camera error: Found no cameras on the 1394 bus");
128 camerror = camera->InitCamera();
129 if (camerror != CAM_SUCCESS) {
131 case CAM_ERROR_NOT_INITIALIZED:
132 vpERROR_TRACE(
"vp1394CMUGrabber error: No camera selected", index);
136 vpERROR_TRACE(
"vp1394CMUGrabber error: The camera %i is busy", index);
138 "The required camera is in use by other application"));
141 vpERROR_TRACE(
"vp1394CMUGrabber error: General I/O error when " 142 "selecting camera number %i",
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) {
172 vpERROR_TRACE(
"vp1394CMUGrabber error: Can't start image acquisition " 173 "from IEEE 1394 camera number %i",
213 unsigned long length;
214 unsigned char *rawdata = NULL;
220 camera->AcquireImageEx(TRUE, &dropped);
221 rawdata = camera->GetRawData(&length);
226 memcpy(I.
bitmap, (
unsigned char *)rawdata, size);
250 vpERROR_TRACE(
"Format conversion not implemented. Acquisition failed.");
252 "Acquisition failed."));
275 unsigned long length;
276 unsigned char *rawdata = NULL;
282 camera->AcquireImageEx(TRUE, &dropped);
283 rawdata = camera->GetRawData(&length);
314 vpERROR_TRACE(
"Format conversion not implemented. Acquisition failed.");
316 "Acquisition failed."));
327 if (camera->IsAcquiring()) {
329 if (camera->StopImageAcquisition() != CAM_SUCCESS) {
331 vpERROR_TRACE(
"vp1394CMUGrabber error: Can't stop image acquisition " 332 "from IEEE 1394 camera number %i",
356 int n_cam = camera->RefreshCameraList();
370 C1394CameraControl *Control;
371 Control = camera->GetCameraControl(FEATURE_GAIN);
373 Control->GetRange(&min, &max);
383 camera->GetCameraControl(FEATURE_GAIN)->SetAutoMode(
true);
395 unsigned short min, max;
396 C1394CameraControl *Control;
398 Control = camera->GetCameraControl(FEATURE_GAIN);
400 Control->GetRange(&min, &max);
404 std::cout <<
"vp1394CMUGrabber warning: Desired gain register value of " 405 "IEEE 1394 camera number " 406 << index <<
" can't be less than " << _gain << std::endl;
407 }
else if (_gain > max) {
409 std::cout <<
"vp1394CMUGrabber warning: Desired gain register value of " 410 "IEEE 1394 camera number " 411 << index <<
" can't be greater than " << _gain << std::endl;
414 Control->SetAutoMode(
false);
415 if (Control->SetValue(_gain) != CAM_SUCCESS) {
416 std::cout <<
"vp1394CMUGrabber warning: Can't set gain register value of " 417 "IEEE 1394 camera number " 418 << index << std::endl;
431 C1394CameraControl *Control;
432 Control = camera->GetCameraControl(FEATURE_SHUTTER);
434 Control->GetRange(&min, &max);
445 camera->GetCameraControl(FEATURE_SHUTTER)->SetAutoMode(
true);
458 unsigned short min, max;
459 C1394CameraControl *Control;
461 Control = camera->GetCameraControl(FEATURE_SHUTTER);
463 Control->GetRange(&min, &max);
465 if (_shutter < min) {
467 std::cout <<
"vp1394CMUGrabber warning: Desired exposure time register " 468 "value of IEEE 1394 camera number " 469 << index <<
" can't be less than " << _shutter << std::endl;
470 }
else if (_shutter > max) {
472 std::cout <<
"vp1394CMUGrabber warning: Desired exposure time register " 473 "value of IEEE 1394 camera number " 474 << index <<
" can't be greater than " << _shutter << std::endl;
476 Control->SetAutoMode(
false);
477 if (Control->SetValue(_shutter) != CAM_SUCCESS) {
478 std::cout <<
"vp1394CMUGrabber warning: Can't set exposure time register " 479 "value of IEEE 1394 camera number " 480 << index << std::endl;
489 if (camera->GetNumberCameras() > cam_id) {
491 camera->GetNodeDescription(cam_id, buf, 512);
492 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 sprintf(buf,
"%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();
758 #elif !defined(VISP_BUILD_SHARED_LIBS) 761 void dummy_vp1394CMUGrabber(){};
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)
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)
static void GreyToRGBa(unsigned char *grey, unsigned char *rgba, unsigned int size)
static void YUV422ToRGBa(unsigned char *yuv, unsigned char *rgba, unsigned int size)
int getNumberOfConnectedCameras() const
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)
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)
vpColorCodingType getVideoColorCoding() const
Get the video color coding format.
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)
unsigned int getHeight() const
static void YUV411ToRGBa(unsigned char *yuv, unsigned char *rgba, unsigned int size)
unsigned int getSize() const
static void YUV411ToGrey(unsigned char *yuv, unsigned char *grey, unsigned int size)
unsigned int getWidth() const
unsigned int width
Number of columns in the image.
void setControl(unsigned short gain, unsigned short shutter)
void selectCamera(int cam_id)