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;
344 if (camera_id >= num_cameras) {
346 bool is_guid =
false;
348 for (
unsigned int i=0; i< num_cameras; i++) {
349 if (cameras[i]->guid == camera_id) {
355 if (is_guid ==
false) {
357 vpERROR_TRACE(
"The camera with GUID 0x%x or id %u is not present",
358 camera_id, camera_id);
361 "The required camera is not present") );
365 this->camera_id = camera_id;
369 camera = cameras[this->camera_id];
391 camera_id = this->camera_id;
397 "No cameras found") );
419 return this->camera_id;
425 "No cameras found") );
440 vpCTRACE <<
"No camera found..."<< std::endl;
444 ncameras = num_cameras;
457 unsigned int ncameras = 0;
459 vpCTRACE <<
"No camera found..."<< std::endl;
463 ncameras = num_cameras;
520 "No camera found") );
523 vpERROR_TRACE(
"Video mode not supported by camera %d",camera_id);
525 "Video mode not supported") );
529 setTransmission(DC1394_OFF);
530 setCapture(DC1394_OFF);
532 if (dc1394_video_set_mode(camera, (dc1394video_mode_t) videomode) != DC1394_SUCCESS) {
537 "Can't set video mode") );
540 setCapture(DC1394_ON);
541 setTransmission(DC1394_ON);
544 if (dc1394_get_image_size_from_video_mode(camera,
545 (dc1394video_mode_t) videomode,
552 "Can't get image size") );
580 "No camera found") );
583 dc1394video_mode_t _videomode;
584 if (dc1394_video_get_mode(camera, &_videomode) != DC1394_SUCCESS) {
589 "Can't get current video mode") );
624 "No camera found") );
626 dc1394video_modes_t _videomodes;
629 if (dc1394_video_get_supported_modes(camera, &_videomodes)!=DC1394_SUCCESS) {
634 "Can't get video modes") );
638 for (
unsigned i=0; i < _videomodes.num; i++) {
640 videomodes.push_back( _mode );
644 return _videomodes.num;
668 "No camera found") );
670 dc1394video_modes_t _videomodes;
673 if (dc1394_video_get_supported_modes(camera, &_videomodes)!=DC1394_SUCCESS) {
678 "Can't get video modes") );
682 for (
unsigned i=0; i < _videomodes.num; i++) {
705 if (dc1394_is_video_mode_scalable((dc1394video_mode_t) videomode))
782 "No camera found") );
791 vpERROR_TRACE(
"Framerate not supported by camera %d",camera_id);
793 "Framerate not supported") );
798 setTransmission(DC1394_OFF);
799 setCapture(DC1394_OFF);
801 if (dc1394_video_set_framerate(camera, (dc1394framerate_t) fps) != DC1394_SUCCESS) {
806 "Can't set framerate") );
809 setCapture(DC1394_ON);
810 setTransmission(DC1394_ON);
836 "No camera found") );
838 dc1394framerate_t _fps;
839 if (dc1394_video_get_framerate(camera, &_fps) != DC1394_SUCCESS) {
844 "Can't get current framerate") );
883 std::list<vp1394TwoFramerateType> & fps)
889 "No camera found") );
912 dc1394framerates_t _fps;
913 if (dc1394_video_get_supported_framerates(camera,
914 (dc1394video_mode_t)mode,
915 &_fps) != DC1394_SUCCESS) {
917 vpERROR_TRACE(
"Could not query supported frametates for mode %d\n",
920 "Could not query supported framerates") );
925 for (
unsigned int i = 0; i < _fps.num; i ++)
974 "No camera found") );
994 dc1394framerates_t _fps;
995 if (dc1394_video_get_supported_framerates(camera,
996 (dc1394video_mode_t)mode,
997 &_fps) != DC1394_SUCCESS) {
999 vpERROR_TRACE(
"Could not query supported frametates for mode %d\n",
1002 "Could not query supported framerates") );
1007 for (
unsigned int i = 0; i < _fps.num; i ++){
1069 if (! num_cameras) {
1073 "No camera found") );
1076 dc1394video_mode_t _videomode;
1077 if (dc1394_video_get_mode(camera, &_videomode) != DC1394_SUCCESS) {
1082 "Can't get current video mode") );
1086 vpERROR_TRACE(
"Color coding not supported by camera %d",camera_id);
1088 "Color coding not supported") );
1093 if (dc1394_is_video_mode_scalable(_videomode)) {
1094 setTransmission(DC1394_OFF);
1095 setCapture(DC1394_OFF);
1097 if (dc1394_format7_set_color_coding(camera, _videomode,
1098 (dc1394color_coding_t) coding)
1099 != DC1394_SUCCESS) {
1104 "Can't set color coding") );
1107 setCapture(DC1394_ON);
1108 setTransmission(DC1394_ON);
1132 if (! num_cameras) {
1136 "No camera found") );
1138 dc1394video_mode_t _videomode;
1139 if (dc1394_video_get_mode(camera, &_videomode) != DC1394_SUCCESS) {
1144 "Can't get current video mode") );
1147 dc1394color_coding_t _coding;
1148 if (dc1394_is_video_mode_scalable(_videomode)) {
1150 if (dc1394_format7_get_color_coding(camera, _videomode, &_coding)
1151 != DC1394_SUCCESS) {
1156 "Can't query current color coding") );
1159 else if (dc1394_is_video_mode_still_image((dc1394video_mode_t)_videomode)) {
1161 "No color coding for format 6 video mode"));
1165 if (dc1394_get_color_coding_from_video_mode(camera,
1166 (dc1394video_mode_t)_videomode,
1167 &_coding) != DC1394_SUCCESS) {
1169 vpERROR_TRACE(
"Could not query supported color coding for mode %d\n",
1172 "Can't query current color coding"));
1201 std::list<vp1394TwoColorCodingType> & codings)
1203 if (! num_cameras) {
1207 "No camera found") );
1213 if (dc1394_is_video_mode_scalable((dc1394video_mode_t)mode)) {
1215 dc1394color_codings_t _codings;
1216 if (dc1394_format7_get_color_codings(camera,
1217 (dc1394video_mode_t)mode,
1218 &_codings) != DC1394_SUCCESS) {
1220 vpERROR_TRACE(
"Could not query supported color codings for mode %d\n",
1223 "Could not query supported color codings") );
1225 if (_codings.num == 0)
1228 for (
unsigned int i = 0; i < _codings.num; i ++)
1231 return _codings.num;
1233 else if (dc1394_is_video_mode_still_image((dc1394video_mode_t)mode)) {
1239 dc1394color_coding_t _coding;
1240 if (dc1394_get_color_coding_from_video_mode(camera,
1241 (dc1394video_mode_t)mode,
1242 &_coding) != DC1394_SUCCESS) {
1244 vpERROR_TRACE(
"Could not query supported color coding for mode %d\n",
1247 "Could not query supported color coding") );
1278 if (! num_cameras) {
1282 "No camera found") );
1286 if (dc1394_is_video_mode_scalable((dc1394video_mode_t)mode)) {
1288 dc1394color_codings_t _codings;
1289 if (dc1394_format7_get_color_codings(camera,
1290 (dc1394video_mode_t)mode,
1291 &_codings) != DC1394_SUCCESS) {
1293 vpERROR_TRACE(
"Could not query supported color codings for mode %d\n",
1296 "Could not query supported color codings") );
1298 if (_codings.num == 0)
1301 for (
unsigned int i = 0; i < _codings.num; i ++){
1307 else if (dc1394_is_video_mode_still_image((dc1394video_mode_t)mode)) {
1313 dc1394color_coding_t _coding;
1314 if (dc1394_get_color_coding_from_video_mode(camera,
1315 (dc1394video_mode_t)mode,
1316 &_coding) != DC1394_SUCCESS) {
1318 vpERROR_TRACE(
"Could not query supported color coding for mode %d\n",
1321 "Could not query supported color coding") );
1365 unsigned int width,
unsigned int height)
1368 if (! num_cameras) {
1372 "No camera found") );
1375 dc1394video_mode_t _videomode;
1376 if (dc1394_video_get_mode(camera, &_videomode) != DC1394_SUCCESS) {
1381 "Can't get current video mode") );
1383 if (dc1394_is_video_mode_scalable(_videomode)) {
1385 setTransmission(DC1394_OFF);
1386 setCapture(DC1394_OFF);
1388 unsigned int max_width, max_height;
1389 if (dc1394_format7_get_max_image_size(camera, _videomode,
1390 &max_width, &max_height)
1391 != DC1394_SUCCESS) {
1396 "Can't get format7 max image size") );
1399 vpTRACE(
"left: %d top: %d width: %d height: %d", left, top,
1400 width == 0 ? DC1394_USE_MAX_AVAIL: width,
1401 height == 0 ? DC1394_USE_MAX_AVAIL : height);
1402 vpTRACE(
"max_width: %d max_height: %d", max_width, max_height);
1405 if (left > max_width) {
1408 "Can't set format7 ROI") );
1410 if (top > max_height) {
1413 "Can't set format7 ROI") );
1421 if (width > (max_width - left))
1422 width = (max_width - left);
1423 roi_width = (int32_t)width;
1426 roi_width = DC1394_USE_MAX_AVAIL;
1431 if (height > (max_height - top))
1432 height = (max_height - top);
1433 roi_height = (int32_t)height;
1436 roi_height = DC1394_USE_MAX_AVAIL;
1440 if (dc1394_format7_set_roi(camera, _videomode,
1441 (dc1394color_coding_t) DC1394_QUERY_FROM_CAMERA,
1442 DC1394_USE_MAX_AVAIL,
1447 != DC1394_SUCCESS) {
1451 "Can't get current video mode") );
1454 if (dc1394_format7_get_image_size(camera, _videomode,
1457 != DC1394_SUCCESS) {
1461 "Can't get format7 image size") );
1464 setCapture(DC1394_ON);
1465 setTransmission(DC1394_ON);
1483 vp1394TwoGrabber::initialize(
bool reset)
1487 #ifdef VISP_HAVE_DC1394_2_CAMERA_ENUMERATE // new API > libdc1394-2.0.0-rc7
1492 if (dc1394_camera_enumerate (d, &list) != DC1394_SUCCESS) {
1493 dc1394_camera_free_list (list);
1497 "Failed to enumerate cameras") );
1500 if (list->num == 0) {
1501 dc1394_camera_free_list (list);
1505 "No cameras found") );
1508 if (cameras != NULL)
1511 cameras =
new dc1394camera_t * [list->num];
1515 for (
unsigned int i=0; i < list->num; i ++) {
1516 cameras[i] = dc1394_camera_new (d, list->ids[i].guid);
1518 vpTRACE (
"Failed to initialize camera with guid \"%ld\"\n",
1530 dc1394_reset_bus(cameras[0]);
1534 dc1394_camera_free_list (list);
1537 #elif defined VISP_HAVE_DC1394_2_FIND_CAMERAS // old API <= libdc1394-2.0.0-rc7
1538 if (cameras != NULL)
1541 int err = dc1394_find_cameras(&cameras, &num_cameras);
1543 if (err!=DC1394_SUCCESS && err != DC1394_NO_CAMERA) {
1547 " - if the kernel modules `ieee1394',`raw1394' and `ohci1394' are loaded \n"
1548 " - if you have read/write access to /dev/raw1394\n\n");
1550 "Unable to look for cameras") );
1555 if (num_cameras == 0) {
1559 "No cameras found") );
1563 isDataModified =
new bool[num_cameras];
1564 for(
unsigned int i=0; i<num_cameras; i++)
1565 isDataModified[i] =
false;
1566 initialShutterMode =
new dc1394feature_mode_t[num_cameras];
1567 dataCam =
new vpDc1394TwoCameraParametersData[num_cameras];
1569 if (camera_id >= num_cameras) {
1579 std::cout <<
"------ Bus information ------" << std::endl;
1580 std::cout <<
"Number of camera(s) on the bus : " << num_cameras <<std::endl;
1581 std::cout <<
"-----------------------------" << std::endl;
1584 if (camIsOpen != NULL)
delete [] camIsOpen;
1585 camIsOpen =
new bool [num_cameras];
1586 for (
unsigned int i = 0;i<num_cameras;i++){
1605 if (
init ==
false) initialize(
false);
1606 if (camIsOpen[camera_id] ==
false){
1607 dc1394switch_t status = DC1394_OFF;
1610 dc1394_video_get_transmission(cameras[camera_id], &status);
1611 if (status != DC1394_OFF){
1613 if (dc1394_video_set_transmission(cameras[camera_id],DC1394_OFF)!=DC1394_SUCCESS)
1614 vpTRACE(
"Could not stop ISO transmission");
1617 if (dc1394_video_get_transmission(cameras[camera_id], &status)!=DC1394_SUCCESS)
1618 vpTRACE(
"Could get ISO status");
1620 if (status==DC1394_ON) {
1621 vpTRACE(
"ISO transmission refuses to stop");
1623 #ifdef VISP_HAVE_DC1394_2_FIND_CAMERAS // old API <= libdc1394-2.0.0-rc7
1625 cameras[camera_id]->is_iso_on=status;
1634 setCapture(DC1394_ON);
1635 setTransmission(DC1394_ON);
1636 camIsOpen[camera_id] =
true;
1652 for (
unsigned int i = 0; i < num_cameras;i++) {
1654 camera = cameras[i];
1655 this->camera_id = i;
1656 setTransmission(DC1394_OFF);
1657 setCapture(DC1394_OFF);
1658 if(isDataModified[i]){
1661 updateDataStructToCam();
1666 if (dc1394_feature_set_mode(camera, DC1394_FEATURE_BRIGHTNESS, initialShutterMode[i]) != DC1394_SUCCESS ||
1667 dc1394_feature_set_mode(camera, DC1394_FEATURE_EXPOSURE, initialShutterMode[i]) != DC1394_SUCCESS ||
1668 dc1394_feature_set_mode(camera, DC1394_FEATURE_SHARPNESS, initialShutterMode[i]) != DC1394_SUCCESS ||
1669 dc1394_feature_set_mode(camera, DC1394_FEATURE_HUE, initialShutterMode[i]) != DC1394_SUCCESS ||
1670 dc1394_feature_set_mode(camera, DC1394_FEATURE_SATURATION, initialShutterMode[i]) != DC1394_SUCCESS ||
1671 dc1394_feature_set_mode(camera, DC1394_FEATURE_GAMMA, initialShutterMode[i]) != DC1394_SUCCESS ||
1672 dc1394_feature_set_mode(camera, DC1394_FEATURE_SHUTTER, initialShutterMode[i]) != DC1394_SUCCESS ||
1673 dc1394_feature_set_mode(camera, DC1394_FEATURE_GAIN, initialShutterMode[i]) != DC1394_SUCCESS ||
1674 dc1394_feature_set_mode(camera, DC1394_FEATURE_IRIS, initialShutterMode[i])){
1678 "Unable to reset the initial mode"));
1681 if (dc1394_camera_set_power(camera, DC1394_OFF) != DC1394_SUCCESS)
1682 std::cout <<
"Unable to turn camera off" << std::endl;
1684 #ifdef VISP_HAVE_DC1394_2_CAMERA_ENUMERATE // new API > libdc1394-2.0.0-rc7
1685 dc1394_camera_free(cameras[i]);
1686 #elif defined VISP_HAVE_DC1394_2_FIND_CAMERAS // old API <= libdc1394-2.0.0-rc7
1687 dc1394_free_camera(cameras[i]);
1691 if (camIsOpen != NULL) {
1692 delete [] camIsOpen;
1696 #ifdef VISP_HAVE_DC1394_2_CAMERA_ENUMERATE // new API > libdc1394-2.0.0-rc7
1697 if (cameras != NULL) {
1706 #elif defined VISP_HAVE_DC1394_2_FIND_CAMERAS // old API <= libdc1394-2.0.0-rc7
1707 if (cameras != NULL) {
1717 if(isDataModified != NULL){
1718 delete[] isDataModified;
1719 isDataModified = NULL;
1721 if(initialShutterMode != NULL){
1722 delete[] initialShutterMode;
1723 initialShutterMode = NULL;
1725 if(dataCam != NULL){
1751 "Could not set ring buffer size") );
1754 if (size != num_buffers) {
1757 if(camIsOpen[camera_id]){
1758 setCapture(DC1394_OFF);
1759 setCapture(DC1394_ON);
1820 if (! num_cameras) {
1824 "No camera found") );
1827 if (dc1394_feature_set_power(camera, DC1394_FEATURE_SHUTTER, DC1394_ON)
1828 != DC1394_SUCCESS) {
1832 "Cannot set shutter on") );
1836 if (dc1394_feature_set_mode(camera,
1837 DC1394_FEATURE_SHUTTER,
1838 DC1394_FEATURE_MODE_AUTO)
1839 != DC1394_SUCCESS) {
1843 "Cannot set auto shutter") );
1846 if (dc1394_avt_set_auto_shutter(camera, minvalue, maxvalue)
1847 != DC1394_SUCCESS) {
1851 "Cannot set auto shutter min and max values") );
1873 vp1394TwoGrabber::setCapture(dc1394switch_t _switch)
1875 if (! num_cameras) {
1879 "No camera found") );
1882 if (_switch == DC1394_ON) {
1885 if (dc1394_capture_setup(camera, num_buffers,
1886 DC1394_CAPTURE_FLAGS_DEFAULT) != DC1394_SUCCESS) {
1888 "make sure that the video mode and framerate are "
1889 "supported by your camera.\n");
1892 "Could not setup dma capture") );
1896 dc1394error_t code = dc1394_capture_stop(camera);
1898 if (code != DC1394_SUCCESS && code != DC1394_CAPTURE_IS_NOT_SET) {
1902 "Could not setup dma capture") );
1923 vp1394TwoGrabber::setTransmission(dc1394switch_t _switch)
1925 if (! num_cameras) {
1929 "No camera found") );
1932 dc1394switch_t status = DC1394_OFF;
1934 if (dc1394_video_get_transmission(camera, &status)!=DC1394_SUCCESS) {
1938 "Could not setup dma capture") );
1943 if (dc1394_video_set_transmission(camera, _switch) != DC1394_SUCCESS) {
1945 "make sure that the video mode and framerate are "
1946 "supported by your camera.\n");
1949 "Could not setup dma capture") );
1952 if (_switch == DC1394_ON) {
1953 status = DC1394_OFF;
1956 while ( status == DC1394_OFF && i++ < 5 ) {
1958 if (dc1394_video_get_transmission(camera, &status)!=DC1394_SUCCESS) {
1962 "Could not setup dma capture") );
2006 if (! num_cameras) {
2010 "No camera found") );
2013 dc1394operation_mode_t op_mode;
2014 dc1394speed_t speed;
2018 if (camera->bmode_capable != DC1394_TRUE) {
2023 "Camera is not 1394B mode capable") );
2026 if(dc1394_video_set_operation_mode(camera,
2027 DC1394_OPERATION_MODE_1394B)
2028 != DC1394_SUCCESS) {
2032 "Cannot set camera to 1394B mode") );
2035 if (dc1394_video_get_operation_mode(camera, &op_mode) != DC1394_SUCCESS) {
2039 "Failed to set 1394B mode") );
2043 if (dc1394_video_set_operation_mode(camera,
2044 DC1394_OPERATION_MODE_LEGACY)
2045 != DC1394_SUCCESS) {
2049 "Cannot set camera to 1394A mode") );
2052 if (dc1394_video_get_operation_mode(camera, &op_mode) != DC1394_SUCCESS) {
2056 "Failed to set 1394A mode") );
2060 if (dc1394_video_set_iso_speed(camera, (dc1394speed_t) isospeed)
2061 != DC1394_SUCCESS) {
2065 "Cannot set requested iso speed") );
2068 if (dc1394_video_get_iso_speed(camera, &speed) != DC1394_SUCCESS) {
2072 "Failed to set iso speed") );
2149 dc1394video_frame_t *
2153 if (! num_cameras) {
2157 "No camera found") );
2160 dc1394video_frame_t *frame = NULL;
2162 if (dc1394_capture_dequeue(camera, DC1394_CAPTURE_POLICY_WAIT, &frame)
2164 vpERROR_TRACE (
"Error: Failed to capture from camera %d\n", camera_id);
2211 dc1394video_frame_t *
2217 dc1394video_frame_t *frame;
2219 frame =
dequeue(I, timestamp,
id);
2272 dc1394video_frame_t *
2274 uint64_t ×tamp,
2280 dc1394video_frame_t *frame;
2286 timestamp = frame->timestamp;
2289 this->
width = frame->size[0];
2290 this->
height = frame->size[1];
2296 switch(frame->color_coding) {
2297 case DC1394_COLOR_CODING_MONO8:
2298 case DC1394_COLOR_CODING_RAW8:
2299 memcpy(I.
bitmap, (
unsigned char *) frame->image,
2300 size*
sizeof(
unsigned char));
2302 case DC1394_COLOR_CODING_MONO16:
2303 case DC1394_COLOR_CODING_RAW16:
2308 case DC1394_COLOR_CODING_YUV411:
2313 case DC1394_COLOR_CODING_YUV422:
2318 case DC1394_COLOR_CODING_YUV444:
2323 case DC1394_COLOR_CODING_RGB8:
2330 vpERROR_TRACE(
"Format conversion not implemented. Acquisition failed.");
2332 "Format conversion not implemented. "
2333 "Acquisition failed.") );
2380 dc1394video_frame_t *
2386 dc1394video_frame_t *frame;
2388 frame =
dequeue(I, timestamp,
id);
2441 dc1394video_frame_t *
2443 uint64_t ×tamp,
2449 dc1394video_frame_t *frame;
2455 timestamp = frame->timestamp;
2458 this->
width = frame->size[0];
2459 this->
height = frame->size[1];
2465 switch (frame->color_coding) {
2466 case DC1394_COLOR_CODING_MONO8:
2467 case DC1394_COLOR_CODING_RAW8:
2469 (
unsigned char *) I.
bitmap, size);
2472 case DC1394_COLOR_CODING_MONO16:
2473 case DC1394_COLOR_CODING_RAW16:
2475 (
unsigned char *) I.
bitmap, size);
2478 case DC1394_COLOR_CODING_YUV411:
2480 (
unsigned char *) I.
bitmap, size);
2483 case DC1394_COLOR_CODING_YUV422:
2485 (
unsigned char *) I.
bitmap, size);
2488 case DC1394_COLOR_CODING_YUV444:
2490 (
unsigned char *) I.
bitmap, size);
2493 case DC1394_COLOR_CODING_RGB8:
2495 (
unsigned char *) I.
bitmap, size);
2501 vpERROR_TRACE(
"Format conversion not implemented. Acquisition failed.");
2503 "Format conversion not implemented. "
2504 "Acquisition failed.") );
2525 if (! num_cameras) {
2529 "No camera found") );
2533 dc1394_capture_enqueue(camera, frame);
2556 dc1394video_frame_t *frame;
2558 frame =
dequeue(I, timestamp,
id);
2582 uint64_t ×tamp,
2585 dc1394video_frame_t *frame;
2588 frame =
dequeue(I, timestamp,
id);
2612 dc1394video_frame_t *frame;
2615 frame =
dequeue(I, timestamp,
id);
2639 uint64_t ×tamp,
2642 dc1394video_frame_t *frame;
2648 timestamp = frame->timestamp;
2651 this->
width = frame->size[0];
2652 this->
height = frame->size[1];
2658 switch (frame->color_coding) {
2659 case DC1394_COLOR_CODING_MONO8:
2660 case DC1394_COLOR_CODING_RAW8:
2662 (
unsigned char *) I.
bitmap, size);
2665 case DC1394_COLOR_CODING_YUV411:
2667 (
unsigned char *) I.
bitmap, size);
2670 case DC1394_COLOR_CODING_YUV422:
2672 (
unsigned char *) I.
bitmap, size);
2675 case DC1394_COLOR_CODING_YUV444:
2677 (
unsigned char *) I.
bitmap, size);
2680 case DC1394_COLOR_CODING_RGB8:
2682 (
unsigned char *) I.
bitmap, size);
2688 vpERROR_TRACE(
"Format conversion not implemented. Acquisition failed.");
2690 "Format conversion not implemented. "
2691 "Acquisition failed.") );
2717 if (! num_cameras) {
2721 "No camera found") );
2724 width = this->
width;
2745 if (! num_cameras) {
2749 "No camera found") );
2774 if (! num_cameras) {
2778 "No camera found") );
2802 if (! num_cameras) {
2806 "No camera found") );
2820 std::cout <<
"----------------------------------------------------------"
2822 <<
"----- Information for camera " << camera_id
2823 <<
" -----" << std::endl
2824 <<
"----------------------------------------------------------" << std::endl;
2826 #ifdef VISP_HAVE_DC1394_2_CAMERA_ENUMERATE // new API > libdc1394-2.0.0-rc7
2827 dc1394_camera_print_info( camera, stdout);
2828 #elif defined VISP_HAVE_DC1394_2_FIND_CAMERAS // old API <= libdc1394-2.0.0-rc7
2829 dc1394_print_camera_info( camera);
2832 dc1394featureset_t features;
2833 #ifdef VISP_HAVE_DC1394_2_CAMERA_ENUMERATE // new API > libdc1394-2.0.0-rc7
2834 if (dc1394_feature_get_all(camera, &features) != DC1394_SUCCESS)
2835 #elif defined VISP_HAVE_DC1394_2_FIND_CAMERAS // old API <= libdc1394-2.0.0-rc7
2836 if (dc1394_get_camera_feature_set(camera, &features) != DC1394_SUCCESS)
2840 vpERROR_TRACE(
"unable to get feature set for camera %d\n", camera_id);
2842 "Cannot get camera features") );
2845 #ifdef VISP_HAVE_DC1394_2_CAMERA_ENUMERATE // new API > libdc1394-2.0.0-rc7
2846 dc1394_feature_print_all(&features, stdout);
2847 #elif defined VISP_HAVE_DC1394_2_FIND_CAMERAS // old API <= libdc1394-2.0.0-rc7
2848 dc1394_print_feature_set(&features);
2851 std::cout <<
"----------------------------------------------------------" << std::endl;
2868 std::string _str =
"";
2869 dc1394video_mode_t _videomode = (dc1394video_mode_t) videomode;
2871 if ((_videomode >= DC1394_VIDEO_MODE_MIN)
2872 && (_videomode <= DC1394_VIDEO_MODE_MAX)) {
2873 _str =
strVideoMode[_videomode - DC1394_VIDEO_MODE_MIN];
2876 vpCERROR <<
"The video mode " << videomode
2877 <<
" is not supported by the camera" << std::endl;
2897 std::string _str =
"";
2898 dc1394framerate_t _fps = (dc1394framerate_t) fps;
2900 if ((_fps >= DC1394_FRAMERATE_MIN)
2901 && (_fps <= DC1394_FRAMERATE_MAX)) {
2905 vpCERROR <<
"The framerate " << fps
2906 <<
" is not supported by the camera" << std::endl;
2926 std::string _str =
"";
2927 dc1394color_coding_t _coding = (dc1394color_coding_t) colorcoding;
2929 if ((_coding >= DC1394_COLOR_CODING_MIN)
2930 && (_coding <= DC1394_COLOR_CODING_MAX)) {
2935 vpCERROR <<
"The color coding " << colorcoding
2936 <<
" is not supported by the camera" << std::endl;
2964 for (
int i = DC1394_VIDEO_MODE_MIN; i <= DC1394_VIDEO_MODE_MAX; i ++) {
2971 "The required videomode is not valid") );
2999 for (
int i = DC1394_FRAMERATE_MIN; i <= DC1394_FRAMERATE_MAX; i ++) {
3006 "The required framerate is not valid") );
3033 for (
int i = DC1394_COLOR_CODING_MIN; i <= DC1394_COLOR_CODING_MAX; i ++) {
3040 "The required color coding is not valid") );
3079 for (
unsigned int i = 0; i < num_cameras;i++) {
3081 camera = cameras[i];
3082 setTransmission(DC1394_OFF);
3083 setCapture(DC1394_OFF);
3086 #ifdef VISP_HAVE_DC1394_2_CAMERA_ENUMERATE // new API > libdc1394-2.0.0-rc7
3089 for (
unsigned int i=0;i<num_cameras;i++){
3090 if (i!=camera_id) dc1394_camera_free(cameras[i]);
3093 printf (
"Reseting bus...\n");
3094 dc1394_reset_bus (camera);
3096 dc1394_camera_free (camera);
3099 if (cameras != NULL)
3102 #elif defined VISP_HAVE_DC1394_2_FIND_CAMERAS // old API <= libdc1394-2.0.0-rc7
3106 for (
unsigned int i=0;i<num_cameras;i++){
3107 if (i!=camera_id) dc1394_free_camera(cameras[i]);
3112 dc1394_reset_bus(camera);
3113 dc1394_free_camera(camera);
3116 if (camIsOpen != NULL)
3117 delete [] camIsOpen;
3159 if (! num_cameras) {
3163 "No camera found") );
3165 uint64_t offset = 0x884;
3166 uint32_t value = 0x82000000 + (uint32_t)panControlValue;
3168 err = dc1394_set_control_register(camera, offset, value);
3169 if (err != DC1394_SUCCESS) {
3173 "Unable to set PAN register") );
3196 if (! num_cameras) {
3200 "No camera found") );
3204 dc1394feature_t feature = (dc1394feature_t)param;
3206 err = dc1394_feature_get_value(camera, feature, &value);
3207 if (err != DC1394_SUCCESS) {
3211 "Unable to get the information") );
3213 return (
unsigned int)value;
3240 if (! num_cameras) {
3244 "No camera found") );
3246 uint32_t value = (uint32_t)val;
3247 dc1394feature_t feature = (dc1394feature_t)param;
3249 dc1394bool_t hasManualMode = DC1394_FALSE;
3250 dc1394feature_modes_t modesAvailable;
3253 err = dc1394_feature_get_modes(camera, feature, &modesAvailable);
3254 if (err != DC1394_SUCCESS) {
3255 vpERROR_TRACE(
"Unable to detect the manual mode information");
3258 "Unable to detect the manual mode information"));
3261 for(
unsigned int i=0; i<modesAvailable.num; i++){
3262 if(modesAvailable.modes[i] == DC1394_FEATURE_MODE_MANUAL){
3263 hasManualMode = DC1394_TRUE;
3267 if(hasManualMode == DC1394_TRUE){
3269 if(!isDataModified[camera_id]){
3271 updateDataCamToStruct();
3272 err = dc1394_feature_get_mode(camera, feature, &(initialShutterMode[camera_id]));
3273 if (err != DC1394_SUCCESS) {
3277 "Unable to get the initial mode"));
3279 isDataModified[camera_id] =
true;
3282 dc1394feature_mode_t manualMode = DC1394_FEATURE_MODE_MANUAL;
3283 err = dc1394_feature_set_mode(camera, feature, manualMode);
3284 if (err != DC1394_SUCCESS) {
3288 "Unable to set the manual mode") );
3290 err = dc1394_feature_set_value(camera, feature, value);
3291 if (err != DC1394_SUCCESS) {
3295 "Unable to set the shutter information") );
3299 vpERROR_TRACE(
"The camera does not have a manual mode.\nCannot change the value");
3301 "The camera does not have a manual mode"));
3314 if (! num_cameras) {
3318 "No camera found") );
3321 guid = camera->guid;
3334 if (! num_cameras) {
3338 "No camera found") );
3341 return camera->guid;
3350 vp1394TwoGrabber::updateDataCamToStruct()
3368 vp1394TwoGrabber::updateDataStructToCam()
3381 #ifdef VISP_BUILD_DEPRECATED_FUNCTIONS
3406 if (! num_cameras) {
3410 "No camera found") );
3412 dc1394video_modes_t _videomodes;
3415 if (dc1394_video_get_supported_modes(camera, &_videomodes)!=DC1394_SUCCESS) {
3420 "Can't get video modes") );
3424 for (
unsigned i=0; i < _videomodes.num; i++) {
3430 return _videomodes.num;
3469 if (! num_cameras) {
3473 "No camera found") );
3496 dc1394framerates_t _fps;
3497 if (dc1394_video_get_supported_framerates(camera,
3498 (dc1394video_mode_t)mode,
3499 &_fps) != DC1394_SUCCESS) {
3501 vpERROR_TRACE(
"Could not query supported frametates for mode %d\n",
3504 "Could not query supported framerates") );
3509 for (
unsigned int i = 0; i < _fps.num; i ++)
3546 if (! num_cameras) {
3550 "No camera found") );
3556 if (dc1394_is_video_mode_scalable((dc1394video_mode_t)mode)) {
3558 dc1394color_codings_t _codings;
3559 if (dc1394_format7_get_color_codings(camera,
3560 (dc1394video_mode_t)mode,
3561 &_codings) != DC1394_SUCCESS) {
3563 vpERROR_TRACE(
"Could not query supported color codings for mode %d\n",
3566 "Could not query supported color codings") );
3568 if (_codings.num == 0)
3571 for (
unsigned int i = 0; i < _codings.num; i ++)
3574 return _codings.num;
3576 else if (dc1394_is_video_mode_still_image((dc1394video_mode_t)mode)) {
3582 dc1394color_coding_t _coding;
3583 if (dc1394_get_color_coding_from_video_mode(camera,
3584 (dc1394video_mode_t)mode,
3585 &_coding) != DC1394_SUCCESS) {
3587 vpERROR_TRACE(
"Could not query supported color coding for mode %d\n",
3590 "Could not query supported color coding") );