40#include <visp3/core/vpConfig.h>
41#include <visp3/core/vpDebug.h>
46#if defined(VISP_HAVE_DC1394)
49#include <visp3/core/vpFrameGrabberException.h>
50#include <visp3/core/vpImageConvert.h>
51#include <visp3/core/vpTime.h>
52#include <visp3/sensor/vp1394TwoGrabber.h>
56 "MODE_160x120_YUV444",
"MODE_320x240_YUV422",
"MODE_640x480_YUV411",
"MODE_640x480_YUV422",
57 "MODE_640x480_RGB8",
"MODE_640x480_MONO8",
"MODE_640x480_MONO16",
"MODE_800x600_YUV422",
58 "MODE_800x600_RGB8",
"MODE_800x600_MONO8",
"MODE_1024x768_YUV422",
"MODE_1024x768_RGB8",
59 "MODE_1024x768_MONO8",
"MODE_800x600_MONO16",
"MODE_1024x768_MONO16",
"MODE_1280x960_YUV422",
60 "MODE_1280x960_RGB8",
"MODE_1280x960_MONO8",
"MODE_1600x1200_YUV422",
"MODE_1600x1200_RGB8",
61 "MODE_1600x1200_MONO8",
"MODE_1280x960_MONO16",
"MODE_1600x1200_MONO16",
"MODE_EXIF",
62 "MODE_FORMAT7_0",
"MODE_FORMAT7_1",
"MODE_FORMAT7_2",
"MODE_FORMAT7_3",
63 "MODE_FORMAT7_4",
"MODE_FORMAT7_5",
"MODE_FORMAT7_6",
"MODE_FORMAT7_7" };
66 "FRAMERATE_1_875",
"FRAMERATE_3_75",
"FRAMERATE_7_5",
"FRAMERATE_15",
67 "FRAMERATE_30",
"FRAMERATE_60",
"FRAMERATE_120",
"FRAMERATE_240" };
70 "COLOR_CODING_MONO8",
"COLOR_CODING_YUV411",
"COLOR_CODING_YUV422",
"COLOR_CODING_YUV444",
71 "COLOR_CODING_RGB8",
"COLOR_CODING_MONO16",
"COLOR_CODING_RGB16",
"COLOR_CODING_MONO16S",
72 "COLOR_CODING_RGB16S",
"COLOR_CODING_RAW8",
"COLOR_CODING_RAW16",
124 : camera(nullptr), cameras(nullptr), num_cameras(0), camera_id(0), verbose(false), camIsOpen(nullptr),
126 isDataModified(nullptr), initialShutterMode(nullptr), dataCam(nullptr)
127#ifdef VISP_HAVE_DC1394_CAMERA_ENUMERATE
129 d(nullptr), list(nullptr)
297 if (cam_id >= num_cameras) {
299 bool is_guid =
false;
301 for (
unsigned int i = 0; i < num_cameras; i++) {
302 if (cameras[i]->guid == cam_id) {
308 if (is_guid ==
false) {
309 std::cout <<
"Error: The camera with guid 0x" << std::hex << cam_id <<
" is not present" << std::endl;
310 std::cout << num_cameras <<
" camera(s) connected" << std::endl;
311 for (
unsigned int i = 0; i < num_cameras; i++) {
312 std::cout <<
" - camera " << i <<
" with guid 0x" << std::hex << cameras[i]->guid << std::endl;
319 this->camera_id =
static_cast<unsigned int>(cam_id);
325 camera = cameras[this->camera_id];
345 cam_id = this->camera_id;
371 return this->camera_id;
390 vpCTRACE <<
"No camera found..." << std::endl;
394 ncameras = num_cameras;
406 unsigned int ncameras = 0;
408 vpCTRACE <<
"No camera found..." << std::endl;
412 ncameras = num_cameras;
476 setTransmission(DC1394_OFF);
477 setCapture(DC1394_OFF);
479 if (dc1394_video_set_mode(camera, (dc1394video_mode_t)videomode) != DC1394_SUCCESS) {
484 setCapture(DC1394_ON);
485 setTransmission(DC1394_ON);
488 if (dc1394_get_image_size_from_video_mode(camera, (dc1394video_mode_t)videomode, &this->
width, &this->
height) !=
520 dc1394video_mode_t _videomode;
521 if (dc1394_video_get_mode(camera, &_videomode) != DC1394_SUCCESS) {
556 dc1394video_modes_t _videomodes;
559 if (dc1394_video_get_supported_modes(camera, &_videomodes) != DC1394_SUCCESS) {
567 for (
unsigned i = 0; i < _videomodes.num; i++) {
569 videomodes.push_back(_mode);
573 return _videomodes.num;
597 dc1394video_modes_t _videomodes;
600 if (dc1394_video_get_supported_modes(camera, &_videomodes) != DC1394_SUCCESS) {
608 for (
unsigned i = 0; i < _videomodes.num; i++) {
631 if (dc1394_is_video_mode_scalable((dc1394video_mode_t)videomode))
718 setTransmission(DC1394_OFF);
719 setCapture(DC1394_OFF);
721 if (dc1394_video_set_framerate(camera, (dc1394framerate_t)fps) != DC1394_SUCCESS) {
727 setCapture(DC1394_ON);
728 setTransmission(DC1394_ON);
754 dc1394framerate_t _fps;
755 if (dc1394_video_get_framerate(camera, &_fps) != DC1394_SUCCESS) {
822 dc1394framerates_t _fps;
823 if (dc1394_video_get_supported_framerates(camera, (dc1394video_mode_t)mode, &_fps) != DC1394_SUCCESS) {
825 vpERROR_TRACE(
"Could not query supported frametates for mode %d\n", mode);
831 for (
unsigned int i = 0; i < _fps.num; i++)
895 dc1394framerates_t _fps;
896 if (dc1394_video_get_supported_framerates(camera, (dc1394video_mode_t)mode, &_fps) != DC1394_SUCCESS) {
898 vpERROR_TRACE(
"Could not query supported frametates for mode %d\n", mode);
904 for (
unsigned int i = 0; i < _fps.num; i++) {
972 dc1394video_mode_t _videomode;
973 if (dc1394_video_get_mode(camera, &_videomode) != DC1394_SUCCESS) {
985 if (dc1394_is_video_mode_scalable(_videomode)) {
986 setTransmission(DC1394_OFF);
987 setCapture(DC1394_OFF);
989 if (dc1394_format7_set_color_coding(camera, _videomode, (dc1394color_coding_t)coding) != DC1394_SUCCESS) {
995 setCapture(DC1394_ON);
996 setTransmission(DC1394_ON);
1024 dc1394video_mode_t _videomode;
1025 if (dc1394_video_get_mode(camera, &_videomode) != DC1394_SUCCESS) {
1032 dc1394color_coding_t _coding;
1033 if (dc1394_is_video_mode_scalable(_videomode)) {
1035 if (dc1394_format7_get_color_coding(camera, _videomode, &_coding) != DC1394_SUCCESS) {
1042 else if (dc1394_is_video_mode_still_image((dc1394video_mode_t)_videomode)) {
1047 if (dc1394_get_color_coding_from_video_mode(camera, (dc1394video_mode_t)_videomode, &_coding) != DC1394_SUCCESS) {
1049 vpERROR_TRACE(
"Could not query supported color coding for mode %d\n", _videomode);
1078 std::list<vp1394TwoColorCodingType> &codings)
1089 if (dc1394_is_video_mode_scalable((dc1394video_mode_t)mode)) {
1091 dc1394color_codings_t _codings;
1092 if (dc1394_format7_get_color_codings(camera, (dc1394video_mode_t)mode, &_codings) != DC1394_SUCCESS) {
1094 vpERROR_TRACE(
"Could not query supported color codings for mode %d\n", mode);
1097 if (_codings.num == 0)
1100 for (
unsigned int i = 0; i < _codings.num; i++)
1103 return _codings.num;
1105 else if (dc1394_is_video_mode_still_image((dc1394video_mode_t)mode)) {
1111 dc1394color_coding_t _coding;
1112 if (dc1394_get_color_coding_from_video_mode(camera, (dc1394video_mode_t)mode, &_coding) != DC1394_SUCCESS) {
1114 vpERROR_TRACE(
"Could not query supported color coding for mode %d\n", mode);
1150 if (dc1394_is_video_mode_scalable((dc1394video_mode_t)mode)) {
1152 dc1394color_codings_t _codings;
1153 if (dc1394_format7_get_color_codings(camera, (dc1394video_mode_t)mode, &_codings) != DC1394_SUCCESS) {
1155 vpERROR_TRACE(
"Could not query supported color codings for mode %d\n", mode);
1158 if (_codings.num == 0)
1161 for (
unsigned int i = 0; i < _codings.num; i++) {
1167 else if (dc1394_is_video_mode_still_image((dc1394video_mode_t)mode)) {
1173 dc1394color_coding_t _coding;
1174 if (dc1394_get_color_coding_from_video_mode(camera, (dc1394video_mode_t)mode, &_coding) != DC1394_SUCCESS) {
1176 vpERROR_TRACE(
"Could not query supported color coding for mode %d\n", mode);
1227 dc1394video_mode_t _videomode;
1228 if (dc1394_video_get_mode(camera, &_videomode) != DC1394_SUCCESS) {
1234 if (dc1394_is_video_mode_scalable(_videomode)) {
1236 setTransmission(DC1394_OFF);
1237 setCapture(DC1394_OFF);
1239 unsigned int max_width, max_height;
1240 if (dc1394_format7_get_max_image_size(camera, _videomode, &max_width, &max_height) != DC1394_SUCCESS) {
1247 vpTRACE(
"left: %d top: %d width: %d height: %d", left, top,
1248 width == 0 ? DC1394_USE_MAX_AVAIL : w,
1249 height == 0 ? DC1394_USE_MAX_AVAIL : h);
1250 vpTRACE(
"max_width: %d max_height: %d", max_width, max_height);
1253 if (left > max_width) {
1257 if (top > max_height) {
1267 if (w > (max_width - left))
1268 w = (max_width - left);
1269 roi_width = (int32_t)w;
1272 roi_width = DC1394_USE_MAX_AVAIL;
1277 if (h > (max_height - top))
1278 h = (max_height - top);
1279 roi_height = (int32_t)h;
1282 roi_height = DC1394_USE_MAX_AVAIL;
1285 if (dc1394_format7_set_roi(camera, _videomode,
1286 (dc1394color_coding_t)DC1394_QUERY_FROM_CAMERA,
1287 DC1394_USE_MAX_AVAIL
1291 roi_width, roi_height) != DC1394_SUCCESS) {
1297 if (dc1394_format7_get_image_size(camera, _videomode, &this->
width, &this->
height) != DC1394_SUCCESS) {
1303 setCapture(DC1394_ON);
1304 setTransmission(DC1394_ON);
1321void vp1394TwoGrabber::initialize(
bool reset)
1323 if (
init ==
false) {
1325#ifdef VISP_HAVE_DC1394_CAMERA_ENUMERATE
1330 if (dc1394_camera_enumerate(d, &list) != DC1394_SUCCESS) {
1331 dc1394_camera_free_list(list);
1337 if (list->num == 0) {
1338 dc1394_camera_free_list(list);
1344 if (cameras !=
nullptr)
1347 cameras =
new dc1394camera_t *[list->num];
1351 for (
unsigned int i = 0;
i < list->num;
i++) {
1352 cameras[
i] = dc1394_camera_new(d, list->ids[i].guid);
1354 vpTRACE(
"Failed to initialize camera with guid \"%ld\"\n", list->ids[i].guid);
1365 dc1394_reset_bus(cameras[0]);
1369 dc1394_camera_free_list(list);
1372#elif defined VISP_HAVE_DC1394_FIND_CAMERAS
1373 if (cameras !=
nullptr)
1376 int err = dc1394_find_cameras(&cameras, &num_cameras);
1378 if (err != DC1394_SUCCESS && err != DC1394_NO_CAMERA) {
1382 " - if the kernel modules `ieee1394',`raw1394' and "
1383 "`ohci1394' are loaded \n"
1384 " - if you have read/write access to /dev/raw1394\n\n");
1389 if (num_cameras == 0) {
1396 isDataModified =
new bool[num_cameras];
1397 for (
unsigned int i = 0;
i < num_cameras;
i++)
1398 isDataModified[i] =
false;
1399 initialShutterMode =
new dc1394feature_mode_t[num_cameras];
1400 dataCam =
new vpDc1394TwoCameraParametersData[num_cameras];
1402 if (camera_id >= num_cameras) {
1411 std::cout <<
"------ Bus information ------" << std::endl;
1412 std::cout <<
"Number of camera(s) on the bus : " << num_cameras << std::endl;
1413 std::cout <<
"-----------------------------" << std::endl;
1416 if (camIsOpen !=
nullptr)
1418 camIsOpen =
new bool[num_cameras];
1419 for (
unsigned int i = 0;
i < num_cameras;
i++) {
1420 camIsOpen[
i] =
false;
1439 if (camIsOpen[camera_id] ==
false) {
1440 dc1394switch_t status = DC1394_OFF;
1444 dc1394_video_get_transmission(cameras[camera_id], &status);
1445 if (status != DC1394_OFF) {
1447 if (dc1394_video_set_transmission(cameras[camera_id], DC1394_OFF) != DC1394_SUCCESS)
1448 vpTRACE(
"Could not stop ISO transmission");
1451 if (dc1394_video_get_transmission(cameras[camera_id], &status) != DC1394_SUCCESS)
1452 vpTRACE(
"Could get ISO status");
1454 if (status == DC1394_ON) {
1455 vpTRACE(
"ISO transmission refuses to stop");
1457#ifdef VISP_HAVE_DC1394_FIND_CAMERAS
1459 cameras[camera_id]->is_iso_on = status;
1469 setCapture(DC1394_ON);
1470 setTransmission(DC1394_ON);
1471 camIsOpen[camera_id] =
true;
1486 for (
unsigned int i = 0; i < num_cameras; i++) {
1488 camera = cameras[i];
1489 this->camera_id = i;
1490 setTransmission(DC1394_OFF);
1491 setCapture(DC1394_OFF);
1492 if (isDataModified[i]) {
1495 updateDataStructToCam();
1500 if (dc1394_feature_set_mode(camera, DC1394_FEATURE_BRIGHTNESS, initialShutterMode[i]) != DC1394_SUCCESS ||
1501 dc1394_feature_set_mode(camera, DC1394_FEATURE_EXPOSURE, initialShutterMode[i]) != DC1394_SUCCESS ||
1502 dc1394_feature_set_mode(camera, DC1394_FEATURE_SHARPNESS, initialShutterMode[i]) != DC1394_SUCCESS ||
1503 dc1394_feature_set_mode(camera, DC1394_FEATURE_HUE, initialShutterMode[i]) != DC1394_SUCCESS ||
1504 dc1394_feature_set_mode(camera, DC1394_FEATURE_SATURATION, initialShutterMode[i]) != DC1394_SUCCESS ||
1505 dc1394_feature_set_mode(camera, DC1394_FEATURE_GAMMA, initialShutterMode[i]) != DC1394_SUCCESS ||
1506 dc1394_feature_set_mode(camera, DC1394_FEATURE_SHUTTER, initialShutterMode[i]) != DC1394_SUCCESS ||
1507 dc1394_feature_set_mode(camera, DC1394_FEATURE_GAIN, initialShutterMode[i]) != DC1394_SUCCESS ||
1508 dc1394_feature_set_mode(camera, DC1394_FEATURE_IRIS, initialShutterMode[i])) {
1514 if (dc1394_camera_set_power(camera, DC1394_OFF) != DC1394_SUCCESS)
1515 std::cout <<
"Unable to turn camera off" << std::endl;
1517#ifdef VISP_HAVE_DC1394_CAMERA_ENUMERATE
1518 dc1394_camera_free(cameras[i]);
1519#elif defined VISP_HAVE_DC1394_FIND_CAMERAS
1520 dc1394_free_camera(cameras[i]);
1524 if (camIsOpen !=
nullptr) {
1526 camIsOpen =
nullptr;
1529#ifdef VISP_HAVE_DC1394_CAMERA_ENUMERATE
1530 if (cameras !=
nullptr) {
1539#elif defined VISP_HAVE_DC1394_FIND_CAMERAS
1540 if (cameras !=
nullptr) {
1546 camIsOpen =
nullptr;
1550 if (isDataModified !=
nullptr) {
1551 delete[] isDataModified;
1552 isDataModified =
nullptr;
1554 if (initialShutterMode !=
nullptr) {
1555 delete[] initialShutterMode;
1556 initialShutterMode =
nullptr;
1558 if (dataCam !=
nullptr) {
1586 if (size != num_buffers) {
1589 if (camIsOpen[camera_id]) {
1590 setCapture(DC1394_OFF);
1591 setCapture(DC1394_ON);
1657 dc1394feature_mode_t mode;
1659 mode = DC1394_FEATURE_MODE_AUTO;
1662 mode = DC1394_FEATURE_MODE_MANUAL;
1665 if (dc1394_feature_set_power(camera, DC1394_FEATURE_SHUTTER, DC1394_ON) != DC1394_SUCCESS) {
1671 if (dc1394_feature_set_mode(camera, DC1394_FEATURE_SHUTTER, mode) != DC1394_SUCCESS) {
1724 if (dc1394_avt_set_auto_shutter(camera, minvalue, maxvalue) != DC1394_SUCCESS) {
1752 if (dc1394_avt_get_auto_shutter(camera, &minvalue, &maxvalue) != DC1394_SUCCESS) {
1810 dc1394feature_mode_t mode;
1812 mode = DC1394_FEATURE_MODE_AUTO;
1815 mode = DC1394_FEATURE_MODE_MANUAL;
1818 if (dc1394_feature_set_power(camera, DC1394_FEATURE_GAIN, DC1394_ON) != DC1394_SUCCESS) {
1824 if (dc1394_feature_set_mode(camera, DC1394_FEATURE_GAIN, mode) != DC1394_SUCCESS) {
1877 if (dc1394_avt_set_auto_gain(camera, minvalue, maxvalue) != DC1394_SUCCESS) {
1905 if (dc1394_avt_get_auto_gain(camera, &minvalue, &maxvalue) != DC1394_SUCCESS) {
1930void vp1394TwoGrabber::setCapture(dc1394switch_t _switch)
1938 if (_switch == DC1394_ON) {
1941 if (dc1394_capture_setup(camera, num_buffers, DC1394_CAPTURE_FLAGS_DEFAULT) != DC1394_SUCCESS) {
1943 "make sure that the video mode and framerate are "
1944 "supported by your camera.\n");
1950 dc1394error_t code = dc1394_capture_stop(camera);
1952 if (code != DC1394_SUCCESS && code != DC1394_CAPTURE_IS_NOT_SET) {
1974void vp1394TwoGrabber::setTransmission(dc1394switch_t _switch)
1982 dc1394switch_t status = DC1394_OFF;
1984 if (dc1394_video_get_transmission(camera, &status) != DC1394_SUCCESS) {
1992 if (dc1394_video_set_transmission(camera, _switch) != DC1394_SUCCESS) {
1994 "make sure that the video mode and framerate are "
1995 "supported by your camera.\n");
2000 if (_switch == DC1394_ON) {
2001 status = DC1394_OFF;
2004 while (status == DC1394_OFF && i++ < 5) {
2006 if (dc1394_video_get_transmission(camera, &status) != DC1394_SUCCESS) {
2061 dc1394operation_mode_t op_mode;
2062 dc1394speed_t speed;
2066 if (camera->bmode_capable != DC1394_TRUE) {
2071 if (dc1394_video_set_operation_mode(camera, DC1394_OPERATION_MODE_1394B) != DC1394_SUCCESS) {
2076 if (dc1394_video_get_operation_mode(camera, &op_mode) != DC1394_SUCCESS) {
2082 if (dc1394_video_set_operation_mode(camera, DC1394_OPERATION_MODE_LEGACY) != DC1394_SUCCESS) {
2087 if (dc1394_video_get_operation_mode(camera, &op_mode) != DC1394_SUCCESS) {
2093 if (dc1394_video_set_iso_speed(camera, (dc1394speed_t)isospeed) != DC1394_SUCCESS) {
2098 if (dc1394_video_get_iso_speed(camera, &speed) != DC1394_SUCCESS) {
2186 dc1394video_frame_t *frame =
nullptr;
2188 if (dc1394_capture_dequeue(camera, DC1394_CAPTURE_POLICY_WAIT, &frame) != DC1394_SUCCESS) {
2189 vpERROR_TRACE(
"Error: Failed to capture from camera %d\n", camera_id);
2244 dc1394video_frame_t *frame;
2246 frame =
dequeue(I, timestamp,
id);
2307 dc1394video_frame_t *frame;
2313 timestamp = frame->timestamp;
2316 this->
width = frame->size[0];
2317 this->
height = frame->size[1];
2320 if ((I.getWidth() != this->width) || (I.getHeight() != this->height))
2321 I.resize(this->height, this->
width);
2323 switch (frame->color_coding) {
2324 case DC1394_COLOR_CODING_MONO8:
2325 case DC1394_COLOR_CODING_RAW8:
2326 memcpy(I.bitmap, (
unsigned char *)frame->image, size *
sizeof(
unsigned char));
2328 case DC1394_COLOR_CODING_MONO16:
2329 case DC1394_COLOR_CODING_RAW16:
2333 case DC1394_COLOR_CODING_YUV411:
2337 case DC1394_COLOR_CODING_YUV422:
2341 case DC1394_COLOR_CODING_YUV444:
2345 case DC1394_COLOR_CODING_RGB8:
2351 vpERROR_TRACE(
"Format conversion not implemented. Acquisition failed.");
2353 "Acquisition failed."));
2407 dc1394video_frame_t *frame;
2409 frame =
dequeue(I, timestamp,
id);
2470 dc1394video_frame_t *frame;
2476 timestamp = frame->timestamp;
2479 this->
width = frame->size[0];
2480 this->
height = frame->size[1];
2483 if ((I.getWidth() !=
width) || (I.getHeight() !=
height))
2486 switch (frame->color_coding) {
2487 case DC1394_COLOR_CODING_MONO8:
2488 case DC1394_COLOR_CODING_RAW8:
2492 case DC1394_COLOR_CODING_MONO16:
2493 case DC1394_COLOR_CODING_RAW16:
2497 case DC1394_COLOR_CODING_YUV411:
2501 case DC1394_COLOR_CODING_YUV422:
2505 case DC1394_COLOR_CODING_YUV444:
2509 case DC1394_COLOR_CODING_RGB8:
2515 vpERROR_TRACE(
"Format conversion not implemented. Acquisition failed.");
2517 "Acquisition failed."));
2543 dc1394_capture_enqueue(camera, frame);
2564 dc1394video_frame_t *frame;
2566 frame =
dequeue(I, timestamp,
id);
2590 dc1394video_frame_t *frame;
2593 frame =
dequeue(I, timestamp,
id);
2614 dc1394video_frame_t *frame;
2617 frame =
dequeue(I, timestamp,
id);
2641 dc1394video_frame_t *frame;
2647 timestamp = frame->timestamp;
2650 this->
width = frame->size[0];
2651 this->
height = frame->size[1];
2654 if ((I.getWidth() !=
width) || (I.getHeight() !=
height))
2657 switch (frame->color_coding) {
2658 case DC1394_COLOR_CODING_MONO8:
2659 case DC1394_COLOR_CODING_RAW8:
2663 case DC1394_COLOR_CODING_YUV411:
2667 case DC1394_COLOR_CODING_YUV422:
2671 case DC1394_COLOR_CODING_YUV444:
2675 case DC1394_COLOR_CODING_RGB8:
2681 vpERROR_TRACE(
"Format conversion not implemented. Acquisition failed.");
2683 "Acquisition failed."));
2806 std::cout <<
"----------------------------------------------------------" << std::endl
2807 <<
"----- Information for camera " << camera_id <<
" -----" << std::endl
2808 <<
"----------------------------------------------------------" << std::endl;
2810#ifdef VISP_HAVE_DC1394_CAMERA_ENUMERATE
2811 dc1394_camera_print_info(camera, stdout);
2812#elif defined VISP_HAVE_DC1394_FIND_CAMERAS
2813 dc1394_print_camera_info(camera);
2816 dc1394featureset_t features;
2817#ifdef VISP_HAVE_DC1394_CAMERA_ENUMERATE
2818 if (dc1394_feature_get_all(camera, &features) != DC1394_SUCCESS)
2819#elif defined VISP_HAVE_DC1394_FIND_CAMERAS
2820 if (dc1394_get_camera_feature_set(camera, &features) != DC1394_SUCCESS)
2824 vpERROR_TRACE(
"unable to get feature set for camera %d\n", camera_id);
2829#ifdef VISP_HAVE_DC1394_CAMERA_ENUMERATE
2830 dc1394_feature_print_all(&features, stdout);
2831#elif defined VISP_HAVE_DC1394_FIND_CAMERAS
2832 dc1394_print_feature_set(&features);
2835 std::cout <<
"----------------------------------------------------------" << std::endl;
2852 std::string _str =
"";
2853 dc1394video_mode_t _videomode = (dc1394video_mode_t)videomode;
2855 if ((_videomode >= DC1394_VIDEO_MODE_MIN) && (_videomode <= DC1394_VIDEO_MODE_MAX)) {
2856 _str =
strVideoMode[_videomode - DC1394_VIDEO_MODE_MIN];
2859 vpCERROR <<
"The video mode " <<
static_cast<int>(videomode) <<
" is not supported by the camera" << std::endl;
2879 std::string _str =
"";
2880 dc1394framerate_t _fps = (dc1394framerate_t)fps;
2882 if ((_fps >= DC1394_FRAMERATE_MIN) && (_fps <= DC1394_FRAMERATE_MAX)) {
2886 vpCERROR <<
"The framerate " <<
static_cast<int>(fps) <<
" is not supported by the camera" << std::endl;
2906 std::string _str =
"";
2907 dc1394color_coding_t _coding = (dc1394color_coding_t)colorcoding;
2909 if ((_coding >= DC1394_COLOR_CODING_MIN) && (_coding <= DC1394_COLOR_CODING_MAX)) {
2914 vpCERROR <<
"The color coding " <<
static_cast<int>(colorcoding) <<
" is not supported by the camera" << std::endl;
2941 for (
int i = DC1394_VIDEO_MODE_MIN; i <= DC1394_VIDEO_MODE_MAX; i++) {
2973 for (
int i = DC1394_FRAMERATE_MIN; i <= DC1394_FRAMERATE_MAX; i++) {
3005 for (
int i = DC1394_COLOR_CODING_MIN; i <= DC1394_COLOR_CODING_MAX; i++) {
3053 for (
unsigned int i = 0; i < num_cameras; i++) {
3055 camera = cameras[i];
3056 setTransmission(DC1394_OFF);
3057 setCapture(DC1394_OFF);
3060#ifdef VISP_HAVE_DC1394_CAMERA_ENUMERATE
3063 for (
unsigned int i = 0; i < num_cameras; i++) {
3065 dc1394_camera_free(cameras[i]);
3068 printf(
"Resetting bus...\n");
3069 dc1394_reset_bus(camera);
3071 dc1394_camera_free(camera);
3077#elif defined VISP_HAVE_DC1394_FIND_CAMERAS
3081 for (
unsigned int i = 0; i < num_cameras; i++) {
3083 dc1394_free_camera(cameras[i]);
3088 dc1394_reset_bus(camera);
3089 dc1394_free_camera(camera);
3092 if (camIsOpen !=
nullptr)
3094 camIsOpen =
nullptr;
3141 uint64_t offset = 0x884;
3142 uint32_t value = 0x82000000 +
static_cast<uint32_t
>(panControlValue);
3144 err = dc1394_set_control_register(camera, offset, value);
3145 if (err != DC1394_SUCCESS) {
3177 dc1394feature_t feature = DC1394_FEATURE_BRIGHTNESS;
3180 feature = DC1394_FEATURE_BRIGHTNESS;
3183 feature = DC1394_FEATURE_EXPOSURE;
3186 feature = DC1394_FEATURE_SHARPNESS;
3190 feature = DC1394_FEATURE_HUE;
3193 feature = DC1394_FEATURE_SATURATION;
3196 feature = DC1394_FEATURE_GAMMA;
3199 feature = DC1394_FEATURE_SHUTTER;
3202 feature = DC1394_FEATURE_GAIN;
3205 feature = DC1394_FEATURE_IRIS;
3222 err = dc1394_feature_get_value(camera, feature, &value);
3223 if (err != DC1394_SUCCESS) {
3228 return (
static_cast<unsigned int>(value));
3259 uint32_t value =
static_cast<uint32_t
>(val);
3260 dc1394feature_t feature = DC1394_FEATURE_BRIGHTNESS;
3263 feature = DC1394_FEATURE_BRIGHTNESS;
3266 feature = DC1394_FEATURE_EXPOSURE;
3269 feature = DC1394_FEATURE_SHARPNESS;
3273 feature = DC1394_FEATURE_HUE;
3276 feature = DC1394_FEATURE_SATURATION;
3279 feature = DC1394_FEATURE_GAMMA;
3282 feature = DC1394_FEATURE_SHUTTER;
3285 feature = DC1394_FEATURE_GAIN;
3288 feature = DC1394_FEATURE_IRIS;
3305 dc1394bool_t hasManualMode = DC1394_FALSE;
3306 dc1394feature_modes_t modesAvailable;
3309 err = dc1394_feature_get_modes(camera, feature, &modesAvailable);
3310 if (err != DC1394_SUCCESS) {
3311 vpERROR_TRACE(
"Unable to detect the manual mode information");
3317 for (
unsigned int i = 0; i < modesAvailable.num; i++) {
3318 if (modesAvailable.modes[i] == DC1394_FEATURE_MODE_MANUAL) {
3319 hasManualMode = DC1394_TRUE;
3323 if (hasManualMode == DC1394_TRUE) {
3325 if (!isDataModified[camera_id]) {
3328 updateDataCamToStruct();
3329 err = dc1394_feature_get_mode(camera, feature, &(initialShutterMode[camera_id]));
3330 if (err != DC1394_SUCCESS) {
3335 isDataModified[camera_id] =
true;
3338 dc1394feature_mode_t manualMode = DC1394_FEATURE_MODE_MANUAL;
3339 err = dc1394_feature_set_mode(camera, feature, manualMode);
3340 if (err != DC1394_SUCCESS) {
3345 err = dc1394_feature_set_value(camera, feature, value);
3346 if (err != DC1394_SUCCESS) {
3353 vpERROR_TRACE(
"The camera does not have a manual mode.\nCannot change the value");
3372 guid = camera->guid;
3390 return camera->guid;
3397inline void vp1394TwoGrabber::updateDataCamToStruct()
3414inline void vp1394TwoGrabber::updateDataStructToCam()
3478#elif !defined(VISP_BUILD_SHARED_LIBS)
3481void dummy_vp1394TwoGrabber() { }
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)
Definition of the vpImage class member functions.
VISP_EXPORT int wait(double t0, double t)