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);
1818 if (! num_cameras) {
1822 "No camera found") );
1825 if (dc1394_feature_set_power(camera, DC1394_FEATURE_SHUTTER, DC1394_ON)
1826 != DC1394_SUCCESS) {
1830 "Cannot set shutter on") );
1833 if (dc1394_feature_set_mode(camera,
1834 DC1394_FEATURE_SHUTTER,
1835 DC1394_FEATURE_MODE_AUTO)
1836 != DC1394_SUCCESS) {
1840 "Cannot set auto shutter") );
1888 if (dc1394_avt_set_auto_shutter(camera, minvalue, maxvalue)
1889 != DC1394_SUCCESS) {
1893 "Cannot set auto shutter min and max values") );
1912 if (! num_cameras) {
1916 "No camera found") );
1919 if (dc1394_avt_get_auto_shutter(camera, &minvalue, &maxvalue)
1920 != DC1394_SUCCESS) {
1924 "Cannot get auto shutter min and max values") );
1967 if (! num_cameras) {
1971 "No camera found") );
1974 if (dc1394_feature_set_power(camera, DC1394_FEATURE_SHUTTER, DC1394_ON)
1975 != DC1394_SUCCESS) {
1979 "Cannot set shutter on") );
1982 if (dc1394_feature_set_mode(camera,
1983 DC1394_FEATURE_GAIN,
1984 DC1394_FEATURE_MODE_AUTO)
1985 != DC1394_SUCCESS) {
1989 "Cannot set auto gain") );
2037 if (dc1394_avt_set_auto_gain(camera, minvalue, maxvalue)
2038 != DC1394_SUCCESS) {
2042 "Cannot set auto gain min and max values") );
2061 if (! num_cameras) {
2065 "No camera found") );
2068 if (dc1394_avt_get_auto_gain(camera, &minvalue, &maxvalue)
2069 != DC1394_SUCCESS) {
2073 "Cannot get auto gain min and max values") );
2096 vp1394TwoGrabber::setCapture(dc1394switch_t _switch)
2098 if (! num_cameras) {
2102 "No camera found") );
2105 if (_switch == DC1394_ON) {
2108 if (dc1394_capture_setup(camera, num_buffers,
2109 DC1394_CAPTURE_FLAGS_DEFAULT) != DC1394_SUCCESS) {
2111 "make sure that the video mode and framerate are "
2112 "supported by your camera.\n");
2115 "Could not setup dma capture") );
2119 dc1394error_t code = dc1394_capture_stop(camera);
2121 if (code != DC1394_SUCCESS && code != DC1394_CAPTURE_IS_NOT_SET) {
2125 "Could not setup dma capture") );
2146 vp1394TwoGrabber::setTransmission(dc1394switch_t _switch)
2148 if (! num_cameras) {
2152 "No camera found") );
2155 dc1394switch_t status = DC1394_OFF;
2157 if (dc1394_video_get_transmission(camera, &status)!=DC1394_SUCCESS) {
2161 "Could not setup dma capture") );
2166 if (dc1394_video_set_transmission(camera, _switch) != DC1394_SUCCESS) {
2168 "make sure that the video mode and framerate are "
2169 "supported by your camera.\n");
2172 "Could not setup dma capture") );
2175 if (_switch == DC1394_ON) {
2176 status = DC1394_OFF;
2179 while ( status == DC1394_OFF && i++ < 5 ) {
2181 if (dc1394_video_get_transmission(camera, &status)!=DC1394_SUCCESS) {
2185 "Could not setup dma capture") );
2229 if (! num_cameras) {
2233 "No camera found") );
2236 dc1394operation_mode_t op_mode;
2237 dc1394speed_t speed;
2241 if (camera->bmode_capable != DC1394_TRUE) {
2246 "Camera is not 1394B mode capable") );
2249 if(dc1394_video_set_operation_mode(camera,
2250 DC1394_OPERATION_MODE_1394B)
2251 != DC1394_SUCCESS) {
2255 "Cannot set camera to 1394B mode") );
2258 if (dc1394_video_get_operation_mode(camera, &op_mode) != DC1394_SUCCESS) {
2262 "Failed to set 1394B mode") );
2266 if (dc1394_video_set_operation_mode(camera,
2267 DC1394_OPERATION_MODE_LEGACY)
2268 != DC1394_SUCCESS) {
2272 "Cannot set camera to 1394A mode") );
2275 if (dc1394_video_get_operation_mode(camera, &op_mode) != DC1394_SUCCESS) {
2279 "Failed to set 1394A mode") );
2283 if (dc1394_video_set_iso_speed(camera, (dc1394speed_t) isospeed)
2284 != DC1394_SUCCESS) {
2288 "Cannot set requested iso speed") );
2291 if (dc1394_video_get_iso_speed(camera, &speed) != DC1394_SUCCESS) {
2295 "Failed to set iso speed") );
2372 dc1394video_frame_t *
2376 if (! num_cameras) {
2380 "No camera found") );
2383 dc1394video_frame_t *frame = NULL;
2385 if (dc1394_capture_dequeue(camera, DC1394_CAPTURE_POLICY_WAIT, &frame)
2387 vpERROR_TRACE (
"Error: Failed to capture from camera %d\n", camera_id);
2434 dc1394video_frame_t *
2440 dc1394video_frame_t *frame;
2442 frame =
dequeue(I, timestamp,
id);
2495 dc1394video_frame_t *
2497 uint64_t ×tamp,
2503 dc1394video_frame_t *frame;
2509 timestamp = frame->timestamp;
2512 this->
width = frame->size[0];
2513 this->
height = frame->size[1];
2519 switch(frame->color_coding) {
2520 case DC1394_COLOR_CODING_MONO8:
2521 case DC1394_COLOR_CODING_RAW8:
2522 memcpy(I.
bitmap, (
unsigned char *) frame->image,
2523 size*
sizeof(
unsigned char));
2525 case DC1394_COLOR_CODING_MONO16:
2526 case DC1394_COLOR_CODING_RAW16:
2531 case DC1394_COLOR_CODING_YUV411:
2536 case DC1394_COLOR_CODING_YUV422:
2541 case DC1394_COLOR_CODING_YUV444:
2546 case DC1394_COLOR_CODING_RGB8:
2553 vpERROR_TRACE(
"Format conversion not implemented. Acquisition failed.");
2555 "Format conversion not implemented. "
2556 "Acquisition failed.") );
2603 dc1394video_frame_t *
2609 dc1394video_frame_t *frame;
2611 frame =
dequeue(I, timestamp,
id);
2664 dc1394video_frame_t *
2666 uint64_t ×tamp,
2672 dc1394video_frame_t *frame;
2678 timestamp = frame->timestamp;
2681 this->
width = frame->size[0];
2682 this->
height = frame->size[1];
2688 switch (frame->color_coding) {
2689 case DC1394_COLOR_CODING_MONO8:
2690 case DC1394_COLOR_CODING_RAW8:
2692 (
unsigned char *) I.
bitmap, size);
2695 case DC1394_COLOR_CODING_MONO16:
2696 case DC1394_COLOR_CODING_RAW16:
2698 (
unsigned char *) I.
bitmap, size);
2701 case DC1394_COLOR_CODING_YUV411:
2703 (
unsigned char *) I.
bitmap, size);
2706 case DC1394_COLOR_CODING_YUV422:
2708 (
unsigned char *) I.
bitmap, size);
2711 case DC1394_COLOR_CODING_YUV444:
2713 (
unsigned char *) I.
bitmap, size);
2716 case DC1394_COLOR_CODING_RGB8:
2718 (
unsigned char *) I.
bitmap, size);
2724 vpERROR_TRACE(
"Format conversion not implemented. Acquisition failed.");
2726 "Format conversion not implemented. "
2727 "Acquisition failed.") );
2748 if (! num_cameras) {
2752 "No camera found") );
2756 dc1394_capture_enqueue(camera, frame);
2779 dc1394video_frame_t *frame;
2781 frame =
dequeue(I, timestamp,
id);
2805 uint64_t ×tamp,
2808 dc1394video_frame_t *frame;
2811 frame =
dequeue(I, timestamp,
id);
2835 dc1394video_frame_t *frame;
2838 frame =
dequeue(I, timestamp,
id);
2862 uint64_t ×tamp,
2865 dc1394video_frame_t *frame;
2871 timestamp = frame->timestamp;
2874 this->
width = frame->size[0];
2875 this->
height = frame->size[1];
2881 switch (frame->color_coding) {
2882 case DC1394_COLOR_CODING_MONO8:
2883 case DC1394_COLOR_CODING_RAW8:
2885 (
unsigned char *) I.
bitmap, size);
2888 case DC1394_COLOR_CODING_YUV411:
2890 (
unsigned char *) I.
bitmap, size);
2893 case DC1394_COLOR_CODING_YUV422:
2895 (
unsigned char *) I.
bitmap, size);
2898 case DC1394_COLOR_CODING_YUV444:
2900 (
unsigned char *) I.
bitmap, size);
2903 case DC1394_COLOR_CODING_RGB8:
2905 (
unsigned char *) I.
bitmap, size);
2911 vpERROR_TRACE(
"Format conversion not implemented. Acquisition failed.");
2913 "Format conversion not implemented. "
2914 "Acquisition failed.") );
2940 if (! num_cameras) {
2944 "No camera found") );
2947 width = this->
width;
2968 if (! num_cameras) {
2972 "No camera found") );
2997 if (! num_cameras) {
3001 "No camera found") );
3025 if (! num_cameras) {
3029 "No camera found") );
3043 std::cout <<
"----------------------------------------------------------"
3045 <<
"----- Information for camera " << camera_id
3046 <<
" -----" << std::endl
3047 <<
"----------------------------------------------------------" << std::endl;
3049 #ifdef VISP_HAVE_DC1394_2_CAMERA_ENUMERATE // new API > libdc1394-2.0.0-rc7
3050 dc1394_camera_print_info( camera, stdout);
3051 #elif defined VISP_HAVE_DC1394_2_FIND_CAMERAS // old API <= libdc1394-2.0.0-rc7
3052 dc1394_print_camera_info( camera);
3055 dc1394featureset_t features;
3056 #ifdef VISP_HAVE_DC1394_2_CAMERA_ENUMERATE // new API > libdc1394-2.0.0-rc7
3057 if (dc1394_feature_get_all(camera, &features) != DC1394_SUCCESS)
3058 #elif defined VISP_HAVE_DC1394_2_FIND_CAMERAS // old API <= libdc1394-2.0.0-rc7
3059 if (dc1394_get_camera_feature_set(camera, &features) != DC1394_SUCCESS)
3063 vpERROR_TRACE(
"unable to get feature set for camera %d\n", camera_id);
3065 "Cannot get camera features") );
3068 #ifdef VISP_HAVE_DC1394_2_CAMERA_ENUMERATE // new API > libdc1394-2.0.0-rc7
3069 dc1394_feature_print_all(&features, stdout);
3070 #elif defined VISP_HAVE_DC1394_2_FIND_CAMERAS // old API <= libdc1394-2.0.0-rc7
3071 dc1394_print_feature_set(&features);
3074 std::cout <<
"----------------------------------------------------------" << std::endl;
3091 std::string _str =
"";
3092 dc1394video_mode_t _videomode = (dc1394video_mode_t) videomode;
3094 if ((_videomode >= DC1394_VIDEO_MODE_MIN)
3095 && (_videomode <= DC1394_VIDEO_MODE_MAX)) {
3096 _str =
strVideoMode[_videomode - DC1394_VIDEO_MODE_MIN];
3099 vpCERROR <<
"The video mode " << videomode
3100 <<
" is not supported by the camera" << std::endl;
3120 std::string _str =
"";
3121 dc1394framerate_t _fps = (dc1394framerate_t) fps;
3123 if ((_fps >= DC1394_FRAMERATE_MIN)
3124 && (_fps <= DC1394_FRAMERATE_MAX)) {
3128 vpCERROR <<
"The framerate " << fps
3129 <<
" is not supported by the camera" << std::endl;
3149 std::string _str =
"";
3150 dc1394color_coding_t _coding = (dc1394color_coding_t) colorcoding;
3152 if ((_coding >= DC1394_COLOR_CODING_MIN)
3153 && (_coding <= DC1394_COLOR_CODING_MAX)) {
3158 vpCERROR <<
"The color coding " << colorcoding
3159 <<
" is not supported by the camera" << std::endl;
3187 for (
int i = DC1394_VIDEO_MODE_MIN; i <= DC1394_VIDEO_MODE_MAX; i ++) {
3194 "The required videomode is not valid") );
3222 for (
int i = DC1394_FRAMERATE_MIN; i <= DC1394_FRAMERATE_MAX; i ++) {
3229 "The required framerate is not valid") );
3256 for (
int i = DC1394_COLOR_CODING_MIN; i <= DC1394_COLOR_CODING_MAX; i ++) {
3263 "The required color coding is not valid") );
3302 for (
unsigned int i = 0; i < num_cameras;i++) {
3304 camera = cameras[i];
3305 setTransmission(DC1394_OFF);
3306 setCapture(DC1394_OFF);
3309 #ifdef VISP_HAVE_DC1394_2_CAMERA_ENUMERATE // new API > libdc1394-2.0.0-rc7
3312 for (
unsigned int i=0;i<num_cameras;i++){
3313 if (i!=camera_id) dc1394_camera_free(cameras[i]);
3316 printf (
"Reseting bus...\n");
3317 dc1394_reset_bus (camera);
3319 dc1394_camera_free (camera);
3322 if (cameras != NULL)
3325 #elif defined VISP_HAVE_DC1394_2_FIND_CAMERAS // old API <= libdc1394-2.0.0-rc7
3329 for (
unsigned int i=0;i<num_cameras;i++){
3330 if (i!=camera_id) dc1394_free_camera(cameras[i]);
3335 dc1394_reset_bus(camera);
3336 dc1394_free_camera(camera);
3339 if (camIsOpen != NULL)
3340 delete [] camIsOpen;
3382 if (! num_cameras) {
3386 "No camera found") );
3388 uint64_t offset = 0x884;
3389 uint32_t value = 0x82000000 + (uint32_t)panControlValue;
3391 err = dc1394_set_control_register(camera, offset, value);
3392 if (err != DC1394_SUCCESS) {
3396 "Unable to set PAN register") );
3419 if (! num_cameras) {
3423 "No camera found") );
3427 dc1394feature_t feature = (dc1394feature_t)param;
3429 err = dc1394_feature_get_value(camera, feature, &value);
3430 if (err != DC1394_SUCCESS) {
3434 "Unable to get the information") );
3436 return (
unsigned int)value;
3463 if (! num_cameras) {
3467 "No camera found") );
3469 uint32_t value = (uint32_t)val;
3470 dc1394feature_t feature = (dc1394feature_t)param;
3472 dc1394bool_t hasManualMode = DC1394_FALSE;
3473 dc1394feature_modes_t modesAvailable;
3476 err = dc1394_feature_get_modes(camera, feature, &modesAvailable);
3477 if (err != DC1394_SUCCESS) {
3478 vpERROR_TRACE(
"Unable to detect the manual mode information");
3481 "Unable to detect the manual mode information"));
3484 for(
unsigned int i=0; i<modesAvailable.num; i++){
3485 if(modesAvailable.modes[i] == DC1394_FEATURE_MODE_MANUAL){
3486 hasManualMode = DC1394_TRUE;
3490 if(hasManualMode == DC1394_TRUE){
3492 if(!isDataModified[camera_id]){
3494 updateDataCamToStruct();
3495 err = dc1394_feature_get_mode(camera, feature, &(initialShutterMode[camera_id]));
3496 if (err != DC1394_SUCCESS) {
3500 "Unable to get the initial mode"));
3502 isDataModified[camera_id] =
true;
3505 dc1394feature_mode_t manualMode = DC1394_FEATURE_MODE_MANUAL;
3506 err = dc1394_feature_set_mode(camera, feature, manualMode);
3507 if (err != DC1394_SUCCESS) {
3511 "Unable to set the manual mode") );
3513 err = dc1394_feature_set_value(camera, feature, value);
3514 if (err != DC1394_SUCCESS) {
3518 "Unable to set the shutter information") );
3522 vpERROR_TRACE(
"The camera does not have a manual mode.\nCannot change the value");
3524 "The camera does not have a manual mode"));
3537 if (! num_cameras) {
3541 "No camera found") );
3544 guid = camera->guid;
3557 if (! num_cameras) {
3561 "No camera found") );
3564 return camera->guid;
3573 vp1394TwoGrabber::updateDataCamToStruct()
3591 vp1394TwoGrabber::updateDataStructToCam()
3604 #ifdef VISP_BUILD_DEPRECATED_FUNCTIONS
3629 if (! num_cameras) {
3633 "No camera found") );
3635 dc1394video_modes_t _videomodes;
3638 if (dc1394_video_get_supported_modes(camera, &_videomodes)!=DC1394_SUCCESS) {
3643 "Can't get video modes") );
3647 for (
unsigned i=0; i < _videomodes.num; i++) {
3653 return _videomodes.num;
3692 if (! num_cameras) {
3696 "No camera found") );
3719 dc1394framerates_t _fps;
3720 if (dc1394_video_get_supported_framerates(camera,
3721 (dc1394video_mode_t)mode,
3722 &_fps) != DC1394_SUCCESS) {
3724 vpERROR_TRACE(
"Could not query supported frametates for mode %d\n",
3727 "Could not query supported framerates") );
3732 for (
unsigned int i = 0; i < _fps.num; i ++)
3769 if (! num_cameras) {
3773 "No camera found") );
3779 if (dc1394_is_video_mode_scalable((dc1394video_mode_t)mode)) {
3781 dc1394color_codings_t _codings;
3782 if (dc1394_format7_get_color_codings(camera,
3783 (dc1394video_mode_t)mode,
3784 &_codings) != DC1394_SUCCESS) {
3786 vpERROR_TRACE(
"Could not query supported color codings for mode %d\n",
3789 "Could not query supported color codings") );
3791 if (_codings.num == 0)
3794 for (
unsigned int i = 0; i < _codings.num; i ++)
3797 return _codings.num;
3799 else if (dc1394_is_video_mode_still_image((dc1394video_mode_t)mode)) {
3805 dc1394color_coding_t _coding;
3806 if (dc1394_get_color_coding_from_video_mode(camera,
3807 (dc1394video_mode_t)mode,
3808 &_coding) != DC1394_SUCCESS) {
3810 vpERROR_TRACE(
"Could not query supported color coding for mode %d\n",
3813 "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 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)
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 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)
void getVideoMode(vp1394TwoVideoModeType &videomode)
unsigned int width
Number of columns in the image.