46 #include <visp3/core/vpConfig.h> 51 #if defined(VISP_HAVE_DC1394) 54 #include <visp3/core/vpFrameGrabberException.h> 55 #include <visp3/core/vpImageConvert.h> 56 #include <visp3/core/vpTime.h> 57 #include <visp3/sensor/vp1394TwoGrabber.h> 60 "MODE_160x120_YUV444",
"MODE_320x240_YUV422",
"MODE_640x480_YUV411",
"MODE_640x480_YUV422",
61 "MODE_640x480_RGB8",
"MODE_640x480_MONO8",
"MODE_640x480_MONO16",
"MODE_800x600_YUV422",
62 "MODE_800x600_RGB8",
"MODE_800x600_MONO8",
"MODE_1024x768_YUV422",
"MODE_1024x768_RGB8",
63 "MODE_1024x768_MONO8",
"MODE_800x600_MONO16",
"MODE_1024x768_MONO16",
"MODE_1280x960_YUV422",
64 "MODE_1280x960_RGB8",
"MODE_1280x960_MONO8",
"MODE_1600x1200_YUV422",
"MODE_1600x1200_RGB8",
65 "MODE_1600x1200_MONO8",
"MODE_1280x960_MONO16",
"MODE_1600x1200_MONO16",
"MODE_EXIF",
66 "MODE_FORMAT7_0",
"MODE_FORMAT7_1",
"MODE_FORMAT7_2",
"MODE_FORMAT7_3",
67 "MODE_FORMAT7_4",
"MODE_FORMAT7_5",
"MODE_FORMAT7_6",
"MODE_FORMAT7_7"};
70 "FRAMERATE_1_875",
"FRAMERATE_3_75",
"FRAMERATE_7_5",
"FRAMERATE_15",
71 "FRAMERATE_30",
"FRAMERATE_60",
"FRAMERATE_120",
"FRAMERATE_240"};
74 "COLOR_CODING_MONO8",
"COLOR_CODING_YUV411",
"COLOR_CODING_YUV422",
"COLOR_CODING_YUV444",
75 "COLOR_CODING_RGB8",
"COLOR_CODING_MONO16",
"COLOR_CODING_RGB16",
"COLOR_CODING_MONO16S",
76 "COLOR_CODING_RGB16S",
"COLOR_CODING_RAW8",
"COLOR_CODING_RAW16",
125 : camera(NULL), cameras(NULL), num_cameras(0), camera_id(0), verbose(false), camIsOpen(NULL),
127 isDataModified(NULL), initialShutterMode(NULL), dataCam(NULL)
128 #ifdef VISP_HAVE_DC1394_CAMERA_ENUMERATE
289 if (cam_id >= num_cameras) {
291 bool is_guid =
false;
293 for (
unsigned int i = 0; i < num_cameras; i++) {
294 if (cameras[i]->guid == cam_id) {
300 if (is_guid ==
false) {
301 std::cout <<
"Error: The camera with guid 0x" << std::hex << cam_id <<
" is not present" << std::endl;
302 std::cout << num_cameras <<
" camera(s) connected" << std::endl;
303 for (
unsigned int i = 0; i < num_cameras; i++) {
304 std::cout <<
" - camera " << i <<
" with guid 0x" << std::hex << cameras[i]->guid << std::endl;
310 this->camera_id = (
unsigned int)cam_id;
316 camera = cameras[this->camera_id];
336 cam_id = this->camera_id;
361 return this->camera_id;
379 vpCTRACE <<
"No camera found..." << std::endl;
383 ncameras = num_cameras;
395 unsigned int ncameras = 0;
397 vpCTRACE <<
"No camera found..." << std::endl;
401 ncameras = num_cameras;
462 setTransmission(DC1394_OFF);
463 setCapture(DC1394_OFF);
465 if (dc1394_video_set_mode(camera, (dc1394video_mode_t)videomode) != DC1394_SUCCESS) {
470 setCapture(DC1394_ON);
471 setTransmission(DC1394_ON);
474 if (dc1394_get_image_size_from_video_mode(camera, (dc1394video_mode_t)videomode, &this->
width, &this->
height) !=
506 dc1394video_mode_t _videomode;
507 if (dc1394_video_get_mode(camera, &_videomode) != DC1394_SUCCESS) {
543 dc1394video_modes_t _videomodes;
546 if (dc1394_video_get_supported_modes(camera, &_videomodes) != DC1394_SUCCESS) {
554 for (
unsigned i = 0; i < _videomodes.num; i++) {
556 videomodes.push_back(_mode);
560 return _videomodes.num;
584 dc1394video_modes_t _videomodes;
587 if (dc1394_video_get_supported_modes(camera, &_videomodes) != DC1394_SUCCESS) {
595 for (
unsigned i = 0; i < _videomodes.num; i++) {
617 if (dc1394_is_video_mode_scalable((dc1394video_mode_t)videomode))
704 setTransmission(DC1394_OFF);
705 setCapture(DC1394_OFF);
707 if (dc1394_video_set_framerate(camera, (dc1394framerate_t)fps) != DC1394_SUCCESS) {
713 setCapture(DC1394_ON);
714 setTransmission(DC1394_ON);
740 dc1394framerate_t _fps;
741 if (dc1394_video_get_framerate(camera, &_fps) != DC1394_SUCCESS) {
808 dc1394framerates_t _fps;
809 if (dc1394_video_get_supported_framerates(camera, (dc1394video_mode_t)mode, &_fps) != DC1394_SUCCESS) {
811 vpERROR_TRACE(
"Could not query supported frametates for mode %d\n", mode);
817 for (
unsigned int i = 0; i < _fps.num; i++)
881 dc1394framerates_t _fps;
882 if (dc1394_video_get_supported_framerates(camera, (dc1394video_mode_t)mode, &_fps) != DC1394_SUCCESS) {
884 vpERROR_TRACE(
"Could not query supported frametates for mode %d\n", mode);
890 for (
unsigned int i = 0; i < _fps.num; i++) {
955 dc1394video_mode_t _videomode;
956 if (dc1394_video_get_mode(camera, &_videomode) != DC1394_SUCCESS) {
968 if (dc1394_is_video_mode_scalable(_videomode)) {
969 setTransmission(DC1394_OFF);
970 setCapture(DC1394_OFF);
972 if (dc1394_format7_set_color_coding(camera, _videomode, (dc1394color_coding_t)coding) != DC1394_SUCCESS) {
978 setCapture(DC1394_ON);
979 setTransmission(DC1394_ON);
1007 dc1394video_mode_t _videomode;
1008 if (dc1394_video_get_mode(camera, &_videomode) != DC1394_SUCCESS) {
1015 dc1394color_coding_t _coding;
1016 if (dc1394_is_video_mode_scalable(_videomode)) {
1018 if (dc1394_format7_get_color_coding(camera, _videomode, &_coding) != DC1394_SUCCESS) {
1024 }
else if (dc1394_is_video_mode_still_image((dc1394video_mode_t)_videomode)) {
1028 if (dc1394_get_color_coding_from_video_mode(camera, (dc1394video_mode_t)_videomode, &_coding) != DC1394_SUCCESS) {
1030 vpERROR_TRACE(
"Could not query supported color coding for mode %d\n", _videomode);
1059 std::list<vp1394TwoColorCodingType> &codings)
1070 if (dc1394_is_video_mode_scalable((dc1394video_mode_t)mode)) {
1072 dc1394color_codings_t _codings;
1073 if (dc1394_format7_get_color_codings(camera, (dc1394video_mode_t)mode, &_codings) != DC1394_SUCCESS) {
1075 vpERROR_TRACE(
"Could not query supported color codings for mode %d\n", mode);
1078 if (_codings.num == 0)
1081 for (
unsigned int i = 0; i < _codings.num; i++)
1084 return _codings.num;
1085 }
else if (dc1394_is_video_mode_still_image((dc1394video_mode_t)mode)) {
1090 dc1394color_coding_t _coding;
1091 if (dc1394_get_color_coding_from_video_mode(camera, (dc1394video_mode_t)mode, &_coding) != DC1394_SUCCESS) {
1093 vpERROR_TRACE(
"Could not query supported color coding for mode %d\n", mode);
1129 if (dc1394_is_video_mode_scalable((dc1394video_mode_t)mode)) {
1131 dc1394color_codings_t _codings;
1132 if (dc1394_format7_get_color_codings(camera, (dc1394video_mode_t)mode, &_codings) != DC1394_SUCCESS) {
1134 vpERROR_TRACE(
"Could not query supported color codings for mode %d\n", mode);
1137 if (_codings.num == 0)
1140 for (
unsigned int i = 0; i < _codings.num; i++) {
1145 }
else if (dc1394_is_video_mode_still_image((dc1394video_mode_t)mode)) {
1150 dc1394color_coding_t _coding;
1151 if (dc1394_get_color_coding_from_video_mode(camera, (dc1394video_mode_t)mode, &_coding) != DC1394_SUCCESS) {
1153 vpERROR_TRACE(
"Could not query supported color coding for mode %d\n", mode);
1204 dc1394video_mode_t _videomode;
1205 if (dc1394_video_get_mode(camera, &_videomode) != DC1394_SUCCESS) {
1211 if (dc1394_is_video_mode_scalable(_videomode)) {
1213 setTransmission(DC1394_OFF);
1214 setCapture(DC1394_OFF);
1216 unsigned int max_width, max_height;
1217 if (dc1394_format7_get_max_image_size(camera, _videomode, &max_width, &max_height) != DC1394_SUCCESS) {
1224 vpTRACE(
"left: %d top: %d width: %d height: %d", left, top,
1225 width == 0 ? DC1394_USE_MAX_AVAIL: w,
1226 height == 0 ? DC1394_USE_MAX_AVAIL : h);
1227 vpTRACE(
"max_width: %d max_height: %d", max_width, max_height);
1230 if (left > max_width) {
1234 if (top > max_height) {
1244 if (w > (max_width - left))
1245 w = (max_width - left);
1246 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;
1257 roi_height = DC1394_USE_MAX_AVAIL;
1260 if (dc1394_format7_set_roi(camera, _videomode,
1261 (dc1394color_coding_t)DC1394_QUERY_FROM_CAMERA,
1262 DC1394_USE_MAX_AVAIL
1266 roi_width, roi_height) != DC1394_SUCCESS) {
1272 if (dc1394_format7_get_image_size(camera, _videomode, &this->
width, &this->
height) != DC1394_SUCCESS) {
1278 setCapture(DC1394_ON);
1279 setTransmission(DC1394_ON);
1296 void vp1394TwoGrabber::initialize(
bool reset)
1298 if (
init ==
false) {
1300 #ifdef VISP_HAVE_DC1394_CAMERA_ENUMERATE // new API > libdc1394-2.0.0-rc7 1305 if (dc1394_camera_enumerate(d, &list) != DC1394_SUCCESS) {
1306 dc1394_camera_free_list(list);
1312 if (list->num == 0) {
1313 dc1394_camera_free_list(list);
1319 if (cameras != NULL)
1322 cameras =
new dc1394camera_t *[list->num];
1326 for (
unsigned int i = 0; i < list->num; i++) {
1327 cameras[i] = dc1394_camera_new(d, list->ids[i].guid);
1329 vpTRACE(
"Failed to initialize camera with guid \"%ld\"\n", list->ids[i].guid);
1340 dc1394_reset_bus(cameras[0]);
1344 dc1394_camera_free_list(list);
1347 #elif defined VISP_HAVE_DC1394_FIND_CAMERAS // old API <= libdc1394-2.0.0-rc7 1348 if (cameras != NULL)
1351 int err = dc1394_find_cameras(&cameras, &num_cameras);
1353 if (err != DC1394_SUCCESS && err != DC1394_NO_CAMERA) {
1357 " - if the kernel modules `ieee1394',`raw1394' and " 1358 "`ohci1394' are loaded \n" 1359 " - if you have read/write access to /dev/raw1394\n\n");
1364 if (num_cameras == 0) {
1371 isDataModified =
new bool[num_cameras];
1372 for (
unsigned int i = 0; i < num_cameras; i++)
1373 isDataModified[i] =
false;
1374 initialShutterMode =
new dc1394feature_mode_t[num_cameras];
1375 dataCam =
new vpDc1394TwoCameraParametersData[num_cameras];
1377 if (camera_id >= num_cameras) {
1386 std::cout <<
"------ Bus information ------" << std::endl;
1387 std::cout <<
"Number of camera(s) on the bus : " << num_cameras << std::endl;
1388 std::cout <<
"-----------------------------" << std::endl;
1391 if (camIsOpen != NULL)
1393 camIsOpen =
new bool[num_cameras];
1394 for (
unsigned int i = 0; i < num_cameras; i++) {
1395 camIsOpen[i] =
false;
1414 if (camIsOpen[camera_id] ==
false) {
1415 dc1394switch_t status = DC1394_OFF;
1419 dc1394_video_get_transmission(cameras[camera_id], &status);
1420 if (status != DC1394_OFF) {
1422 if (dc1394_video_set_transmission(cameras[camera_id], DC1394_OFF) != DC1394_SUCCESS)
1423 vpTRACE(
"Could not stop ISO transmission");
1426 if (dc1394_video_get_transmission(cameras[camera_id], &status) != DC1394_SUCCESS)
1427 vpTRACE(
"Could get ISO status");
1429 if (status == DC1394_ON) {
1430 vpTRACE(
"ISO transmission refuses to stop");
1432 #ifdef VISP_HAVE_DC1394_FIND_CAMERAS // old API <= libdc1394-2.0.0-rc7 1434 cameras[camera_id]->is_iso_on = status;
1444 setCapture(DC1394_ON);
1445 setTransmission(DC1394_ON);
1446 camIsOpen[camera_id] =
true;
1461 for (
unsigned int i = 0; i < num_cameras; i++) {
1463 camera = cameras[i];
1464 this->camera_id = i;
1465 setTransmission(DC1394_OFF);
1466 setCapture(DC1394_OFF);
1467 if (isDataModified[i]) {
1470 updateDataStructToCam();
1474 if (dc1394_feature_set_mode(camera, DC1394_FEATURE_BRIGHTNESS, initialShutterMode[i]) != DC1394_SUCCESS ||
1475 dc1394_feature_set_mode(camera, DC1394_FEATURE_EXPOSURE, initialShutterMode[i]) != DC1394_SUCCESS ||
1476 dc1394_feature_set_mode(camera, DC1394_FEATURE_SHARPNESS, initialShutterMode[i]) != DC1394_SUCCESS ||
1477 dc1394_feature_set_mode(camera, DC1394_FEATURE_HUE, initialShutterMode[i]) != DC1394_SUCCESS ||
1478 dc1394_feature_set_mode(camera, DC1394_FEATURE_SATURATION, initialShutterMode[i]) != DC1394_SUCCESS ||
1479 dc1394_feature_set_mode(camera, DC1394_FEATURE_GAMMA, initialShutterMode[i]) != DC1394_SUCCESS ||
1480 dc1394_feature_set_mode(camera, DC1394_FEATURE_SHUTTER, initialShutterMode[i]) != DC1394_SUCCESS ||
1481 dc1394_feature_set_mode(camera, DC1394_FEATURE_GAIN, initialShutterMode[i]) != DC1394_SUCCESS ||
1482 dc1394_feature_set_mode(camera, DC1394_FEATURE_IRIS, initialShutterMode[i])) {
1488 if (dc1394_camera_set_power(camera, DC1394_OFF) != DC1394_SUCCESS)
1489 std::cout <<
"Unable to turn camera off" << std::endl;
1491 #ifdef VISP_HAVE_DC1394_CAMERA_ENUMERATE // new API > libdc1394-2.0.0-rc7 1492 dc1394_camera_free(cameras[i]);
1493 #elif defined VISP_HAVE_DC1394_FIND_CAMERAS // old API <= libdc1394-2.0.0-rc7 1494 dc1394_free_camera(cameras[i]);
1498 if (camIsOpen != NULL) {
1503 #ifdef VISP_HAVE_DC1394_CAMERA_ENUMERATE // new API > libdc1394-2.0.0-rc7 1504 if (cameras != NULL) {
1513 #elif defined VISP_HAVE_DC1394_FIND_CAMERAS // old API <= libdc1394-2.0.0-rc7 1514 if (cameras != NULL) {
1524 if (isDataModified != NULL) {
1525 delete[] isDataModified;
1526 isDataModified = NULL;
1528 if (initialShutterMode != NULL) {
1529 delete[] initialShutterMode;
1530 initialShutterMode = NULL;
1532 if (dataCam != NULL) {
1560 if (size != num_buffers) {
1563 if (camIsOpen[camera_id]) {
1564 setCapture(DC1394_OFF);
1565 setCapture(DC1394_ON);
1628 dc1394feature_mode_t mode;
1630 mode = DC1394_FEATURE_MODE_AUTO;
1632 mode = DC1394_FEATURE_MODE_MANUAL;
1635 if (dc1394_feature_set_power(camera, DC1394_FEATURE_SHUTTER, DC1394_ON) != DC1394_SUCCESS) {
1641 if (dc1394_feature_set_mode(camera, DC1394_FEATURE_SHUTTER, mode) != DC1394_SUCCESS) {
1691 if (dc1394_avt_set_auto_shutter(camera, minvalue, maxvalue) != DC1394_SUCCESS) {
1719 if (dc1394_avt_get_auto_shutter(camera, &minvalue, &maxvalue) != DC1394_SUCCESS) {
1774 dc1394feature_mode_t mode;
1776 mode = DC1394_FEATURE_MODE_AUTO;
1778 mode = DC1394_FEATURE_MODE_MANUAL;
1781 if (dc1394_feature_set_power(camera, DC1394_FEATURE_GAIN, DC1394_ON) != DC1394_SUCCESS) {
1787 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");
1909 dc1394error_t code = dc1394_capture_stop(camera);
1911 if (code != DC1394_SUCCESS && code != DC1394_CAPTURE_IS_NOT_SET) {
1933 void vp1394TwoGrabber::setTransmission(dc1394switch_t _switch)
1941 dc1394switch_t status = DC1394_OFF;
1943 if (dc1394_video_get_transmission(camera, &status) != DC1394_SUCCESS) {
1951 if (dc1394_video_set_transmission(camera, _switch) != DC1394_SUCCESS) {
1953 "make sure that the video mode and framerate are " 1954 "supported by your camera.\n");
1959 if (_switch == DC1394_ON) {
1960 status = DC1394_OFF;
1963 while (status == DC1394_OFF && i++ < 5) {
1965 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) {
2029 if (dc1394_video_set_operation_mode(camera, DC1394_OPERATION_MODE_1394B) != DC1394_SUCCESS) {
2035 if (dc1394_video_get_operation_mode(camera, &op_mode) != DC1394_SUCCESS) {
2041 if (dc1394_video_set_operation_mode(camera, DC1394_OPERATION_MODE_LEGACY) != DC1394_SUCCESS) {
2047 if (dc1394_video_get_operation_mode(camera, &op_mode) != DC1394_SUCCESS) {
2054 if (dc1394_video_set_iso_speed(camera, (dc1394speed_t)isospeed) != DC1394_SUCCESS) {
2060 if (dc1394_video_get_iso_speed(camera, &speed) != DC1394_SUCCESS) {
2146 dc1394video_frame_t *frame = NULL;
2148 if (dc1394_capture_dequeue(camera, DC1394_CAPTURE_POLICY_WAIT, &frame) != DC1394_SUCCESS) {
2149 vpERROR_TRACE(
"Error: Failed to capture from camera %d\n", camera_id);
2201 dc1394video_frame_t *frame;
2203 frame =
dequeue(I, timestamp,
id);
2261 dc1394video_frame_t *frame;
2267 timestamp = frame->timestamp;
2270 this->
width = frame->size[0];
2271 this->
height = frame->size[1];
2277 switch (frame->color_coding) {
2278 case DC1394_COLOR_CODING_MONO8:
2279 case DC1394_COLOR_CODING_RAW8:
2280 memcpy(I.
bitmap, (
unsigned char *)frame->image, size *
sizeof(
unsigned char));
2282 case DC1394_COLOR_CODING_MONO16:
2283 case DC1394_COLOR_CODING_RAW16:
2287 case DC1394_COLOR_CODING_YUV411:
2291 case DC1394_COLOR_CODING_YUV422:
2295 case DC1394_COLOR_CODING_YUV444:
2299 case DC1394_COLOR_CODING_RGB8:
2305 vpERROR_TRACE(
"Format conversion not implemented. Acquisition failed.");
2307 "Acquisition failed."));
2358 dc1394video_frame_t *frame;
2360 frame =
dequeue(I, timestamp,
id);
2418 dc1394video_frame_t *frame;
2424 timestamp = frame->timestamp;
2427 this->
width = frame->size[0];
2428 this->
height = frame->size[1];
2434 switch (frame->color_coding) {
2435 case DC1394_COLOR_CODING_MONO8:
2436 case DC1394_COLOR_CODING_RAW8:
2440 case DC1394_COLOR_CODING_MONO16:
2441 case DC1394_COLOR_CODING_RAW16:
2445 case DC1394_COLOR_CODING_YUV411:
2449 case DC1394_COLOR_CODING_YUV422:
2453 case DC1394_COLOR_CODING_YUV444:
2457 case DC1394_COLOR_CODING_RGB8:
2463 vpERROR_TRACE(
"Format conversion not implemented. Acquisition failed.");
2465 "Acquisition failed."));
2491 dc1394_capture_enqueue(camera, frame);
2512 dc1394video_frame_t *frame;
2514 frame =
dequeue(I, timestamp,
id);
2538 dc1394video_frame_t *frame;
2541 frame =
dequeue(I, timestamp,
id);
2562 dc1394video_frame_t *frame;
2565 frame =
dequeue(I, timestamp,
id);
2589 dc1394video_frame_t *frame;
2595 timestamp = frame->timestamp;
2598 this->
width = frame->size[0];
2599 this->
height = frame->size[1];
2605 switch (frame->color_coding) {
2606 case DC1394_COLOR_CODING_MONO8:
2607 case DC1394_COLOR_CODING_RAW8:
2611 case DC1394_COLOR_CODING_YUV411:
2615 case DC1394_COLOR_CODING_YUV422:
2619 case DC1394_COLOR_CODING_YUV444:
2623 case DC1394_COLOR_CODING_RGB8:
2629 vpERROR_TRACE(
"Format conversion not implemented. Acquisition failed.");
2631 "Acquisition failed."));
2754 std::cout <<
"----------------------------------------------------------" << std::endl
2755 <<
"----- Information for camera " << camera_id <<
" -----" << std::endl
2756 <<
"----------------------------------------------------------" << std::endl;
2758 #ifdef VISP_HAVE_DC1394_CAMERA_ENUMERATE // new API > libdc1394-2.0.0-rc7 2759 dc1394_camera_print_info(camera, stdout);
2760 #elif defined VISP_HAVE_DC1394_FIND_CAMERAS // old API <= libdc1394-2.0.0-rc7 2761 dc1394_print_camera_info(camera);
2764 dc1394featureset_t features;
2765 #ifdef VISP_HAVE_DC1394_CAMERA_ENUMERATE // new API > libdc1394-2.0.0-rc7 2766 if (dc1394_feature_get_all(camera, &features) != DC1394_SUCCESS)
2767 #elif defined VISP_HAVE_DC1394_FIND_CAMERAS // old API <= libdc1394-2.0.0-rc7 2768 if (dc1394_get_camera_feature_set(camera, &features) != DC1394_SUCCESS)
2772 vpERROR_TRACE(
"unable to get feature set for camera %d\n", camera_id);
2776 #ifdef VISP_HAVE_DC1394_CAMERA_ENUMERATE // new API > libdc1394-2.0.0-rc7 2777 dc1394_feature_print_all(&features, stdout);
2778 #elif defined VISP_HAVE_DC1394_FIND_CAMERAS // old API <= libdc1394-2.0.0-rc7 2779 dc1394_print_feature_set(&features);
2782 std::cout <<
"----------------------------------------------------------" << std::endl;
2799 std::string _str =
"";
2800 dc1394video_mode_t _videomode = (dc1394video_mode_t)videomode;
2802 if ((_videomode >= DC1394_VIDEO_MODE_MIN) && (_videomode <= DC1394_VIDEO_MODE_MAX)) {
2803 _str =
strVideoMode[_videomode - DC1394_VIDEO_MODE_MIN];
2805 vpCERROR <<
"The video mode " << (int)videomode <<
" is not supported by the camera" << std::endl;
2825 std::string _str =
"";
2826 dc1394framerate_t _fps = (dc1394framerate_t)fps;
2828 if ((_fps >= DC1394_FRAMERATE_MIN) && (_fps <= DC1394_FRAMERATE_MAX)) {
2831 vpCERROR <<
"The framerate " << (int)fps <<
" is not supported by the camera" << std::endl;
2851 std::string _str =
"";
2852 dc1394color_coding_t _coding = (dc1394color_coding_t)colorcoding;
2854 if ((_coding >= DC1394_COLOR_CODING_MIN) && (_coding <= DC1394_COLOR_CODING_MAX)) {
2858 vpCERROR <<
"The color coding " << (int)colorcoding <<
" is not supported by the camera" << std::endl;
2885 for (
int i = DC1394_VIDEO_MODE_MIN; i <= DC1394_VIDEO_MODE_MAX; i++) {
2917 for (
int i = DC1394_FRAMERATE_MIN; i <= DC1394_FRAMERATE_MAX; i++) {
2949 for (
int i = DC1394_COLOR_CODING_MIN; i <= DC1394_COLOR_CODING_MAX; i++) {
2994 for (
unsigned int i = 0; i < num_cameras; i++) {
2996 camera = cameras[i];
2997 setTransmission(DC1394_OFF);
2998 setCapture(DC1394_OFF);
3001 #ifdef VISP_HAVE_DC1394_CAMERA_ENUMERATE // new API > libdc1394-2.0.0-rc7 3004 for (
unsigned int i = 0; i < num_cameras; i++) {
3006 dc1394_camera_free(cameras[i]);
3009 printf(
"Reseting bus...\n");
3010 dc1394_reset_bus(camera);
3012 dc1394_camera_free(camera);
3018 #elif defined VISP_HAVE_DC1394_FIND_CAMERAS // old API <= libdc1394-2.0.0-rc7 3022 for (
unsigned int i = 0; i < num_cameras; i++) {
3024 dc1394_free_camera(cameras[i]);
3029 dc1394_reset_bus(camera);
3030 dc1394_free_camera(camera);
3033 if (camIsOpen != NULL)
3082 uint64_t offset = 0x884;
3083 uint32_t value = 0x82000000 + (uint32_t)panControlValue;
3085 err = dc1394_set_control_register(camera, offset, value);
3086 if (err != DC1394_SUCCESS) {
3118 dc1394feature_t feature = DC1394_FEATURE_BRIGHTNESS;
3121 feature = DC1394_FEATURE_BRIGHTNESS;
3124 feature = DC1394_FEATURE_EXPOSURE;
3127 feature = DC1394_FEATURE_SHARPNESS;
3131 feature = DC1394_FEATURE_HUE;
3134 feature = DC1394_FEATURE_SATURATION;
3137 feature = DC1394_FEATURE_GAMMA;
3140 feature = DC1394_FEATURE_SHUTTER;
3143 feature = DC1394_FEATURE_GAIN;
3146 feature = DC1394_FEATURE_IRIS;
3163 err = dc1394_feature_get_value(camera, feature, &value);
3164 if (err != DC1394_SUCCESS) {
3169 return (
unsigned int)value;
3200 uint32_t value = (uint32_t)val;
3201 dc1394feature_t feature = DC1394_FEATURE_BRIGHTNESS;
3204 feature = DC1394_FEATURE_BRIGHTNESS;
3207 feature = DC1394_FEATURE_EXPOSURE;
3210 feature = DC1394_FEATURE_SHARPNESS;
3214 feature = DC1394_FEATURE_HUE;
3217 feature = DC1394_FEATURE_SATURATION;
3220 feature = DC1394_FEATURE_GAMMA;
3223 feature = DC1394_FEATURE_SHUTTER;
3226 feature = DC1394_FEATURE_GAIN;
3229 feature = DC1394_FEATURE_IRIS;
3246 dc1394bool_t hasManualMode = DC1394_FALSE;
3247 dc1394feature_modes_t modesAvailable;
3250 err = dc1394_feature_get_modes(camera, feature, &modesAvailable);
3251 if (err != DC1394_SUCCESS) {
3252 vpERROR_TRACE(
"Unable to detect the manual mode information");
3258 for (
unsigned int i = 0; i < modesAvailable.num; i++) {
3259 if (modesAvailable.modes[i] == DC1394_FEATURE_MODE_MANUAL) {
3260 hasManualMode = DC1394_TRUE;
3264 if (hasManualMode == DC1394_TRUE) {
3266 if (!isDataModified[camera_id]) {
3269 updateDataCamToStruct();
3270 err = dc1394_feature_get_mode(camera, feature, &(initialShutterMode[camera_id]));
3271 if (err != DC1394_SUCCESS) {
3276 isDataModified[camera_id] =
true;
3279 dc1394feature_mode_t manualMode = DC1394_FEATURE_MODE_MANUAL;
3280 err = dc1394_feature_set_mode(camera, feature, manualMode);
3281 if (err != DC1394_SUCCESS) {
3286 err = dc1394_feature_set_value(camera, feature, value);
3287 if (err != DC1394_SUCCESS) {
3293 vpERROR_TRACE(
"The camera does not have a manual mode.\nCannot change the value");
3312 guid = camera->guid;
3330 return camera->guid;
3337 inline void vp1394TwoGrabber::updateDataCamToStruct()
3354 inline void vp1394TwoGrabber::updateDataStructToCam()
3411 #elif !defined(VISP_BUILD_SHARED_LIBS) 3414 void dummy_vp1394TwoGrabber(){};
void getColorCoding(vp1394TwoColorCodingType &coding)
static const char * strFramerate[DC1394_FRAMERATE_NUM]
VISP_EXPORT int wait(double t0, double t)
uint32_t getColorCodingSupported(vp1394TwoVideoModeType videomode, std::list< vp1394TwoColorCodingType > &codings)
static std::string colorCoding2string(vp1394TwoColorCodingType colorcoding)
static void RGBToGrey(unsigned char *rgb, unsigned char *grey, unsigned int size)
void setAutoGain(bool enable=true)
void setIsoTransmissionSpeed(vp1394TwoIsoSpeedType isospeed)
static std::string framerate2string(vp1394TwoFramerateType fps)
void getAutoGain(unsigned int &minvalue, unsigned int &maxvalue)
unsigned int getWidth() const
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)
vp1394TwoGrabber(bool reset=true)
bool isVideoModeFormat7(vp1394TwoVideoModeType videomode)
static const char * strColorCoding[DC1394_COLOR_CODING_NUM]
static void GreyToRGBa(unsigned char *grey, unsigned char *rgba, unsigned int size)
static void YUV422ToRGBa(unsigned char *yuv, unsigned char *rgba, unsigned int size)
vp1394TwoGrabber & operator>>(vpImage< unsigned char > &I)
unsigned int getParameterValue(vp1394TwoParametersType param)
void acquire(vpImage< unsigned char > &I)
static vp1394TwoColorCodingType string2colorCoding(std::string colorcoding)
Error that can be emited by the vpFrameGrabber class and its derivates.
uint32_t getVideoModeSupported(std::list< vp1394TwoVideoModeType > &videomodes)
static void YUV444ToRGBa(unsigned char *yuv, unsigned char *rgba, unsigned int size)
bool isFramerateSupported(vp1394TwoVideoModeType videomode, vp1394TwoFramerateType fps)
void setColorCoding(vp1394TwoColorCodingType coding)
void open(vpImage< unsigned char > &I)
static void YUV422ToGrey(unsigned char *yuv, unsigned char *grey, unsigned int size)
void setRingBufferSize(unsigned int size)
static vp1394TwoVideoModeType string2videoMode(std::string videomode)
void setFormat7ROI(unsigned int left=0, unsigned int top=0, unsigned int width=0, unsigned int height=0)
unsigned int height
Number of rows in the image.
void setCamera(uint64_t camera)
static const char * strVideoMode[DC1394_VIDEO_MODE_NUM]
static void MONO16ToRGBa(unsigned char *grey16, unsigned char *rgba, unsigned int size)
void resize(const unsigned int h, const unsigned int w)
resize the image : Image initialization
void enqueue(dc1394video_frame_t *frame)
static vp1394TwoFramerateType string2framerate(std::string fps)
void getFramerate(vp1394TwoFramerateType &fps)
static std::string videoMode2string(vp1394TwoVideoModeType videomode)
bool init
Set to true if the frame grabber has been initialized.
void setParameterValue(vp1394TwoParametersType param, unsigned int val)
static void YUV444ToGrey(unsigned char *yuv, unsigned char *grey, unsigned int size)
virtual ~vp1394TwoGrabber()
bool isColorCodingSupported(vp1394TwoVideoModeType videomode, vp1394TwoColorCodingType coding)
static void YUV411ToRGBa(unsigned char *yuv, unsigned char *rgba, unsigned int size)
unsigned int getRingBufferSize() const
void setFramerate(vp1394TwoFramerateType fps)
dc1394video_frame_t * dequeue()
void getAutoShutter(unsigned int &minvalue, unsigned int &maxvalue)
void setVideoMode(vp1394TwoVideoModeType videomode)
void setPanControl(unsigned int panControlValue)
uint32_t getFramerateSupported(vp1394TwoVideoModeType videomode, std::list< vp1394TwoFramerateType > &fps)
unsigned int getHeight() const
bool isVideoModeSupported(vp1394TwoVideoModeType videomode)
Class for firewire ieee1394 video devices using libdc1394-2.x api.
static void YUV411ToGrey(unsigned char *yuv, unsigned char *grey, unsigned int size)
unsigned int getNumCameras() const
void getVideoMode(vp1394TwoVideoModeType &videomode)
unsigned int width
Number of columns in the image.
void setAutoShutter(bool enable=true)