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",
183 #ifdef VISP_HAVE_DC1394_2_CAMERA_ENUMERATE // new API > libdc1394-2.0.0-rc7
189 isDataModified = NULL;
190 initialShutterMode = NULL;
345 if (camera_id >= num_cameras) {
347 bool is_guid =
false;
349 for (
unsigned int i=0; i< num_cameras; i++) {
350 if (cameras[i]->guid == camera_id) {
356 if (is_guid ==
false) {
358 vpERROR_TRACE(
"The camera with GUID 0x%x or id %u is not present",
359 camera_id, camera_id);
362 "The required camera is not present") );
366 this->camera_id = camera_id;
370 camera = cameras[this->camera_id];
392 camera_id = this->camera_id;
398 "No cameras found") );
420 return this->camera_id;
426 "No cameras found") );
441 vpCTRACE <<
"No camera found..."<< std::endl;
445 ncameras = num_cameras;
458 unsigned int ncameras = 0;
460 vpCTRACE <<
"No camera found..."<< std::endl;
464 ncameras = num_cameras;
521 "No camera found") );
524 vpERROR_TRACE(
"Video mode not supported by camera %d",camera_id);
526 "Video mode not supported") );
530 setTransmission(DC1394_OFF);
531 setCapture(DC1394_OFF);
533 if (dc1394_video_set_mode(camera, (dc1394video_mode_t) videomode) != DC1394_SUCCESS) {
538 "Can't set video mode") );
541 setCapture(DC1394_ON);
542 setTransmission(DC1394_ON);
545 if (dc1394_get_image_size_from_video_mode(camera,
546 (dc1394video_mode_t) videomode,
553 "Can't get image size") );
581 "No camera found") );
584 dc1394video_mode_t _videomode;
585 if (dc1394_video_get_mode(camera, &_videomode) != DC1394_SUCCESS) {
590 "Can't get current video mode") );
625 "No camera found") );
627 dc1394video_modes_t _videomodes;
630 if (dc1394_video_get_supported_modes(camera, &_videomodes)!=DC1394_SUCCESS) {
635 "Can't get video modes") );
639 for (
unsigned i=0; i < _videomodes.num; i++) {
641 videomodes.push_back( _mode );
645 return _videomodes.num;
669 "No camera found") );
671 dc1394video_modes_t _videomodes;
674 if (dc1394_video_get_supported_modes(camera, &_videomodes)!=DC1394_SUCCESS) {
679 "Can't get video modes") );
683 for (
unsigned i=0; i < _videomodes.num; i++) {
706 if (dc1394_is_video_mode_scalable((dc1394video_mode_t) videomode))
783 "No camera found") );
792 vpERROR_TRACE(
"Framerate not supported by camera %d",camera_id);
794 "Framerate not supported") );
799 setTransmission(DC1394_OFF);
800 setCapture(DC1394_OFF);
802 if (dc1394_video_set_framerate(camera, (dc1394framerate_t) fps) != DC1394_SUCCESS) {
807 "Can't set framerate") );
810 setCapture(DC1394_ON);
811 setTransmission(DC1394_ON);
837 "No camera found") );
839 dc1394framerate_t _fps;
840 if (dc1394_video_get_framerate(camera, &_fps) != DC1394_SUCCESS) {
845 "Can't get current framerate") );
884 std::list<vp1394TwoFramerateType> & fps)
890 "No camera found") );
913 dc1394framerates_t _fps;
914 if (dc1394_video_get_supported_framerates(camera,
915 (dc1394video_mode_t)mode,
916 &_fps) != DC1394_SUCCESS) {
918 vpERROR_TRACE(
"Could not query supported frametates for mode %d\n",
921 "Could not query supported framerates") );
926 for (
unsigned int i = 0; i < _fps.num; i ++)
975 "No camera found") );
995 dc1394framerates_t _fps;
996 if (dc1394_video_get_supported_framerates(camera,
997 (dc1394video_mode_t)mode,
998 &_fps) != DC1394_SUCCESS) {
1000 vpERROR_TRACE(
"Could not query supported frametates for mode %d\n",
1003 "Could not query supported framerates") );
1008 for (
unsigned int i = 0; i < _fps.num; i ++){
1070 if (! num_cameras) {
1074 "No camera found") );
1077 dc1394video_mode_t _videomode;
1078 if (dc1394_video_get_mode(camera, &_videomode) != DC1394_SUCCESS) {
1083 "Can't get current video mode") );
1087 vpERROR_TRACE(
"Color coding not supported by camera %d",camera_id);
1089 "Color coding not supported") );
1094 if (dc1394_is_video_mode_scalable(_videomode)) {
1095 setTransmission(DC1394_OFF);
1096 setCapture(DC1394_OFF);
1098 if (dc1394_format7_set_color_coding(camera, _videomode,
1099 (dc1394color_coding_t) coding)
1100 != DC1394_SUCCESS) {
1105 "Can't set color coding") );
1108 setCapture(DC1394_ON);
1109 setTransmission(DC1394_ON);
1133 if (! num_cameras) {
1137 "No camera found") );
1139 dc1394video_mode_t _videomode;
1140 if (dc1394_video_get_mode(camera, &_videomode) != DC1394_SUCCESS) {
1145 "Can't get current video mode") );
1148 dc1394color_coding_t _coding;
1149 if (dc1394_is_video_mode_scalable(_videomode)) {
1151 if (dc1394_format7_get_color_coding(camera, _videomode, &_coding)
1152 != DC1394_SUCCESS) {
1157 "Can't query current color coding") );
1160 else if (dc1394_is_video_mode_still_image((dc1394video_mode_t)_videomode)) {
1162 "No color coding for format 6 video mode"));
1166 if (dc1394_get_color_coding_from_video_mode(camera,
1167 (dc1394video_mode_t)_videomode,
1168 &_coding) != DC1394_SUCCESS) {
1170 vpERROR_TRACE(
"Could not query supported color coding for mode %d\n",
1173 "Can't query current color coding"));
1202 std::list<vp1394TwoColorCodingType> & codings)
1204 if (! num_cameras) {
1208 "No camera found") );
1214 if (dc1394_is_video_mode_scalable((dc1394video_mode_t)mode)) {
1216 dc1394color_codings_t _codings;
1217 if (dc1394_format7_get_color_codings(camera,
1218 (dc1394video_mode_t)mode,
1219 &_codings) != DC1394_SUCCESS) {
1221 vpERROR_TRACE(
"Could not query supported color codings for mode %d\n",
1224 "Could not query supported color codings") );
1226 if (_codings.num == 0)
1229 for (
unsigned int i = 0; i < _codings.num; i ++)
1232 return _codings.num;
1234 else if (dc1394_is_video_mode_still_image((dc1394video_mode_t)mode)) {
1240 dc1394color_coding_t _coding;
1241 if (dc1394_get_color_coding_from_video_mode(camera,
1242 (dc1394video_mode_t)mode,
1243 &_coding) != DC1394_SUCCESS) {
1245 vpERROR_TRACE(
"Could not query supported color coding for mode %d\n",
1248 "Could not query supported color coding") );
1279 if (! num_cameras) {
1283 "No camera found") );
1287 if (dc1394_is_video_mode_scalable((dc1394video_mode_t)mode)) {
1289 dc1394color_codings_t _codings;
1290 if (dc1394_format7_get_color_codings(camera,
1291 (dc1394video_mode_t)mode,
1292 &_codings) != DC1394_SUCCESS) {
1294 vpERROR_TRACE(
"Could not query supported color codings for mode %d\n",
1297 "Could not query supported color codings") );
1299 if (_codings.num == 0)
1302 for (
unsigned int i = 0; i < _codings.num; i ++){
1308 else if (dc1394_is_video_mode_still_image((dc1394video_mode_t)mode)) {
1314 dc1394color_coding_t _coding;
1315 if (dc1394_get_color_coding_from_video_mode(camera,
1316 (dc1394video_mode_t)mode,
1317 &_coding) != DC1394_SUCCESS) {
1319 vpERROR_TRACE(
"Could not query supported color coding for mode %d\n",
1322 "Could not query supported color coding") );
1366 unsigned int width,
unsigned int height)
1369 if (! num_cameras) {
1373 "No camera found") );
1376 dc1394video_mode_t _videomode;
1377 if (dc1394_video_get_mode(camera, &_videomode) != DC1394_SUCCESS) {
1382 "Can't get current video mode") );
1384 if (dc1394_is_video_mode_scalable(_videomode)) {
1386 setTransmission(DC1394_OFF);
1387 setCapture(DC1394_OFF);
1389 unsigned int max_width, max_height;
1390 if (dc1394_format7_get_max_image_size(camera, _videomode,
1391 &max_width, &max_height)
1392 != DC1394_SUCCESS) {
1397 "Can't get format7 max image size") );
1400 vpTRACE(
"left: %d top: %d width: %d height: %d", left, top,
1401 width == 0 ? DC1394_USE_MAX_AVAIL: width,
1402 height == 0 ? DC1394_USE_MAX_AVAIL : height);
1403 vpTRACE(
"max_width: %d max_height: %d", max_width, max_height);
1406 if (left > max_width) {
1409 "Can't set format7 ROI") );
1411 if (top > max_height) {
1414 "Can't set format7 ROI") );
1422 if (width > (max_width - left))
1423 width = (max_width - left);
1424 roi_width = (int32_t)width;
1427 roi_width = DC1394_USE_MAX_AVAIL;
1432 if (height > (max_height - top))
1433 height = (max_height - top);
1434 roi_height = (int32_t)height;
1437 roi_height = DC1394_USE_MAX_AVAIL;
1441 if (dc1394_format7_set_roi(camera, _videomode,
1442 (dc1394color_coding_t) DC1394_QUERY_FROM_CAMERA,
1443 DC1394_USE_MAX_AVAIL,
1448 != DC1394_SUCCESS) {
1452 "Can't get current video mode") );
1455 if (dc1394_format7_get_image_size(camera, _videomode,
1458 != DC1394_SUCCESS) {
1462 "Can't get format7 image size") );
1465 setCapture(DC1394_ON);
1466 setTransmission(DC1394_ON);
1484 vp1394TwoGrabber::initialize(
bool reset)
1488 #ifdef VISP_HAVE_DC1394_2_CAMERA_ENUMERATE // new API > libdc1394-2.0.0-rc7
1493 if (dc1394_camera_enumerate (d, &list) != DC1394_SUCCESS) {
1494 dc1394_camera_free_list (list);
1498 "Failed to enumerate cameras") );
1501 if (list->num == 0) {
1502 dc1394_camera_free_list (list);
1506 "No cameras found") );
1509 if (cameras != NULL)
1512 cameras =
new dc1394camera_t * [list->num];
1516 for (
unsigned int i=0; i < list->num; i ++) {
1517 cameras[i] = dc1394_camera_new (d, list->ids[i].guid);
1519 vpTRACE (
"Failed to initialize camera with guid \"%ld\"\n",
1531 dc1394_reset_bus(cameras[0]);
1535 dc1394_camera_free_list (list);
1538 #elif defined VISP_HAVE_DC1394_2_FIND_CAMERAS // old API <= libdc1394-2.0.0-rc7
1539 if (cameras != NULL)
1542 int err = dc1394_find_cameras(&cameras, &num_cameras);
1544 if (err!=DC1394_SUCCESS && err != DC1394_NO_CAMERA) {
1548 " - if the kernel modules `ieee1394',`raw1394' and `ohci1394' are loaded \n"
1549 " - if you have read/write access to /dev/raw1394\n\n");
1551 "Unable to look for cameras") );
1556 if (num_cameras == 0) {
1560 "No cameras found") );
1564 isDataModified =
new bool[num_cameras];
1565 for(
unsigned int i=0; i<num_cameras; i++)
1566 isDataModified[i] =
false;
1567 initialShutterMode =
new dc1394feature_mode_t[num_cameras];
1568 dataCam =
new vpDc1394TwoCameraParametersData[num_cameras];
1570 if (camera_id >= num_cameras) {
1580 std::cout <<
"------ Bus information ------" << std::endl;
1581 std::cout <<
"Number of camera(s) on the bus : " << num_cameras <<std::endl;
1582 std::cout <<
"-----------------------------" << std::endl;
1585 if (camIsOpen != NULL)
delete [] camIsOpen;
1586 camIsOpen =
new bool [num_cameras];
1587 for (
unsigned int i = 0;i<num_cameras;i++){
1606 if (
init ==
false) initialize(
false);
1607 if (camIsOpen[camera_id] ==
false){
1608 dc1394switch_t status = DC1394_OFF;
1611 dc1394_video_get_transmission(cameras[camera_id], &status);
1612 if (status != DC1394_OFF){
1614 if (dc1394_video_set_transmission(cameras[camera_id],DC1394_OFF)!=DC1394_SUCCESS)
1615 vpTRACE(
"Could not stop ISO transmission");
1618 if (dc1394_video_get_transmission(cameras[camera_id], &status)!=DC1394_SUCCESS)
1619 vpTRACE(
"Could get ISO status");
1621 if (status==DC1394_ON) {
1622 vpTRACE(
"ISO transmission refuses to stop");
1624 #ifdef VISP_HAVE_DC1394_2_FIND_CAMERAS // old API <= libdc1394-2.0.0-rc7
1626 cameras[camera_id]->is_iso_on=status;
1635 setCapture(DC1394_ON);
1636 setTransmission(DC1394_ON);
1637 camIsOpen[camera_id] =
true;
1653 for (
unsigned int i = 0; i < num_cameras;i++) {
1655 camera = cameras[i];
1656 this->camera_id = i;
1657 setTransmission(DC1394_OFF);
1658 setCapture(DC1394_OFF);
1659 if(isDataModified[i]){
1662 updateDataStructToCam();
1667 if (dc1394_feature_set_mode(camera, DC1394_FEATURE_BRIGHTNESS, initialShutterMode[i]) != DC1394_SUCCESS ||
1668 dc1394_feature_set_mode(camera, DC1394_FEATURE_EXPOSURE, initialShutterMode[i]) != DC1394_SUCCESS ||
1669 dc1394_feature_set_mode(camera, DC1394_FEATURE_SHARPNESS, initialShutterMode[i]) != DC1394_SUCCESS ||
1670 dc1394_feature_set_mode(camera, DC1394_FEATURE_HUE, initialShutterMode[i]) != DC1394_SUCCESS ||
1671 dc1394_feature_set_mode(camera, DC1394_FEATURE_SATURATION, initialShutterMode[i]) != DC1394_SUCCESS ||
1672 dc1394_feature_set_mode(camera, DC1394_FEATURE_GAMMA, initialShutterMode[i]) != DC1394_SUCCESS ||
1673 dc1394_feature_set_mode(camera, DC1394_FEATURE_SHUTTER, initialShutterMode[i]) != DC1394_SUCCESS ||
1674 dc1394_feature_set_mode(camera, DC1394_FEATURE_GAIN, initialShutterMode[i]) != DC1394_SUCCESS ||
1675 dc1394_feature_set_mode(camera, DC1394_FEATURE_IRIS, initialShutterMode[i])){
1679 "Unable to reset the initial mode"));
1683 #ifdef VISP_HAVE_DC1394_2_CAMERA_ENUMERATE // new API > libdc1394-2.0.0-rc7
1684 dc1394_camera_free(cameras[i]);
1685 #elif defined VISP_HAVE_DC1394_2_FIND_CAMERAS // old API <= libdc1394-2.0.0-rc7
1686 dc1394_free_camera(cameras[i]);
1690 if (camIsOpen != NULL) {
1691 delete [] camIsOpen;
1695 #ifdef VISP_HAVE_DC1394_2_CAMERA_ENUMERATE // new API > libdc1394-2.0.0-rc7
1696 if (cameras != NULL) {
1705 #elif defined VISP_HAVE_DC1394_2_FIND_CAMERAS // old API <= libdc1394-2.0.0-rc7
1706 if (cameras != NULL) {
1716 if(isDataModified != NULL){
1717 delete[] isDataModified;
1718 isDataModified = NULL;
1720 if(initialShutterMode != NULL){
1721 delete[] initialShutterMode;
1722 initialShutterMode = NULL;
1724 if(dataCam != NULL){
1750 "Could not set ring buffer size") );
1753 if (size != num_buffers) {
1756 if(camIsOpen[camera_id]){
1757 setCapture(DC1394_OFF);
1758 setCapture(DC1394_ON);
1819 if (! num_cameras) {
1823 "No camera found") );
1826 if (dc1394_feature_set_power(camera, DC1394_FEATURE_SHUTTER, DC1394_ON)
1827 != DC1394_SUCCESS) {
1831 "Cannot set shutter on") );
1835 if (dc1394_feature_set_mode(camera,
1836 DC1394_FEATURE_SHUTTER,
1837 DC1394_FEATURE_MODE_AUTO)
1838 != DC1394_SUCCESS) {
1842 "Cannot set auto shutter") );
1845 if (dc1394_avt_set_auto_shutter(camera, minvalue, maxvalue)
1846 != DC1394_SUCCESS) {
1850 "Cannot set auto shutter min and max values") );
1872 vp1394TwoGrabber::setCapture(dc1394switch_t _switch)
1874 if (! num_cameras) {
1878 "No camera found") );
1881 if (_switch == DC1394_ON) {
1884 if (dc1394_capture_setup(camera, num_buffers,
1885 DC1394_CAPTURE_FLAGS_DEFAULT) != DC1394_SUCCESS) {
1887 "make sure that the video mode and framerate are "
1888 "supported by your camera.\n");
1891 "Could not setup dma capture") );
1895 dc1394error_t code = dc1394_capture_stop(camera);
1897 if (code != DC1394_SUCCESS && code != DC1394_CAPTURE_IS_NOT_SET) {
1901 "Could not setup dma capture") );
1922 vp1394TwoGrabber::setTransmission(dc1394switch_t _switch)
1924 if (! num_cameras) {
1928 "No camera found") );
1931 dc1394switch_t status = DC1394_OFF;
1933 if (dc1394_video_get_transmission(camera, &status)!=DC1394_SUCCESS) {
1937 "Could not setup dma capture") );
1942 if (dc1394_video_set_transmission(camera, _switch) != DC1394_SUCCESS) {
1944 "make sure that the video mode and framerate are "
1945 "supported by your camera.\n");
1948 "Could not setup dma capture") );
1951 if (_switch == DC1394_ON) {
1952 status = DC1394_OFF;
1955 while ( status == DC1394_OFF && i++ < 5 ) {
1957 if (dc1394_video_get_transmission(camera, &status)!=DC1394_SUCCESS) {
1961 "Could not setup dma capture") );
2005 if (! num_cameras) {
2009 "No camera found") );
2012 dc1394operation_mode_t op_mode;
2013 dc1394speed_t speed;
2017 if (camera->bmode_capable != DC1394_TRUE) {
2022 "Camera is not 1394B mode capable") );
2025 if(dc1394_video_set_operation_mode(camera,
2026 DC1394_OPERATION_MODE_1394B)
2027 != DC1394_SUCCESS) {
2031 "Cannot set camera to 1394B mode") );
2034 if (dc1394_video_get_operation_mode(camera, &op_mode) != DC1394_SUCCESS) {
2038 "Failed to set 1394B mode") );
2042 if (dc1394_video_set_operation_mode(camera,
2043 DC1394_OPERATION_MODE_LEGACY)
2044 != DC1394_SUCCESS) {
2048 "Cannot set camera to 1394A mode") );
2051 if (dc1394_video_get_operation_mode(camera, &op_mode) != DC1394_SUCCESS) {
2055 "Failed to set 1394A mode") );
2059 if (dc1394_video_set_iso_speed(camera, (dc1394speed_t) isospeed)
2060 != DC1394_SUCCESS) {
2064 "Cannot set requested iso speed") );
2067 if (dc1394_video_get_iso_speed(camera, &speed) != DC1394_SUCCESS) {
2071 "Failed to set iso speed") );
2148 dc1394video_frame_t *
2152 if (! num_cameras) {
2156 "No camera found") );
2159 dc1394video_frame_t *frame = NULL;
2161 if (dc1394_capture_dequeue(camera, DC1394_CAPTURE_POLICY_WAIT, &frame)
2163 vpERROR_TRACE (
"Error: Failed to capture from camera %d\n", camera_id);
2210 dc1394video_frame_t *
2216 dc1394video_frame_t *frame;
2218 frame =
dequeue(I, timestamp,
id);
2271 dc1394video_frame_t *
2273 uint64_t ×tamp,
2279 dc1394video_frame_t *frame;
2285 timestamp = frame->timestamp;
2288 this->
width = frame->size[0];
2289 this->
height = frame->size[1];
2295 switch(frame->color_coding) {
2296 case DC1394_COLOR_CODING_MONO8:
2297 case DC1394_COLOR_CODING_RAW8:
2298 memcpy(I.
bitmap, (
unsigned char *) frame->image,
2299 size*
sizeof(
unsigned char));
2301 case DC1394_COLOR_CODING_MONO16:
2302 case DC1394_COLOR_CODING_RAW16:
2307 case DC1394_COLOR_CODING_YUV411:
2312 case DC1394_COLOR_CODING_YUV422:
2317 case DC1394_COLOR_CODING_YUV444:
2322 case DC1394_COLOR_CODING_RGB8:
2329 vpERROR_TRACE(
"Format conversion not implemented. Acquisition failed.");
2331 "Format conversion not implemented. "
2332 "Acquisition failed.") );
2379 dc1394video_frame_t *
2385 dc1394video_frame_t *frame;
2387 frame =
dequeue(I, timestamp,
id);
2440 dc1394video_frame_t *
2442 uint64_t ×tamp,
2448 dc1394video_frame_t *frame;
2454 timestamp = frame->timestamp;
2457 this->
width = frame->size[0];
2458 this->
height = frame->size[1];
2464 switch (frame->color_coding) {
2465 case DC1394_COLOR_CODING_MONO8:
2466 case DC1394_COLOR_CODING_RAW8:
2468 (
unsigned char *) I.
bitmap, size);
2471 case DC1394_COLOR_CODING_MONO16:
2472 case DC1394_COLOR_CODING_RAW16:
2474 (
unsigned char *) I.
bitmap, size);
2477 case DC1394_COLOR_CODING_YUV411:
2479 (
unsigned char *) I.
bitmap, size);
2482 case DC1394_COLOR_CODING_YUV422:
2484 (
unsigned char *) I.
bitmap, size);
2487 case DC1394_COLOR_CODING_YUV444:
2489 (
unsigned char *) I.
bitmap, size);
2492 case DC1394_COLOR_CODING_RGB8:
2494 (
unsigned char *) I.
bitmap, size);
2500 vpERROR_TRACE(
"Format conversion not implemented. Acquisition failed.");
2502 "Format conversion not implemented. "
2503 "Acquisition failed.") );
2524 if (! num_cameras) {
2528 "No camera found") );
2532 dc1394_capture_enqueue(camera, frame);
2555 dc1394video_frame_t *frame;
2557 frame =
dequeue(I, timestamp,
id);
2581 uint64_t ×tamp,
2584 dc1394video_frame_t *frame;
2587 frame =
dequeue(I, timestamp,
id);
2611 dc1394video_frame_t *frame;
2614 frame =
dequeue(I, timestamp,
id);
2638 uint64_t ×tamp,
2641 dc1394video_frame_t *frame;
2647 timestamp = frame->timestamp;
2650 this->
width = frame->size[0];
2651 this->
height = frame->size[1];
2657 switch (frame->color_coding) {
2658 case DC1394_COLOR_CODING_MONO8:
2659 case DC1394_COLOR_CODING_RAW8:
2661 (
unsigned char *) I.
bitmap, size);
2664 case DC1394_COLOR_CODING_YUV411:
2666 (
unsigned char *) I.
bitmap, size);
2669 case DC1394_COLOR_CODING_YUV422:
2671 (
unsigned char *) I.
bitmap, size);
2674 case DC1394_COLOR_CODING_YUV444:
2676 (
unsigned char *) I.
bitmap, size);
2679 case DC1394_COLOR_CODING_RGB8:
2681 (
unsigned char *) I.
bitmap, size);
2687 vpERROR_TRACE(
"Format conversion not implemented. Acquisition failed.");
2689 "Format conversion not implemented. "
2690 "Acquisition failed.") );
2716 if (! num_cameras) {
2720 "No camera found") );
2723 width = this->
width;
2744 if (! num_cameras) {
2748 "No camera found") );
2773 if (! num_cameras) {
2777 "No camera found") );
2801 if (! num_cameras) {
2805 "No camera found") );
2819 std::cout <<
"----------------------------------------------------------"
2821 <<
"----- Information for camera " << camera_id
2822 <<
" -----" << std::endl
2823 <<
"----------------------------------------------------------" << std::endl;
2825 #ifdef VISP_HAVE_DC1394_2_CAMERA_ENUMERATE // new API > libdc1394-2.0.0-rc7
2826 dc1394_camera_print_info( camera, stdout);
2827 #elif defined VISP_HAVE_DC1394_2_FIND_CAMERAS // old API <= libdc1394-2.0.0-rc7
2828 dc1394_print_camera_info( camera);
2831 dc1394featureset_t features;
2832 #ifdef VISP_HAVE_DC1394_2_CAMERA_ENUMERATE // new API > libdc1394-2.0.0-rc7
2833 if (dc1394_feature_get_all(camera, &features) != DC1394_SUCCESS) {
2834 #elif defined VISP_HAVE_DC1394_2_FIND_CAMERAS // old API <= libdc1394-2.0.0-rc7
2835 if (dc1394_get_camera_feature_set(camera, &features) != DC1394_SUCCESS) {
2838 vpERROR_TRACE(
"unable to get feature set for camera %d\n", camera_id);
2840 "Cannot get camera features") );
2843 #ifdef VISP_HAVE_DC1394_2_CAMERA_ENUMERATE // new API > libdc1394-2.0.0-rc7
2844 dc1394_feature_print_all(&features, stdout);
2845 #elif defined VISP_HAVE_DC1394_2_FIND_CAMERAS // old API <= libdc1394-2.0.0-rc7
2846 dc1394_print_feature_set(&features);
2849 std::cout <<
"----------------------------------------------------------" << std::endl;
2866 std::string _str =
"";
2867 dc1394video_mode_t _videomode = (dc1394video_mode_t) videomode;
2869 if ((_videomode >= DC1394_VIDEO_MODE_MIN)
2870 && (_videomode <= DC1394_VIDEO_MODE_MAX)) {
2871 _str =
strVideoMode[_videomode - DC1394_VIDEO_MODE_MIN];
2874 vpCERROR <<
"The video mode " << videomode
2875 <<
" is not supported by the camera" << std::endl;
2895 std::string _str =
"";
2896 dc1394framerate_t _fps = (dc1394framerate_t) fps;
2898 if ((_fps >= DC1394_FRAMERATE_MIN)
2899 && (_fps <= DC1394_FRAMERATE_MAX)) {
2903 vpCERROR <<
"The framerate " << fps
2904 <<
" is not supported by the camera" << std::endl;
2924 std::string _str =
"";
2925 dc1394color_coding_t _coding = (dc1394color_coding_t) colorcoding;
2927 if ((_coding >= DC1394_COLOR_CODING_MIN)
2928 && (_coding <= DC1394_COLOR_CODING_MAX)) {
2933 vpCERROR <<
"The color coding " << colorcoding
2934 <<
" is not supported by the camera" << std::endl;
2962 for (
int i = DC1394_VIDEO_MODE_MIN; i <= DC1394_VIDEO_MODE_MAX; i ++) {
2969 "The required videomode is not valid") );
2997 for (
int i = DC1394_FRAMERATE_MIN; i <= DC1394_FRAMERATE_MAX; i ++) {
3004 "The required framerate is not valid") );
3031 for (
int i = DC1394_COLOR_CODING_MIN; i <= DC1394_COLOR_CODING_MAX; i ++) {
3038 "The required color coding is not valid") );
3077 for (
unsigned int i = 0; i < num_cameras;i++) {
3079 camera = cameras[i];
3080 setTransmission(DC1394_OFF);
3081 setCapture(DC1394_OFF);
3084 #ifdef VISP_HAVE_DC1394_2_CAMERA_ENUMERATE // new API > libdc1394-2.0.0-rc7
3087 for (
unsigned int i=0;i<num_cameras;i++){
3088 if (i!=camera_id) dc1394_camera_free(cameras[i]);
3091 printf (
"Reseting bus...\n");
3092 dc1394_reset_bus (camera);
3094 dc1394_camera_free (camera);
3097 if (cameras != NULL)
3100 #elif defined VISP_HAVE_DC1394_2_FIND_CAMERAS // old API <= libdc1394-2.0.0-rc7
3104 for (
unsigned int i=0;i<num_cameras;i++){
3105 if (i!=camera_id) dc1394_free_camera(cameras[i]);
3110 dc1394_reset_bus(camera);
3111 dc1394_free_camera(camera);
3114 if (camIsOpen != NULL)
3115 delete [] camIsOpen;
3157 if (! num_cameras) {
3161 "No camera found") );
3163 uint64_t offset = 0x884;
3164 uint32_t value = 0x82000000 + (uint32_t)panControlValue;
3166 err = dc1394_set_control_register(camera, offset, value);
3167 if (err != DC1394_SUCCESS) {
3171 "Unable to set PAN register") );
3194 if (! num_cameras) {
3198 "No camera found") );
3202 dc1394feature_t feature = (dc1394feature_t)param;
3204 err = dc1394_feature_get_value(camera, feature, &value);
3205 if (err != DC1394_SUCCESS) {
3209 "Unable to get the information") );
3211 return (
unsigned int)value;
3238 if (! num_cameras) {
3242 "No camera found") );
3244 uint32_t value = (uint32_t)val;
3245 dc1394feature_t feature = (dc1394feature_t)param;
3247 dc1394bool_t hasManualMode = DC1394_FALSE;
3248 dc1394feature_modes_t modesAvailable;
3251 err = dc1394_feature_get_modes(camera, feature, &modesAvailable);
3252 if (err != DC1394_SUCCESS) {
3253 vpERROR_TRACE(
"Unable to detect the manual mode information");
3256 "Unable to detect the manual mode information"));
3259 for(
unsigned int i=0; i<modesAvailable.num; i++){
3260 if(modesAvailable.modes[i] == DC1394_FEATURE_MODE_MANUAL){
3261 hasManualMode = DC1394_TRUE;
3265 if(hasManualMode == DC1394_TRUE){
3267 if(!isDataModified[camera_id]){
3269 updateDataCamToStruct();
3270 err = dc1394_feature_get_mode(camera, feature, &(initialShutterMode[camera_id]));
3271 if (err != DC1394_SUCCESS) {
3275 "Unable to get the initial mode"));
3277 isDataModified[camera_id] =
true;
3280 dc1394feature_mode_t manualMode = DC1394_FEATURE_MODE_MANUAL;
3281 err = dc1394_feature_set_mode(camera, feature, manualMode);
3282 if (err != DC1394_SUCCESS) {
3286 "Unable to set the manual mode") );
3288 err = dc1394_feature_set_value(camera, feature, value);
3289 if (err != DC1394_SUCCESS) {
3293 "Unable to set the shutter information") );
3297 vpERROR_TRACE(
"The camera does not have a manual mode.\nCannot change the value");
3299 "The camera does not have a manual mode"));
3312 if (! num_cameras) {
3316 "No camera found") );
3319 guid = camera->guid;
3332 if (! num_cameras) {
3336 "No camera found") );
3339 return camera->guid;
3348 vp1394TwoGrabber::updateDataCamToStruct()
3366 vp1394TwoGrabber::updateDataStructToCam()
3379 #ifdef VISP_BUILD_DEPRECATED_FUNCTIONS
3404 if (! num_cameras) {
3408 "No camera found") );
3410 dc1394video_modes_t _videomodes;
3413 if (dc1394_video_get_supported_modes(camera, &_videomodes)!=DC1394_SUCCESS) {
3418 "Can't get video modes") );
3422 for (
unsigned i=0; i < _videomodes.num; i++) {
3428 return _videomodes.num;
3467 if (! num_cameras) {
3471 "No camera found") );
3494 dc1394framerates_t _fps;
3495 if (dc1394_video_get_supported_framerates(camera,
3496 (dc1394video_mode_t)mode,
3497 &_fps) != DC1394_SUCCESS) {
3499 vpERROR_TRACE(
"Could not query supported frametates for mode %d\n",
3502 "Could not query supported framerates") );
3507 for (
unsigned int i = 0; i < _fps.num; i ++)
3544 if (! num_cameras) {
3548 "No camera found") );
3554 if (dc1394_is_video_mode_scalable((dc1394video_mode_t)mode)) {
3556 dc1394color_codings_t _codings;
3557 if (dc1394_format7_get_color_codings(camera,
3558 (dc1394video_mode_t)mode,
3559 &_codings) != DC1394_SUCCESS) {
3561 vpERROR_TRACE(
"Could not query supported color codings for mode %d\n",
3564 "Could not query supported color codings") );
3566 if (_codings.num == 0)
3569 for (
unsigned int i = 0; i < _codings.num; i ++)
3572 return _codings.num;
3574 else if (dc1394_is_video_mode_still_image((dc1394video_mode_t)mode)) {
3580 dc1394color_coding_t _coding;
3581 if (dc1394_get_color_coding_from_video_mode(camera,
3582 (dc1394video_mode_t)mode,
3583 &_coding) != DC1394_SUCCESS) {
3585 vpERROR_TRACE(
"Could not query supported color coding for mode %d\n",
3588 "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 setAutoShutter(unsigned int minvalue, unsigned int maxvalue)
void setIsoTransmissionSpeed(vp1394TwoIsoSpeedType isospeed)
static std::string framerate2string(vp1394TwoFramerateType fps)
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)
void resize(const unsigned int height, const unsigned int width)
set the size of the image
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)
unsigned int getNumCameras()
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)
unsigned int getRingBufferSize()
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 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)
void setFramerate(vp1394TwoFramerateType fps)
dc1394video_frame_t * dequeue()
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)
void getVideoMode(vp1394TwoVideoModeType &videomode)
unsigned int width
Number of columns in the image.