42 #include <visp3/core/vpConfig.h>
47 #if defined(VISP_HAVE_DC1394)
50 #include <visp3/core/vpFrameGrabberException.h>
51 #include <visp3/core/vpImageConvert.h>
52 #include <visp3/core/vpTime.h>
53 #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",
120 : camera(nullptr), cameras(nullptr), num_cameras(0), camera_id(0), verbose(false), camIsOpen(nullptr),
122 isDataModified(nullptr), initialShutterMode(nullptr), dataCam(nullptr)
123 #ifdef VISP_HAVE_DC1394_CAMERA_ENUMERATE
125 d(nullptr), list(nullptr)
281 if (cam_id >= num_cameras) {
283 bool is_guid =
false;
285 for (
unsigned int i = 0; i < num_cameras; i++) {
286 if (cameras[i]->guid == cam_id) {
292 if (is_guid ==
false) {
293 std::cout <<
"Error: The camera with guid 0x" << std::hex << cam_id <<
" is not present" << std::endl;
294 std::cout << num_cameras <<
" camera(s) connected" << std::endl;
295 for (
unsigned int i = 0; i < num_cameras; i++) {
296 std::cout <<
" - camera " << i <<
" with guid 0x" << std::hex << cameras[i]->guid << std::endl;
303 this->camera_id = (
unsigned int)cam_id;
309 camera = cameras[this->camera_id];
329 cam_id = this->camera_id;
355 return this->camera_id;
374 vpCTRACE <<
"No camera found..." << std::endl;
378 ncameras = num_cameras;
390 unsigned int ncameras = 0;
392 vpCTRACE <<
"No camera found..." << std::endl;
396 ncameras = num_cameras;
456 setTransmission(DC1394_OFF);
457 setCapture(DC1394_OFF);
459 if (dc1394_video_set_mode(camera, (dc1394video_mode_t)videomode) != DC1394_SUCCESS) {
464 setCapture(DC1394_ON);
465 setTransmission(DC1394_ON);
468 if (dc1394_get_image_size_from_video_mode(camera, (dc1394video_mode_t)videomode, &this->
width, &this->
height) !=
500 dc1394video_mode_t _videomode;
501 if (dc1394_video_get_mode(camera, &_videomode) != DC1394_SUCCESS) {
537 dc1394video_modes_t _videomodes;
540 if (dc1394_video_get_supported_modes(camera, &_videomodes) != DC1394_SUCCESS) {
548 for (
unsigned i = 0; i < _videomodes.num; i++) {
550 videomodes.push_back(_mode);
554 return _videomodes.num;
578 dc1394video_modes_t _videomodes;
581 if (dc1394_video_get_supported_modes(camera, &_videomodes) != DC1394_SUCCESS) {
589 for (
unsigned i = 0; i < _videomodes.num; i++) {
611 if (dc1394_is_video_mode_scalable((dc1394video_mode_t)videomode))
698 setTransmission(DC1394_OFF);
699 setCapture(DC1394_OFF);
701 if (dc1394_video_set_framerate(camera, (dc1394framerate_t)fps) != DC1394_SUCCESS) {
707 setCapture(DC1394_ON);
708 setTransmission(DC1394_ON);
734 dc1394framerate_t _fps;
735 if (dc1394_video_get_framerate(camera, &_fps) != DC1394_SUCCESS) {
802 dc1394framerates_t _fps;
803 if (dc1394_video_get_supported_framerates(camera, (dc1394video_mode_t)mode, &_fps) != DC1394_SUCCESS) {
805 vpERROR_TRACE(
"Could not query supported frametates for mode %d\n", mode);
811 for (
unsigned int i = 0; i < _fps.num; i++)
875 dc1394framerates_t _fps;
876 if (dc1394_video_get_supported_framerates(camera, (dc1394video_mode_t)mode, &_fps) != DC1394_SUCCESS) {
878 vpERROR_TRACE(
"Could not query supported frametates for mode %d\n", mode);
884 for (
unsigned int i = 0; i < _fps.num; i++) {
948 dc1394video_mode_t _videomode;
949 if (dc1394_video_get_mode(camera, &_videomode) != DC1394_SUCCESS) {
961 if (dc1394_is_video_mode_scalable(_videomode)) {
962 setTransmission(DC1394_OFF);
963 setCapture(DC1394_OFF);
965 if (dc1394_format7_set_color_coding(camera, _videomode, (dc1394color_coding_t)coding) != DC1394_SUCCESS) {
971 setCapture(DC1394_ON);
972 setTransmission(DC1394_ON);
1000 dc1394video_mode_t _videomode;
1001 if (dc1394_video_get_mode(camera, &_videomode) != DC1394_SUCCESS) {
1008 dc1394color_coding_t _coding;
1009 if (dc1394_is_video_mode_scalable(_videomode)) {
1011 if (dc1394_format7_get_color_coding(camera, _videomode, &_coding) != DC1394_SUCCESS) {
1018 else if (dc1394_is_video_mode_still_image((dc1394video_mode_t)_videomode)) {
1023 if (dc1394_get_color_coding_from_video_mode(camera, (dc1394video_mode_t)_videomode, &_coding) != DC1394_SUCCESS) {
1025 vpERROR_TRACE(
"Could not query supported color coding for mode %d\n", _videomode);
1054 std::list<vp1394TwoColorCodingType> &codings)
1065 if (dc1394_is_video_mode_scalable((dc1394video_mode_t)mode)) {
1067 dc1394color_codings_t _codings;
1068 if (dc1394_format7_get_color_codings(camera, (dc1394video_mode_t)mode, &_codings) != DC1394_SUCCESS) {
1070 vpERROR_TRACE(
"Could not query supported color codings for mode %d\n", mode);
1073 if (_codings.num == 0)
1076 for (
unsigned int i = 0; i < _codings.num; i++)
1079 return _codings.num;
1081 else if (dc1394_is_video_mode_still_image((dc1394video_mode_t)mode)) {
1087 dc1394color_coding_t _coding;
1088 if (dc1394_get_color_coding_from_video_mode(camera, (dc1394video_mode_t)mode, &_coding) != DC1394_SUCCESS) {
1090 vpERROR_TRACE(
"Could not query supported color coding for mode %d\n", mode);
1126 if (dc1394_is_video_mode_scalable((dc1394video_mode_t)mode)) {
1128 dc1394color_codings_t _codings;
1129 if (dc1394_format7_get_color_codings(camera, (dc1394video_mode_t)mode, &_codings) != DC1394_SUCCESS) {
1131 vpERROR_TRACE(
"Could not query supported color codings for mode %d\n", mode);
1134 if (_codings.num == 0)
1137 for (
unsigned int i = 0; i < _codings.num; i++) {
1143 else if (dc1394_is_video_mode_still_image((dc1394video_mode_t)mode)) {
1149 dc1394color_coding_t _coding;
1150 if (dc1394_get_color_coding_from_video_mode(camera, (dc1394video_mode_t)mode, &_coding) != DC1394_SUCCESS) {
1152 vpERROR_TRACE(
"Could not query supported color coding for mode %d\n", mode);
1203 dc1394video_mode_t _videomode;
1204 if (dc1394_video_get_mode(camera, &_videomode) != DC1394_SUCCESS) {
1210 if (dc1394_is_video_mode_scalable(_videomode)) {
1212 setTransmission(DC1394_OFF);
1213 setCapture(DC1394_OFF);
1215 unsigned int max_width, max_height;
1216 if (dc1394_format7_get_max_image_size(camera, _videomode, &max_width, &max_height) != DC1394_SUCCESS) {
1223 vpTRACE(
"left: %d top: %d width: %d height: %d", left, top,
1224 width == 0 ? DC1394_USE_MAX_AVAIL : w,
1225 height == 0 ? DC1394_USE_MAX_AVAIL : h);
1226 vpTRACE(
"max_width: %d max_height: %d", max_width, max_height);
1229 if (left > max_width) {
1233 if (top > max_height) {
1243 if (w > (max_width - left))
1244 w = (max_width - left);
1245 roi_width = (int32_t)w;
1248 roi_width = DC1394_USE_MAX_AVAIL;
1253 if (h > (max_height - top))
1254 h = (max_height - top);
1255 roi_height = (int32_t)h;
1258 roi_height = DC1394_USE_MAX_AVAIL;
1261 if (dc1394_format7_set_roi(camera, _videomode,
1262 (dc1394color_coding_t)DC1394_QUERY_FROM_CAMERA,
1263 DC1394_USE_MAX_AVAIL
1267 roi_width, roi_height) != DC1394_SUCCESS) {
1273 if (dc1394_format7_get_image_size(camera, _videomode, &this->
width, &this->
height) != DC1394_SUCCESS) {
1279 setCapture(DC1394_ON);
1280 setTransmission(DC1394_ON);
1297 void vp1394TwoGrabber::initialize(
bool reset)
1299 if (
init ==
false) {
1301 #ifdef VISP_HAVE_DC1394_CAMERA_ENUMERATE
1306 if (dc1394_camera_enumerate(d, &list) != DC1394_SUCCESS) {
1307 dc1394_camera_free_list(list);
1313 if (list->num == 0) {
1314 dc1394_camera_free_list(list);
1320 if (cameras !=
nullptr)
1323 cameras =
new dc1394camera_t *[list->num];
1327 for (
unsigned int i = 0; i < list->num; i++) {
1328 cameras[i] = dc1394_camera_new(d, list->ids[i].guid);
1330 vpTRACE(
"Failed to initialize camera with guid \"%ld\"\n", list->ids[i].guid);
1341 dc1394_reset_bus(cameras[0]);
1345 dc1394_camera_free_list(list);
1348 #elif defined VISP_HAVE_DC1394_FIND_CAMERAS
1349 if (cameras !=
nullptr)
1352 int err = dc1394_find_cameras(&cameras, &num_cameras);
1354 if (err != DC1394_SUCCESS && err != DC1394_NO_CAMERA) {
1358 " - if the kernel modules `ieee1394',`raw1394' and "
1359 "`ohci1394' are loaded \n"
1360 " - if you have read/write access to /dev/raw1394\n\n");
1365 if (num_cameras == 0) {
1372 isDataModified =
new bool[num_cameras];
1373 for (
unsigned int i = 0; i < num_cameras; i++)
1374 isDataModified[i] =
false;
1375 initialShutterMode =
new dc1394feature_mode_t[num_cameras];
1376 dataCam =
new vpDc1394TwoCameraParametersData[num_cameras];
1378 if (camera_id >= num_cameras) {
1387 std::cout <<
"------ Bus information ------" << std::endl;
1388 std::cout <<
"Number of camera(s) on the bus : " << num_cameras << std::endl;
1389 std::cout <<
"-----------------------------" << std::endl;
1392 if (camIsOpen !=
nullptr)
1394 camIsOpen =
new bool[num_cameras];
1395 for (
unsigned int i = 0; i < num_cameras; i++) {
1396 camIsOpen[i] =
false;
1415 if (camIsOpen[camera_id] ==
false) {
1416 dc1394switch_t status = DC1394_OFF;
1420 dc1394_video_get_transmission(cameras[camera_id], &status);
1421 if (status != DC1394_OFF) {
1423 if (dc1394_video_set_transmission(cameras[camera_id], DC1394_OFF) != DC1394_SUCCESS)
1424 vpTRACE(
"Could not stop ISO transmission");
1427 if (dc1394_video_get_transmission(cameras[camera_id], &status) != DC1394_SUCCESS)
1428 vpTRACE(
"Could get ISO status");
1430 if (status == DC1394_ON) {
1431 vpTRACE(
"ISO transmission refuses to stop");
1433 #ifdef VISP_HAVE_DC1394_FIND_CAMERAS
1435 cameras[camera_id]->is_iso_on = status;
1445 setCapture(DC1394_ON);
1446 setTransmission(DC1394_ON);
1447 camIsOpen[camera_id] =
true;
1462 for (
unsigned int i = 0; i < num_cameras; i++) {
1464 camera = cameras[i];
1465 this->camera_id = i;
1466 setTransmission(DC1394_OFF);
1467 setCapture(DC1394_OFF);
1468 if (isDataModified[i]) {
1471 updateDataStructToCam();
1476 if (dc1394_feature_set_mode(camera, DC1394_FEATURE_BRIGHTNESS, initialShutterMode[i]) != DC1394_SUCCESS ||
1477 dc1394_feature_set_mode(camera, DC1394_FEATURE_EXPOSURE, initialShutterMode[i]) != DC1394_SUCCESS ||
1478 dc1394_feature_set_mode(camera, DC1394_FEATURE_SHARPNESS, initialShutterMode[i]) != DC1394_SUCCESS ||
1479 dc1394_feature_set_mode(camera, DC1394_FEATURE_HUE, initialShutterMode[i]) != DC1394_SUCCESS ||
1480 dc1394_feature_set_mode(camera, DC1394_FEATURE_SATURATION, initialShutterMode[i]) != DC1394_SUCCESS ||
1481 dc1394_feature_set_mode(camera, DC1394_FEATURE_GAMMA, initialShutterMode[i]) != DC1394_SUCCESS ||
1482 dc1394_feature_set_mode(camera, DC1394_FEATURE_SHUTTER, initialShutterMode[i]) != DC1394_SUCCESS ||
1483 dc1394_feature_set_mode(camera, DC1394_FEATURE_GAIN, initialShutterMode[i]) != DC1394_SUCCESS ||
1484 dc1394_feature_set_mode(camera, DC1394_FEATURE_IRIS, initialShutterMode[i])) {
1490 if (dc1394_camera_set_power(camera, DC1394_OFF) != DC1394_SUCCESS)
1491 std::cout <<
"Unable to turn camera off" << std::endl;
1493 #ifdef VISP_HAVE_DC1394_CAMERA_ENUMERATE
1494 dc1394_camera_free(cameras[i]);
1495 #elif defined VISP_HAVE_DC1394_FIND_CAMERAS
1496 dc1394_free_camera(cameras[i]);
1500 if (camIsOpen !=
nullptr) {
1502 camIsOpen =
nullptr;
1505 #ifdef VISP_HAVE_DC1394_CAMERA_ENUMERATE
1506 if (cameras !=
nullptr) {
1515 #elif defined VISP_HAVE_DC1394_FIND_CAMERAS
1516 if (cameras !=
nullptr) {
1522 camIsOpen =
nullptr;
1526 if (isDataModified !=
nullptr) {
1527 delete[] isDataModified;
1528 isDataModified =
nullptr;
1530 if (initialShutterMode !=
nullptr) {
1531 delete[] initialShutterMode;
1532 initialShutterMode =
nullptr;
1534 if (dataCam !=
nullptr) {
1562 if (size != num_buffers) {
1565 if (camIsOpen[camera_id]) {
1566 setCapture(DC1394_OFF);
1567 setCapture(DC1394_ON);
1629 dc1394feature_mode_t mode;
1631 mode = DC1394_FEATURE_MODE_AUTO;
1634 mode = DC1394_FEATURE_MODE_MANUAL;
1637 if (dc1394_feature_set_power(camera, DC1394_FEATURE_SHUTTER, DC1394_ON) != DC1394_SUCCESS) {
1643 if (dc1394_feature_set_mode(camera, DC1394_FEATURE_SHUTTER, mode) != DC1394_SUCCESS) {
1692 if (dc1394_avt_set_auto_shutter(camera, minvalue, maxvalue) != DC1394_SUCCESS) {
1720 if (dc1394_avt_get_auto_shutter(camera, &minvalue, &maxvalue) != DC1394_SUCCESS) {
1774 dc1394feature_mode_t mode;
1776 mode = DC1394_FEATURE_MODE_AUTO;
1779 mode = DC1394_FEATURE_MODE_MANUAL;
1782 if (dc1394_feature_set_power(camera, DC1394_FEATURE_GAIN, DC1394_ON) != DC1394_SUCCESS) {
1788 if (dc1394_feature_set_mode(camera, DC1394_FEATURE_GAIN, mode) != DC1394_SUCCESS) {
1837 if (dc1394_avt_set_auto_gain(camera, minvalue, maxvalue) != DC1394_SUCCESS) {
1865 if (dc1394_avt_get_auto_gain(camera, &minvalue, &maxvalue) != DC1394_SUCCESS) {
1890 void vp1394TwoGrabber::setCapture(dc1394switch_t _switch)
1898 if (_switch == DC1394_ON) {
1901 if (dc1394_capture_setup(camera, num_buffers, DC1394_CAPTURE_FLAGS_DEFAULT) != DC1394_SUCCESS) {
1903 "make sure that the video mode and framerate are "
1904 "supported by your camera.\n");
1910 dc1394error_t code = dc1394_capture_stop(camera);
1912 if (code != DC1394_SUCCESS && code != DC1394_CAPTURE_IS_NOT_SET) {
1934 void vp1394TwoGrabber::setTransmission(dc1394switch_t _switch)
1942 dc1394switch_t status = DC1394_OFF;
1944 if (dc1394_video_get_transmission(camera, &status) != DC1394_SUCCESS) {
1952 if (dc1394_video_set_transmission(camera, _switch) != DC1394_SUCCESS) {
1954 "make sure that the video mode and framerate are "
1955 "supported by your camera.\n");
1960 if (_switch == DC1394_ON) {
1961 status = DC1394_OFF;
1964 while (status == DC1394_OFF && i++ < 5) {
1966 if (dc1394_video_get_transmission(camera, &status) != DC1394_SUCCESS) {
2017 dc1394operation_mode_t op_mode;
2018 dc1394speed_t speed;
2022 if (camera->bmode_capable != DC1394_TRUE) {
2027 if (dc1394_video_set_operation_mode(camera, DC1394_OPERATION_MODE_1394B) != DC1394_SUCCESS) {
2032 if (dc1394_video_get_operation_mode(camera, &op_mode) != DC1394_SUCCESS) {
2038 if (dc1394_video_set_operation_mode(camera, DC1394_OPERATION_MODE_LEGACY) != DC1394_SUCCESS) {
2043 if (dc1394_video_get_operation_mode(camera, &op_mode) != DC1394_SUCCESS) {
2049 if (dc1394_video_set_iso_speed(camera, (dc1394speed_t)isospeed) != DC1394_SUCCESS) {
2054 if (dc1394_video_get_iso_speed(camera, &speed) != DC1394_SUCCESS) {
2138 dc1394video_frame_t *frame =
nullptr;
2140 if (dc1394_capture_dequeue(camera, DC1394_CAPTURE_POLICY_WAIT, &frame) != DC1394_SUCCESS) {
2141 vpERROR_TRACE(
"Error: Failed to capture from camera %d\n", camera_id);
2192 dc1394video_frame_t *frame;
2194 frame =
dequeue(I, timestamp,
id);
2251 dc1394video_frame_t *frame;
2257 timestamp = frame->timestamp;
2260 this->
width = frame->size[0];
2261 this->
height = frame->size[1];
2267 switch (frame->color_coding) {
2268 case DC1394_COLOR_CODING_MONO8:
2269 case DC1394_COLOR_CODING_RAW8:
2270 memcpy(I.
bitmap, (
unsigned char *)frame->image, size *
sizeof(
unsigned char));
2272 case DC1394_COLOR_CODING_MONO16:
2273 case DC1394_COLOR_CODING_RAW16:
2277 case DC1394_COLOR_CODING_YUV411:
2281 case DC1394_COLOR_CODING_YUV422:
2285 case DC1394_COLOR_CODING_YUV444:
2289 case DC1394_COLOR_CODING_RGB8:
2295 vpERROR_TRACE(
"Format conversion not implemented. Acquisition failed.");
2297 "Acquisition failed."));
2347 dc1394video_frame_t *frame;
2349 frame =
dequeue(I, timestamp,
id);
2406 dc1394video_frame_t *frame;
2412 timestamp = frame->timestamp;
2415 this->
width = frame->size[0];
2416 this->
height = frame->size[1];
2422 switch (frame->color_coding) {
2423 case DC1394_COLOR_CODING_MONO8:
2424 case DC1394_COLOR_CODING_RAW8:
2428 case DC1394_COLOR_CODING_MONO16:
2429 case DC1394_COLOR_CODING_RAW16:
2433 case DC1394_COLOR_CODING_YUV411:
2437 case DC1394_COLOR_CODING_YUV422:
2441 case DC1394_COLOR_CODING_YUV444:
2445 case DC1394_COLOR_CODING_RGB8:
2451 vpERROR_TRACE(
"Format conversion not implemented. Acquisition failed.");
2453 "Acquisition failed."));
2479 dc1394_capture_enqueue(camera, frame);
2500 dc1394video_frame_t *frame;
2502 frame =
dequeue(I, timestamp,
id);
2526 dc1394video_frame_t *frame;
2529 frame =
dequeue(I, timestamp,
id);
2550 dc1394video_frame_t *frame;
2553 frame =
dequeue(I, timestamp,
id);
2577 dc1394video_frame_t *frame;
2583 timestamp = frame->timestamp;
2586 this->
width = frame->size[0];
2587 this->
height = frame->size[1];
2593 switch (frame->color_coding) {
2594 case DC1394_COLOR_CODING_MONO8:
2595 case DC1394_COLOR_CODING_RAW8:
2599 case DC1394_COLOR_CODING_YUV411:
2603 case DC1394_COLOR_CODING_YUV422:
2607 case DC1394_COLOR_CODING_YUV444:
2611 case DC1394_COLOR_CODING_RGB8:
2617 vpERROR_TRACE(
"Format conversion not implemented. Acquisition failed.");
2619 "Acquisition failed."));
2742 std::cout <<
"----------------------------------------------------------" << std::endl
2743 <<
"----- Information for camera " << camera_id <<
" -----" << std::endl
2744 <<
"----------------------------------------------------------" << std::endl;
2746 #ifdef VISP_HAVE_DC1394_CAMERA_ENUMERATE
2747 dc1394_camera_print_info(camera, stdout);
2748 #elif defined VISP_HAVE_DC1394_FIND_CAMERAS
2749 dc1394_print_camera_info(camera);
2752 dc1394featureset_t features;
2753 #ifdef VISP_HAVE_DC1394_CAMERA_ENUMERATE
2754 if (dc1394_feature_get_all(camera, &features) != DC1394_SUCCESS)
2755 #elif defined VISP_HAVE_DC1394_FIND_CAMERAS
2756 if (dc1394_get_camera_feature_set(camera, &features) != DC1394_SUCCESS)
2760 vpERROR_TRACE(
"unable to get feature set for camera %d\n", camera_id);
2765 #ifdef VISP_HAVE_DC1394_CAMERA_ENUMERATE
2766 dc1394_feature_print_all(&features, stdout);
2767 #elif defined VISP_HAVE_DC1394_FIND_CAMERAS
2768 dc1394_print_feature_set(&features);
2771 std::cout <<
"----------------------------------------------------------" << std::endl;
2788 std::string _str =
"";
2789 dc1394video_mode_t _videomode = (dc1394video_mode_t)videomode;
2791 if ((_videomode >= DC1394_VIDEO_MODE_MIN) && (_videomode <= DC1394_VIDEO_MODE_MAX)) {
2792 _str =
strVideoMode[_videomode - DC1394_VIDEO_MODE_MIN];
2795 vpCERROR <<
"The video mode " << (int)videomode <<
" is not supported by the camera" << std::endl;
2815 std::string _str =
"";
2816 dc1394framerate_t _fps = (dc1394framerate_t)fps;
2818 if ((_fps >= DC1394_FRAMERATE_MIN) && (_fps <= DC1394_FRAMERATE_MAX)) {
2822 vpCERROR <<
"The framerate " << (int)fps <<
" is not supported by the camera" << std::endl;
2842 std::string _str =
"";
2843 dc1394color_coding_t _coding = (dc1394color_coding_t)colorcoding;
2845 if ((_coding >= DC1394_COLOR_CODING_MIN) && (_coding <= DC1394_COLOR_CODING_MAX)) {
2850 vpCERROR <<
"The color coding " << (int)colorcoding <<
" is not supported by the camera" << std::endl;
2877 for (
int i = DC1394_VIDEO_MODE_MIN; i <= DC1394_VIDEO_MODE_MAX; i++) {
2909 for (
int i = DC1394_FRAMERATE_MIN; i <= DC1394_FRAMERATE_MAX; i++) {
2941 for (
int i = DC1394_COLOR_CODING_MIN; i <= DC1394_COLOR_CODING_MAX; i++) {
2985 for (
unsigned int i = 0; i < num_cameras; i++) {
2987 camera = cameras[i];
2988 setTransmission(DC1394_OFF);
2989 setCapture(DC1394_OFF);
2992 #ifdef VISP_HAVE_DC1394_CAMERA_ENUMERATE
2995 for (
unsigned int i = 0; i < num_cameras; i++) {
2997 dc1394_camera_free(cameras[i]);
3000 printf(
"Resetting bus...\n");
3001 dc1394_reset_bus(camera);
3003 dc1394_camera_free(camera);
3009 #elif defined VISP_HAVE_DC1394_FIND_CAMERAS
3013 for (
unsigned int i = 0; i < num_cameras; i++) {
3015 dc1394_free_camera(cameras[i]);
3020 dc1394_reset_bus(camera);
3021 dc1394_free_camera(camera);
3024 if (camIsOpen !=
nullptr)
3026 camIsOpen =
nullptr;
3073 uint64_t offset = 0x884;
3074 uint32_t value = 0x82000000 + (uint32_t)panControlValue;
3076 err = dc1394_set_control_register(camera, offset, value);
3077 if (err != DC1394_SUCCESS) {
3109 dc1394feature_t feature = DC1394_FEATURE_BRIGHTNESS;
3112 feature = DC1394_FEATURE_BRIGHTNESS;
3115 feature = DC1394_FEATURE_EXPOSURE;
3118 feature = DC1394_FEATURE_SHARPNESS;
3122 feature = DC1394_FEATURE_HUE;
3125 feature = DC1394_FEATURE_SATURATION;
3128 feature = DC1394_FEATURE_GAMMA;
3131 feature = DC1394_FEATURE_SHUTTER;
3134 feature = DC1394_FEATURE_GAIN;
3137 feature = DC1394_FEATURE_IRIS;
3154 err = dc1394_feature_get_value(camera, feature, &value);
3155 if (err != DC1394_SUCCESS) {
3160 return (
unsigned int)value;
3191 uint32_t value = (uint32_t)val;
3192 dc1394feature_t feature = DC1394_FEATURE_BRIGHTNESS;
3195 feature = DC1394_FEATURE_BRIGHTNESS;
3198 feature = DC1394_FEATURE_EXPOSURE;
3201 feature = DC1394_FEATURE_SHARPNESS;
3205 feature = DC1394_FEATURE_HUE;
3208 feature = DC1394_FEATURE_SATURATION;
3211 feature = DC1394_FEATURE_GAMMA;
3214 feature = DC1394_FEATURE_SHUTTER;
3217 feature = DC1394_FEATURE_GAIN;
3220 feature = DC1394_FEATURE_IRIS;
3237 dc1394bool_t hasManualMode = DC1394_FALSE;
3238 dc1394feature_modes_t modesAvailable;
3241 err = dc1394_feature_get_modes(camera, feature, &modesAvailable);
3242 if (err != DC1394_SUCCESS) {
3243 vpERROR_TRACE(
"Unable to detect the manual mode information");
3249 for (
unsigned int i = 0; i < modesAvailable.num; i++) {
3250 if (modesAvailable.modes[i] == DC1394_FEATURE_MODE_MANUAL) {
3251 hasManualMode = DC1394_TRUE;
3255 if (hasManualMode == DC1394_TRUE) {
3257 if (!isDataModified[camera_id]) {
3260 updateDataCamToStruct();
3261 err = dc1394_feature_get_mode(camera, feature, &(initialShutterMode[camera_id]));
3262 if (err != DC1394_SUCCESS) {
3267 isDataModified[camera_id] =
true;
3270 dc1394feature_mode_t manualMode = DC1394_FEATURE_MODE_MANUAL;
3271 err = dc1394_feature_set_mode(camera, feature, manualMode);
3272 if (err != DC1394_SUCCESS) {
3277 err = dc1394_feature_set_value(camera, feature, value);
3278 if (err != DC1394_SUCCESS) {
3285 vpERROR_TRACE(
"The camera does not have a manual mode.\nCannot change the value");
3304 guid = camera->guid;
3322 return camera->guid;
3329 inline void vp1394TwoGrabber::updateDataCamToStruct()
3346 inline void vp1394TwoGrabber::updateDataStructToCam()
3403 #elif !defined(VISP_BUILD_SHARED_LIBS)
3406 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]
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)