50 #include <visp/vpConfig.h>
55 #if defined(VISP_HAVE_DC1394_2)
58 #include <visp/vp1394TwoGrabber.h>
59 #include <visp/vpFrameGrabberException.h>
60 #include <visp/vpImageIo.h>
61 #include <visp/vpImageConvert.h>
62 #include <visp/vpTime.h>
65 "MODE_160x120_YUV444",
66 "MODE_320x240_YUV422",
67 "MODE_640x480_YUV411",
68 "MODE_640x480_YUV422",
71 "MODE_640x480_MONO16",
72 "MODE_800x600_YUV422",
75 "MODE_1024x768_YUV422",
77 "MODE_1024x768_MONO8",
78 "MODE_800x600_MONO16",
79 "MODE_1024x768_MONO16",
80 "MODE_1280x960_YUV422",
82 "MODE_1280x960_MONO8",
83 "MODE_1600x1200_YUV422",
84 "MODE_1600x1200_RGB8",
85 "MODE_1600x1200_MONO8",
86 "MODE_1280x960_MONO16",
87 "MODE_1600x1200_MONO16",
111 "COLOR_CODING_MONO8",
112 "COLOR_CODING_YUV411",
113 "COLOR_CODING_YUV422",
114 "COLOR_CODING_YUV444",
116 "COLOR_CODING_MONO16",
117 "COLOR_CODING_RGB16",
118 "COLOR_CODING_MONO16S",
119 "COLOR_CODING_RGB16S",
121 "COLOR_CODING_RAW16",
171 : camera(NULL), cameras(NULL), num_cameras(0), camera_id(0), verbose(false), camIsOpen(NULL),
173 isDataModified(NULL), initialShutterMode(NULL), dataCam(NULL)
174 #ifdef VISP_HAVE_DC1394_2_CAMERA_ENUMERATE
335 if (cam_id >= num_cameras) {
337 bool is_guid =
false;
339 for (
unsigned int i=0; i< num_cameras; i++) {
340 if (cameras[i]->guid == cam_id) {
346 if (is_guid ==
false) {
347 std::cout <<
"Error: The camera with guid 0x" << std::hex << cam_id <<
" is not present" << std::endl;
348 std::cout << num_cameras <<
" camera(s) connected" << std::endl;
349 for (
unsigned int i=0; i< num_cameras; i++) {
350 std::cout <<
" - camera " << i <<
" with guid 0x" << std::hex << cameras[i]->guid << std::endl;
354 "The required camera is not present") );
358 this->camera_id = (
unsigned int) cam_id;
362 camera = cameras[this->camera_id];
384 cam_id = this->camera_id;
390 "No cameras found") );
412 return this->camera_id;
418 "No cameras found") );
433 vpCTRACE <<
"No camera found..."<< std::endl;
437 ncameras = num_cameras;
450 unsigned int ncameras = 0;
452 vpCTRACE <<
"No camera found..."<< std::endl;
456 ncameras = num_cameras;
513 "No camera found") );
516 vpERROR_TRACE(
"Video mode not supported by camera %d",camera_id);
518 "Video mode not supported") );
522 setTransmission(DC1394_OFF);
523 setCapture(DC1394_OFF);
525 if (dc1394_video_set_mode(camera, (dc1394video_mode_t) videomode) != DC1394_SUCCESS) {
530 "Can't set video mode") );
533 setCapture(DC1394_ON);
534 setTransmission(DC1394_ON);
537 if (dc1394_get_image_size_from_video_mode(camera,
538 (dc1394video_mode_t) videomode,
545 "Can't get image size") );
573 "No camera found") );
576 dc1394video_mode_t _videomode;
577 if (dc1394_video_get_mode(camera, &_videomode) != DC1394_SUCCESS) {
582 "Can't get current video mode") );
617 "No camera found") );
619 dc1394video_modes_t _videomodes;
622 if (dc1394_video_get_supported_modes(camera, &_videomodes)!=DC1394_SUCCESS) {
627 "Can't get video modes") );
631 for (
unsigned i=0; i < _videomodes.num; i++) {
633 videomodes.push_back( _mode );
637 return _videomodes.num;
661 "No camera found") );
663 dc1394video_modes_t _videomodes;
666 if (dc1394_video_get_supported_modes(camera, &_videomodes)!=DC1394_SUCCESS) {
671 "Can't get video modes") );
675 for (
unsigned i=0; i < _videomodes.num; i++) {
698 if (dc1394_is_video_mode_scalable((dc1394video_mode_t) videomode))
775 "No camera found") );
784 vpERROR_TRACE(
"Framerate not supported by camera %d",camera_id);
786 "Framerate not supported") );
791 setTransmission(DC1394_OFF);
792 setCapture(DC1394_OFF);
794 if (dc1394_video_set_framerate(camera, (dc1394framerate_t) fps) != DC1394_SUCCESS) {
799 "Can't set framerate") );
802 setCapture(DC1394_ON);
803 setTransmission(DC1394_ON);
829 "No camera found") );
831 dc1394framerate_t _fps;
832 if (dc1394_video_get_framerate(camera, &_fps) != DC1394_SUCCESS) {
837 "Can't get current framerate") );
876 std::list<vp1394TwoFramerateType> & fps)
882 "No camera found") );
905 dc1394framerates_t _fps;
906 if (dc1394_video_get_supported_framerates(camera,
907 (dc1394video_mode_t)mode,
908 &_fps) != DC1394_SUCCESS) {
910 vpERROR_TRACE(
"Could not query supported frametates for mode %d\n",
913 "Could not query supported framerates") );
918 for (
unsigned int i = 0; i < _fps.num; i ++)
967 "No camera found") );
987 dc1394framerates_t _fps;
988 if (dc1394_video_get_supported_framerates(camera,
989 (dc1394video_mode_t)mode,
990 &_fps) != DC1394_SUCCESS) {
992 vpERROR_TRACE(
"Could not query supported frametates for mode %d\n",
995 "Could not query supported framerates") );
1000 for (
unsigned int i = 0; i < _fps.num; i ++){
1062 if (! num_cameras) {
1066 "No camera found") );
1069 dc1394video_mode_t _videomode;
1070 if (dc1394_video_get_mode(camera, &_videomode) != DC1394_SUCCESS) {
1075 "Can't get current video mode") );
1079 vpERROR_TRACE(
"Color coding not supported by camera %d",camera_id);
1081 "Color coding not supported") );
1086 if (dc1394_is_video_mode_scalable(_videomode)) {
1087 setTransmission(DC1394_OFF);
1088 setCapture(DC1394_OFF);
1090 if (dc1394_format7_set_color_coding(camera, _videomode,
1091 (dc1394color_coding_t) coding)
1092 != DC1394_SUCCESS) {
1097 "Can't set color coding") );
1100 setCapture(DC1394_ON);
1101 setTransmission(DC1394_ON);
1125 if (! num_cameras) {
1129 "No camera found") );
1131 dc1394video_mode_t _videomode;
1132 if (dc1394_video_get_mode(camera, &_videomode) != DC1394_SUCCESS) {
1137 "Can't get current video mode") );
1140 dc1394color_coding_t _coding;
1141 if (dc1394_is_video_mode_scalable(_videomode)) {
1143 if (dc1394_format7_get_color_coding(camera, _videomode, &_coding)
1144 != DC1394_SUCCESS) {
1149 "Can't query current color coding") );
1152 else if (dc1394_is_video_mode_still_image((dc1394video_mode_t)_videomode)) {
1154 "No color coding for format 6 video mode"));
1158 if (dc1394_get_color_coding_from_video_mode(camera,
1159 (dc1394video_mode_t)_videomode,
1160 &_coding) != DC1394_SUCCESS) {
1162 vpERROR_TRACE(
"Could not query supported color coding for mode %d\n",
1165 "Can't query current color coding"));
1194 std::list<vp1394TwoColorCodingType> & codings)
1196 if (! num_cameras) {
1200 "No camera found") );
1206 if (dc1394_is_video_mode_scalable((dc1394video_mode_t)mode)) {
1208 dc1394color_codings_t _codings;
1209 if (dc1394_format7_get_color_codings(camera,
1210 (dc1394video_mode_t)mode,
1211 &_codings) != DC1394_SUCCESS) {
1213 vpERROR_TRACE(
"Could not query supported color codings for mode %d\n",
1216 "Could not query supported color codings") );
1218 if (_codings.num == 0)
1221 for (
unsigned int i = 0; i < _codings.num; i ++)
1224 return _codings.num;
1226 else if (dc1394_is_video_mode_still_image((dc1394video_mode_t)mode)) {
1232 dc1394color_coding_t _coding;
1233 if (dc1394_get_color_coding_from_video_mode(camera,
1234 (dc1394video_mode_t)mode,
1235 &_coding) != DC1394_SUCCESS) {
1237 vpERROR_TRACE(
"Could not query supported color coding for mode %d\n",
1240 "Could not query supported color coding") );
1271 if (! num_cameras) {
1275 "No camera found") );
1279 if (dc1394_is_video_mode_scalable((dc1394video_mode_t)mode)) {
1281 dc1394color_codings_t _codings;
1282 if (dc1394_format7_get_color_codings(camera,
1283 (dc1394video_mode_t)mode,
1284 &_codings) != DC1394_SUCCESS) {
1286 vpERROR_TRACE(
"Could not query supported color codings for mode %d\n",
1289 "Could not query supported color codings") );
1291 if (_codings.num == 0)
1294 for (
unsigned int i = 0; i < _codings.num; i ++){
1300 else if (dc1394_is_video_mode_still_image((dc1394video_mode_t)mode)) {
1306 dc1394color_coding_t _coding;
1307 if (dc1394_get_color_coding_from_video_mode(camera,
1308 (dc1394video_mode_t)mode,
1309 &_coding) != DC1394_SUCCESS) {
1311 vpERROR_TRACE(
"Could not query supported color coding for mode %d\n",
1314 "Could not query supported color coding") );
1358 unsigned int w,
unsigned int h)
1361 if (! num_cameras) {
1365 "No camera found") );
1368 dc1394video_mode_t _videomode;
1369 if (dc1394_video_get_mode(camera, &_videomode) != DC1394_SUCCESS) {
1374 "Can't get current video mode") );
1376 if (dc1394_is_video_mode_scalable(_videomode)) {
1378 setTransmission(DC1394_OFF);
1379 setCapture(DC1394_OFF);
1381 unsigned int max_width, max_height;
1382 if (dc1394_format7_get_max_image_size(camera, _videomode,
1383 &max_width, &max_height)
1384 != DC1394_SUCCESS) {
1389 "Can't get format7 max image size") );
1392 vpTRACE(
"left: %d top: %d width: %d height: %d", left, top,
1393 width == 0 ? DC1394_USE_MAX_AVAIL: w,
1394 height == 0 ? DC1394_USE_MAX_AVAIL : h);
1395 vpTRACE(
"max_width: %d max_height: %d", max_width, max_height);
1398 if (left > max_width) {
1401 "Can't set format7 ROI") );
1403 if (top > max_height) {
1406 "Can't set format7 ROI") );
1414 if (w > (max_width - left))
1415 w = (max_width - left);
1416 roi_width = (int32_t)w;
1419 roi_width = DC1394_USE_MAX_AVAIL;
1424 if (h > (max_height - top))
1425 h = (max_height - top);
1426 roi_height = (int32_t)h;
1429 roi_height = DC1394_USE_MAX_AVAIL;
1432 if (dc1394_format7_set_roi(camera, _videomode,
1433 (dc1394color_coding_t) DC1394_QUERY_FROM_CAMERA,
1434 DC1394_USE_MAX_AVAIL,
1439 != DC1394_SUCCESS) {
1443 "Can't get current video mode") );
1446 if (dc1394_format7_get_image_size(camera, _videomode,
1449 != DC1394_SUCCESS) {
1453 "Can't get format7 image size") );
1456 setCapture(DC1394_ON);
1457 setTransmission(DC1394_ON);
1475 vp1394TwoGrabber::initialize(
bool reset)
1479 #ifdef VISP_HAVE_DC1394_2_CAMERA_ENUMERATE // new API > libdc1394-2.0.0-rc7
1484 if (dc1394_camera_enumerate (d, &list) != DC1394_SUCCESS) {
1485 dc1394_camera_free_list (list);
1489 "Failed to enumerate cameras") );
1492 if (list->num == 0) {
1493 dc1394_camera_free_list (list);
1497 "No cameras found") );
1500 if (cameras != NULL)
1503 cameras =
new dc1394camera_t * [list->num];
1507 for (
unsigned int i=0; i < list->num; i ++) {
1508 cameras[i] = dc1394_camera_new (d, list->ids[i].guid);
1510 vpTRACE (
"Failed to initialize camera with guid \"%ld\"\n",
1522 dc1394_reset_bus(cameras[0]);
1526 dc1394_camera_free_list (list);
1529 #elif defined VISP_HAVE_DC1394_2_FIND_CAMERAS // old API <= libdc1394-2.0.0-rc7
1530 if (cameras != NULL)
1533 int err = dc1394_find_cameras(&cameras, &num_cameras);
1535 if (err!=DC1394_SUCCESS && err != DC1394_NO_CAMERA) {
1539 " - if the kernel modules `ieee1394',`raw1394' and `ohci1394' are loaded \n"
1540 " - if you have read/write access to /dev/raw1394\n\n");
1542 "Unable to look for cameras") );
1547 if (num_cameras == 0) {
1551 "No cameras found") );
1555 isDataModified =
new bool[num_cameras];
1556 for(
unsigned int i=0; i<num_cameras; i++)
1557 isDataModified[i] =
false;
1558 initialShutterMode =
new dc1394feature_mode_t[num_cameras];
1559 dataCam =
new vpDc1394TwoCameraParametersData[num_cameras];
1561 if (camera_id >= num_cameras) {
1571 std::cout <<
"------ Bus information ------" << std::endl;
1572 std::cout <<
"Number of camera(s) on the bus : " << num_cameras <<std::endl;
1573 std::cout <<
"-----------------------------" << std::endl;
1576 if (camIsOpen != NULL)
delete [] camIsOpen;
1577 camIsOpen =
new bool [num_cameras];
1578 for (
unsigned int i = 0;i<num_cameras;i++){
1597 if (
init ==
false) initialize(
false);
1598 if (camIsOpen[camera_id] ==
false){
1599 dc1394switch_t status = DC1394_OFF;
1602 dc1394_video_get_transmission(cameras[camera_id], &status);
1603 if (status != DC1394_OFF){
1605 if (dc1394_video_set_transmission(cameras[camera_id],DC1394_OFF)!=DC1394_SUCCESS)
1606 vpTRACE(
"Could not stop ISO transmission");
1609 if (dc1394_video_get_transmission(cameras[camera_id], &status)!=DC1394_SUCCESS)
1610 vpTRACE(
"Could get ISO status");
1612 if (status==DC1394_ON) {
1613 vpTRACE(
"ISO transmission refuses to stop");
1615 #ifdef VISP_HAVE_DC1394_2_FIND_CAMERAS // old API <= libdc1394-2.0.0-rc7
1617 cameras[camera_id]->is_iso_on=status;
1626 setCapture(DC1394_ON);
1627 setTransmission(DC1394_ON);
1628 camIsOpen[camera_id] =
true;
1644 for (
unsigned int i = 0; i < num_cameras;i++) {
1646 camera = cameras[i];
1647 this->camera_id = i;
1648 setTransmission(DC1394_OFF);
1649 setCapture(DC1394_OFF);
1650 if(isDataModified[i]){
1653 updateDataStructToCam();
1658 if (dc1394_feature_set_mode(camera, DC1394_FEATURE_BRIGHTNESS, initialShutterMode[i]) != DC1394_SUCCESS ||
1659 dc1394_feature_set_mode(camera, DC1394_FEATURE_EXPOSURE, initialShutterMode[i]) != DC1394_SUCCESS ||
1660 dc1394_feature_set_mode(camera, DC1394_FEATURE_SHARPNESS, initialShutterMode[i]) != DC1394_SUCCESS ||
1661 dc1394_feature_set_mode(camera, DC1394_FEATURE_HUE, initialShutterMode[i]) != DC1394_SUCCESS ||
1662 dc1394_feature_set_mode(camera, DC1394_FEATURE_SATURATION, initialShutterMode[i]) != DC1394_SUCCESS ||
1663 dc1394_feature_set_mode(camera, DC1394_FEATURE_GAMMA, initialShutterMode[i]) != DC1394_SUCCESS ||
1664 dc1394_feature_set_mode(camera, DC1394_FEATURE_SHUTTER, initialShutterMode[i]) != DC1394_SUCCESS ||
1665 dc1394_feature_set_mode(camera, DC1394_FEATURE_GAIN, initialShutterMode[i]) != DC1394_SUCCESS ||
1666 dc1394_feature_set_mode(camera, DC1394_FEATURE_IRIS, initialShutterMode[i])){
1670 "Unable to reset the initial mode"));
1673 if (dc1394_camera_set_power(camera, DC1394_OFF) != DC1394_SUCCESS)
1674 std::cout <<
"Unable to turn camera off" << std::endl;
1676 #ifdef VISP_HAVE_DC1394_2_CAMERA_ENUMERATE // new API > libdc1394-2.0.0-rc7
1677 dc1394_camera_free(cameras[i]);
1678 #elif defined VISP_HAVE_DC1394_2_FIND_CAMERAS // old API <= libdc1394-2.0.0-rc7
1679 dc1394_free_camera(cameras[i]);
1683 if (camIsOpen != NULL) {
1684 delete [] camIsOpen;
1688 #ifdef VISP_HAVE_DC1394_2_CAMERA_ENUMERATE // new API > libdc1394-2.0.0-rc7
1689 if (cameras != NULL) {
1698 #elif defined VISP_HAVE_DC1394_2_FIND_CAMERAS // old API <= libdc1394-2.0.0-rc7
1699 if (cameras != NULL) {
1709 if(isDataModified != NULL){
1710 delete[] isDataModified;
1711 isDataModified = NULL;
1713 if(initialShutterMode != NULL){
1714 delete[] initialShutterMode;
1715 initialShutterMode = NULL;
1717 if(dataCam != NULL){
1743 "Could not set ring buffer size") );
1746 if (size != num_buffers) {
1749 if(camIsOpen[camera_id]){
1750 setCapture(DC1394_OFF);
1751 setCapture(DC1394_ON);
1813 if (! num_cameras) {
1817 "No camera found") );
1820 dc1394feature_mode_t mode;
1822 mode = DC1394_FEATURE_MODE_AUTO;
1825 mode = DC1394_FEATURE_MODE_MANUAL;
1828 if (dc1394_feature_set_power(camera, DC1394_FEATURE_SHUTTER, DC1394_ON)
1829 != DC1394_SUCCESS) {
1833 "Cannot set shutter on") );
1836 if (dc1394_feature_set_mode(camera,
1837 DC1394_FEATURE_SHUTTER,
1839 != DC1394_SUCCESS) {
1843 "Cannot set auto shutter") );
1891 if (dc1394_avt_set_auto_shutter(camera, minvalue, maxvalue)
1892 != DC1394_SUCCESS) {
1896 "Cannot set auto shutter min and max values") );
1915 if (! num_cameras) {
1919 "No camera found") );
1922 if (dc1394_avt_get_auto_shutter(camera, &minvalue, &maxvalue)
1923 != DC1394_SUCCESS) {
1927 "Cannot get auto shutter min and max values") );
1973 if (! num_cameras) {
1977 "No camera found") );
1980 dc1394feature_mode_t mode;
1982 mode = DC1394_FEATURE_MODE_AUTO;
1985 mode = DC1394_FEATURE_MODE_MANUAL;
1988 if (dc1394_feature_set_power(camera, DC1394_FEATURE_GAIN, DC1394_ON)
1989 != DC1394_SUCCESS) {
1993 "Cannot set shutter on") );
1996 if (dc1394_feature_set_mode(camera,
1997 DC1394_FEATURE_GAIN,
1999 != DC1394_SUCCESS) {
2003 "Cannot set auto gain") );
2051 if (dc1394_avt_set_auto_gain(camera, minvalue, maxvalue)
2052 != DC1394_SUCCESS) {
2056 "Cannot set auto gain min and max values") );
2075 if (! num_cameras) {
2079 "No camera found") );
2082 if (dc1394_avt_get_auto_gain(camera, &minvalue, &maxvalue)
2083 != DC1394_SUCCESS) {
2087 "Cannot get auto gain min and max values") );
2110 vp1394TwoGrabber::setCapture(dc1394switch_t _switch)
2112 if (! num_cameras) {
2116 "No camera found") );
2119 if (_switch == DC1394_ON) {
2122 if (dc1394_capture_setup(camera, num_buffers,
2123 DC1394_CAPTURE_FLAGS_DEFAULT) != DC1394_SUCCESS) {
2125 "make sure that the video mode and framerate are "
2126 "supported by your camera.\n");
2129 "Could not setup dma capture") );
2133 dc1394error_t code = dc1394_capture_stop(camera);
2135 if (code != DC1394_SUCCESS && code != DC1394_CAPTURE_IS_NOT_SET) {
2139 "Could not setup dma capture") );
2160 vp1394TwoGrabber::setTransmission(dc1394switch_t _switch)
2162 if (! num_cameras) {
2166 "No camera found") );
2169 dc1394switch_t status = DC1394_OFF;
2171 if (dc1394_video_get_transmission(camera, &status)!=DC1394_SUCCESS) {
2175 "Could not setup dma capture") );
2180 if (dc1394_video_set_transmission(camera, _switch) != DC1394_SUCCESS) {
2182 "make sure that the video mode and framerate are "
2183 "supported by your camera.\n");
2186 "Could not setup dma capture") );
2189 if (_switch == DC1394_ON) {
2190 status = DC1394_OFF;
2193 while ( status == DC1394_OFF && i++ < 5 ) {
2195 if (dc1394_video_get_transmission(camera, &status)!=DC1394_SUCCESS) {
2199 "Could not setup dma capture") );
2243 if (! num_cameras) {
2247 "No camera found") );
2250 dc1394operation_mode_t op_mode;
2251 dc1394speed_t speed;
2255 if (camera->bmode_capable != DC1394_TRUE) {
2260 "Camera is not 1394B mode capable") );
2263 if(dc1394_video_set_operation_mode(camera,
2264 DC1394_OPERATION_MODE_1394B)
2265 != DC1394_SUCCESS) {
2269 "Cannot set camera to 1394B mode") );
2272 if (dc1394_video_get_operation_mode(camera, &op_mode) != DC1394_SUCCESS) {
2276 "Failed to set 1394B mode") );
2280 if (dc1394_video_set_operation_mode(camera,
2281 DC1394_OPERATION_MODE_LEGACY)
2282 != DC1394_SUCCESS) {
2286 "Cannot set camera to 1394A mode") );
2289 if (dc1394_video_get_operation_mode(camera, &op_mode) != DC1394_SUCCESS) {
2293 "Failed to set 1394A mode") );
2297 if (dc1394_video_set_iso_speed(camera, (dc1394speed_t) isospeed)
2298 != DC1394_SUCCESS) {
2302 "Cannot set requested iso speed") );
2305 if (dc1394_video_get_iso_speed(camera, &speed) != DC1394_SUCCESS) {
2309 "Failed to set iso speed") );
2386 dc1394video_frame_t *
2390 if (! num_cameras) {
2394 "No camera found") );
2397 dc1394video_frame_t *frame = NULL;
2399 if (dc1394_capture_dequeue(camera, DC1394_CAPTURE_POLICY_WAIT, &frame)
2401 vpERROR_TRACE (
"Error: Failed to capture from camera %d\n", camera_id);
2448 dc1394video_frame_t *
2454 dc1394video_frame_t *frame;
2456 frame =
dequeue(I, timestamp,
id);
2509 dc1394video_frame_t *
2511 uint64_t ×tamp,
2517 dc1394video_frame_t *frame;
2523 timestamp = frame->timestamp;
2526 this->
width = frame->size[0];
2527 this->
height = frame->size[1];
2533 switch(frame->color_coding) {
2534 case DC1394_COLOR_CODING_MONO8:
2535 case DC1394_COLOR_CODING_RAW8:
2536 memcpy(I.
bitmap, (
unsigned char *) frame->image,
2537 size*
sizeof(
unsigned char));
2539 case DC1394_COLOR_CODING_MONO16:
2540 case DC1394_COLOR_CODING_RAW16:
2545 case DC1394_COLOR_CODING_YUV411:
2550 case DC1394_COLOR_CODING_YUV422:
2555 case DC1394_COLOR_CODING_YUV444:
2560 case DC1394_COLOR_CODING_RGB8:
2567 vpERROR_TRACE(
"Format conversion not implemented. Acquisition failed.");
2569 "Format conversion not implemented. "
2570 "Acquisition failed.") );
2617 dc1394video_frame_t *
2623 dc1394video_frame_t *frame;
2625 frame =
dequeue(I, timestamp,
id);
2678 dc1394video_frame_t *
2680 uint64_t ×tamp,
2686 dc1394video_frame_t *frame;
2692 timestamp = frame->timestamp;
2695 this->
width = frame->size[0];
2696 this->
height = frame->size[1];
2702 switch (frame->color_coding) {
2703 case DC1394_COLOR_CODING_MONO8:
2704 case DC1394_COLOR_CODING_RAW8:
2706 (
unsigned char *) I.
bitmap, size);
2709 case DC1394_COLOR_CODING_MONO16:
2710 case DC1394_COLOR_CODING_RAW16:
2712 (
unsigned char *) I.
bitmap, size);
2715 case DC1394_COLOR_CODING_YUV411:
2717 (
unsigned char *) I.
bitmap, size);
2720 case DC1394_COLOR_CODING_YUV422:
2722 (
unsigned char *) I.
bitmap, size);
2725 case DC1394_COLOR_CODING_YUV444:
2727 (
unsigned char *) I.
bitmap, size);
2730 case DC1394_COLOR_CODING_RGB8:
2732 (
unsigned char *) I.
bitmap, size);
2738 vpERROR_TRACE(
"Format conversion not implemented. Acquisition failed.");
2740 "Format conversion not implemented. "
2741 "Acquisition failed.") );
2762 if (! num_cameras) {
2766 "No camera found") );
2770 dc1394_capture_enqueue(camera, frame);
2793 dc1394video_frame_t *frame;
2795 frame =
dequeue(I, timestamp,
id);
2819 uint64_t ×tamp,
2822 dc1394video_frame_t *frame;
2825 frame =
dequeue(I, timestamp,
id);
2849 dc1394video_frame_t *frame;
2852 frame =
dequeue(I, timestamp,
id);
2876 uint64_t ×tamp,
2879 dc1394video_frame_t *frame;
2885 timestamp = frame->timestamp;
2888 this->
width = frame->size[0];
2889 this->
height = frame->size[1];
2895 switch (frame->color_coding) {
2896 case DC1394_COLOR_CODING_MONO8:
2897 case DC1394_COLOR_CODING_RAW8:
2899 (
unsigned char *) I.
bitmap, size);
2902 case DC1394_COLOR_CODING_YUV411:
2904 (
unsigned char *) I.
bitmap, size);
2907 case DC1394_COLOR_CODING_YUV422:
2909 (
unsigned char *) I.
bitmap, size);
2912 case DC1394_COLOR_CODING_YUV444:
2914 (
unsigned char *) I.
bitmap, size);
2917 case DC1394_COLOR_CODING_RGB8:
2919 (
unsigned char *) I.
bitmap, size);
2925 vpERROR_TRACE(
"Format conversion not implemented. Acquisition failed.");
2927 "Format conversion not implemented. "
2928 "Acquisition failed.") );
2954 if (! num_cameras) {
2958 "No camera found") );
2982 if (! num_cameras) {
2986 "No camera found") );
3011 if (! num_cameras) {
3015 "No camera found") );
3039 if (! num_cameras) {
3043 "No camera found") );
3057 std::cout <<
"----------------------------------------------------------"
3059 <<
"----- Information for camera " << camera_id
3060 <<
" -----" << std::endl
3061 <<
"----------------------------------------------------------" << std::endl;
3063 #ifdef VISP_HAVE_DC1394_2_CAMERA_ENUMERATE // new API > libdc1394-2.0.0-rc7
3064 dc1394_camera_print_info( camera, stdout);
3065 #elif defined VISP_HAVE_DC1394_2_FIND_CAMERAS // old API <= libdc1394-2.0.0-rc7
3066 dc1394_print_camera_info( camera);
3069 dc1394featureset_t features;
3070 #ifdef VISP_HAVE_DC1394_2_CAMERA_ENUMERATE // new API > libdc1394-2.0.0-rc7
3071 if (dc1394_feature_get_all(camera, &features) != DC1394_SUCCESS)
3072 #elif defined VISP_HAVE_DC1394_2_FIND_CAMERAS // old API <= libdc1394-2.0.0-rc7
3073 if (dc1394_get_camera_feature_set(camera, &features) != DC1394_SUCCESS)
3077 vpERROR_TRACE(
"unable to get feature set for camera %d\n", camera_id);
3079 "Cannot get camera features") );
3082 #ifdef VISP_HAVE_DC1394_2_CAMERA_ENUMERATE // new API > libdc1394-2.0.0-rc7
3083 dc1394_feature_print_all(&features, stdout);
3084 #elif defined VISP_HAVE_DC1394_2_FIND_CAMERAS // old API <= libdc1394-2.0.0-rc7
3085 dc1394_print_feature_set(&features);
3088 std::cout <<
"----------------------------------------------------------" << std::endl;
3105 std::string _str =
"";
3106 dc1394video_mode_t _videomode = (dc1394video_mode_t) videomode;
3108 if ((_videomode >= DC1394_VIDEO_MODE_MIN)
3109 && (_videomode <= DC1394_VIDEO_MODE_MAX)) {
3110 _str =
strVideoMode[_videomode - DC1394_VIDEO_MODE_MIN];
3113 vpCERROR <<
"The video mode " << (int)videomode
3114 <<
" is not supported by the camera" << std::endl;
3134 std::string _str =
"";
3135 dc1394framerate_t _fps = (dc1394framerate_t) fps;
3137 if ((_fps >= DC1394_FRAMERATE_MIN)
3138 && (_fps <= DC1394_FRAMERATE_MAX)) {
3142 vpCERROR <<
"The framerate " << (int)fps
3143 <<
" is not supported by the camera" << std::endl;
3163 std::string _str =
"";
3164 dc1394color_coding_t _coding = (dc1394color_coding_t) colorcoding;
3166 if ((_coding >= DC1394_COLOR_CODING_MIN)
3167 && (_coding <= DC1394_COLOR_CODING_MAX)) {
3172 vpCERROR <<
"The color coding " << (int)colorcoding
3173 <<
" is not supported by the camera" << std::endl;
3201 for (
int i = DC1394_VIDEO_MODE_MIN; i <= DC1394_VIDEO_MODE_MAX; i ++) {
3208 "The required videomode is not valid") );
3236 for (
int i = DC1394_FRAMERATE_MIN; i <= DC1394_FRAMERATE_MAX; i ++) {
3243 "The required framerate is not valid") );
3270 for (
int i = DC1394_COLOR_CODING_MIN; i <= DC1394_COLOR_CODING_MAX; i ++) {
3277 "The required color coding is not valid") );
3316 for (
unsigned int i = 0; i < num_cameras;i++) {
3318 camera = cameras[i];
3319 setTransmission(DC1394_OFF);
3320 setCapture(DC1394_OFF);
3323 #ifdef VISP_HAVE_DC1394_2_CAMERA_ENUMERATE // new API > libdc1394-2.0.0-rc7
3326 for (
unsigned int i=0;i<num_cameras;i++){
3327 if (i!=camera_id) dc1394_camera_free(cameras[i]);
3330 printf (
"Reseting bus...\n");
3331 dc1394_reset_bus (camera);
3333 dc1394_camera_free (camera);
3339 #elif defined VISP_HAVE_DC1394_2_FIND_CAMERAS // old API <= libdc1394-2.0.0-rc7
3343 for (
unsigned int i=0;i<num_cameras;i++){
3344 if (i!=camera_id) dc1394_free_camera(cameras[i]);
3349 dc1394_reset_bus(camera);
3350 dc1394_free_camera(camera);
3353 if (camIsOpen != NULL)
3354 delete [] camIsOpen;
3396 if (! num_cameras) {
3400 "No camera found") );
3402 uint64_t offset = 0x884;
3403 uint32_t value = 0x82000000 + (uint32_t)panControlValue;
3405 err = dc1394_set_control_register(camera, offset, value);
3406 if (err != DC1394_SUCCESS) {
3410 "Unable to set PAN register") );
3433 if (! num_cameras) {
3437 "No camera found") );
3441 dc1394feature_t feature = (dc1394feature_t)param;
3443 err = dc1394_feature_get_value(camera, feature, &value);
3444 if (err != DC1394_SUCCESS) {
3448 "Unable to get the information") );
3450 return (
unsigned int)value;
3477 if (! num_cameras) {
3481 "No camera found") );
3483 uint32_t value = (uint32_t)val;
3484 dc1394feature_t feature = (dc1394feature_t)param;
3486 dc1394bool_t hasManualMode = DC1394_FALSE;
3487 dc1394feature_modes_t modesAvailable;
3490 err = dc1394_feature_get_modes(camera, feature, &modesAvailable);
3491 if (err != DC1394_SUCCESS) {
3492 vpERROR_TRACE(
"Unable to detect the manual mode information");
3495 "Unable to detect the manual mode information"));
3498 for(
unsigned int i=0; i<modesAvailable.num; i++){
3499 if(modesAvailable.modes[i] == DC1394_FEATURE_MODE_MANUAL){
3500 hasManualMode = DC1394_TRUE;
3504 if(hasManualMode == DC1394_TRUE){
3506 if(!isDataModified[camera_id]){
3508 updateDataCamToStruct();
3509 err = dc1394_feature_get_mode(camera, feature, &(initialShutterMode[camera_id]));
3510 if (err != DC1394_SUCCESS) {
3514 "Unable to get the initial mode"));
3516 isDataModified[camera_id] =
true;
3519 dc1394feature_mode_t manualMode = DC1394_FEATURE_MODE_MANUAL;
3520 err = dc1394_feature_set_mode(camera, feature, manualMode);
3521 if (err != DC1394_SUCCESS) {
3525 "Unable to set the manual mode") );
3527 err = dc1394_feature_set_value(camera, feature, value);
3528 if (err != DC1394_SUCCESS) {
3532 "Unable to set the shutter information") );
3536 vpERROR_TRACE(
"The camera does not have a manual mode.\nCannot change the value");
3538 "The camera does not have a manual mode"));
3551 if (! num_cameras) {
3555 "No camera found") );
3558 guid = camera->guid;
3571 if (! num_cameras) {
3575 "No camera found") );
3578 return camera->guid;
3587 vp1394TwoGrabber::updateDataCamToStruct()
3605 vp1394TwoGrabber::updateDataStructToCam()
3618 #ifdef VISP_BUILD_DEPRECATED_FUNCTIONS
3643 if (! num_cameras) {
3647 "No camera found") );
3649 dc1394video_modes_t _videomodes;
3652 if (dc1394_video_get_supported_modes(camera, &_videomodes)!=DC1394_SUCCESS) {
3657 "Can't get video modes") );
3661 for (
unsigned i=0; i < _videomodes.num; i++) {
3667 return _videomodes.num;
3706 if (! num_cameras) {
3710 "No camera found") );
3733 dc1394framerates_t _fps;
3734 if (dc1394_video_get_supported_framerates(camera,
3735 (dc1394video_mode_t)mode,
3736 &_fps) != DC1394_SUCCESS) {
3738 vpERROR_TRACE(
"Could not query supported frametates for mode %d\n",
3741 "Could not query supported framerates") );
3746 for (
unsigned int i = 0; i < _fps.num; i ++)
3783 if (! num_cameras) {
3787 "No camera found") );
3793 if (dc1394_is_video_mode_scalable((dc1394video_mode_t)mode)) {
3795 dc1394color_codings_t _codings;
3796 if (dc1394_format7_get_color_codings(camera,
3797 (dc1394video_mode_t)mode,
3798 &_codings) != DC1394_SUCCESS) {
3800 vpERROR_TRACE(
"Could not query supported color codings for mode %d\n",
3803 "Could not query supported color codings") );
3805 if (_codings.num == 0)
3808 for (
unsigned int i = 0; i < _codings.num; i ++)
3811 return _codings.num;
3813 else if (dc1394_is_video_mode_still_image((dc1394video_mode_t)mode)) {
3819 dc1394color_coding_t _coding;
3820 if (dc1394_get_color_coding_from_video_mode(camera,
3821 (dc1394video_mode_t)mode,
3822 &_coding) != DC1394_SUCCESS) {
3824 vpERROR_TRACE(
"Could not query supported color coding for mode %d\n",
3827 "Could not query supported color coding") );
void getColorCoding(vp1394TwoColorCodingType &coding)
static const char * strFramerate[DC1394_FRAMERATE_NUM]
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)
Provide simple list management.
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)
void kill()
Destroy the list.
static int wait(double t0, double t)
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]
void addRight(const type &el)
add a new element in the list, at the right of the current one
static void MONO16ToRGBa(unsigned char *grey16, unsigned char *rgba, unsigned int size)
void resize(const unsigned int h, const unsigned int w)
set the size of the image without initializing it.
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)
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)