46 #include <visp3/core/vpConfig.h>
51 #if defined(VISP_HAVE_DC1394)
54 #include <visp3/sensor/vp1394TwoGrabber.h>
55 #include <visp3/core/vpFrameGrabberException.h>
56 #include <visp3/core/vpImageConvert.h>
57 #include <visp3/core/vpTime.h>
60 "MODE_160x120_YUV444",
61 "MODE_320x240_YUV422",
62 "MODE_640x480_YUV411",
63 "MODE_640x480_YUV422",
66 "MODE_640x480_MONO16",
67 "MODE_800x600_YUV422",
70 "MODE_1024x768_YUV422",
72 "MODE_1024x768_MONO8",
73 "MODE_800x600_MONO16",
74 "MODE_1024x768_MONO16",
75 "MODE_1280x960_YUV422",
77 "MODE_1280x960_MONO8",
78 "MODE_1600x1200_YUV422",
79 "MODE_1600x1200_RGB8",
80 "MODE_1600x1200_MONO8",
81 "MODE_1280x960_MONO16",
82 "MODE_1600x1200_MONO16",
106 "COLOR_CODING_MONO8",
107 "COLOR_CODING_YUV411",
108 "COLOR_CODING_YUV422",
109 "COLOR_CODING_YUV444",
111 "COLOR_CODING_MONO16",
112 "COLOR_CODING_RGB16",
113 "COLOR_CODING_MONO16S",
114 "COLOR_CODING_RGB16S",
116 "COLOR_CODING_RAW16",
166 : camera(NULL), cameras(NULL), num_cameras(0), camera_id(0), verbose(false), camIsOpen(NULL),
168 isDataModified(NULL), initialShutterMode(NULL), dataCam(NULL)
169 #ifdef VISP_HAVE_DC1394_CAMERA_ENUMERATE
330 if (cam_id >= num_cameras) {
332 bool is_guid =
false;
334 for (
unsigned int i=0; i< num_cameras; i++) {
335 if (cameras[i]->guid == cam_id) {
341 if (is_guid ==
false) {
342 std::cout <<
"Error: The camera with guid 0x" << std::hex << cam_id <<
" is not present" << std::endl;
343 std::cout << num_cameras <<
" camera(s) connected" << std::endl;
344 for (
unsigned int i=0; i< num_cameras; i++) {
345 std::cout <<
" - camera " << i <<
" with guid 0x" << std::hex << cameras[i]->guid << std::endl;
349 "The required camera is not present") );
353 this->camera_id = (
unsigned int) cam_id;
357 camera = cameras[this->camera_id];
379 cam_id = this->camera_id;
385 "No cameras found") );
407 return this->camera_id;
413 "No cameras found") );
428 vpCTRACE <<
"No camera found..."<< std::endl;
432 ncameras = num_cameras;
445 unsigned int ncameras = 0;
447 vpCTRACE <<
"No camera found..."<< std::endl;
451 ncameras = num_cameras;
507 "No camera found") );
511 "Video mode not supported by camera %d",camera_id) );
514 setTransmission(DC1394_OFF);
515 setCapture(DC1394_OFF);
517 if (dc1394_video_set_mode(camera, (dc1394video_mode_t) videomode) != DC1394_SUCCESS) {
520 "Can't set video mode") );
523 setCapture(DC1394_ON);
524 setTransmission(DC1394_ON);
527 if (dc1394_get_image_size_from_video_mode(camera,
528 (dc1394video_mode_t) videomode,
534 "Can't get image size") );
561 "No camera found") );
564 dc1394video_mode_t _videomode;
565 if (dc1394_video_get_mode(camera, &_videomode) != DC1394_SUCCESS) {
570 "Can't get current video mode") );
605 "No camera found") );
607 dc1394video_modes_t _videomodes;
610 if (dc1394_video_get_supported_modes(camera, &_videomodes)!=DC1394_SUCCESS) {
615 "Can't get video modes") );
619 for (
unsigned i=0; i < _videomodes.num; i++) {
621 videomodes.push_back( _mode );
625 return _videomodes.num;
649 "No camera found") );
651 dc1394video_modes_t _videomodes;
654 if (dc1394_video_get_supported_modes(camera, &_videomodes)!=DC1394_SUCCESS) {
659 "Can't get video modes") );
663 for (
unsigned i=0; i < _videomodes.num; i++) {
686 if (dc1394_is_video_mode_scalable((dc1394video_mode_t) videomode))
762 "No camera found") );
772 "Framerate not supported by camera %d",camera_id) );
776 setTransmission(DC1394_OFF);
777 setCapture(DC1394_OFF);
779 if (dc1394_video_set_framerate(camera, (dc1394framerate_t) fps) != DC1394_SUCCESS) {
783 "Can't set framerate") );
786 setCapture(DC1394_ON);
787 setTransmission(DC1394_ON);
813 "No camera found") );
815 dc1394framerate_t _fps;
816 if (dc1394_video_get_framerate(camera, &_fps) != DC1394_SUCCESS) {
821 "Can't get current framerate") );
860 std::list<vp1394TwoFramerateType> & fps)
866 "No camera found") );
889 dc1394framerates_t _fps;
890 if (dc1394_video_get_supported_framerates(camera,
891 (dc1394video_mode_t)mode,
892 &_fps) != DC1394_SUCCESS) {
894 vpERROR_TRACE(
"Could not query supported frametates for mode %d\n",
897 "Could not query supported framerates") );
902 for (
unsigned int i = 0; i < _fps.num; i ++)
951 "No camera found") );
971 dc1394framerates_t _fps;
972 if (dc1394_video_get_supported_framerates(camera,
973 (dc1394video_mode_t)mode,
974 &_fps) != DC1394_SUCCESS) {
976 vpERROR_TRACE(
"Could not query supported frametates for mode %d\n",
979 "Could not query supported framerates") );
984 for (
unsigned int i = 0; i < _fps.num; i ++){
1046 if (! num_cameras) {
1049 "No camera found") );
1052 dc1394video_mode_t _videomode;
1053 if (dc1394_video_get_mode(camera, &_videomode) != DC1394_SUCCESS) {
1057 "Can't get current video mode") );
1062 "Color coding not supported by camera %d", camera_id) );
1066 if (dc1394_is_video_mode_scalable(_videomode)) {
1067 setTransmission(DC1394_OFF);
1068 setCapture(DC1394_OFF);
1070 if (dc1394_format7_set_color_coding(camera, _videomode,
1071 (dc1394color_coding_t) coding)
1072 != DC1394_SUCCESS) {
1076 "Can't set color coding") );
1079 setCapture(DC1394_ON);
1080 setTransmission(DC1394_ON);
1104 if (! num_cameras) {
1108 "No camera found") );
1110 dc1394video_mode_t _videomode;
1111 if (dc1394_video_get_mode(camera, &_videomode) != DC1394_SUCCESS) {
1116 "Can't get current video mode") );
1119 dc1394color_coding_t _coding;
1120 if (dc1394_is_video_mode_scalable(_videomode)) {
1122 if (dc1394_format7_get_color_coding(camera, _videomode, &_coding)
1123 != DC1394_SUCCESS) {
1128 "Can't query current color coding") );
1131 else if (dc1394_is_video_mode_still_image((dc1394video_mode_t)_videomode)) {
1133 "No color coding for format 6 video mode"));
1137 if (dc1394_get_color_coding_from_video_mode(camera,
1138 (dc1394video_mode_t)_videomode,
1139 &_coding) != DC1394_SUCCESS) {
1141 vpERROR_TRACE(
"Could not query supported color coding for mode %d\n",
1144 "Can't query current color coding"));
1173 std::list<vp1394TwoColorCodingType> & codings)
1175 if (! num_cameras) {
1179 "No camera found") );
1185 if (dc1394_is_video_mode_scalable((dc1394video_mode_t)mode)) {
1187 dc1394color_codings_t _codings;
1188 if (dc1394_format7_get_color_codings(camera,
1189 (dc1394video_mode_t)mode,
1190 &_codings) != DC1394_SUCCESS) {
1192 vpERROR_TRACE(
"Could not query supported color codings for mode %d\n",
1195 "Could not query supported color codings") );
1197 if (_codings.num == 0)
1200 for (
unsigned int i = 0; i < _codings.num; i ++)
1203 return _codings.num;
1205 else if (dc1394_is_video_mode_still_image((dc1394video_mode_t)mode)) {
1211 dc1394color_coding_t _coding;
1212 if (dc1394_get_color_coding_from_video_mode(camera,
1213 (dc1394video_mode_t)mode,
1214 &_coding) != DC1394_SUCCESS) {
1216 vpERROR_TRACE(
"Could not query supported color coding for mode %d\n",
1219 "Could not query supported color coding") );
1250 if (! num_cameras) {
1254 "No camera found") );
1258 if (dc1394_is_video_mode_scalable((dc1394video_mode_t)mode)) {
1260 dc1394color_codings_t _codings;
1261 if (dc1394_format7_get_color_codings(camera,
1262 (dc1394video_mode_t)mode,
1263 &_codings) != DC1394_SUCCESS) {
1265 vpERROR_TRACE(
"Could not query supported color codings for mode %d\n",
1268 "Could not query supported color codings") );
1270 if (_codings.num == 0)
1273 for (
unsigned int i = 0; i < _codings.num; i ++){
1279 else if (dc1394_is_video_mode_still_image((dc1394video_mode_t)mode)) {
1285 dc1394color_coding_t _coding;
1286 if (dc1394_get_color_coding_from_video_mode(camera,
1287 (dc1394video_mode_t)mode,
1288 &_coding) != DC1394_SUCCESS) {
1290 vpERROR_TRACE(
"Could not query supported color coding for mode %d\n",
1293 "Could not query supported color coding") );
1337 unsigned int w,
unsigned int h)
1340 if (! num_cameras) {
1344 "No camera found") );
1347 dc1394video_mode_t _videomode;
1348 if (dc1394_video_get_mode(camera, &_videomode) != DC1394_SUCCESS) {
1353 "Can't get current video mode") );
1355 if (dc1394_is_video_mode_scalable(_videomode)) {
1357 setTransmission(DC1394_OFF);
1358 setCapture(DC1394_OFF);
1360 unsigned int max_width, max_height;
1361 if (dc1394_format7_get_max_image_size(camera, _videomode,
1362 &max_width, &max_height)
1363 != DC1394_SUCCESS) {
1368 "Can't get format7 max image size") );
1371 vpTRACE(
"left: %d top: %d width: %d height: %d", left, top,
1372 width == 0 ? DC1394_USE_MAX_AVAIL: w,
1373 height == 0 ? DC1394_USE_MAX_AVAIL : h);
1374 vpTRACE(
"max_width: %d max_height: %d", max_width, max_height);
1377 if (left > max_width) {
1380 "Can't set format7 ROI") );
1382 if (top > max_height) {
1385 "Can't set format7 ROI") );
1393 if (w > (max_width - left))
1394 w = (max_width - left);
1395 roi_width = (int32_t)w;
1398 roi_width = DC1394_USE_MAX_AVAIL;
1403 if (h > (max_height - top))
1404 h = (max_height - top);
1405 roi_height = (int32_t)h;
1408 roi_height = DC1394_USE_MAX_AVAIL;
1411 if (dc1394_format7_set_roi(camera, _videomode,
1412 (dc1394color_coding_t) DC1394_QUERY_FROM_CAMERA,
1413 DC1394_USE_MAX_AVAIL,
1418 != DC1394_SUCCESS) {
1422 "Can't get current video mode") );
1425 if (dc1394_format7_get_image_size(camera, _videomode,
1428 != DC1394_SUCCESS) {
1432 "Can't get format7 image size") );
1435 setCapture(DC1394_ON);
1436 setTransmission(DC1394_ON);
1454 vp1394TwoGrabber::initialize(
bool reset)
1458 #ifdef VISP_HAVE_DC1394_CAMERA_ENUMERATE // new API > libdc1394-2.0.0-rc7
1463 if (dc1394_camera_enumerate (d, &list) != DC1394_SUCCESS) {
1464 dc1394_camera_free_list (list);
1468 "Failed to enumerate cameras") );
1471 if (list->num == 0) {
1472 dc1394_camera_free_list (list);
1476 "No cameras found") );
1479 if (cameras != NULL)
1482 cameras =
new dc1394camera_t * [list->num];
1486 for (
unsigned int i=0; i < list->num; i ++) {
1487 cameras[i] = dc1394_camera_new (d, list->ids[i].guid);
1489 vpTRACE (
"Failed to initialize camera with guid \"%ld\"\n",
1501 dc1394_reset_bus(cameras[0]);
1505 dc1394_camera_free_list (list);
1508 #elif defined VISP_HAVE_DC1394_FIND_CAMERAS // old API <= libdc1394-2.0.0-rc7
1509 if (cameras != NULL)
1512 int err = dc1394_find_cameras(&cameras, &num_cameras);
1514 if (err!=DC1394_SUCCESS && err != DC1394_NO_CAMERA) {
1518 " - if the kernel modules `ieee1394',`raw1394' and `ohci1394' are loaded \n"
1519 " - if you have read/write access to /dev/raw1394\n\n");
1521 "Unable to look for cameras") );
1526 if (num_cameras == 0) {
1530 "No cameras found") );
1534 isDataModified =
new bool[num_cameras];
1535 for(
unsigned int i=0; i<num_cameras; i++)
1536 isDataModified[i] =
false;
1537 initialShutterMode =
new dc1394feature_mode_t[num_cameras];
1538 dataCam =
new vpDc1394TwoCameraParametersData[num_cameras];
1540 if (camera_id >= num_cameras) {
1550 std::cout <<
"------ Bus information ------" << std::endl;
1551 std::cout <<
"Number of camera(s) on the bus : " << num_cameras <<std::endl;
1552 std::cout <<
"-----------------------------" << std::endl;
1555 if (camIsOpen != NULL)
delete [] camIsOpen;
1556 camIsOpen =
new bool [num_cameras];
1557 for (
unsigned int i = 0;i<num_cameras;i++){
1576 if (
init ==
false) initialize(
false);
1577 if (camIsOpen[camera_id] ==
false){
1578 dc1394switch_t status = DC1394_OFF;
1581 dc1394_video_get_transmission(cameras[camera_id], &status);
1582 if (status != DC1394_OFF){
1584 if (dc1394_video_set_transmission(cameras[camera_id],DC1394_OFF)!=DC1394_SUCCESS)
1585 vpTRACE(
"Could not stop ISO transmission");
1588 if (dc1394_video_get_transmission(cameras[camera_id], &status)!=DC1394_SUCCESS)
1589 vpTRACE(
"Could get ISO status");
1591 if (status==DC1394_ON) {
1592 vpTRACE(
"ISO transmission refuses to stop");
1594 #ifdef VISP_HAVE_DC1394_FIND_CAMERAS // old API <= libdc1394-2.0.0-rc7
1596 cameras[camera_id]->is_iso_on=status;
1605 setCapture(DC1394_ON);
1606 setTransmission(DC1394_ON);
1607 camIsOpen[camera_id] =
true;
1623 for (
unsigned int i = 0; i < num_cameras;i++) {
1625 camera = cameras[i];
1626 this->camera_id = i;
1627 setTransmission(DC1394_OFF);
1628 setCapture(DC1394_OFF);
1629 if(isDataModified[i]){
1632 updateDataStructToCam();
1637 if (dc1394_feature_set_mode(camera, DC1394_FEATURE_BRIGHTNESS, initialShutterMode[i]) != DC1394_SUCCESS ||
1638 dc1394_feature_set_mode(camera, DC1394_FEATURE_EXPOSURE, initialShutterMode[i]) != DC1394_SUCCESS ||
1639 dc1394_feature_set_mode(camera, DC1394_FEATURE_SHARPNESS, initialShutterMode[i]) != DC1394_SUCCESS ||
1640 dc1394_feature_set_mode(camera, DC1394_FEATURE_HUE, initialShutterMode[i]) != DC1394_SUCCESS ||
1641 dc1394_feature_set_mode(camera, DC1394_FEATURE_SATURATION, initialShutterMode[i]) != DC1394_SUCCESS ||
1642 dc1394_feature_set_mode(camera, DC1394_FEATURE_GAMMA, initialShutterMode[i]) != DC1394_SUCCESS ||
1643 dc1394_feature_set_mode(camera, DC1394_FEATURE_SHUTTER, initialShutterMode[i]) != DC1394_SUCCESS ||
1644 dc1394_feature_set_mode(camera, DC1394_FEATURE_GAIN, initialShutterMode[i]) != DC1394_SUCCESS ||
1645 dc1394_feature_set_mode(camera, DC1394_FEATURE_IRIS, initialShutterMode[i])){
1649 "Unable to reset the initial mode"));
1652 if (dc1394_camera_set_power(camera, DC1394_OFF) != DC1394_SUCCESS)
1653 std::cout <<
"Unable to turn camera off" << std::endl;
1655 #ifdef VISP_HAVE_DC1394_CAMERA_ENUMERATE // new API > libdc1394-2.0.0-rc7
1656 dc1394_camera_free(cameras[i]);
1657 #elif defined VISP_HAVE_DC1394_FIND_CAMERAS // old API <= libdc1394-2.0.0-rc7
1658 dc1394_free_camera(cameras[i]);
1662 if (camIsOpen != NULL) {
1663 delete [] camIsOpen;
1667 #ifdef VISP_HAVE_DC1394_CAMERA_ENUMERATE // new API > libdc1394-2.0.0-rc7
1668 if (cameras != NULL) {
1677 #elif defined VISP_HAVE_DC1394_FIND_CAMERAS // old API <= libdc1394-2.0.0-rc7
1678 if (cameras != NULL) {
1688 if(isDataModified != NULL){
1689 delete[] isDataModified;
1690 isDataModified = NULL;
1692 if(initialShutterMode != NULL){
1693 delete[] initialShutterMode;
1694 initialShutterMode = NULL;
1696 if(dataCam != NULL){
1722 "Could not set ring buffer size") );
1725 if (size != num_buffers) {
1728 if(camIsOpen[camera_id]){
1729 setCapture(DC1394_OFF);
1730 setCapture(DC1394_ON);
1792 if (! num_cameras) {
1796 "No camera found") );
1799 dc1394feature_mode_t mode;
1801 mode = DC1394_FEATURE_MODE_AUTO;
1804 mode = DC1394_FEATURE_MODE_MANUAL;
1807 if (dc1394_feature_set_power(camera, DC1394_FEATURE_SHUTTER, DC1394_ON)
1808 != DC1394_SUCCESS) {
1812 "Cannot set shutter on") );
1815 if (dc1394_feature_set_mode(camera,
1816 DC1394_FEATURE_SHUTTER,
1818 != DC1394_SUCCESS) {
1822 "Cannot set auto shutter") );
1870 if (dc1394_avt_set_auto_shutter(camera, minvalue, maxvalue)
1871 != DC1394_SUCCESS) {
1875 "Cannot set auto shutter min and max values") );
1894 if (! num_cameras) {
1898 "No camera found") );
1901 if (dc1394_avt_get_auto_shutter(camera, &minvalue, &maxvalue)
1902 != DC1394_SUCCESS) {
1906 "Cannot get auto shutter min and max values") );
1952 if (! num_cameras) {
1956 "No camera found") );
1959 dc1394feature_mode_t mode;
1961 mode = DC1394_FEATURE_MODE_AUTO;
1964 mode = DC1394_FEATURE_MODE_MANUAL;
1967 if (dc1394_feature_set_power(camera, DC1394_FEATURE_GAIN, DC1394_ON)
1968 != DC1394_SUCCESS) {
1972 "Cannot set shutter on") );
1975 if (dc1394_feature_set_mode(camera,
1976 DC1394_FEATURE_GAIN,
1978 != DC1394_SUCCESS) {
1982 "Cannot set auto gain") );
2030 if (dc1394_avt_set_auto_gain(camera, minvalue, maxvalue)
2031 != DC1394_SUCCESS) {
2035 "Cannot set auto gain min and max values") );
2054 if (! num_cameras) {
2058 "No camera found") );
2061 if (dc1394_avt_get_auto_gain(camera, &minvalue, &maxvalue)
2062 != DC1394_SUCCESS) {
2066 "Cannot get auto gain min and max values") );
2089 vp1394TwoGrabber::setCapture(dc1394switch_t _switch)
2091 if (! num_cameras) {
2095 "No camera found") );
2098 if (_switch == DC1394_ON) {
2101 if (dc1394_capture_setup(camera, num_buffers,
2102 DC1394_CAPTURE_FLAGS_DEFAULT) != DC1394_SUCCESS) {
2104 "make sure that the video mode and framerate are "
2105 "supported by your camera.\n");
2108 "Could not setup dma capture") );
2112 dc1394error_t code = dc1394_capture_stop(camera);
2114 if (code != DC1394_SUCCESS && code != DC1394_CAPTURE_IS_NOT_SET) {
2118 "Could not setup dma capture") );
2139 vp1394TwoGrabber::setTransmission(dc1394switch_t _switch)
2141 if (! num_cameras) {
2145 "No camera found") );
2148 dc1394switch_t status = DC1394_OFF;
2150 if (dc1394_video_get_transmission(camera, &status)!=DC1394_SUCCESS) {
2154 "Could not setup dma capture") );
2159 if (dc1394_video_set_transmission(camera, _switch) != DC1394_SUCCESS) {
2161 "make sure that the video mode and framerate are "
2162 "supported by your camera.\n");
2165 "Could not setup dma capture") );
2168 if (_switch == DC1394_ON) {
2169 status = DC1394_OFF;
2172 while ( status == DC1394_OFF && i++ < 5 ) {
2174 if (dc1394_video_get_transmission(camera, &status)!=DC1394_SUCCESS) {
2178 "Could not setup dma capture") );
2222 if (! num_cameras) {
2226 "No camera found") );
2229 dc1394operation_mode_t op_mode;
2230 dc1394speed_t speed;
2234 if (camera->bmode_capable != DC1394_TRUE) {
2239 "Camera is not 1394B mode capable") );
2242 if(dc1394_video_set_operation_mode(camera,
2243 DC1394_OPERATION_MODE_1394B)
2244 != DC1394_SUCCESS) {
2248 "Cannot set camera to 1394B mode") );
2251 if (dc1394_video_get_operation_mode(camera, &op_mode) != DC1394_SUCCESS) {
2255 "Failed to set 1394B mode") );
2259 if (dc1394_video_set_operation_mode(camera,
2260 DC1394_OPERATION_MODE_LEGACY)
2261 != DC1394_SUCCESS) {
2265 "Cannot set camera to 1394A mode") );
2268 if (dc1394_video_get_operation_mode(camera, &op_mode) != DC1394_SUCCESS) {
2272 "Failed to set 1394A mode") );
2276 if (dc1394_video_set_iso_speed(camera, (dc1394speed_t) isospeed)
2277 != DC1394_SUCCESS) {
2281 "Cannot set requested iso speed") );
2284 if (dc1394_video_get_iso_speed(camera, &speed) != DC1394_SUCCESS) {
2288 "Failed to set iso speed") );
2365 dc1394video_frame_t *
2369 if (! num_cameras) {
2373 "No camera found") );
2376 dc1394video_frame_t *frame = NULL;
2378 if (dc1394_capture_dequeue(camera, DC1394_CAPTURE_POLICY_WAIT, &frame)
2380 vpERROR_TRACE (
"Error: Failed to capture from camera %d\n", camera_id);
2427 dc1394video_frame_t *
2433 dc1394video_frame_t *frame;
2435 frame =
dequeue(I, timestamp,
id);
2488 dc1394video_frame_t *
2490 uint64_t ×tamp,
2496 dc1394video_frame_t *frame;
2502 timestamp = frame->timestamp;
2505 this->
width = frame->size[0];
2506 this->
height = frame->size[1];
2512 switch(frame->color_coding) {
2513 case DC1394_COLOR_CODING_MONO8:
2514 case DC1394_COLOR_CODING_RAW8:
2515 memcpy(I.
bitmap, (
unsigned char *) frame->image,
2516 size*
sizeof(
unsigned char));
2518 case DC1394_COLOR_CODING_MONO16:
2519 case DC1394_COLOR_CODING_RAW16:
2524 case DC1394_COLOR_CODING_YUV411:
2529 case DC1394_COLOR_CODING_YUV422:
2534 case DC1394_COLOR_CODING_YUV444:
2539 case DC1394_COLOR_CODING_RGB8:
2546 vpERROR_TRACE(
"Format conversion not implemented. Acquisition failed.");
2548 "Format conversion not implemented. "
2549 "Acquisition failed.") );
2596 dc1394video_frame_t *
2602 dc1394video_frame_t *frame;
2604 frame =
dequeue(I, timestamp,
id);
2657 dc1394video_frame_t *
2659 uint64_t ×tamp,
2665 dc1394video_frame_t *frame;
2671 timestamp = frame->timestamp;
2674 this->
width = frame->size[0];
2675 this->
height = frame->size[1];
2681 switch (frame->color_coding) {
2682 case DC1394_COLOR_CODING_MONO8:
2683 case DC1394_COLOR_CODING_RAW8:
2685 (
unsigned char *) I.
bitmap, size);
2688 case DC1394_COLOR_CODING_MONO16:
2689 case DC1394_COLOR_CODING_RAW16:
2691 (
unsigned char *) I.
bitmap, size);
2694 case DC1394_COLOR_CODING_YUV411:
2696 (
unsigned char *) I.
bitmap, size);
2699 case DC1394_COLOR_CODING_YUV422:
2701 (
unsigned char *) I.
bitmap, size);
2704 case DC1394_COLOR_CODING_YUV444:
2706 (
unsigned char *) I.
bitmap, size);
2709 case DC1394_COLOR_CODING_RGB8:
2711 (
unsigned char *) I.
bitmap, size);
2717 vpERROR_TRACE(
"Format conversion not implemented. Acquisition failed.");
2719 "Format conversion not implemented. "
2720 "Acquisition failed.") );
2741 if (! num_cameras) {
2745 "No camera found") );
2749 dc1394_capture_enqueue(camera, frame);
2772 dc1394video_frame_t *frame;
2774 frame =
dequeue(I, timestamp,
id);
2798 uint64_t ×tamp,
2801 dc1394video_frame_t *frame;
2804 frame =
dequeue(I, timestamp,
id);
2828 dc1394video_frame_t *frame;
2831 frame =
dequeue(I, timestamp,
id);
2855 uint64_t ×tamp,
2858 dc1394video_frame_t *frame;
2864 timestamp = frame->timestamp;
2867 this->
width = frame->size[0];
2868 this->
height = frame->size[1];
2874 switch (frame->color_coding) {
2875 case DC1394_COLOR_CODING_MONO8:
2876 case DC1394_COLOR_CODING_RAW8:
2878 (
unsigned char *) I.
bitmap, size);
2881 case DC1394_COLOR_CODING_YUV411:
2883 (
unsigned char *) I.
bitmap, size);
2886 case DC1394_COLOR_CODING_YUV422:
2888 (
unsigned char *) I.
bitmap, size);
2891 case DC1394_COLOR_CODING_YUV444:
2893 (
unsigned char *) I.
bitmap, size);
2896 case DC1394_COLOR_CODING_RGB8:
2898 (
unsigned char *) I.
bitmap, size);
2904 vpERROR_TRACE(
"Format conversion not implemented. Acquisition failed.");
2906 "Format conversion not implemented. "
2907 "Acquisition failed.") );
2933 if (! num_cameras) {
2937 "No camera found") );
2961 if (! num_cameras) {
2965 "No camera found") );
2990 if (! num_cameras) {
2994 "No camera found") );
3018 if (! num_cameras) {
3022 "No camera found") );
3036 std::cout <<
"----------------------------------------------------------"
3038 <<
"----- Information for camera " << camera_id
3039 <<
" -----" << std::endl
3040 <<
"----------------------------------------------------------" << std::endl;
3042 #ifdef VISP_HAVE_DC1394_CAMERA_ENUMERATE // new API > libdc1394-2.0.0-rc7
3043 dc1394_camera_print_info( camera, stdout);
3044 #elif defined VISP_HAVE_DC1394_FIND_CAMERAS // old API <= libdc1394-2.0.0-rc7
3045 dc1394_print_camera_info( camera);
3048 dc1394featureset_t features;
3049 #ifdef VISP_HAVE_DC1394_CAMERA_ENUMERATE // new API > libdc1394-2.0.0-rc7
3050 if (dc1394_feature_get_all(camera, &features) != DC1394_SUCCESS)
3051 #elif defined VISP_HAVE_DC1394_FIND_CAMERAS // old API <= libdc1394-2.0.0-rc7
3052 if (dc1394_get_camera_feature_set(camera, &features) != DC1394_SUCCESS)
3056 vpERROR_TRACE(
"unable to get feature set for camera %d\n", camera_id);
3058 "Cannot get camera features") );
3061 #ifdef VISP_HAVE_DC1394_CAMERA_ENUMERATE // new API > libdc1394-2.0.0-rc7
3062 dc1394_feature_print_all(&features, stdout);
3063 #elif defined VISP_HAVE_DC1394_FIND_CAMERAS // old API <= libdc1394-2.0.0-rc7
3064 dc1394_print_feature_set(&features);
3067 std::cout <<
"----------------------------------------------------------" << std::endl;
3084 std::string _str =
"";
3085 dc1394video_mode_t _videomode = (dc1394video_mode_t) videomode;
3087 if ((_videomode >= DC1394_VIDEO_MODE_MIN)
3088 && (_videomode <= DC1394_VIDEO_MODE_MAX)) {
3089 _str =
strVideoMode[_videomode - DC1394_VIDEO_MODE_MIN];
3092 vpCERROR <<
"The video mode " << (int)videomode
3093 <<
" is not supported by the camera" << std::endl;
3113 std::string _str =
"";
3114 dc1394framerate_t _fps = (dc1394framerate_t) fps;
3116 if ((_fps >= DC1394_FRAMERATE_MIN)
3117 && (_fps <= DC1394_FRAMERATE_MAX)) {
3121 vpCERROR <<
"The framerate " << (int)fps
3122 <<
" is not supported by the camera" << std::endl;
3142 std::string _str =
"";
3143 dc1394color_coding_t _coding = (dc1394color_coding_t) colorcoding;
3145 if ((_coding >= DC1394_COLOR_CODING_MIN)
3146 && (_coding <= DC1394_COLOR_CODING_MAX)) {
3151 vpCERROR <<
"The color coding " << (int)colorcoding
3152 <<
" is not supported by the camera" << std::endl;
3180 for (
int i = DC1394_VIDEO_MODE_MIN; i <= DC1394_VIDEO_MODE_MAX; i ++) {
3187 "The required videomode is not valid") );
3215 for (
int i = DC1394_FRAMERATE_MIN; i <= DC1394_FRAMERATE_MAX; i ++) {
3222 "The required framerate is not valid") );
3249 for (
int i = DC1394_COLOR_CODING_MIN; i <= DC1394_COLOR_CODING_MAX; i ++) {
3256 "The required color coding is not valid") );
3295 for (
unsigned int i = 0; i < num_cameras;i++) {
3297 camera = cameras[i];
3298 setTransmission(DC1394_OFF);
3299 setCapture(DC1394_OFF);
3302 #ifdef VISP_HAVE_DC1394_CAMERA_ENUMERATE // new API > libdc1394-2.0.0-rc7
3305 for (
unsigned int i=0;i<num_cameras;i++){
3306 if (i!=camera_id) dc1394_camera_free(cameras[i]);
3309 printf (
"Reseting bus...\n");
3310 dc1394_reset_bus (camera);
3312 dc1394_camera_free (camera);
3318 #elif defined VISP_HAVE_DC1394_FIND_CAMERAS // old API <= libdc1394-2.0.0-rc7
3322 for (
unsigned int i=0;i<num_cameras;i++){
3323 if (i!=camera_id) dc1394_free_camera(cameras[i]);
3328 dc1394_reset_bus(camera);
3329 dc1394_free_camera(camera);
3332 if (camIsOpen != NULL)
3333 delete [] camIsOpen;
3375 if (! num_cameras) {
3379 "No camera found") );
3381 uint64_t offset = 0x884;
3382 uint32_t value = 0x82000000 + (uint32_t)panControlValue;
3384 err = dc1394_set_control_register(camera, offset, value);
3385 if (err != DC1394_SUCCESS) {
3389 "Unable to set PAN register") );
3412 if (! num_cameras) {
3416 "No camera found") );
3420 dc1394feature_t feature = DC1394_FEATURE_BRIGHTNESS;
3447 err = dc1394_feature_get_value(camera, feature, &value);
3448 if (err != DC1394_SUCCESS) {
3452 "Unable to get the information") );
3454 return (
unsigned int)value;
3481 if (! num_cameras) {
3485 "No camera found") );
3487 uint32_t value = (uint32_t)val;
3488 dc1394feature_t feature = DC1394_FEATURE_BRIGHTNESS;
3515 dc1394bool_t hasManualMode = DC1394_FALSE;
3516 dc1394feature_modes_t modesAvailable;
3519 err = dc1394_feature_get_modes(camera, feature, &modesAvailable);
3520 if (err != DC1394_SUCCESS) {
3521 vpERROR_TRACE(
"Unable to detect the manual mode information");
3524 "Unable to detect the manual mode information"));
3527 for(
unsigned int i=0; i<modesAvailable.num; i++){
3528 if(modesAvailable.modes[i] == DC1394_FEATURE_MODE_MANUAL){
3529 hasManualMode = DC1394_TRUE;
3533 if(hasManualMode == DC1394_TRUE){
3535 if(!isDataModified[camera_id]){
3537 updateDataCamToStruct();
3538 err = dc1394_feature_get_mode(camera, feature, &(initialShutterMode[camera_id]));
3539 if (err != DC1394_SUCCESS) {
3543 "Unable to get the initial mode"));
3545 isDataModified[camera_id] =
true;
3548 dc1394feature_mode_t manualMode = DC1394_FEATURE_MODE_MANUAL;
3549 err = dc1394_feature_set_mode(camera, feature, manualMode);
3550 if (err != DC1394_SUCCESS) {
3554 "Unable to set the manual mode") );
3556 err = dc1394_feature_set_value(camera, feature, value);
3557 if (err != DC1394_SUCCESS) {
3561 "Unable to set the shutter information") );
3565 vpERROR_TRACE(
"The camera does not have a manual mode.\nCannot change the value");
3567 "The camera does not have a manual mode"));
3580 if (! num_cameras) {
3584 "No camera found") );
3587 guid = camera->guid;
3600 if (! num_cameras) {
3604 "No camera found") );
3607 return camera->guid;
3616 vp1394TwoGrabber::updateDataCamToStruct()
3634 vp1394TwoGrabber::updateDataStructToCam()
3691 #elif !defined(VISP_BUILD_SHARED_LIBS)
3693 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)