46 #include <visp3/core/vpConfig.h>
51 #if defined(VISP_HAVE_DC1394)
54 #include <visp3/sensor/vp1394TwoGrabber.h>
55 #include <visp3/core/vpFrameGrabberException.h>
56 #include <visp3/core/vpImageConvert.h>
57 #include <visp3/core/vpTime.h>
60 "MODE_160x120_YUV444",
61 "MODE_320x240_YUV422",
62 "MODE_640x480_YUV411",
63 "MODE_640x480_YUV422",
66 "MODE_640x480_MONO16",
67 "MODE_800x600_YUV422",
70 "MODE_1024x768_YUV422",
72 "MODE_1024x768_MONO8",
73 "MODE_800x600_MONO16",
74 "MODE_1024x768_MONO16",
75 "MODE_1280x960_YUV422",
77 "MODE_1280x960_MONO8",
78 "MODE_1600x1200_YUV422",
79 "MODE_1600x1200_RGB8",
80 "MODE_1600x1200_MONO8",
81 "MODE_1280x960_MONO16",
82 "MODE_1600x1200_MONO16",
106 "COLOR_CODING_MONO8",
107 "COLOR_CODING_YUV411",
108 "COLOR_CODING_YUV422",
109 "COLOR_CODING_YUV444",
111 "COLOR_CODING_MONO16",
112 "COLOR_CODING_RGB16",
113 "COLOR_CODING_MONO16S",
114 "COLOR_CODING_RGB16S",
116 "COLOR_CODING_RAW16",
166 : camera(NULL), cameras(NULL), num_cameras(0), camera_id(0), verbose(false), camIsOpen(NULL),
168 isDataModified(NULL), initialShutterMode(NULL), dataCam(NULL)
169 #ifdef VISP_HAVE_DC1394_CAMERA_ENUMERATE
330 if (cam_id >= num_cameras) {
332 bool is_guid =
false;
334 for (
unsigned int i=0; i< num_cameras; i++) {
335 if (cameras[i]->guid == cam_id) {
341 if (is_guid ==
false) {
342 std::cout <<
"Error: The camera with guid 0x" << std::hex << cam_id <<
" is not present" << std::endl;
343 std::cout << num_cameras <<
" camera(s) connected" << std::endl;
344 for (
unsigned int i=0; i< num_cameras; i++) {
345 std::cout <<
" - camera " << i <<
" with guid 0x" << std::hex << cameras[i]->guid << std::endl;
349 "The required camera is not present") );
353 this->camera_id = (
unsigned int) cam_id;
357 camera = cameras[this->camera_id];
379 cam_id = this->camera_id;
385 "No cameras found") );
407 return this->camera_id;
413 "No cameras found") );
428 vpCTRACE <<
"No camera found..."<< std::endl;
432 ncameras = num_cameras;
445 unsigned int ncameras = 0;
447 vpCTRACE <<
"No camera found..."<< std::endl;
451 ncameras = num_cameras;
508 "No camera found") );
511 vpERROR_TRACE(
"Video mode not supported by camera %d",camera_id);
513 "Video mode not supported") );
517 setTransmission(DC1394_OFF);
518 setCapture(DC1394_OFF);
520 if (dc1394_video_set_mode(camera, (dc1394video_mode_t) videomode) != DC1394_SUCCESS) {
525 "Can't set video mode") );
528 setCapture(DC1394_ON);
529 setTransmission(DC1394_ON);
532 if (dc1394_get_image_size_from_video_mode(camera,
533 (dc1394video_mode_t) videomode,
540 "Can't get image size") );
568 "No camera found") );
571 dc1394video_mode_t _videomode;
572 if (dc1394_video_get_mode(camera, &_videomode) != DC1394_SUCCESS) {
577 "Can't get current video mode") );
612 "No camera found") );
614 dc1394video_modes_t _videomodes;
617 if (dc1394_video_get_supported_modes(camera, &_videomodes)!=DC1394_SUCCESS) {
622 "Can't get video modes") );
626 for (
unsigned i=0; i < _videomodes.num; i++) {
628 videomodes.push_back( _mode );
632 return _videomodes.num;
656 "No camera found") );
658 dc1394video_modes_t _videomodes;
661 if (dc1394_video_get_supported_modes(camera, &_videomodes)!=DC1394_SUCCESS) {
666 "Can't get video modes") );
670 for (
unsigned i=0; i < _videomodes.num; i++) {
693 if (dc1394_is_video_mode_scalable((dc1394video_mode_t) videomode))
770 "No camera found") );
779 vpERROR_TRACE(
"Framerate not supported by camera %d",camera_id);
781 "Framerate not supported") );
786 setTransmission(DC1394_OFF);
787 setCapture(DC1394_OFF);
789 if (dc1394_video_set_framerate(camera, (dc1394framerate_t) fps) != DC1394_SUCCESS) {
794 "Can't set framerate") );
797 setCapture(DC1394_ON);
798 setTransmission(DC1394_ON);
824 "No camera found") );
826 dc1394framerate_t _fps;
827 if (dc1394_video_get_framerate(camera, &_fps) != DC1394_SUCCESS) {
832 "Can't get current framerate") );
871 std::list<vp1394TwoFramerateType> & fps)
877 "No camera found") );
900 dc1394framerates_t _fps;
901 if (dc1394_video_get_supported_framerates(camera,
902 (dc1394video_mode_t)mode,
903 &_fps) != DC1394_SUCCESS) {
905 vpERROR_TRACE(
"Could not query supported frametates for mode %d\n",
908 "Could not query supported framerates") );
913 for (
unsigned int i = 0; i < _fps.num; i ++)
962 "No camera found") );
982 dc1394framerates_t _fps;
983 if (dc1394_video_get_supported_framerates(camera,
984 (dc1394video_mode_t)mode,
985 &_fps) != DC1394_SUCCESS) {
987 vpERROR_TRACE(
"Could not query supported frametates for mode %d\n",
990 "Could not query supported framerates") );
995 for (
unsigned int i = 0; i < _fps.num; i ++){
1057 if (! num_cameras) {
1061 "No camera found") );
1064 dc1394video_mode_t _videomode;
1065 if (dc1394_video_get_mode(camera, &_videomode) != DC1394_SUCCESS) {
1070 "Can't get current video mode") );
1074 vpERROR_TRACE(
"Color coding not supported by camera %d",camera_id);
1076 "Color coding not supported") );
1081 if (dc1394_is_video_mode_scalable(_videomode)) {
1082 setTransmission(DC1394_OFF);
1083 setCapture(DC1394_OFF);
1085 if (dc1394_format7_set_color_coding(camera, _videomode,
1086 (dc1394color_coding_t) coding)
1087 != DC1394_SUCCESS) {
1092 "Can't set color coding") );
1095 setCapture(DC1394_ON);
1096 setTransmission(DC1394_ON);
1120 if (! num_cameras) {
1124 "No camera found") );
1126 dc1394video_mode_t _videomode;
1127 if (dc1394_video_get_mode(camera, &_videomode) != DC1394_SUCCESS) {
1132 "Can't get current video mode") );
1135 dc1394color_coding_t _coding;
1136 if (dc1394_is_video_mode_scalable(_videomode)) {
1138 if (dc1394_format7_get_color_coding(camera, _videomode, &_coding)
1139 != DC1394_SUCCESS) {
1144 "Can't query current color coding") );
1147 else if (dc1394_is_video_mode_still_image((dc1394video_mode_t)_videomode)) {
1149 "No color coding for format 6 video mode"));
1153 if (dc1394_get_color_coding_from_video_mode(camera,
1154 (dc1394video_mode_t)_videomode,
1155 &_coding) != DC1394_SUCCESS) {
1157 vpERROR_TRACE(
"Could not query supported color coding for mode %d\n",
1160 "Can't query current color coding"));
1189 std::list<vp1394TwoColorCodingType> & codings)
1191 if (! num_cameras) {
1195 "No camera found") );
1201 if (dc1394_is_video_mode_scalable((dc1394video_mode_t)mode)) {
1203 dc1394color_codings_t _codings;
1204 if (dc1394_format7_get_color_codings(camera,
1205 (dc1394video_mode_t)mode,
1206 &_codings) != DC1394_SUCCESS) {
1208 vpERROR_TRACE(
"Could not query supported color codings for mode %d\n",
1211 "Could not query supported color codings") );
1213 if (_codings.num == 0)
1216 for (
unsigned int i = 0; i < _codings.num; i ++)
1219 return _codings.num;
1221 else if (dc1394_is_video_mode_still_image((dc1394video_mode_t)mode)) {
1227 dc1394color_coding_t _coding;
1228 if (dc1394_get_color_coding_from_video_mode(camera,
1229 (dc1394video_mode_t)mode,
1230 &_coding) != DC1394_SUCCESS) {
1232 vpERROR_TRACE(
"Could not query supported color coding for mode %d\n",
1235 "Could not query supported color coding") );
1266 if (! num_cameras) {
1270 "No camera found") );
1274 if (dc1394_is_video_mode_scalable((dc1394video_mode_t)mode)) {
1276 dc1394color_codings_t _codings;
1277 if (dc1394_format7_get_color_codings(camera,
1278 (dc1394video_mode_t)mode,
1279 &_codings) != DC1394_SUCCESS) {
1281 vpERROR_TRACE(
"Could not query supported color codings for mode %d\n",
1284 "Could not query supported color codings") );
1286 if (_codings.num == 0)
1289 for (
unsigned int i = 0; i < _codings.num; i ++){
1295 else if (dc1394_is_video_mode_still_image((dc1394video_mode_t)mode)) {
1301 dc1394color_coding_t _coding;
1302 if (dc1394_get_color_coding_from_video_mode(camera,
1303 (dc1394video_mode_t)mode,
1304 &_coding) != DC1394_SUCCESS) {
1306 vpERROR_TRACE(
"Could not query supported color coding for mode %d\n",
1309 "Could not query supported color coding") );
1353 unsigned int w,
unsigned int h)
1356 if (! num_cameras) {
1360 "No camera found") );
1363 dc1394video_mode_t _videomode;
1364 if (dc1394_video_get_mode(camera, &_videomode) != DC1394_SUCCESS) {
1369 "Can't get current video mode") );
1371 if (dc1394_is_video_mode_scalable(_videomode)) {
1373 setTransmission(DC1394_OFF);
1374 setCapture(DC1394_OFF);
1376 unsigned int max_width, max_height;
1377 if (dc1394_format7_get_max_image_size(camera, _videomode,
1378 &max_width, &max_height)
1379 != DC1394_SUCCESS) {
1384 "Can't get format7 max image size") );
1387 vpTRACE(
"left: %d top: %d width: %d height: %d", left, top,
1388 width == 0 ? DC1394_USE_MAX_AVAIL: w,
1389 height == 0 ? DC1394_USE_MAX_AVAIL : h);
1390 vpTRACE(
"max_width: %d max_height: %d", max_width, max_height);
1393 if (left > max_width) {
1396 "Can't set format7 ROI") );
1398 if (top > max_height) {
1401 "Can't set format7 ROI") );
1409 if (w > (max_width - left))
1410 w = (max_width - left);
1411 roi_width = (int32_t)w;
1414 roi_width = DC1394_USE_MAX_AVAIL;
1419 if (h > (max_height - top))
1420 h = (max_height - top);
1421 roi_height = (int32_t)h;
1424 roi_height = DC1394_USE_MAX_AVAIL;
1427 if (dc1394_format7_set_roi(camera, _videomode,
1428 (dc1394color_coding_t) DC1394_QUERY_FROM_CAMERA,
1429 DC1394_USE_MAX_AVAIL,
1434 != DC1394_SUCCESS) {
1438 "Can't get current video mode") );
1441 if (dc1394_format7_get_image_size(camera, _videomode,
1444 != DC1394_SUCCESS) {
1448 "Can't get format7 image size") );
1451 setCapture(DC1394_ON);
1452 setTransmission(DC1394_ON);
1470 vp1394TwoGrabber::initialize(
bool reset)
1474 #ifdef VISP_HAVE_DC1394_CAMERA_ENUMERATE // new API > libdc1394-2.0.0-rc7
1479 if (dc1394_camera_enumerate (d, &list) != DC1394_SUCCESS) {
1480 dc1394_camera_free_list (list);
1484 "Failed to enumerate cameras") );
1487 if (list->num == 0) {
1488 dc1394_camera_free_list (list);
1492 "No cameras found") );
1495 if (cameras != NULL)
1498 cameras =
new dc1394camera_t * [list->num];
1502 for (
unsigned int i=0; i < list->num; i ++) {
1503 cameras[i] = dc1394_camera_new (d, list->ids[i].guid);
1505 vpTRACE (
"Failed to initialize camera with guid \"%ld\"\n",
1517 dc1394_reset_bus(cameras[0]);
1521 dc1394_camera_free_list (list);
1524 #elif defined VISP_HAVE_DC1394_FIND_CAMERAS // old API <= libdc1394-2.0.0-rc7
1525 if (cameras != NULL)
1528 int err = dc1394_find_cameras(&cameras, &num_cameras);
1530 if (err!=DC1394_SUCCESS && err != DC1394_NO_CAMERA) {
1534 " - if the kernel modules `ieee1394',`raw1394' and `ohci1394' are loaded \n"
1535 " - if you have read/write access to /dev/raw1394\n\n");
1537 "Unable to look for cameras") );
1542 if (num_cameras == 0) {
1546 "No cameras found") );
1550 isDataModified =
new bool[num_cameras];
1551 for(
unsigned int i=0; i<num_cameras; i++)
1552 isDataModified[i] =
false;
1553 initialShutterMode =
new dc1394feature_mode_t[num_cameras];
1554 dataCam =
new vpDc1394TwoCameraParametersData[num_cameras];
1556 if (camera_id >= num_cameras) {
1566 std::cout <<
"------ Bus information ------" << std::endl;
1567 std::cout <<
"Number of camera(s) on the bus : " << num_cameras <<std::endl;
1568 std::cout <<
"-----------------------------" << std::endl;
1571 if (camIsOpen != NULL)
delete [] camIsOpen;
1572 camIsOpen =
new bool [num_cameras];
1573 for (
unsigned int i = 0;i<num_cameras;i++){
1592 if (
init ==
false) initialize(
false);
1593 if (camIsOpen[camera_id] ==
false){
1594 dc1394switch_t status = DC1394_OFF;
1597 dc1394_video_get_transmission(cameras[camera_id], &status);
1598 if (status != DC1394_OFF){
1600 if (dc1394_video_set_transmission(cameras[camera_id],DC1394_OFF)!=DC1394_SUCCESS)
1601 vpTRACE(
"Could not stop ISO transmission");
1604 if (dc1394_video_get_transmission(cameras[camera_id], &status)!=DC1394_SUCCESS)
1605 vpTRACE(
"Could get ISO status");
1607 if (status==DC1394_ON) {
1608 vpTRACE(
"ISO transmission refuses to stop");
1610 #ifdef VISP_HAVE_DC1394_FIND_CAMERAS // old API <= libdc1394-2.0.0-rc7
1612 cameras[camera_id]->is_iso_on=status;
1621 setCapture(DC1394_ON);
1622 setTransmission(DC1394_ON);
1623 camIsOpen[camera_id] =
true;
1639 for (
unsigned int i = 0; i < num_cameras;i++) {
1641 camera = cameras[i];
1642 this->camera_id = i;
1643 setTransmission(DC1394_OFF);
1644 setCapture(DC1394_OFF);
1645 if(isDataModified[i]){
1648 updateDataStructToCam();
1653 if (dc1394_feature_set_mode(camera, DC1394_FEATURE_BRIGHTNESS, initialShutterMode[i]) != DC1394_SUCCESS ||
1654 dc1394_feature_set_mode(camera, DC1394_FEATURE_EXPOSURE, initialShutterMode[i]) != DC1394_SUCCESS ||
1655 dc1394_feature_set_mode(camera, DC1394_FEATURE_SHARPNESS, initialShutterMode[i]) != DC1394_SUCCESS ||
1656 dc1394_feature_set_mode(camera, DC1394_FEATURE_HUE, initialShutterMode[i]) != DC1394_SUCCESS ||
1657 dc1394_feature_set_mode(camera, DC1394_FEATURE_SATURATION, initialShutterMode[i]) != DC1394_SUCCESS ||
1658 dc1394_feature_set_mode(camera, DC1394_FEATURE_GAMMA, initialShutterMode[i]) != DC1394_SUCCESS ||
1659 dc1394_feature_set_mode(camera, DC1394_FEATURE_SHUTTER, initialShutterMode[i]) != DC1394_SUCCESS ||
1660 dc1394_feature_set_mode(camera, DC1394_FEATURE_GAIN, initialShutterMode[i]) != DC1394_SUCCESS ||
1661 dc1394_feature_set_mode(camera, DC1394_FEATURE_IRIS, initialShutterMode[i])){
1665 "Unable to reset the initial mode"));
1668 if (dc1394_camera_set_power(camera, DC1394_OFF) != DC1394_SUCCESS)
1669 std::cout <<
"Unable to turn camera off" << std::endl;
1671 #ifdef VISP_HAVE_DC1394_CAMERA_ENUMERATE // new API > libdc1394-2.0.0-rc7
1672 dc1394_camera_free(cameras[i]);
1673 #elif defined VISP_HAVE_DC1394_FIND_CAMERAS // old API <= libdc1394-2.0.0-rc7
1674 dc1394_free_camera(cameras[i]);
1678 if (camIsOpen != NULL) {
1679 delete [] camIsOpen;
1683 #ifdef VISP_HAVE_DC1394_CAMERA_ENUMERATE // new API > libdc1394-2.0.0-rc7
1684 if (cameras != NULL) {
1693 #elif defined VISP_HAVE_DC1394_FIND_CAMERAS // old API <= libdc1394-2.0.0-rc7
1694 if (cameras != NULL) {
1704 if(isDataModified != NULL){
1705 delete[] isDataModified;
1706 isDataModified = NULL;
1708 if(initialShutterMode != NULL){
1709 delete[] initialShutterMode;
1710 initialShutterMode = NULL;
1712 if(dataCam != NULL){
1738 "Could not set ring buffer size") );
1741 if (size != num_buffers) {
1744 if(camIsOpen[camera_id]){
1745 setCapture(DC1394_OFF);
1746 setCapture(DC1394_ON);
1808 if (! num_cameras) {
1812 "No camera found") );
1815 dc1394feature_mode_t mode;
1817 mode = DC1394_FEATURE_MODE_AUTO;
1820 mode = DC1394_FEATURE_MODE_MANUAL;
1823 if (dc1394_feature_set_power(camera, DC1394_FEATURE_SHUTTER, DC1394_ON)
1824 != DC1394_SUCCESS) {
1828 "Cannot set shutter on") );
1831 if (dc1394_feature_set_mode(camera,
1832 DC1394_FEATURE_SHUTTER,
1834 != DC1394_SUCCESS) {
1838 "Cannot set auto shutter") );
1886 if (dc1394_avt_set_auto_shutter(camera, minvalue, maxvalue)
1887 != DC1394_SUCCESS) {
1891 "Cannot set auto shutter min and max values") );
1910 if (! num_cameras) {
1914 "No camera found") );
1917 if (dc1394_avt_get_auto_shutter(camera, &minvalue, &maxvalue)
1918 != DC1394_SUCCESS) {
1922 "Cannot get auto shutter min and max values") );
1968 if (! num_cameras) {
1972 "No camera found") );
1975 dc1394feature_mode_t mode;
1977 mode = DC1394_FEATURE_MODE_AUTO;
1980 mode = DC1394_FEATURE_MODE_MANUAL;
1983 if (dc1394_feature_set_power(camera, DC1394_FEATURE_GAIN, DC1394_ON)
1984 != DC1394_SUCCESS) {
1988 "Cannot set shutter on") );
1991 if (dc1394_feature_set_mode(camera,
1992 DC1394_FEATURE_GAIN,
1994 != DC1394_SUCCESS) {
1998 "Cannot set auto gain") );
2046 if (dc1394_avt_set_auto_gain(camera, minvalue, maxvalue)
2047 != DC1394_SUCCESS) {
2051 "Cannot set auto gain min and max values") );
2070 if (! num_cameras) {
2074 "No camera found") );
2077 if (dc1394_avt_get_auto_gain(camera, &minvalue, &maxvalue)
2078 != DC1394_SUCCESS) {
2082 "Cannot get auto gain min and max values") );
2105 vp1394TwoGrabber::setCapture(dc1394switch_t _switch)
2107 if (! num_cameras) {
2111 "No camera found") );
2114 if (_switch == DC1394_ON) {
2117 if (dc1394_capture_setup(camera, num_buffers,
2118 DC1394_CAPTURE_FLAGS_DEFAULT) != DC1394_SUCCESS) {
2120 "make sure that the video mode and framerate are "
2121 "supported by your camera.\n");
2124 "Could not setup dma capture") );
2128 dc1394error_t code = dc1394_capture_stop(camera);
2130 if (code != DC1394_SUCCESS && code != DC1394_CAPTURE_IS_NOT_SET) {
2134 "Could not setup dma capture") );
2155 vp1394TwoGrabber::setTransmission(dc1394switch_t _switch)
2157 if (! num_cameras) {
2161 "No camera found") );
2164 dc1394switch_t status = DC1394_OFF;
2166 if (dc1394_video_get_transmission(camera, &status)!=DC1394_SUCCESS) {
2170 "Could not setup dma capture") );
2175 if (dc1394_video_set_transmission(camera, _switch) != DC1394_SUCCESS) {
2177 "make sure that the video mode and framerate are "
2178 "supported by your camera.\n");
2181 "Could not setup dma capture") );
2184 if (_switch == DC1394_ON) {
2185 status = DC1394_OFF;
2188 while ( status == DC1394_OFF && i++ < 5 ) {
2190 if (dc1394_video_get_transmission(camera, &status)!=DC1394_SUCCESS) {
2194 "Could not setup dma capture") );
2238 if (! num_cameras) {
2242 "No camera found") );
2245 dc1394operation_mode_t op_mode;
2246 dc1394speed_t speed;
2250 if (camera->bmode_capable != DC1394_TRUE) {
2255 "Camera is not 1394B mode capable") );
2258 if(dc1394_video_set_operation_mode(camera,
2259 DC1394_OPERATION_MODE_1394B)
2260 != DC1394_SUCCESS) {
2264 "Cannot set camera to 1394B mode") );
2267 if (dc1394_video_get_operation_mode(camera, &op_mode) != DC1394_SUCCESS) {
2271 "Failed to set 1394B mode") );
2275 if (dc1394_video_set_operation_mode(camera,
2276 DC1394_OPERATION_MODE_LEGACY)
2277 != DC1394_SUCCESS) {
2281 "Cannot set camera to 1394A mode") );
2284 if (dc1394_video_get_operation_mode(camera, &op_mode) != DC1394_SUCCESS) {
2288 "Failed to set 1394A mode") );
2292 if (dc1394_video_set_iso_speed(camera, (dc1394speed_t) isospeed)
2293 != DC1394_SUCCESS) {
2297 "Cannot set requested iso speed") );
2300 if (dc1394_video_get_iso_speed(camera, &speed) != DC1394_SUCCESS) {
2304 "Failed to set iso speed") );
2381 dc1394video_frame_t *
2385 if (! num_cameras) {
2389 "No camera found") );
2392 dc1394video_frame_t *frame = NULL;
2394 if (dc1394_capture_dequeue(camera, DC1394_CAPTURE_POLICY_WAIT, &frame)
2396 vpERROR_TRACE (
"Error: Failed to capture from camera %d\n", camera_id);
2443 dc1394video_frame_t *
2449 dc1394video_frame_t *frame;
2451 frame =
dequeue(I, timestamp,
id);
2504 dc1394video_frame_t *
2506 uint64_t ×tamp,
2512 dc1394video_frame_t *frame;
2518 timestamp = frame->timestamp;
2521 this->
width = frame->size[0];
2522 this->
height = frame->size[1];
2528 switch(frame->color_coding) {
2529 case DC1394_COLOR_CODING_MONO8:
2530 case DC1394_COLOR_CODING_RAW8:
2531 memcpy(I.
bitmap, (
unsigned char *) frame->image,
2532 size*
sizeof(
unsigned char));
2534 case DC1394_COLOR_CODING_MONO16:
2535 case DC1394_COLOR_CODING_RAW16:
2540 case DC1394_COLOR_CODING_YUV411:
2545 case DC1394_COLOR_CODING_YUV422:
2550 case DC1394_COLOR_CODING_YUV444:
2555 case DC1394_COLOR_CODING_RGB8:
2562 vpERROR_TRACE(
"Format conversion not implemented. Acquisition failed.");
2564 "Format conversion not implemented. "
2565 "Acquisition failed.") );
2612 dc1394video_frame_t *
2618 dc1394video_frame_t *frame;
2620 frame =
dequeue(I, timestamp,
id);
2673 dc1394video_frame_t *
2675 uint64_t ×tamp,
2681 dc1394video_frame_t *frame;
2687 timestamp = frame->timestamp;
2690 this->
width = frame->size[0];
2691 this->
height = frame->size[1];
2697 switch (frame->color_coding) {
2698 case DC1394_COLOR_CODING_MONO8:
2699 case DC1394_COLOR_CODING_RAW8:
2701 (
unsigned char *) I.
bitmap, size);
2704 case DC1394_COLOR_CODING_MONO16:
2705 case DC1394_COLOR_CODING_RAW16:
2707 (
unsigned char *) I.
bitmap, size);
2710 case DC1394_COLOR_CODING_YUV411:
2712 (
unsigned char *) I.
bitmap, size);
2715 case DC1394_COLOR_CODING_YUV422:
2717 (
unsigned char *) I.
bitmap, size);
2720 case DC1394_COLOR_CODING_YUV444:
2722 (
unsigned char *) I.
bitmap, size);
2725 case DC1394_COLOR_CODING_RGB8:
2727 (
unsigned char *) I.
bitmap, size);
2733 vpERROR_TRACE(
"Format conversion not implemented. Acquisition failed.");
2735 "Format conversion not implemented. "
2736 "Acquisition failed.") );
2757 if (! num_cameras) {
2761 "No camera found") );
2765 dc1394_capture_enqueue(camera, frame);
2788 dc1394video_frame_t *frame;
2790 frame =
dequeue(I, timestamp,
id);
2814 uint64_t ×tamp,
2817 dc1394video_frame_t *frame;
2820 frame =
dequeue(I, timestamp,
id);
2844 dc1394video_frame_t *frame;
2847 frame =
dequeue(I, timestamp,
id);
2871 uint64_t ×tamp,
2874 dc1394video_frame_t *frame;
2880 timestamp = frame->timestamp;
2883 this->
width = frame->size[0];
2884 this->
height = frame->size[1];
2890 switch (frame->color_coding) {
2891 case DC1394_COLOR_CODING_MONO8:
2892 case DC1394_COLOR_CODING_RAW8:
2894 (
unsigned char *) I.
bitmap, size);
2897 case DC1394_COLOR_CODING_YUV411:
2899 (
unsigned char *) I.
bitmap, size);
2902 case DC1394_COLOR_CODING_YUV422:
2904 (
unsigned char *) I.
bitmap, size);
2907 case DC1394_COLOR_CODING_YUV444:
2909 (
unsigned char *) I.
bitmap, size);
2912 case DC1394_COLOR_CODING_RGB8:
2914 (
unsigned char *) I.
bitmap, size);
2920 vpERROR_TRACE(
"Format conversion not implemented. Acquisition failed.");
2922 "Format conversion not implemented. "
2923 "Acquisition failed.") );
2949 if (! num_cameras) {
2953 "No camera found") );
2977 if (! num_cameras) {
2981 "No camera found") );
3006 if (! num_cameras) {
3010 "No camera found") );
3034 if (! num_cameras) {
3038 "No camera found") );
3052 std::cout <<
"----------------------------------------------------------"
3054 <<
"----- Information for camera " << camera_id
3055 <<
" -----" << std::endl
3056 <<
"----------------------------------------------------------" << std::endl;
3058 #ifdef VISP_HAVE_DC1394_CAMERA_ENUMERATE // new API > libdc1394-2.0.0-rc7
3059 dc1394_camera_print_info( camera, stdout);
3060 #elif defined VISP_HAVE_DC1394_FIND_CAMERAS // old API <= libdc1394-2.0.0-rc7
3061 dc1394_print_camera_info( camera);
3064 dc1394featureset_t features;
3065 #ifdef VISP_HAVE_DC1394_CAMERA_ENUMERATE // new API > libdc1394-2.0.0-rc7
3066 if (dc1394_feature_get_all(camera, &features) != DC1394_SUCCESS)
3067 #elif defined VISP_HAVE_DC1394_FIND_CAMERAS // old API <= libdc1394-2.0.0-rc7
3068 if (dc1394_get_camera_feature_set(camera, &features) != DC1394_SUCCESS)
3072 vpERROR_TRACE(
"unable to get feature set for camera %d\n", camera_id);
3074 "Cannot get camera features") );
3077 #ifdef VISP_HAVE_DC1394_CAMERA_ENUMERATE // new API > libdc1394-2.0.0-rc7
3078 dc1394_feature_print_all(&features, stdout);
3079 #elif defined VISP_HAVE_DC1394_FIND_CAMERAS // old API <= libdc1394-2.0.0-rc7
3080 dc1394_print_feature_set(&features);
3083 std::cout <<
"----------------------------------------------------------" << std::endl;
3100 std::string _str =
"";
3101 dc1394video_mode_t _videomode = (dc1394video_mode_t) videomode;
3103 if ((_videomode >= DC1394_VIDEO_MODE_MIN)
3104 && (_videomode <= DC1394_VIDEO_MODE_MAX)) {
3105 _str =
strVideoMode[_videomode - DC1394_VIDEO_MODE_MIN];
3108 vpCERROR <<
"The video mode " << (int)videomode
3109 <<
" is not supported by the camera" << std::endl;
3129 std::string _str =
"";
3130 dc1394framerate_t _fps = (dc1394framerate_t) fps;
3132 if ((_fps >= DC1394_FRAMERATE_MIN)
3133 && (_fps <= DC1394_FRAMERATE_MAX)) {
3137 vpCERROR <<
"The framerate " << (int)fps
3138 <<
" is not supported by the camera" << std::endl;
3158 std::string _str =
"";
3159 dc1394color_coding_t _coding = (dc1394color_coding_t) colorcoding;
3161 if ((_coding >= DC1394_COLOR_CODING_MIN)
3162 && (_coding <= DC1394_COLOR_CODING_MAX)) {
3167 vpCERROR <<
"The color coding " << (int)colorcoding
3168 <<
" is not supported by the camera" << std::endl;
3196 for (
int i = DC1394_VIDEO_MODE_MIN; i <= DC1394_VIDEO_MODE_MAX; i ++) {
3203 "The required videomode is not valid") );
3231 for (
int i = DC1394_FRAMERATE_MIN; i <= DC1394_FRAMERATE_MAX; i ++) {
3238 "The required framerate is not valid") );
3265 for (
int i = DC1394_COLOR_CODING_MIN; i <= DC1394_COLOR_CODING_MAX; i ++) {
3272 "The required color coding is not valid") );
3311 for (
unsigned int i = 0; i < num_cameras;i++) {
3313 camera = cameras[i];
3314 setTransmission(DC1394_OFF);
3315 setCapture(DC1394_OFF);
3318 #ifdef VISP_HAVE_DC1394_CAMERA_ENUMERATE // new API > libdc1394-2.0.0-rc7
3321 for (
unsigned int i=0;i<num_cameras;i++){
3322 if (i!=camera_id) dc1394_camera_free(cameras[i]);
3325 printf (
"Reseting bus...\n");
3326 dc1394_reset_bus (camera);
3328 dc1394_camera_free (camera);
3334 #elif defined VISP_HAVE_DC1394_FIND_CAMERAS // old API <= libdc1394-2.0.0-rc7
3338 for (
unsigned int i=0;i<num_cameras;i++){
3339 if (i!=camera_id) dc1394_free_camera(cameras[i]);
3344 dc1394_reset_bus(camera);
3345 dc1394_free_camera(camera);
3348 if (camIsOpen != NULL)
3349 delete [] camIsOpen;
3391 if (! num_cameras) {
3395 "No camera found") );
3397 uint64_t offset = 0x884;
3398 uint32_t value = 0x82000000 + (uint32_t)panControlValue;
3400 err = dc1394_set_control_register(camera, offset, value);
3401 if (err != DC1394_SUCCESS) {
3405 "Unable to set PAN register") );
3428 if (! num_cameras) {
3432 "No camera found") );
3436 dc1394feature_t feature = DC1394_FEATURE_BRIGHTNESS;
3463 err = dc1394_feature_get_value(camera, feature, &value);
3464 if (err != DC1394_SUCCESS) {
3468 "Unable to get the information") );
3470 return (
unsigned int)value;
3497 if (! num_cameras) {
3501 "No camera found") );
3503 uint32_t value = (uint32_t)val;
3504 dc1394feature_t feature = DC1394_FEATURE_BRIGHTNESS;
3531 dc1394bool_t hasManualMode = DC1394_FALSE;
3532 dc1394feature_modes_t modesAvailable;
3535 err = dc1394_feature_get_modes(camera, feature, &modesAvailable);
3536 if (err != DC1394_SUCCESS) {
3537 vpERROR_TRACE(
"Unable to detect the manual mode information");
3540 "Unable to detect the manual mode information"));
3543 for(
unsigned int i=0; i<modesAvailable.num; i++){
3544 if(modesAvailable.modes[i] == DC1394_FEATURE_MODE_MANUAL){
3545 hasManualMode = DC1394_TRUE;
3549 if(hasManualMode == DC1394_TRUE){
3551 if(!isDataModified[camera_id]){
3553 updateDataCamToStruct();
3554 err = dc1394_feature_get_mode(camera, feature, &(initialShutterMode[camera_id]));
3555 if (err != DC1394_SUCCESS) {
3559 "Unable to get the initial mode"));
3561 isDataModified[camera_id] =
true;
3564 dc1394feature_mode_t manualMode = DC1394_FEATURE_MODE_MANUAL;
3565 err = dc1394_feature_set_mode(camera, feature, manualMode);
3566 if (err != DC1394_SUCCESS) {
3570 "Unable to set the manual mode") );
3572 err = dc1394_feature_set_value(camera, feature, value);
3573 if (err != DC1394_SUCCESS) {
3577 "Unable to set the shutter information") );
3581 vpERROR_TRACE(
"The camera does not have a manual mode.\nCannot change the value");
3583 "The camera does not have a manual mode"));
3596 if (! num_cameras) {
3600 "No camera found") );
3603 guid = camera->guid;
3616 if (! num_cameras) {
3620 "No camera found") );
3623 return camera->guid;
3632 vp1394TwoGrabber::updateDataCamToStruct()
3650 vp1394TwoGrabber::updateDataStructToCam()
3663 #elif !defined(VISP_BUILD_SHARED_LIBS)
3665 void dummy_vp1394TwoGrabber() {};
void getColorCoding(vp1394TwoColorCodingType &coding)
static const char * strFramerate[DC1394_FRAMERATE_NUM]
VISP_EXPORT int wait(double t0, double t)
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)
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)
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]
static void MONO16ToRGBa(unsigned char *grey16, unsigned char *rgba, unsigned int size)
void resize(const unsigned int h, const unsigned int w)
set the size of the image without initializing it.
void enqueue(dc1394video_frame_t *frame)
static vp1394TwoFramerateType string2framerate(std::string fps)
void getFramerate(vp1394TwoFramerateType &fps)
static std::string videoMode2string(vp1394TwoVideoModeType videomode)
bool init
Set to true if the frame grabber has been initialized.
void setParameterValue(vp1394TwoParametersType param, unsigned int val)
static void YUV444ToGrey(unsigned char *yuv, unsigned char *grey, unsigned int size)
virtual ~vp1394TwoGrabber()
bool isColorCodingSupported(vp1394TwoVideoModeType videomode, vp1394TwoColorCodingType coding)
static void YUV411ToRGBa(unsigned char *yuv, unsigned char *rgba, unsigned int size)
unsigned int getRingBufferSize() const
void setFramerate(vp1394TwoFramerateType fps)
dc1394video_frame_t * dequeue()
void getAutoShutter(unsigned int &minvalue, unsigned int &maxvalue)
void setVideoMode(vp1394TwoVideoModeType videomode)
void setPanControl(unsigned int panControlValue)
uint32_t getFramerateSupported(vp1394TwoVideoModeType videomode, std::list< vp1394TwoFramerateType > &fps)
unsigned int getHeight() const
bool isVideoModeSupported(vp1394TwoVideoModeType videomode)
static void YUV411ToGrey(unsigned char *yuv, unsigned char *grey, unsigned int size)
unsigned int getNumCameras() const
void getVideoMode(vp1394TwoVideoModeType &videomode)
unsigned int width
Number of columns in the image.
void setAutoShutter(bool enable=true)