42 #include <visp3/core/vpConfig.h>
43 #include <visp3/core/vpDebug.h>
48 #if defined(VISP_HAVE_DC1394)
51 #include <visp3/core/vpFrameGrabberException.h>
52 #include <visp3/core/vpImageConvert.h>
53 #include <visp3/core/vpTime.h>
54 #include <visp3/sensor/vp1394TwoGrabber.h>
58 "MODE_160x120_YUV444",
"MODE_320x240_YUV422",
"MODE_640x480_YUV411",
"MODE_640x480_YUV422",
59 "MODE_640x480_RGB8",
"MODE_640x480_MONO8",
"MODE_640x480_MONO16",
"MODE_800x600_YUV422",
60 "MODE_800x600_RGB8",
"MODE_800x600_MONO8",
"MODE_1024x768_YUV422",
"MODE_1024x768_RGB8",
61 "MODE_1024x768_MONO8",
"MODE_800x600_MONO16",
"MODE_1024x768_MONO16",
"MODE_1280x960_YUV422",
62 "MODE_1280x960_RGB8",
"MODE_1280x960_MONO8",
"MODE_1600x1200_YUV422",
"MODE_1600x1200_RGB8",
63 "MODE_1600x1200_MONO8",
"MODE_1280x960_MONO16",
"MODE_1600x1200_MONO16",
"MODE_EXIF",
64 "MODE_FORMAT7_0",
"MODE_FORMAT7_1",
"MODE_FORMAT7_2",
"MODE_FORMAT7_3",
65 "MODE_FORMAT7_4",
"MODE_FORMAT7_5",
"MODE_FORMAT7_6",
"MODE_FORMAT7_7" };
68 "FRAMERATE_1_875",
"FRAMERATE_3_75",
"FRAMERATE_7_5",
"FRAMERATE_15",
69 "FRAMERATE_30",
"FRAMERATE_60",
"FRAMERATE_120",
"FRAMERATE_240" };
72 "COLOR_CODING_MONO8",
"COLOR_CODING_YUV411",
"COLOR_CODING_YUV422",
"COLOR_CODING_YUV444",
73 "COLOR_CODING_RGB8",
"COLOR_CODING_MONO16",
"COLOR_CODING_RGB16",
"COLOR_CODING_MONO16S",
74 "COLOR_CODING_RGB16S",
"COLOR_CODING_RAW8",
"COLOR_CODING_RAW16",
126 : camera(nullptr), cameras(nullptr), num_cameras(0), camera_id(0), verbose(false), camIsOpen(nullptr),
128 isDataModified(nullptr), initialShutterMode(nullptr), dataCam(nullptr)
129 #ifdef VISP_HAVE_DC1394_CAMERA_ENUMERATE
131 d(nullptr), list(nullptr)
299 if (cam_id >= num_cameras) {
301 bool is_guid =
false;
303 for (
unsigned int i = 0; i < num_cameras; i++) {
304 if (cameras[i]->guid == cam_id) {
310 if (is_guid ==
false) {
311 std::cout <<
"Error: The camera with guid 0x" << std::hex << cam_id <<
" is not present" << std::endl;
312 std::cout << num_cameras <<
" camera(s) connected" << std::endl;
313 for (
unsigned int i = 0; i < num_cameras; i++) {
314 std::cout <<
" - camera " << i <<
" with guid 0x" << std::hex << cameras[i]->guid << std::endl;
321 this->camera_id = (
unsigned int)cam_id;
327 camera = cameras[this->camera_id];
347 cam_id = this->camera_id;
351 vpERROR_TRACE(
"No cameras found");
373 return this->camera_id;
377 vpERROR_TRACE(
"No cameras found");
392 vpCTRACE <<
"No camera found..." << std::endl;
396 ncameras = num_cameras;
408 unsigned int ncameras = 0;
410 vpCTRACE <<
"No camera found..." << std::endl;
414 ncameras = num_cameras;
478 setTransmission(DC1394_OFF);
479 setCapture(DC1394_OFF);
481 if (dc1394_video_set_mode(camera, (dc1394video_mode_t)videomode) != DC1394_SUCCESS) {
486 setCapture(DC1394_ON);
487 setTransmission(DC1394_ON);
490 if (dc1394_get_image_size_from_video_mode(camera, (dc1394video_mode_t)videomode, &this->
width, &this->
height) !=
518 vpERROR_TRACE(
"No camera found");
522 dc1394video_mode_t _videomode;
523 if (dc1394_video_get_mode(camera, &_videomode) != DC1394_SUCCESS) {
526 vpERROR_TRACE(
"Can't get current video mode");
555 vpERROR_TRACE(
"No camera found");
558 dc1394video_modes_t _videomodes;
561 if (dc1394_video_get_supported_modes(camera, &_videomodes) != DC1394_SUCCESS) {
564 vpERROR_TRACE(
"Can't get video modes");
569 for (
unsigned i = 0; i < _videomodes.num; i++) {
571 videomodes.push_back(_mode);
575 return _videomodes.num;
596 vpERROR_TRACE(
"No camera found");
599 dc1394video_modes_t _videomodes;
602 if (dc1394_video_get_supported_modes(camera, &_videomodes) != DC1394_SUCCESS) {
605 vpERROR_TRACE(
"Can't get video modes");
610 for (
unsigned i = 0; i < _videomodes.num; i++) {
633 if (dc1394_is_video_mode_scalable((dc1394video_mode_t)videomode))
720 setTransmission(DC1394_OFF);
721 setCapture(DC1394_OFF);
723 if (dc1394_video_set_framerate(camera, (dc1394framerate_t)fps) != DC1394_SUCCESS) {
729 setCapture(DC1394_ON);
730 setTransmission(DC1394_ON);
753 vpERROR_TRACE(
"No camera found");
756 dc1394framerate_t _fps;
757 if (dc1394_video_get_framerate(camera, &_fps) != DC1394_SUCCESS) {
760 vpERROR_TRACE(
"Can't get current framerate");
801 vpERROR_TRACE(
"No camera found");
824 dc1394framerates_t _fps;
825 if (dc1394_video_get_supported_framerates(camera, (dc1394video_mode_t)mode, &_fps) != DC1394_SUCCESS) {
827 vpERROR_TRACE(
"Could not query supported frametates for mode %d\n", mode);
833 for (
unsigned int i = 0; i < _fps.num; i++)
877 vpERROR_TRACE(
"No camera found");
897 dc1394framerates_t _fps;
898 if (dc1394_video_get_supported_framerates(camera, (dc1394video_mode_t)mode, &_fps) != DC1394_SUCCESS) {
900 vpERROR_TRACE(
"Could not query supported frametates for mode %d\n", mode);
906 for (
unsigned int i = 0; i < _fps.num; i++) {
974 dc1394video_mode_t _videomode;
975 if (dc1394_video_get_mode(camera, &_videomode) != DC1394_SUCCESS) {
987 if (dc1394_is_video_mode_scalable(_videomode)) {
988 setTransmission(DC1394_OFF);
989 setCapture(DC1394_OFF);
991 if (dc1394_format7_set_color_coding(camera, _videomode, (dc1394color_coding_t)coding) != DC1394_SUCCESS) {
997 setCapture(DC1394_ON);
998 setTransmission(DC1394_ON);
1023 vpERROR_TRACE(
"No camera found");
1026 dc1394video_mode_t _videomode;
1027 if (dc1394_video_get_mode(camera, &_videomode) != DC1394_SUCCESS) {
1030 vpERROR_TRACE(
"Can't get current video mode");
1034 dc1394color_coding_t _coding;
1035 if (dc1394_is_video_mode_scalable(_videomode)) {
1037 if (dc1394_format7_get_color_coding(camera, _videomode, &_coding) != DC1394_SUCCESS) {
1040 vpERROR_TRACE(
"Can't get current color coding");
1044 else if (dc1394_is_video_mode_still_image((dc1394video_mode_t)_videomode)) {
1049 if (dc1394_get_color_coding_from_video_mode(camera, (dc1394video_mode_t)_videomode, &_coding) != DC1394_SUCCESS) {
1051 vpERROR_TRACE(
"Could not query supported color coding for mode %d\n", _videomode);
1080 std::list<vp1394TwoColorCodingType> &codings)
1084 vpERROR_TRACE(
"No camera found");
1091 if (dc1394_is_video_mode_scalable((dc1394video_mode_t)mode)) {
1093 dc1394color_codings_t _codings;
1094 if (dc1394_format7_get_color_codings(camera, (dc1394video_mode_t)mode, &_codings) != DC1394_SUCCESS) {
1096 vpERROR_TRACE(
"Could not query supported color codings for mode %d\n", mode);
1099 if (_codings.num == 0)
1102 for (
unsigned int i = 0; i < _codings.num; i++)
1105 return _codings.num;
1107 else if (dc1394_is_video_mode_still_image((dc1394video_mode_t)mode)) {
1113 dc1394color_coding_t _coding;
1114 if (dc1394_get_color_coding_from_video_mode(camera, (dc1394video_mode_t)mode, &_coding) != DC1394_SUCCESS) {
1116 vpERROR_TRACE(
"Could not query supported color coding for mode %d\n", mode);
1148 vpERROR_TRACE(
"No camera found");
1152 if (dc1394_is_video_mode_scalable((dc1394video_mode_t)mode)) {
1154 dc1394color_codings_t _codings;
1155 if (dc1394_format7_get_color_codings(camera, (dc1394video_mode_t)mode, &_codings) != DC1394_SUCCESS) {
1157 vpERROR_TRACE(
"Could not query supported color codings for mode %d\n", mode);
1160 if (_codings.num == 0)
1163 for (
unsigned int i = 0; i < _codings.num; i++) {
1169 else if (dc1394_is_video_mode_still_image((dc1394video_mode_t)mode)) {
1175 dc1394color_coding_t _coding;
1176 if (dc1394_get_color_coding_from_video_mode(camera, (dc1394video_mode_t)mode, &_coding) != DC1394_SUCCESS) {
1178 vpERROR_TRACE(
"Could not query supported color coding for mode %d\n", mode);
1225 vpERROR_TRACE(
"No camera found");
1229 dc1394video_mode_t _videomode;
1230 if (dc1394_video_get_mode(camera, &_videomode) != DC1394_SUCCESS) {
1233 vpERROR_TRACE(
"Can't get current video mode");
1236 if (dc1394_is_video_mode_scalable(_videomode)) {
1238 setTransmission(DC1394_OFF);
1239 setCapture(DC1394_OFF);
1241 unsigned int max_width, max_height;
1242 if (dc1394_format7_get_max_image_size(camera, _videomode, &max_width, &max_height) != DC1394_SUCCESS) {
1245 vpERROR_TRACE(
"Can't get format7 max image size");
1249 vpTRACE(
"left: %d top: %d width: %d height: %d", left, top,
1250 width == 0 ? DC1394_USE_MAX_AVAIL : w,
1251 height == 0 ? DC1394_USE_MAX_AVAIL : h);
1252 vpTRACE(
"max_width: %d max_height: %d", max_width, max_height);
1255 if (left > max_width) {
1256 vpERROR_TRACE(
"Can't set format7 ROI");
1259 if (top > max_height) {
1260 vpERROR_TRACE(
"Can't set format7 ROI");
1269 if (w > (max_width - left))
1270 w = (max_width - left);
1271 roi_width = (int32_t)w;
1274 roi_width = DC1394_USE_MAX_AVAIL;
1279 if (h > (max_height - top))
1280 h = (max_height - top);
1281 roi_height = (int32_t)h;
1284 roi_height = DC1394_USE_MAX_AVAIL;
1287 if (dc1394_format7_set_roi(camera, _videomode,
1288 (dc1394color_coding_t)DC1394_QUERY_FROM_CAMERA,
1289 DC1394_USE_MAX_AVAIL
1293 roi_width, roi_height) != DC1394_SUCCESS) {
1295 vpERROR_TRACE(
"Can't set format7 roi");
1299 if (dc1394_format7_get_image_size(camera, _videomode, &this->
width, &this->
height) != DC1394_SUCCESS) {
1301 vpERROR_TRACE(
"Can't get format7 image size");
1305 setCapture(DC1394_ON);
1306 setTransmission(DC1394_ON);
1323 void vp1394TwoGrabber::initialize(
bool reset)
1325 if (
init ==
false) {
1327 #ifdef VISP_HAVE_DC1394_CAMERA_ENUMERATE
1332 if (dc1394_camera_enumerate(d, &list) != DC1394_SUCCESS) {
1333 dc1394_camera_free_list(list);
1335 vpERROR_TRACE(
"Failed to enumerate cameras\n");
1339 if (list->num == 0) {
1340 dc1394_camera_free_list(list);
1342 vpERROR_TRACE(
"No cameras found");
1346 if (cameras !=
nullptr)
1349 cameras =
new dc1394camera_t *[list->num];
1353 for (
unsigned int i = 0; i < list->num; i++) {
1354 cameras[i] = dc1394_camera_new(d, list->ids[i].guid);
1356 vpTRACE(
"Failed to initialize camera with guid \"%ld\"\n", list->ids[i].guid);
1367 dc1394_reset_bus(cameras[0]);
1371 dc1394_camera_free_list(list);
1374 #elif defined VISP_HAVE_DC1394_FIND_CAMERAS
1375 if (cameras !=
nullptr)
1378 int err = dc1394_find_cameras(&cameras, &num_cameras);
1380 if (err != DC1394_SUCCESS && err != DC1394_NO_CAMERA) {
1382 vpERROR_TRACE(
"Unable to look for cameras\n\n"
1384 " - if the kernel modules `ieee1394',`raw1394' and "
1385 "`ohci1394' are loaded \n"
1386 " - if you have read/write access to /dev/raw1394\n\n");
1391 if (num_cameras == 0) {
1393 vpERROR_TRACE(
"No cameras found");
1398 isDataModified =
new bool[num_cameras];
1399 for (
unsigned int i = 0; i < num_cameras; i++)
1400 isDataModified[i] =
false;
1401 initialShutterMode =
new dc1394feature_mode_t[num_cameras];
1402 dataCam =
new vpDc1394TwoCameraParametersData[num_cameras];
1404 if (camera_id >= num_cameras) {
1407 vpERROR_TRACE(
"Bad camera id: %u", camera_id);
1408 vpERROR_TRACE(
"Only %u camera on the bus.", num_cameras);
1413 std::cout <<
"------ Bus information ------" << std::endl;
1414 std::cout <<
"Number of camera(s) on the bus : " << num_cameras << std::endl;
1415 std::cout <<
"-----------------------------" << std::endl;
1418 if (camIsOpen !=
nullptr)
1420 camIsOpen =
new bool[num_cameras];
1421 for (
unsigned int i = 0; i < num_cameras; i++) {
1422 camIsOpen[i] =
false;
1441 if (camIsOpen[camera_id] ==
false) {
1442 dc1394switch_t status = DC1394_OFF;
1446 dc1394_video_get_transmission(cameras[camera_id], &status);
1447 if (status != DC1394_OFF) {
1449 if (dc1394_video_set_transmission(cameras[camera_id], DC1394_OFF) != DC1394_SUCCESS)
1450 vpTRACE(
"Could not stop ISO transmission");
1453 if (dc1394_video_get_transmission(cameras[camera_id], &status) != DC1394_SUCCESS)
1454 vpTRACE(
"Could get ISO status");
1456 if (status == DC1394_ON) {
1457 vpTRACE(
"ISO transmission refuses to stop");
1459 #ifdef VISP_HAVE_DC1394_FIND_CAMERAS
1461 cameras[camera_id]->is_iso_on = status;
1471 setCapture(DC1394_ON);
1472 setTransmission(DC1394_ON);
1473 camIsOpen[camera_id] =
true;
1488 for (
unsigned int i = 0; i < num_cameras; i++) {
1490 camera = cameras[i];
1491 this->camera_id = i;
1492 setTransmission(DC1394_OFF);
1493 setCapture(DC1394_OFF);
1494 if (isDataModified[i]) {
1497 updateDataStructToCam();
1502 if (dc1394_feature_set_mode(camera, DC1394_FEATURE_BRIGHTNESS, initialShutterMode[i]) != DC1394_SUCCESS ||
1503 dc1394_feature_set_mode(camera, DC1394_FEATURE_EXPOSURE, initialShutterMode[i]) != DC1394_SUCCESS ||
1504 dc1394_feature_set_mode(camera, DC1394_FEATURE_SHARPNESS, initialShutterMode[i]) != DC1394_SUCCESS ||
1505 dc1394_feature_set_mode(camera, DC1394_FEATURE_HUE, initialShutterMode[i]) != DC1394_SUCCESS ||
1506 dc1394_feature_set_mode(camera, DC1394_FEATURE_SATURATION, initialShutterMode[i]) != DC1394_SUCCESS ||
1507 dc1394_feature_set_mode(camera, DC1394_FEATURE_GAMMA, initialShutterMode[i]) != DC1394_SUCCESS ||
1508 dc1394_feature_set_mode(camera, DC1394_FEATURE_SHUTTER, initialShutterMode[i]) != DC1394_SUCCESS ||
1509 dc1394_feature_set_mode(camera, DC1394_FEATURE_GAIN, initialShutterMode[i]) != DC1394_SUCCESS ||
1510 dc1394_feature_set_mode(camera, DC1394_FEATURE_IRIS, initialShutterMode[i])) {
1512 vpERROR_TRACE(
"Unable to reset the initial mode");
1516 if (dc1394_camera_set_power(camera, DC1394_OFF) != DC1394_SUCCESS)
1517 std::cout <<
"Unable to turn camera off" << std::endl;
1519 #ifdef VISP_HAVE_DC1394_CAMERA_ENUMERATE
1520 dc1394_camera_free(cameras[i]);
1521 #elif defined VISP_HAVE_DC1394_FIND_CAMERAS
1522 dc1394_free_camera(cameras[i]);
1526 if (camIsOpen !=
nullptr) {
1528 camIsOpen =
nullptr;
1531 #ifdef VISP_HAVE_DC1394_CAMERA_ENUMERATE
1532 if (cameras !=
nullptr) {
1541 #elif defined VISP_HAVE_DC1394_FIND_CAMERAS
1542 if (cameras !=
nullptr) {
1548 camIsOpen =
nullptr;
1552 if (isDataModified !=
nullptr) {
1553 delete[] isDataModified;
1554 isDataModified =
nullptr;
1556 if (initialShutterMode !=
nullptr) {
1557 delete[] initialShutterMode;
1558 initialShutterMode =
nullptr;
1560 if (dataCam !=
nullptr) {
1588 if (size != num_buffers) {
1591 if (camIsOpen[camera_id]) {
1592 setCapture(DC1394_OFF);
1593 setCapture(DC1394_ON);
1655 vpERROR_TRACE(
"No camera found");
1659 dc1394feature_mode_t mode;
1661 mode = DC1394_FEATURE_MODE_AUTO;
1664 mode = DC1394_FEATURE_MODE_MANUAL;
1667 if (dc1394_feature_set_power(camera, DC1394_FEATURE_SHUTTER, DC1394_ON) != DC1394_SUCCESS) {
1673 if (dc1394_feature_set_mode(camera, DC1394_FEATURE_SHUTTER, mode) != DC1394_SUCCESS) {
1726 if (dc1394_avt_set_auto_shutter(camera, minvalue, maxvalue) != DC1394_SUCCESS) {
1750 vpERROR_TRACE(
"No camera found");
1754 if (dc1394_avt_get_auto_shutter(camera, &minvalue, &maxvalue) != DC1394_SUCCESS) {
1808 vpERROR_TRACE(
"No camera found");
1812 dc1394feature_mode_t mode;
1814 mode = DC1394_FEATURE_MODE_AUTO;
1817 mode = DC1394_FEATURE_MODE_MANUAL;
1820 if (dc1394_feature_set_power(camera, DC1394_FEATURE_GAIN, DC1394_ON) != DC1394_SUCCESS) {
1826 if (dc1394_feature_set_mode(camera, DC1394_FEATURE_GAIN, mode) != DC1394_SUCCESS) {
1879 if (dc1394_avt_set_auto_gain(camera, minvalue, maxvalue) != DC1394_SUCCESS) {
1903 vpERROR_TRACE(
"No camera found");
1907 if (dc1394_avt_get_auto_gain(camera, &minvalue, &maxvalue) != DC1394_SUCCESS) {
1932 void vp1394TwoGrabber::setCapture(dc1394switch_t _switch)
1936 vpERROR_TRACE(
"No camera found");
1940 if (_switch == DC1394_ON) {
1943 if (dc1394_capture_setup(camera, num_buffers, DC1394_CAPTURE_FLAGS_DEFAULT) != DC1394_SUCCESS) {
1944 vpERROR_TRACE(
"Unable to setup camera capture-\n"
1945 "make sure that the video mode and framerate are "
1946 "supported by your camera.\n");
1952 dc1394error_t code = dc1394_capture_stop(camera);
1954 if (code != DC1394_SUCCESS && code != DC1394_CAPTURE_IS_NOT_SET) {
1955 vpERROR_TRACE(
"Unable to stop camera capture\n");
1976 void vp1394TwoGrabber::setTransmission(dc1394switch_t _switch)
1980 vpERROR_TRACE(
"No camera found");
1984 dc1394switch_t status = DC1394_OFF;
1986 if (dc1394_video_get_transmission(camera, &status) != DC1394_SUCCESS) {
1987 vpERROR_TRACE(
"Unable to get transmision status");
1994 if (dc1394_video_set_transmission(camera, _switch) != DC1394_SUCCESS) {
1995 vpERROR_TRACE(
"Unable to setup camera capture-\n"
1996 "make sure that the video mode and framerate are "
1997 "supported by your camera.\n");
2002 if (_switch == DC1394_ON) {
2003 status = DC1394_OFF;
2006 while (status == DC1394_OFF && i++ < 5) {
2008 if (dc1394_video_get_transmission(camera, &status) != DC1394_SUCCESS) {
2009 vpERROR_TRACE(
"Unable to get transmision status");
2059 vpERROR_TRACE(
"No camera found");
2063 dc1394operation_mode_t op_mode;
2064 dc1394speed_t speed;
2068 if (camera->bmode_capable != DC1394_TRUE) {
2073 if (dc1394_video_set_operation_mode(camera, DC1394_OPERATION_MODE_1394B) != DC1394_SUCCESS) {
2078 if (dc1394_video_get_operation_mode(camera, &op_mode) != DC1394_SUCCESS) {
2084 if (dc1394_video_set_operation_mode(camera, DC1394_OPERATION_MODE_LEGACY) != DC1394_SUCCESS) {
2089 if (dc1394_video_get_operation_mode(camera, &op_mode) != DC1394_SUCCESS) {
2095 if (dc1394_video_set_iso_speed(camera, (dc1394speed_t)isospeed) != DC1394_SUCCESS) {
2100 if (dc1394_video_get_iso_speed(camera, &speed) != DC1394_SUCCESS) {
2184 vpERROR_TRACE(
"No camera found");
2188 dc1394video_frame_t *frame =
nullptr;
2190 if (dc1394_capture_dequeue(camera, DC1394_CAPTURE_POLICY_WAIT, &frame) != DC1394_SUCCESS) {
2191 vpERROR_TRACE(
"Error: Failed to capture from camera %d\n", camera_id);
2246 dc1394video_frame_t *frame;
2248 frame =
dequeue(I, timestamp,
id);
2309 dc1394video_frame_t *frame;
2315 timestamp = frame->timestamp;
2318 this->
width = frame->size[0];
2319 this->
height = frame->size[1];
2325 switch (frame->color_coding) {
2326 case DC1394_COLOR_CODING_MONO8:
2327 case DC1394_COLOR_CODING_RAW8:
2328 memcpy(I.
bitmap, (
unsigned char *)frame->image, size *
sizeof(
unsigned char));
2330 case DC1394_COLOR_CODING_MONO16:
2331 case DC1394_COLOR_CODING_RAW16:
2335 case DC1394_COLOR_CODING_YUV411:
2339 case DC1394_COLOR_CODING_YUV422:
2343 case DC1394_COLOR_CODING_YUV444:
2347 case DC1394_COLOR_CODING_RGB8:
2353 vpERROR_TRACE(
"Format conversion not implemented. Acquisition failed.");
2355 "Acquisition failed."));
2409 dc1394video_frame_t *frame;
2411 frame =
dequeue(I, timestamp,
id);
2472 dc1394video_frame_t *frame;
2478 timestamp = frame->timestamp;
2481 this->
width = frame->size[0];
2482 this->
height = frame->size[1];
2488 switch (frame->color_coding) {
2489 case DC1394_COLOR_CODING_MONO8:
2490 case DC1394_COLOR_CODING_RAW8:
2494 case DC1394_COLOR_CODING_MONO16:
2495 case DC1394_COLOR_CODING_RAW16:
2499 case DC1394_COLOR_CODING_YUV411:
2503 case DC1394_COLOR_CODING_YUV422:
2507 case DC1394_COLOR_CODING_YUV444:
2511 case DC1394_COLOR_CODING_RGB8:
2517 vpERROR_TRACE(
"Format conversion not implemented. Acquisition failed.");
2519 "Acquisition failed."));
2540 vpERROR_TRACE(
"No camera found");
2545 dc1394_capture_enqueue(camera, frame);
2566 dc1394video_frame_t *frame;
2568 frame =
dequeue(I, timestamp,
id);
2592 dc1394video_frame_t *frame;
2595 frame =
dequeue(I, timestamp,
id);
2616 dc1394video_frame_t *frame;
2619 frame =
dequeue(I, timestamp,
id);
2643 dc1394video_frame_t *frame;
2649 timestamp = frame->timestamp;
2652 this->
width = frame->size[0];
2653 this->
height = frame->size[1];
2659 switch (frame->color_coding) {
2660 case DC1394_COLOR_CODING_MONO8:
2661 case DC1394_COLOR_CODING_RAW8:
2665 case DC1394_COLOR_CODING_YUV411:
2669 case DC1394_COLOR_CODING_YUV422:
2673 case DC1394_COLOR_CODING_YUV444:
2677 case DC1394_COLOR_CODING_RGB8:
2683 vpERROR_TRACE(
"Format conversion not implemented. Acquisition failed.");
2685 "Acquisition failed."));
2711 vpERROR_TRACE(
"No camera found");
2739 vpERROR_TRACE(
"No camera found");
2767 vpERROR_TRACE(
"No camera found");
2794 vpERROR_TRACE(
"No camera found");
2808 std::cout <<
"----------------------------------------------------------" << std::endl
2809 <<
"----- Information for camera " << camera_id <<
" -----" << std::endl
2810 <<
"----------------------------------------------------------" << std::endl;
2812 #ifdef VISP_HAVE_DC1394_CAMERA_ENUMERATE
2813 dc1394_camera_print_info(camera, stdout);
2814 #elif defined VISP_HAVE_DC1394_FIND_CAMERAS
2815 dc1394_print_camera_info(camera);
2818 dc1394featureset_t features;
2819 #ifdef VISP_HAVE_DC1394_CAMERA_ENUMERATE
2820 if (dc1394_feature_get_all(camera, &features) != DC1394_SUCCESS)
2821 #elif defined VISP_HAVE_DC1394_FIND_CAMERAS
2822 if (dc1394_get_camera_feature_set(camera, &features) != DC1394_SUCCESS)
2826 vpERROR_TRACE(
"unable to get feature set for camera %d\n", camera_id);
2831 #ifdef VISP_HAVE_DC1394_CAMERA_ENUMERATE
2832 dc1394_feature_print_all(&features, stdout);
2833 #elif defined VISP_HAVE_DC1394_FIND_CAMERAS
2834 dc1394_print_feature_set(&features);
2837 std::cout <<
"----------------------------------------------------------" << std::endl;
2854 std::string _str =
"";
2855 dc1394video_mode_t _videomode = (dc1394video_mode_t)videomode;
2857 if ((_videomode >= DC1394_VIDEO_MODE_MIN) && (_videomode <= DC1394_VIDEO_MODE_MAX)) {
2858 _str =
strVideoMode[_videomode - DC1394_VIDEO_MODE_MIN];
2861 vpCERROR <<
"The video mode " << (int)videomode <<
" is not supported by the camera" << std::endl;
2881 std::string _str =
"";
2882 dc1394framerate_t _fps = (dc1394framerate_t)fps;
2884 if ((_fps >= DC1394_FRAMERATE_MIN) && (_fps <= DC1394_FRAMERATE_MAX)) {
2888 vpCERROR <<
"The framerate " << (int)fps <<
" is not supported by the camera" << std::endl;
2908 std::string _str =
"";
2909 dc1394color_coding_t _coding = (dc1394color_coding_t)colorcoding;
2911 if ((_coding >= DC1394_COLOR_CODING_MIN) && (_coding <= DC1394_COLOR_CODING_MAX)) {
2916 vpCERROR <<
"The color coding " << (int)colorcoding <<
" is not supported by the camera" << std::endl;
2943 for (
int i = DC1394_VIDEO_MODE_MIN; i <= DC1394_VIDEO_MODE_MAX; i++) {
2975 for (
int i = DC1394_FRAMERATE_MIN; i <= DC1394_FRAMERATE_MAX; i++) {
3007 for (
int i = DC1394_COLOR_CODING_MIN; i <= DC1394_COLOR_CODING_MAX; i++) {
3055 for (
unsigned int i = 0; i < num_cameras; i++) {
3057 camera = cameras[i];
3058 setTransmission(DC1394_OFF);
3059 setCapture(DC1394_OFF);
3062 #ifdef VISP_HAVE_DC1394_CAMERA_ENUMERATE
3065 for (
unsigned int i = 0; i < num_cameras; i++) {
3067 dc1394_camera_free(cameras[i]);
3070 printf(
"Resetting bus...\n");
3071 dc1394_reset_bus(camera);
3073 dc1394_camera_free(camera);
3079 #elif defined VISP_HAVE_DC1394_FIND_CAMERAS
3083 for (
unsigned int i = 0; i < num_cameras; i++) {
3085 dc1394_free_camera(cameras[i]);
3090 dc1394_reset_bus(camera);
3091 dc1394_free_camera(camera);
3094 if (camIsOpen !=
nullptr)
3096 camIsOpen =
nullptr;
3140 vpERROR_TRACE(
"No camera found");
3143 uint64_t offset = 0x884;
3144 uint32_t value = 0x82000000 + (uint32_t)panControlValue;
3146 err = dc1394_set_control_register(camera, offset, value);
3147 if (err != DC1394_SUCCESS) {
3148 vpERROR_TRACE(
"Unable to set PAN register");
3174 vpERROR_TRACE(
"No camera found");
3179 dc1394feature_t feature = DC1394_FEATURE_BRIGHTNESS;
3182 feature = DC1394_FEATURE_BRIGHTNESS;
3185 feature = DC1394_FEATURE_EXPOSURE;
3188 feature = DC1394_FEATURE_SHARPNESS;
3192 feature = DC1394_FEATURE_HUE;
3195 feature = DC1394_FEATURE_SATURATION;
3198 feature = DC1394_FEATURE_GAMMA;
3201 feature = DC1394_FEATURE_SHUTTER;
3204 feature = DC1394_FEATURE_GAIN;
3207 feature = DC1394_FEATURE_IRIS;
3224 err = dc1394_feature_get_value(camera, feature, &value);
3225 if (err != DC1394_SUCCESS) {
3226 vpERROR_TRACE(
"Unable to get the information");
3230 return (
unsigned int)value;
3258 vpERROR_TRACE(
"No camera found");
3261 uint32_t value = (uint32_t)val;
3262 dc1394feature_t feature = DC1394_FEATURE_BRIGHTNESS;
3265 feature = DC1394_FEATURE_BRIGHTNESS;
3268 feature = DC1394_FEATURE_EXPOSURE;
3271 feature = DC1394_FEATURE_SHARPNESS;
3275 feature = DC1394_FEATURE_HUE;
3278 feature = DC1394_FEATURE_SATURATION;
3281 feature = DC1394_FEATURE_GAMMA;
3284 feature = DC1394_FEATURE_SHUTTER;
3287 feature = DC1394_FEATURE_GAIN;
3290 feature = DC1394_FEATURE_IRIS;
3307 dc1394bool_t hasManualMode = DC1394_FALSE;
3308 dc1394feature_modes_t modesAvailable;
3311 err = dc1394_feature_get_modes(camera, feature, &modesAvailable);
3312 if (err != DC1394_SUCCESS) {
3313 vpERROR_TRACE(
"Unable to detect the manual mode information");
3319 for (
unsigned int i = 0; i < modesAvailable.num; i++) {
3320 if (modesAvailable.modes[i] == DC1394_FEATURE_MODE_MANUAL) {
3321 hasManualMode = DC1394_TRUE;
3325 if (hasManualMode == DC1394_TRUE) {
3327 if (!isDataModified[camera_id]) {
3330 updateDataCamToStruct();
3331 err = dc1394_feature_get_mode(camera, feature, &(initialShutterMode[camera_id]));
3332 if (err != DC1394_SUCCESS) {
3333 vpERROR_TRACE(
"Unable to get the initial mode");
3337 isDataModified[camera_id] =
true;
3340 dc1394feature_mode_t manualMode = DC1394_FEATURE_MODE_MANUAL;
3341 err = dc1394_feature_set_mode(camera, feature, manualMode);
3342 if (err != DC1394_SUCCESS) {
3343 vpERROR_TRACE(
"Unable to set the muanual mode");
3347 err = dc1394_feature_set_value(camera, feature, value);
3348 if (err != DC1394_SUCCESS) {
3349 vpERROR_TRACE(
"Unable to set the shutter information");
3355 vpERROR_TRACE(
"The camera does not have a manual mode.\nCannot change the value");
3370 vpERROR_TRACE(
"No camera found");
3374 guid = camera->guid;
3388 vpERROR_TRACE(
"No camera found");
3392 return camera->guid;
3399 inline void vp1394TwoGrabber::updateDataCamToStruct()
3416 inline void vp1394TwoGrabber::updateDataStructToCam()
3480 #elif !defined(VISP_BUILD_SHARED_LIBS)
3483 void dummy_vp1394TwoGrabber() { };
Class for firewire ieee1394 video devices using libdc1394-2.x api.
void setAutoShutter(bool enable=true)
static const char * strColorCoding[DC1394_COLOR_CODING_NUM]
void getVideoMode(vp1394TwoVideoModeType &videomode)
void setAutoGain(bool enable=true)
void setParameterValue(vp1394TwoParametersType param, unsigned int val)
static std::string colorCoding2string(vp1394TwoColorCodingType colorcoding)
void setRingBufferSize(unsigned int size)
void getFramerate(vp1394TwoFramerateType &fps)
uint32_t getFramerateSupported(vp1394TwoVideoModeType videomode, std::list< vp1394TwoFramerateType > &fps)
void acquire(vpImage< unsigned char > &I)
void setPanControl(unsigned int panControlValue)
static vp1394TwoColorCodingType string2colorCoding(std::string colorcoding)
static vp1394TwoVideoModeType string2videoMode(std::string videomode)
void setColorCoding(vp1394TwoColorCodingType coding)
bool isVideoModeFormat7(vp1394TwoVideoModeType videomode)
void setVideoMode(vp1394TwoVideoModeType videomode)
unsigned int getRingBufferSize() const
void setFormat7ROI(unsigned int left=0, unsigned int top=0, unsigned int width=0, unsigned int height=0)
void getAutoShutter(unsigned int &minvalue, unsigned int &maxvalue)
unsigned int getNumCameras() const
void setCamera(uint64_t camera)
static vp1394TwoFramerateType string2framerate(std::string fps)
void enqueue(dc1394video_frame_t *frame)
vp1394TwoGrabber & operator>>(vpImage< unsigned char > &I)
unsigned int getParameterValue(vp1394TwoParametersType param)
void getAutoGain(unsigned int &minvalue, unsigned int &maxvalue)
void getColorCoding(vp1394TwoColorCodingType &coding)
void setIsoTransmissionSpeed(vp1394TwoIsoSpeedType isospeed)
uint32_t getColorCodingSupported(vp1394TwoVideoModeType videomode, std::list< vp1394TwoColorCodingType > &codings)
virtual ~vp1394TwoGrabber()
void setFramerate(vp1394TwoFramerateType fps)
static std::string framerate2string(vp1394TwoFramerateType fps)
bool isColorCodingSupported(vp1394TwoVideoModeType videomode, vp1394TwoColorCodingType coding)
bool isFramerateSupported(vp1394TwoVideoModeType videomode, vp1394TwoFramerateType fps)
dc1394video_frame_t * dequeue()
static std::string videoMode2string(vp1394TwoVideoModeType videomode)
static const char * strVideoMode[DC1394_VIDEO_MODE_NUM]
VP_EXPLICIT vp1394TwoGrabber(bool reset=true)
bool isVideoModeSupported(vp1394TwoVideoModeType videomode)
uint32_t getVideoModeSupported(std::list< vp1394TwoVideoModeType > &videomodes)
void open(vpImage< unsigned char > &I)
static const char * strFramerate[DC1394_FRAMERATE_NUM]
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
Type * bitmap
points toward the bitmap
unsigned int getHeight() const
VISP_EXPORT int wait(double t0, double t)