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 == camera_id) {
346 if (is_guid ==
false) {
348 vpERROR_TRACE(
"The camera with GUID 0x%x or id %u is not present",
349 camera_id, camera_id);
352 "The required camera is not present") );
356 this->camera_id = cam_id;
360 camera = cameras[this->camera_id];
382 cam_id = this->camera_id;
388 "No cameras found") );
410 return this->camera_id;
416 "No cameras found") );
431 vpCTRACE <<
"No camera found..."<< std::endl;
435 ncameras = num_cameras;
448 unsigned int ncameras = 0;
450 vpCTRACE <<
"No camera found..."<< std::endl;
454 ncameras = num_cameras;
511 "No camera found") );
514 vpERROR_TRACE(
"Video mode not supported by camera %d",camera_id);
516 "Video mode not supported") );
520 setTransmission(DC1394_OFF);
521 setCapture(DC1394_OFF);
523 if (dc1394_video_set_mode(camera, (dc1394video_mode_t) videomode) != DC1394_SUCCESS) {
528 "Can't set video mode") );
531 setCapture(DC1394_ON);
532 setTransmission(DC1394_ON);
535 if (dc1394_get_image_size_from_video_mode(camera,
536 (dc1394video_mode_t) videomode,
543 "Can't get image size") );
571 "No camera found") );
574 dc1394video_mode_t _videomode;
575 if (dc1394_video_get_mode(camera, &_videomode) != DC1394_SUCCESS) {
580 "Can't get current video mode") );
615 "No camera found") );
617 dc1394video_modes_t _videomodes;
620 if (dc1394_video_get_supported_modes(camera, &_videomodes)!=DC1394_SUCCESS) {
625 "Can't get video modes") );
629 for (
unsigned i=0; i < _videomodes.num; i++) {
631 videomodes.push_back( _mode );
635 return _videomodes.num;
659 "No camera found") );
661 dc1394video_modes_t _videomodes;
664 if (dc1394_video_get_supported_modes(camera, &_videomodes)!=DC1394_SUCCESS) {
669 "Can't get video modes") );
673 for (
unsigned i=0; i < _videomodes.num; i++) {
696 if (dc1394_is_video_mode_scalable((dc1394video_mode_t) videomode))
773 "No camera found") );
782 vpERROR_TRACE(
"Framerate not supported by camera %d",camera_id);
784 "Framerate not supported") );
789 setTransmission(DC1394_OFF);
790 setCapture(DC1394_OFF);
792 if (dc1394_video_set_framerate(camera, (dc1394framerate_t) fps) != DC1394_SUCCESS) {
797 "Can't set framerate") );
800 setCapture(DC1394_ON);
801 setTransmission(DC1394_ON);
827 "No camera found") );
829 dc1394framerate_t _fps;
830 if (dc1394_video_get_framerate(camera, &_fps) != DC1394_SUCCESS) {
835 "Can't get current framerate") );
874 std::list<vp1394TwoFramerateType> & fps)
880 "No camera found") );
903 dc1394framerates_t _fps;
904 if (dc1394_video_get_supported_framerates(camera,
905 (dc1394video_mode_t)mode,
906 &_fps) != DC1394_SUCCESS) {
908 vpERROR_TRACE(
"Could not query supported frametates for mode %d\n",
911 "Could not query supported framerates") );
916 for (
unsigned int i = 0; i < _fps.num; i ++)
965 "No camera found") );
985 dc1394framerates_t _fps;
986 if (dc1394_video_get_supported_framerates(camera,
987 (dc1394video_mode_t)mode,
988 &_fps) != DC1394_SUCCESS) {
990 vpERROR_TRACE(
"Could not query supported frametates for mode %d\n",
993 "Could not query supported framerates") );
998 for (
unsigned int i = 0; i < _fps.num; i ++){
1060 if (! num_cameras) {
1064 "No camera found") );
1067 dc1394video_mode_t _videomode;
1068 if (dc1394_video_get_mode(camera, &_videomode) != DC1394_SUCCESS) {
1073 "Can't get current video mode") );
1077 vpERROR_TRACE(
"Color coding not supported by camera %d",camera_id);
1079 "Color coding not supported") );
1084 if (dc1394_is_video_mode_scalable(_videomode)) {
1085 setTransmission(DC1394_OFF);
1086 setCapture(DC1394_OFF);
1088 if (dc1394_format7_set_color_coding(camera, _videomode,
1089 (dc1394color_coding_t) coding)
1090 != DC1394_SUCCESS) {
1095 "Can't set color coding") );
1098 setCapture(DC1394_ON);
1099 setTransmission(DC1394_ON);
1123 if (! num_cameras) {
1127 "No camera found") );
1129 dc1394video_mode_t _videomode;
1130 if (dc1394_video_get_mode(camera, &_videomode) != DC1394_SUCCESS) {
1135 "Can't get current video mode") );
1138 dc1394color_coding_t _coding;
1139 if (dc1394_is_video_mode_scalable(_videomode)) {
1141 if (dc1394_format7_get_color_coding(camera, _videomode, &_coding)
1142 != DC1394_SUCCESS) {
1147 "Can't query current color coding") );
1150 else if (dc1394_is_video_mode_still_image((dc1394video_mode_t)_videomode)) {
1152 "No color coding for format 6 video mode"));
1156 if (dc1394_get_color_coding_from_video_mode(camera,
1157 (dc1394video_mode_t)_videomode,
1158 &_coding) != DC1394_SUCCESS) {
1160 vpERROR_TRACE(
"Could not query supported color coding for mode %d\n",
1163 "Can't query current color coding"));
1192 std::list<vp1394TwoColorCodingType> & codings)
1194 if (! num_cameras) {
1198 "No camera found") );
1204 if (dc1394_is_video_mode_scalable((dc1394video_mode_t)mode)) {
1206 dc1394color_codings_t _codings;
1207 if (dc1394_format7_get_color_codings(camera,
1208 (dc1394video_mode_t)mode,
1209 &_codings) != DC1394_SUCCESS) {
1211 vpERROR_TRACE(
"Could not query supported color codings for mode %d\n",
1214 "Could not query supported color codings") );
1216 if (_codings.num == 0)
1219 for (
unsigned int i = 0; i < _codings.num; i ++)
1222 return _codings.num;
1224 else if (dc1394_is_video_mode_still_image((dc1394video_mode_t)mode)) {
1230 dc1394color_coding_t _coding;
1231 if (dc1394_get_color_coding_from_video_mode(camera,
1232 (dc1394video_mode_t)mode,
1233 &_coding) != DC1394_SUCCESS) {
1235 vpERROR_TRACE(
"Could not query supported color coding for mode %d\n",
1238 "Could not query supported color coding") );
1269 if (! num_cameras) {
1273 "No camera found") );
1277 if (dc1394_is_video_mode_scalable((dc1394video_mode_t)mode)) {
1279 dc1394color_codings_t _codings;
1280 if (dc1394_format7_get_color_codings(camera,
1281 (dc1394video_mode_t)mode,
1282 &_codings) != DC1394_SUCCESS) {
1284 vpERROR_TRACE(
"Could not query supported color codings for mode %d\n",
1287 "Could not query supported color codings") );
1289 if (_codings.num == 0)
1292 for (
unsigned int i = 0; i < _codings.num; i ++){
1298 else if (dc1394_is_video_mode_still_image((dc1394video_mode_t)mode)) {
1304 dc1394color_coding_t _coding;
1305 if (dc1394_get_color_coding_from_video_mode(camera,
1306 (dc1394video_mode_t)mode,
1307 &_coding) != DC1394_SUCCESS) {
1309 vpERROR_TRACE(
"Could not query supported color coding for mode %d\n",
1312 "Could not query supported color coding") );
1356 unsigned int w,
unsigned int h)
1359 if (! num_cameras) {
1363 "No camera found") );
1366 dc1394video_mode_t _videomode;
1367 if (dc1394_video_get_mode(camera, &_videomode) != DC1394_SUCCESS) {
1372 "Can't get current video mode") );
1374 if (dc1394_is_video_mode_scalable(_videomode)) {
1376 setTransmission(DC1394_OFF);
1377 setCapture(DC1394_OFF);
1379 unsigned int max_width, max_height;
1380 if (dc1394_format7_get_max_image_size(camera, _videomode,
1381 &max_width, &max_height)
1382 != DC1394_SUCCESS) {
1387 "Can't get format7 max image size") );
1390 vpTRACE(
"left: %d top: %d width: %d height: %d", left, top,
1391 width == 0 ? DC1394_USE_MAX_AVAIL: w,
1392 height == 0 ? DC1394_USE_MAX_AVAIL : h);
1393 vpTRACE(
"max_width: %d max_height: %d", max_width, max_height);
1396 if (left > max_width) {
1399 "Can't set format7 ROI") );
1401 if (top > max_height) {
1404 "Can't set format7 ROI") );
1412 if (w > (max_width - left))
1413 w = (max_width - left);
1414 roi_width = (int32_t)w;
1417 roi_width = DC1394_USE_MAX_AVAIL;
1422 if (h > (max_height - top))
1423 h = (max_height - top);
1424 roi_height = (int32_t)h;
1427 roi_height = DC1394_USE_MAX_AVAIL;
1430 if (dc1394_format7_set_roi(camera, _videomode,
1431 (dc1394color_coding_t) DC1394_QUERY_FROM_CAMERA,
1432 DC1394_USE_MAX_AVAIL,
1437 != DC1394_SUCCESS) {
1441 "Can't get current video mode") );
1444 if (dc1394_format7_get_image_size(camera, _videomode,
1447 != DC1394_SUCCESS) {
1451 "Can't get format7 image size") );
1454 setCapture(DC1394_ON);
1455 setTransmission(DC1394_ON);
1473 vp1394TwoGrabber::initialize(
bool reset)
1477 #ifdef VISP_HAVE_DC1394_2_CAMERA_ENUMERATE // new API > libdc1394-2.0.0-rc7
1482 if (dc1394_camera_enumerate (d, &list) != DC1394_SUCCESS) {
1483 dc1394_camera_free_list (list);
1487 "Failed to enumerate cameras") );
1490 if (list->num == 0) {
1491 dc1394_camera_free_list (list);
1495 "No cameras found") );
1498 if (cameras != NULL)
1501 cameras =
new dc1394camera_t * [list->num];
1505 for (
unsigned int i=0; i < list->num; i ++) {
1506 cameras[i] = dc1394_camera_new (d, list->ids[i].guid);
1508 vpTRACE (
"Failed to initialize camera with guid \"%ld\"\n",
1520 dc1394_reset_bus(cameras[0]);
1524 dc1394_camera_free_list (list);
1527 #elif defined VISP_HAVE_DC1394_2_FIND_CAMERAS // old API <= libdc1394-2.0.0-rc7
1528 if (cameras != NULL)
1531 int err = dc1394_find_cameras(&cameras, &num_cameras);
1533 if (err!=DC1394_SUCCESS && err != DC1394_NO_CAMERA) {
1537 " - if the kernel modules `ieee1394',`raw1394' and `ohci1394' are loaded \n"
1538 " - if you have read/write access to /dev/raw1394\n\n");
1540 "Unable to look for cameras") );
1545 if (num_cameras == 0) {
1549 "No cameras found") );
1553 isDataModified =
new bool[num_cameras];
1554 for(
unsigned int i=0; i<num_cameras; i++)
1555 isDataModified[i] =
false;
1556 initialShutterMode =
new dc1394feature_mode_t[num_cameras];
1557 dataCam =
new vpDc1394TwoCameraParametersData[num_cameras];
1559 if (camera_id >= num_cameras) {
1569 std::cout <<
"------ Bus information ------" << std::endl;
1570 std::cout <<
"Number of camera(s) on the bus : " << num_cameras <<std::endl;
1571 std::cout <<
"-----------------------------" << std::endl;
1574 if (camIsOpen != NULL)
delete [] camIsOpen;
1575 camIsOpen =
new bool [num_cameras];
1576 for (
unsigned int i = 0;i<num_cameras;i++){
1595 if (
init ==
false) initialize(
false);
1596 if (camIsOpen[camera_id] ==
false){
1597 dc1394switch_t status = DC1394_OFF;
1600 dc1394_video_get_transmission(cameras[camera_id], &status);
1601 if (status != DC1394_OFF){
1603 if (dc1394_video_set_transmission(cameras[camera_id],DC1394_OFF)!=DC1394_SUCCESS)
1604 vpTRACE(
"Could not stop ISO transmission");
1607 if (dc1394_video_get_transmission(cameras[camera_id], &status)!=DC1394_SUCCESS)
1608 vpTRACE(
"Could get ISO status");
1610 if (status==DC1394_ON) {
1611 vpTRACE(
"ISO transmission refuses to stop");
1613 #ifdef VISP_HAVE_DC1394_2_FIND_CAMERAS // old API <= libdc1394-2.0.0-rc7
1615 cameras[camera_id]->is_iso_on=status;
1624 setCapture(DC1394_ON);
1625 setTransmission(DC1394_ON);
1626 camIsOpen[camera_id] =
true;
1642 for (
unsigned int i = 0; i < num_cameras;i++) {
1644 camera = cameras[i];
1645 this->camera_id = i;
1646 setTransmission(DC1394_OFF);
1647 setCapture(DC1394_OFF);
1648 if(isDataModified[i]){
1651 updateDataStructToCam();
1656 if (dc1394_feature_set_mode(camera, DC1394_FEATURE_BRIGHTNESS, initialShutterMode[i]) != DC1394_SUCCESS ||
1657 dc1394_feature_set_mode(camera, DC1394_FEATURE_EXPOSURE, initialShutterMode[i]) != DC1394_SUCCESS ||
1658 dc1394_feature_set_mode(camera, DC1394_FEATURE_SHARPNESS, initialShutterMode[i]) != DC1394_SUCCESS ||
1659 dc1394_feature_set_mode(camera, DC1394_FEATURE_HUE, initialShutterMode[i]) != DC1394_SUCCESS ||
1660 dc1394_feature_set_mode(camera, DC1394_FEATURE_SATURATION, initialShutterMode[i]) != DC1394_SUCCESS ||
1661 dc1394_feature_set_mode(camera, DC1394_FEATURE_GAMMA, initialShutterMode[i]) != DC1394_SUCCESS ||
1662 dc1394_feature_set_mode(camera, DC1394_FEATURE_SHUTTER, initialShutterMode[i]) != DC1394_SUCCESS ||
1663 dc1394_feature_set_mode(camera, DC1394_FEATURE_GAIN, initialShutterMode[i]) != DC1394_SUCCESS ||
1664 dc1394_feature_set_mode(camera, DC1394_FEATURE_IRIS, initialShutterMode[i])){
1668 "Unable to reset the initial mode"));
1671 if (dc1394_camera_set_power(camera, DC1394_OFF) != DC1394_SUCCESS)
1672 std::cout <<
"Unable to turn camera off" << std::endl;
1674 #ifdef VISP_HAVE_DC1394_2_CAMERA_ENUMERATE // new API > libdc1394-2.0.0-rc7
1675 dc1394_camera_free(cameras[i]);
1676 #elif defined VISP_HAVE_DC1394_2_FIND_CAMERAS // old API <= libdc1394-2.0.0-rc7
1677 dc1394_free_camera(cameras[i]);
1681 if (camIsOpen != NULL) {
1682 delete [] camIsOpen;
1686 #ifdef VISP_HAVE_DC1394_2_CAMERA_ENUMERATE // new API > libdc1394-2.0.0-rc7
1687 if (cameras != NULL) {
1696 #elif defined VISP_HAVE_DC1394_2_FIND_CAMERAS // old API <= libdc1394-2.0.0-rc7
1697 if (cameras != NULL) {
1707 if(isDataModified != NULL){
1708 delete[] isDataModified;
1709 isDataModified = NULL;
1711 if(initialShutterMode != NULL){
1712 delete[] initialShutterMode;
1713 initialShutterMode = NULL;
1715 if(dataCam != NULL){
1741 "Could not set ring buffer size") );
1744 if (size != num_buffers) {
1747 if(camIsOpen[camera_id]){
1748 setCapture(DC1394_OFF);
1749 setCapture(DC1394_ON);
1811 if (! num_cameras) {
1815 "No camera found") );
1818 dc1394feature_mode_t mode;
1820 mode = DC1394_FEATURE_MODE_AUTO;
1823 mode = DC1394_FEATURE_MODE_MANUAL;
1826 if (dc1394_feature_set_power(camera, DC1394_FEATURE_SHUTTER, DC1394_ON)
1827 != DC1394_SUCCESS) {
1831 "Cannot set shutter on") );
1834 if (dc1394_feature_set_mode(camera,
1835 DC1394_FEATURE_SHUTTER,
1837 != DC1394_SUCCESS) {
1841 "Cannot set auto shutter") );
1889 if (dc1394_avt_set_auto_shutter(camera, minvalue, maxvalue)
1890 != DC1394_SUCCESS) {
1894 "Cannot set auto shutter min and max values") );
1913 if (! num_cameras) {
1917 "No camera found") );
1920 if (dc1394_avt_get_auto_shutter(camera, &minvalue, &maxvalue)
1921 != DC1394_SUCCESS) {
1925 "Cannot get auto shutter min and max values") );
1971 if (! num_cameras) {
1975 "No camera found") );
1978 dc1394feature_mode_t mode;
1980 mode = DC1394_FEATURE_MODE_AUTO;
1983 mode = DC1394_FEATURE_MODE_MANUAL;
1986 if (dc1394_feature_set_power(camera, DC1394_FEATURE_GAIN, DC1394_ON)
1987 != DC1394_SUCCESS) {
1991 "Cannot set shutter on") );
1994 if (dc1394_feature_set_mode(camera,
1995 DC1394_FEATURE_GAIN,
1997 != DC1394_SUCCESS) {
2001 "Cannot set auto gain") );
2049 if (dc1394_avt_set_auto_gain(camera, minvalue, maxvalue)
2050 != DC1394_SUCCESS) {
2054 "Cannot set auto gain min and max values") );
2073 if (! num_cameras) {
2077 "No camera found") );
2080 if (dc1394_avt_get_auto_gain(camera, &minvalue, &maxvalue)
2081 != DC1394_SUCCESS) {
2085 "Cannot get auto gain min and max values") );
2108 vp1394TwoGrabber::setCapture(dc1394switch_t _switch)
2110 if (! num_cameras) {
2114 "No camera found") );
2117 if (_switch == DC1394_ON) {
2120 if (dc1394_capture_setup(camera, num_buffers,
2121 DC1394_CAPTURE_FLAGS_DEFAULT) != DC1394_SUCCESS) {
2123 "make sure that the video mode and framerate are "
2124 "supported by your camera.\n");
2127 "Could not setup dma capture") );
2131 dc1394error_t code = dc1394_capture_stop(camera);
2133 if (code != DC1394_SUCCESS && code != DC1394_CAPTURE_IS_NOT_SET) {
2137 "Could not setup dma capture") );
2158 vp1394TwoGrabber::setTransmission(dc1394switch_t _switch)
2160 if (! num_cameras) {
2164 "No camera found") );
2167 dc1394switch_t status = DC1394_OFF;
2169 if (dc1394_video_get_transmission(camera, &status)!=DC1394_SUCCESS) {
2173 "Could not setup dma capture") );
2178 if (dc1394_video_set_transmission(camera, _switch) != DC1394_SUCCESS) {
2180 "make sure that the video mode and framerate are "
2181 "supported by your camera.\n");
2184 "Could not setup dma capture") );
2187 if (_switch == DC1394_ON) {
2188 status = DC1394_OFF;
2191 while ( status == DC1394_OFF && i++ < 5 ) {
2193 if (dc1394_video_get_transmission(camera, &status)!=DC1394_SUCCESS) {
2197 "Could not setup dma capture") );
2241 if (! num_cameras) {
2245 "No camera found") );
2248 dc1394operation_mode_t op_mode;
2249 dc1394speed_t speed;
2253 if (camera->bmode_capable != DC1394_TRUE) {
2258 "Camera is not 1394B mode capable") );
2261 if(dc1394_video_set_operation_mode(camera,
2262 DC1394_OPERATION_MODE_1394B)
2263 != DC1394_SUCCESS) {
2267 "Cannot set camera to 1394B mode") );
2270 if (dc1394_video_get_operation_mode(camera, &op_mode) != DC1394_SUCCESS) {
2274 "Failed to set 1394B mode") );
2278 if (dc1394_video_set_operation_mode(camera,
2279 DC1394_OPERATION_MODE_LEGACY)
2280 != DC1394_SUCCESS) {
2284 "Cannot set camera to 1394A mode") );
2287 if (dc1394_video_get_operation_mode(camera, &op_mode) != DC1394_SUCCESS) {
2291 "Failed to set 1394A mode") );
2295 if (dc1394_video_set_iso_speed(camera, (dc1394speed_t) isospeed)
2296 != DC1394_SUCCESS) {
2300 "Cannot set requested iso speed") );
2303 if (dc1394_video_get_iso_speed(camera, &speed) != DC1394_SUCCESS) {
2307 "Failed to set iso speed") );
2384 dc1394video_frame_t *
2388 if (! num_cameras) {
2392 "No camera found") );
2395 dc1394video_frame_t *frame = NULL;
2397 if (dc1394_capture_dequeue(camera, DC1394_CAPTURE_POLICY_WAIT, &frame)
2399 vpERROR_TRACE (
"Error: Failed to capture from camera %d\n", camera_id);
2446 dc1394video_frame_t *
2452 dc1394video_frame_t *frame;
2454 frame =
dequeue(I, timestamp,
id);
2507 dc1394video_frame_t *
2509 uint64_t ×tamp,
2515 dc1394video_frame_t *frame;
2521 timestamp = frame->timestamp;
2524 this->
width = frame->size[0];
2525 this->
height = frame->size[1];
2531 switch(frame->color_coding) {
2532 case DC1394_COLOR_CODING_MONO8:
2533 case DC1394_COLOR_CODING_RAW8:
2534 memcpy(I.
bitmap, (
unsigned char *) frame->image,
2535 size*
sizeof(
unsigned char));
2537 case DC1394_COLOR_CODING_MONO16:
2538 case DC1394_COLOR_CODING_RAW16:
2543 case DC1394_COLOR_CODING_YUV411:
2548 case DC1394_COLOR_CODING_YUV422:
2553 case DC1394_COLOR_CODING_YUV444:
2558 case DC1394_COLOR_CODING_RGB8:
2565 vpERROR_TRACE(
"Format conversion not implemented. Acquisition failed.");
2567 "Format conversion not implemented. "
2568 "Acquisition failed.") );
2615 dc1394video_frame_t *
2621 dc1394video_frame_t *frame;
2623 frame =
dequeue(I, timestamp,
id);
2676 dc1394video_frame_t *
2678 uint64_t ×tamp,
2684 dc1394video_frame_t *frame;
2690 timestamp = frame->timestamp;
2693 this->
width = frame->size[0];
2694 this->
height = frame->size[1];
2700 switch (frame->color_coding) {
2701 case DC1394_COLOR_CODING_MONO8:
2702 case DC1394_COLOR_CODING_RAW8:
2704 (
unsigned char *) I.
bitmap, size);
2707 case DC1394_COLOR_CODING_MONO16:
2708 case DC1394_COLOR_CODING_RAW16:
2710 (
unsigned char *) I.
bitmap, size);
2713 case DC1394_COLOR_CODING_YUV411:
2715 (
unsigned char *) I.
bitmap, size);
2718 case DC1394_COLOR_CODING_YUV422:
2720 (
unsigned char *) I.
bitmap, size);
2723 case DC1394_COLOR_CODING_YUV444:
2725 (
unsigned char *) I.
bitmap, size);
2728 case DC1394_COLOR_CODING_RGB8:
2730 (
unsigned char *) I.
bitmap, size);
2736 vpERROR_TRACE(
"Format conversion not implemented. Acquisition failed.");
2738 "Format conversion not implemented. "
2739 "Acquisition failed.") );
2760 if (! num_cameras) {
2764 "No camera found") );
2768 dc1394_capture_enqueue(camera, frame);
2791 dc1394video_frame_t *frame;
2793 frame =
dequeue(I, timestamp,
id);
2817 uint64_t ×tamp,
2820 dc1394video_frame_t *frame;
2823 frame =
dequeue(I, timestamp,
id);
2847 dc1394video_frame_t *frame;
2850 frame =
dequeue(I, timestamp,
id);
2874 uint64_t ×tamp,
2877 dc1394video_frame_t *frame;
2883 timestamp = frame->timestamp;
2886 this->
width = frame->size[0];
2887 this->
height = frame->size[1];
2893 switch (frame->color_coding) {
2894 case DC1394_COLOR_CODING_MONO8:
2895 case DC1394_COLOR_CODING_RAW8:
2897 (
unsigned char *) I.
bitmap, size);
2900 case DC1394_COLOR_CODING_YUV411:
2902 (
unsigned char *) I.
bitmap, size);
2905 case DC1394_COLOR_CODING_YUV422:
2907 (
unsigned char *) I.
bitmap, size);
2910 case DC1394_COLOR_CODING_YUV444:
2912 (
unsigned char *) I.
bitmap, size);
2915 case DC1394_COLOR_CODING_RGB8:
2917 (
unsigned char *) I.
bitmap, size);
2923 vpERROR_TRACE(
"Format conversion not implemented. Acquisition failed.");
2925 "Format conversion not implemented. "
2926 "Acquisition failed.") );
2952 if (! num_cameras) {
2956 "No camera found") );
2980 if (! num_cameras) {
2984 "No camera found") );
3009 if (! num_cameras) {
3013 "No camera found") );
3037 if (! num_cameras) {
3041 "No camera found") );
3055 std::cout <<
"----------------------------------------------------------"
3057 <<
"----- Information for camera " << camera_id
3058 <<
" -----" << std::endl
3059 <<
"----------------------------------------------------------" << std::endl;
3061 #ifdef VISP_HAVE_DC1394_2_CAMERA_ENUMERATE // new API > libdc1394-2.0.0-rc7
3062 dc1394_camera_print_info( camera, stdout);
3063 #elif defined VISP_HAVE_DC1394_2_FIND_CAMERAS // old API <= libdc1394-2.0.0-rc7
3064 dc1394_print_camera_info( camera);
3067 dc1394featureset_t features;
3068 #ifdef VISP_HAVE_DC1394_2_CAMERA_ENUMERATE // new API > libdc1394-2.0.0-rc7
3069 if (dc1394_feature_get_all(camera, &features) != DC1394_SUCCESS)
3070 #elif defined VISP_HAVE_DC1394_2_FIND_CAMERAS // old API <= libdc1394-2.0.0-rc7
3071 if (dc1394_get_camera_feature_set(camera, &features) != DC1394_SUCCESS)
3075 vpERROR_TRACE(
"unable to get feature set for camera %d\n", camera_id);
3077 "Cannot get camera features") );
3080 #ifdef VISP_HAVE_DC1394_2_CAMERA_ENUMERATE // new API > libdc1394-2.0.0-rc7
3081 dc1394_feature_print_all(&features, stdout);
3082 #elif defined VISP_HAVE_DC1394_2_FIND_CAMERAS // old API <= libdc1394-2.0.0-rc7
3083 dc1394_print_feature_set(&features);
3086 std::cout <<
"----------------------------------------------------------" << std::endl;
3103 std::string _str =
"";
3104 dc1394video_mode_t _videomode = (dc1394video_mode_t) videomode;
3106 if ((_videomode >= DC1394_VIDEO_MODE_MIN)
3107 && (_videomode <= DC1394_VIDEO_MODE_MAX)) {
3108 _str =
strVideoMode[_videomode - DC1394_VIDEO_MODE_MIN];
3111 vpCERROR <<
"The video mode " << (int)videomode
3112 <<
" is not supported by the camera" << std::endl;
3132 std::string _str =
"";
3133 dc1394framerate_t _fps = (dc1394framerate_t) fps;
3135 if ((_fps >= DC1394_FRAMERATE_MIN)
3136 && (_fps <= DC1394_FRAMERATE_MAX)) {
3140 vpCERROR <<
"The framerate " << (int)fps
3141 <<
" is not supported by the camera" << std::endl;
3161 std::string _str =
"";
3162 dc1394color_coding_t _coding = (dc1394color_coding_t) colorcoding;
3164 if ((_coding >= DC1394_COLOR_CODING_MIN)
3165 && (_coding <= DC1394_COLOR_CODING_MAX)) {
3170 vpCERROR <<
"The color coding " << (int)colorcoding
3171 <<
" is not supported by the camera" << std::endl;
3199 for (
int i = DC1394_VIDEO_MODE_MIN; i <= DC1394_VIDEO_MODE_MAX; i ++) {
3206 "The required videomode is not valid") );
3234 for (
int i = DC1394_FRAMERATE_MIN; i <= DC1394_FRAMERATE_MAX; i ++) {
3241 "The required framerate is not valid") );
3268 for (
int i = DC1394_COLOR_CODING_MIN; i <= DC1394_COLOR_CODING_MAX; i ++) {
3275 "The required color coding is not valid") );
3314 for (
unsigned int i = 0; i < num_cameras;i++) {
3316 camera = cameras[i];
3317 setTransmission(DC1394_OFF);
3318 setCapture(DC1394_OFF);
3321 #ifdef VISP_HAVE_DC1394_2_CAMERA_ENUMERATE // new API > libdc1394-2.0.0-rc7
3324 for (
unsigned int i=0;i<num_cameras;i++){
3325 if (i!=camera_id) dc1394_camera_free(cameras[i]);
3328 printf (
"Reseting bus...\n");
3329 dc1394_reset_bus (camera);
3331 dc1394_camera_free (camera);
3337 #elif defined VISP_HAVE_DC1394_2_FIND_CAMERAS // old API <= libdc1394-2.0.0-rc7
3341 for (
unsigned int i=0;i<num_cameras;i++){
3342 if (i!=camera_id) dc1394_free_camera(cameras[i]);
3347 dc1394_reset_bus(camera);
3348 dc1394_free_camera(camera);
3351 if (camIsOpen != NULL)
3352 delete [] camIsOpen;
3394 if (! num_cameras) {
3398 "No camera found") );
3400 uint64_t offset = 0x884;
3401 uint32_t value = 0x82000000 + (uint32_t)panControlValue;
3403 err = dc1394_set_control_register(camera, offset, value);
3404 if (err != DC1394_SUCCESS) {
3408 "Unable to set PAN register") );
3431 if (! num_cameras) {
3435 "No camera found") );
3439 dc1394feature_t feature = (dc1394feature_t)param;
3441 err = dc1394_feature_get_value(camera, feature, &value);
3442 if (err != DC1394_SUCCESS) {
3446 "Unable to get the information") );
3448 return (
unsigned int)value;
3475 if (! num_cameras) {
3479 "No camera found") );
3481 uint32_t value = (uint32_t)val;
3482 dc1394feature_t feature = (dc1394feature_t)param;
3484 dc1394bool_t hasManualMode = DC1394_FALSE;
3485 dc1394feature_modes_t modesAvailable;
3488 err = dc1394_feature_get_modes(camera, feature, &modesAvailable);
3489 if (err != DC1394_SUCCESS) {
3490 vpERROR_TRACE(
"Unable to detect the manual mode information");
3493 "Unable to detect the manual mode information"));
3496 for(
unsigned int i=0; i<modesAvailable.num; i++){
3497 if(modesAvailable.modes[i] == DC1394_FEATURE_MODE_MANUAL){
3498 hasManualMode = DC1394_TRUE;
3502 if(hasManualMode == DC1394_TRUE){
3504 if(!isDataModified[camera_id]){
3506 updateDataCamToStruct();
3507 err = dc1394_feature_get_mode(camera, feature, &(initialShutterMode[camera_id]));
3508 if (err != DC1394_SUCCESS) {
3512 "Unable to get the initial mode"));
3514 isDataModified[camera_id] =
true;
3517 dc1394feature_mode_t manualMode = DC1394_FEATURE_MODE_MANUAL;
3518 err = dc1394_feature_set_mode(camera, feature, manualMode);
3519 if (err != DC1394_SUCCESS) {
3523 "Unable to set the manual mode") );
3525 err = dc1394_feature_set_value(camera, feature, value);
3526 if (err != DC1394_SUCCESS) {
3530 "Unable to set the shutter information") );
3534 vpERROR_TRACE(
"The camera does not have a manual mode.\nCannot change the value");
3536 "The camera does not have a manual mode"));
3549 if (! num_cameras) {
3553 "No camera found") );
3556 guid = camera->guid;
3569 if (! num_cameras) {
3573 "No camera found") );
3576 return camera->guid;
3585 vp1394TwoGrabber::updateDataCamToStruct()
3603 vp1394TwoGrabber::updateDataStructToCam()
3616 #ifdef VISP_BUILD_DEPRECATED_FUNCTIONS
3641 if (! num_cameras) {
3645 "No camera found") );
3647 dc1394video_modes_t _videomodes;
3650 if (dc1394_video_get_supported_modes(camera, &_videomodes)!=DC1394_SUCCESS) {
3655 "Can't get video modes") );
3659 for (
unsigned i=0; i < _videomodes.num; i++) {
3665 return _videomodes.num;
3704 if (! num_cameras) {
3708 "No camera found") );
3731 dc1394framerates_t _fps;
3732 if (dc1394_video_get_supported_framerates(camera,
3733 (dc1394video_mode_t)mode,
3734 &_fps) != DC1394_SUCCESS) {
3736 vpERROR_TRACE(
"Could not query supported frametates for mode %d\n",
3739 "Could not query supported framerates") );
3744 for (
unsigned int i = 0; i < _fps.num; i ++)
3781 if (! num_cameras) {
3785 "No camera found") );
3791 if (dc1394_is_video_mode_scalable((dc1394video_mode_t)mode)) {
3793 dc1394color_codings_t _codings;
3794 if (dc1394_format7_get_color_codings(camera,
3795 (dc1394video_mode_t)mode,
3796 &_codings) != DC1394_SUCCESS) {
3798 vpERROR_TRACE(
"Could not query supported color codings for mode %d\n",
3801 "Could not query supported color codings") );
3803 if (_codings.num == 0)
3806 for (
unsigned int i = 0; i < _codings.num; i ++)
3809 return _codings.num;
3811 else if (dc1394_is_video_mode_still_image((dc1394video_mode_t)mode)) {
3817 dc1394color_coding_t _coding;
3818 if (dc1394_get_color_coding_from_video_mode(camera,
3819 (dc1394video_mode_t)mode,
3820 &_coding) != DC1394_SUCCESS) {
3822 vpERROR_TRACE(
"Could not query supported color coding for mode %d\n",
3825 "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
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)