50 #include <visp/vpConfig.h>
52 #ifdef VISP_BUILD_DEPRECATED_FUNCTIONS
53 #if defined(VISP_HAVE_DC1394_1)
57 #include <visp/vp1394Grabber.h>
58 #include <visp/vpFrameGrabberException.h>
59 #include <visp/vpImageIo.h>
60 #include <visp/vpImageConvert.h>
79 "Format_0, Mode_0: 160x120 YUV (4:4:4)",
80 "Format_0, Mode_1: 320x240 YUV (4:2:2)",
81 "Format_0, Mode_2: 640x480 YUV (4:1:1)",
82 "Format_0, Mode_3: 640x480 YUV (4:2:2)",
83 "Format_0, Mode_4: 640x480 RGB 24bpp",
84 "Format_0, Mode_5: 640x480 Mono 8bpp",
85 "Format_0, Mode_6: 640x480 Mono 16bpp"
89 "Format_1, Mode_0: 800x600 YUV (4:2:2)",
90 "Format_1, Mode_1: 800x600 RGB 24bpp",
91 "Format_1, Mode_2: 800x600 Mono 8bpp",
92 "Format_1, Mode_3: 1024x768 YUV (4:2:2)",
93 "Format_1, Mode_4: 1024x768 RGB 24bpp",
94 "Format_1, Mode_5: 1024x768 Mono 8bpp",
95 "Format_1, Mode_6: 800x600 Mono 16bpp",
96 "Format_1, Mode_7: 1024x768 Mono 16bpp"
100 "Format_2, Mode_0: 1280x960 YUV (4:2:2)",
101 "Format_2, Mode_1: 1280x960 RGB 24bpp",
102 "Format_2, Mode_2: 1280x960 Mono 8bpp",
103 "Format_2, Mode_3: 1600x1200 YUV (4:2:2)",
104 "Format_2, Mode_4: 1600x1200 RGB 24bpp",
105 "Format_2, Mode_5: 1600x1200 Mono 8bpp",
106 "Format_2, Mode_6: 1280x960 Mono 16bpp",
107 "Format_2, Mode_7: 1600x1200 Mono 16bpp"
111 "Format6, Mode_0: EXIT (not supported)"
126 "Format_7 Color, Mono 8bpp",
127 "Format_7 Color, YUV 4:1:1",
128 "Format_7 Color, YUV 4:2:2",
129 "Format_7 Color, YUV 4:4:4",
130 "Format_7 Color, RGB 24bpp",
131 "Format_7 Color, Mono 16bpp",
132 "Format_7 Color, RGB 48bpp"
174 sprintf(device_name,
"/dev/video1394/0");
195 iso_transmission_started =
false;
196 handle_created =
false;
197 camera_found =
false;
206 image_format[i] =
RGB;
242 sprintf(device_name,
"/dev/video1394/0");
263 iso_transmission_started =
false;
264 handle_created =
false;
265 camera_found =
false;
273 image_format[i] =
RGB;
326 if (camera >= num_cameras) {
330 "The required camera is not present") );
333 this->camera = camera;
350 camera = this->camera;
382 if (iso_transmission_started ==
true) {
384 stopIsoTransmission();
386 for (
unsigned int i=0; i < num_cameras; i++)
387 dc1394_dma_unlisten( handles[i], &cameras[i] );
388 iso_transmission_started =
false;
391 this->pformat[camera] = format;
394 startIsoTransmission();
423 if (handle_created ==
false) {
425 vpERROR_TRACE(
"To set the shutter the handle must be created");
427 "To set the shutter the handle must be created") );
429 if (camera_found ==
false) {
431 vpERROR_TRACE(
"To set the shutter a camera must be connected");
433 "To set the shutter a camera must be connected") );
436 if(dc1394_get_camera_misc_info(handles[camera],
437 cameras[camera].node,
438 &miscinfo) !=DC1394_SUCCESS) {
441 "Unable to get misc info") );
444 format = miscinfo.format;
473 if (handle_created ==
false) {
475 vpERROR_TRACE(
"To set the shutter the handle must be created");
477 "To set the shutter the handle must be created") );
479 if (camera_found ==
false) {
481 vpERROR_TRACE(
"To set the shutter a camera must be connected");
483 "To set the shutter a camera must be connected") );
487 if (dc1394_query_supported_formats(handles[camera],
488 cameras[camera].node,
489 &value) != DC1394_SUCCESS) {
492 "Could not query supported formats") );
495 if (value & (0x1<<31)) {
496 formats.
addRight(FORMAT_VGA_NONCOMPRESSED);
499 if (value & (0x1<<30)) {
500 formats.
addRight(FORMAT_SVGA_NONCOMPRESSED_1);
503 if (value & (0x1<<29)) {
504 formats.
addRight(FORMAT_SVGA_NONCOMPRESSED_2);
507 if (value & (0x1<<25)) {
508 formats.
addRight(FORMAT_STILL_IMAGE);
511 if (value & (0x1<<24)) {
512 formats.
addRight(FORMAT_SCALABLE_IMAGE_SIZE);
556 if (iso_transmission_started ==
true) {
558 stopIsoTransmission();
560 for (
unsigned int i=0; i < num_cameras; i++)
561 dc1394_dma_unlisten( handles[i], &cameras[i] );
562 iso_transmission_started =
false;
565 this->pmode[camera] = mode;
568 startIsoTransmission();
591 if (handle_created ==
false) {
593 vpERROR_TRACE(
"To set the shutter the handle must be created");
595 "To set the shutter the handle must be created") );
597 if (camera_found ==
false) {
599 vpERROR_TRACE(
"To set the shutter a camera must be connected");
601 "To set the shutter a camera must be connected") );
603 if(dc1394_get_camera_misc_info(handles[camera],
604 cameras[camera].node,
605 &miscinfo) !=DC1394_SUCCESS) {
608 "Unable to get misc info") );
611 mode = miscinfo.mode;
647 if (handle_created ==
false) {
649 vpERROR_TRACE(
"To set the shutter the handle must be created");
651 "To set the shutter the handle must be created") );
653 if (camera_found ==
false) {
655 vpERROR_TRACE(
"To set the shutter a camera must be connected");
657 "To set the shutter a camera must be connected") );
661 if (dc1394_query_supported_modes(handles[camera],
662 cameras[camera].node,
663 format, &value) != DC1394_SUCCESS) {
664 vpERROR_TRACE(
"Could not query supported modes for format %d\n", format);
666 "Could not query supported mode") );
670 case FORMAT_VGA_NONCOMPRESSED:
671 for (
int m = MODE_FORMAT0_MIN; m <= MODE_FORMAT0_MAX; m ++) {
672 if (value & (0x1<<(31-(m-MODE_FORMAT0_MIN)))) {
679 case FORMAT_SVGA_NONCOMPRESSED_1:
680 for (
int m = MODE_FORMAT1_MIN; m <= MODE_FORMAT1_MAX; m ++) {
681 if (value & (0x1<<(31-(m-MODE_FORMAT1_MIN)))) {
688 case FORMAT_SVGA_NONCOMPRESSED_2:
689 for (
int m = MODE_FORMAT2_MIN; m <= MODE_FORMAT2_MAX; m ++) {
690 if (value & (0x1<<(31-(m-MODE_FORMAT2_MIN)))) {
697 case FORMAT_STILL_IMAGE:
698 for (
int m = MODE_FORMAT6_MIN; m <= MODE_FORMAT6_MAX; m ++) {
699 if (value & (0x1<<(31-(m-MODE_FORMAT6_MIN)))) {
706 case FORMAT_SCALABLE_IMAGE_SIZE:
707 for (
int m = MODE_FORMAT7_MIN; m <= MODE_FORMAT7_MAX; m ++) {
708 if (value & (0x1<<(31-(m-MODE_FORMAT7_MIN)))) {
748 if (iso_transmission_started ==
true) {
750 stopIsoTransmission();
752 for (
unsigned int i=0; i < num_cameras; i++)
753 dc1394_dma_unlisten( handles[i], &cameras[i] );
754 iso_transmission_started =
false;
757 this->pframerate[camera] = framerate;
760 startIsoTransmission();
785 if (handle_created ==
false) {
787 vpERROR_TRACE(
"To set the shutter the handle must be created");
789 "To set the shutter the handle must be created") );
791 if (camera_found ==
false) {
793 vpERROR_TRACE(
"To set the shutter a camera must be connected");
795 "To set the shutter a camera must be connected") );
798 if(dc1394_get_camera_misc_info(handles[camera],
799 cameras[camera].node,
800 &miscinfo) !=DC1394_SUCCESS) {
803 "Unable to get misc info") );
806 framerate = miscinfo.framerate;
844 if (handle_created ==
false) {
846 vpERROR_TRACE(
"To set the shutter the handle must be created");
848 "To set the shutter the handle must be created") );
850 if (camera_found ==
false) {
852 vpERROR_TRACE(
"To set the shutter a camera must be connected");
854 "To set the shutter a camera must be connected") );
858 case FORMAT_VGA_NONCOMPRESSED:
859 case FORMAT_SVGA_NONCOMPRESSED_1:
860 case FORMAT_SVGA_NONCOMPRESSED_2:
864 if (dc1394_query_supported_framerates(handles[camera],
865 cameras[camera].node,
867 &value) != DC1394_SUCCESS) {
868 vpERROR_TRACE(
"Could not query supported frametates for format %d\n"
869 "and mode %d\n", format, mode);
871 "Could not query supported framerates") );
874 for (
int f = FRAMERATE_MIN; f <= FRAMERATE_MAX; f ++) {
875 if (value & (0x1<<(31-(f-FRAMERATE_MIN)))) {
913 for (
int i = FORMAT_MIN; i <= FORMAT_MAX; i ++) {
938 for (
int i = MODE_FORMAT0_MIN; i <= MODE_FORMAT0_MAX; i ++) {
942 for (
int i = MODE_FORMAT1_MIN; i <= MODE_FORMAT1_MAX; i ++) {
946 for (
int i = MODE_FORMAT2_MIN; i <= MODE_FORMAT2_MAX; i ++) {
950 for (
int i = MODE_FORMAT6_MIN; i <= MODE_FORMAT6_MAX; i ++) {
954 for (
int i = MODE_FORMAT7_MIN; i <= MODE_FORMAT7_MAX; i ++) {
958 for (
int i = COLOR_FORMAT7_MIN; i <= COLOR_FORMAT7_MAX; i ++) {
982 for (
int i = FRAMERATE_MIN; i <= FRAMERATE_MAX; i ++) {
1011 std::string _format;
1012 if ((format >= FORMAT_MIN) && (format <= FORMAT_MAX)) {
1014 case FORMAT_VGA_NONCOMPRESSED: _format =
strFormats[0];
break;
1015 case FORMAT_SVGA_NONCOMPRESSED_1: _format =
strFormats[1];
break;
1016 case FORMAT_SVGA_NONCOMPRESSED_2: _format =
strFormats[2];
break;
1018 case FORMAT_SVGA_NONCOMPRESSED_2 + 1: _format =
strFormats[3];
break;
1019 case FORMAT_SVGA_NONCOMPRESSED_2 + 2: _format =
strFormats[4];
break;
1020 case FORMAT_SVGA_NONCOMPRESSED_2 + 3: _format =
strFormats[5];
break;
1022 case FORMAT_STILL_IMAGE: _format =
strFormats[6];
break;
1023 case FORMAT_SCALABLE_IMAGE_SIZE: _format =
strFormats[7];
break;
1029 std::cout <<
"The format " << format
1030 <<
" is not supported by the camera" << std::endl;
1031 _format =
"Not Valid";
1053 if ((mode >= MODE_FORMAT0_MIN) && (mode <= MODE_FORMAT0_MAX)) {
1065 else if ((mode >= MODE_FORMAT1_MIN) && (mode <= MODE_FORMAT1_MAX)) {
1078 else if ((mode >= MODE_FORMAT2_MIN) && (mode <= MODE_FORMAT2_MAX)) {
1091 else if ((mode >= MODE_FORMAT6_MIN) && (mode <= MODE_FORMAT6_MAX)) {
1097 else if ((mode >= MODE_FORMAT7_MIN) && (mode <= MODE_FORMAT7_MAX)) {
1110 else if ((mode >= COLOR_FORMAT7_MIN) && (mode <= COLOR_FORMAT7_MAX)) {
1123 std::cout <<
"The mode " << mode <<
" is not supported by the camera" << std::endl;
1124 _mode =
"Not valid";
1145 std::string _framerate;
1147 if ((framerate >= FRAMERATE_MIN) && (framerate <= FRAMERATE_MAX)) {
1148 switch (framerate) {
1159 std::cout <<
"The framerate " << framerate
1160 <<
" is not supported by the camera" << std::endl;
1161 _framerate =
"Not valid";
1185 unsigned int min_shutter = 0;
1186 unsigned int max_shutter = 0;
1189 if (handle_created ==
false) {
1191 vpERROR_TRACE(
"To set the shutter the handle must be created");
1193 "To set the shutter the handle must be created") );
1195 if (camera_found ==
false) {
1197 vpERROR_TRACE(
"To set the shutter a camera must be connected");
1199 "To set the shutter a camera must be connected") );
1202 if(dc1394_get_min_value(handles[camera],
1203 cameras[camera].node,
1204 FEATURE_SHUTTER, &min_shutter) !=DC1394_SUCCESS) {
1208 "Unable to get min shutter value") );
1211 if(dc1394_get_max_value(handles[camera],
1212 cameras[camera].node,
1213 FEATURE_SHUTTER, &max_shutter) !=DC1394_SUCCESS) {
1217 "Unable to get max shutter value") );
1220 if (shutter < min_shutter || shutter > max_shutter) {
1221 vpCERROR <<
"The requested shutter " << shutter
1222 <<
" must be comprised between " << min_shutter
1223 <<
" and " << max_shutter << std::endl;
1225 "Cannot set shutter: bad value") );
1228 if ( dc1394_set_shutter(handles[camera],
1229 cameras[camera].node,
1230 shutter) != DC1394_SUCCESS) {
1233 "Cannot set shutter") );
1261 unsigned int &shutter,
1262 unsigned int &max_shutter)
1268 if (handle_created ==
false) {
1270 vpERROR_TRACE(
"To set the shutter the handle must be created");
1272 "To set the shutter the handle must be created") );
1274 if (camera_found ==
false) {
1276 vpERROR_TRACE(
"To set the shutter a camera must be connected");
1278 "To set the shutter a camera must be connected") );
1280 if(dc1394_get_shutter(handles[camera],
1281 cameras[camera].node,
1282 &shutter) !=DC1394_SUCCESS) {
1286 "Unable to get shutter value") );
1290 if(dc1394_get_min_value(handles[camera],
1291 cameras[camera].node,
1292 FEATURE_SHUTTER, &min_shutter) !=DC1394_SUCCESS) {
1296 "Unable to get min shutter value") );
1299 if(dc1394_get_max_value(handles[camera],
1300 cameras[camera].node,
1301 FEATURE_SHUTTER, &max_shutter) !=DC1394_SUCCESS) {
1305 "Unable to get max shutter value") );
1325 unsigned int min_gain = 0;
1326 unsigned int max_gain = 0;
1329 if (handle_created ==
false) {
1331 vpERROR_TRACE(
"To set the shutter the handle must be created");
1333 "To set the shutter the handle must be created") );
1335 if (camera_found ==
false) {
1337 vpERROR_TRACE(
"To set the shutter a camera must be connected");
1339 "To set the shutter a camera must be connected") );
1341 if(dc1394_get_min_value(handles[camera],
1342 cameras[camera].node,
1343 FEATURE_GAIN, &min_gain) !=DC1394_SUCCESS) {
1347 "Unable to get min gain value") );
1350 if(dc1394_get_max_value(handles[camera],
1351 cameras[camera].node,
1352 FEATURE_GAIN, &max_gain) !=DC1394_SUCCESS) {
1356 "Unable to get max gain value") );
1359 if (gain < min_gain || gain > max_gain) {
1360 vpCERROR <<
"The requested gain " << gain
1361 <<
" must be comprised between " << min_gain
1362 <<
" and " << max_gain << std::endl;
1364 "Cannot set shutter: bad value") );
1367 if ( dc1394_set_gain(handles[camera],
1368 cameras[camera].node,
1369 gain) != DC1394_SUCCESS) {
1372 "Cannot set gain") );
1400 unsigned int &max_gain)
1406 if (handle_created ==
false) {
1408 vpERROR_TRACE(
"To set the shutter the handle must be created");
1410 "To set the shutter the handle must be created") );
1412 if (camera_found ==
false) {
1414 vpERROR_TRACE(
"To set the shutter a camera must be connected");
1416 "To set the shutter a camera must be connected") );
1419 if(dc1394_get_gain(handles[camera],
1420 cameras[camera].node,
1421 &gain) !=DC1394_SUCCESS) {
1425 "Unable to get gain value") );
1429 if(dc1394_get_min_value(handles[camera],
1430 cameras[camera].node,
1431 FEATURE_GAIN, &min_gain) !=DC1394_SUCCESS) {
1435 "Unable to get min gain value") );
1438 if(dc1394_get_max_value(handles[camera],
1439 cameras[camera].node,
1440 FEATURE_GAIN, &max_gain) !=DC1394_SUCCESS) {
1444 "Unable to get max gain value") );
1466 if (camera >= num_cameras) {
1470 "The required camera is not present") );
1473 width = this->_width[camera];
1474 this->width =
width;
1495 if (camera >= num_cameras) {
1499 "The required camera is not present") );
1502 height = this->_height[camera];
1517 if (camera_found ==
false) {
1518 vpCTRACE <<
"No camera found..."<< std::endl;
1522 cameras = num_cameras;
1544 startIsoTransmission();
1576 startIsoTransmission();
1608 "Initialization not done") );
1611 int *bitmap = NULL ;
1612 bitmap = dmaCapture();
1622 switch (image_format[camera])
1625 memcpy(I.
bitmap, (
unsigned char *) bitmap, size*
sizeof(
unsigned char));
1645 "Format conversion not implemented. Acquisition failed.") );
1649 dmaDoneWithBuffer();
1671 "Initialization not done") );
1674 int *bitmap = NULL ;
1675 bitmap = dmaCapture();
1685 switch (image_format[camera])
1689 (
unsigned char *) I.
bitmap, size);
1693 (
unsigned char *) I.
bitmap, size);
1698 (
unsigned char *) I.
bitmap, size);
1703 (
unsigned char *) I.
bitmap, size);
1707 memcpy((
unsigned char *) I.
bitmap, (
unsigned char *) bitmap, size);
1712 "Format conversion not implemented. Acquisition failed.") );
1716 dmaDoneWithBuffer();
1732 vp1394Grabber::open()
1737 raw1394handle_t raw_handle;
1739 if (handles == NULL)
1741 if (cameras == NULL)
1743 if (cam_count == NULL)
1745 if (pformat == NULL)
1749 if (pframerate == NULL)
1753 if (_height == NULL)
1755 if (image_format == NULL)
1758 raw_handle = raw1394_new_handle();
1760 if (raw_handle==NULL) {
1764 " - if the kernel modules `ieee1394',`raw1394' and `ohci1394' are loaded \n"
1765 " - if you have read/write access to /dev/raw1394\n\n");
1767 "Unable to aquire a raw1394 handle") );
1770 num_ports = raw1394_get_port_info(raw_handle, ports, num_ports);
1771 raw1394_destroy_handle(raw_handle);
1773 printf(
"number of ports detected: %d\n", num_ports);
1775 if (num_ports < 1) {
1778 "no ports found") );
1785 for (
int p = 0; p < num_ports; p++) {
1788 raw_handle = raw1394_new_handle();
1789 raw1394_set_port( raw_handle, p );
1791 camera_nodes = NULL;
1792 camera_nodes = dc1394_get_camera_nodes(raw_handle, &cam_count[p], 0);
1793 raw1394_destroy_handle(raw_handle);
1795 fprintf(stdout,
"%d camera(s) on port %d\n", cam_count[p], p);
1797 for (
int i = 0; i < cam_count[p]; i++, num_cameras ++) {
1798 handles[num_cameras] = dc1394_create_handle(p);
1799 if (handles[num_cameras]==NULL) {
1804 "Unable to aquire a raw1394 handle.") );
1806 cameras[num_cameras].node = camera_nodes[i];
1810 dc1394_free_camera_nodes(camera_nodes);
1813 if (num_cameras < 1) {
1816 "no cameras found") );
1820 camera_found =
true;
1822 handle_created =
true;
1845 vp1394Grabber::setup()
1847 unsigned int channel;
1850 if ( handle_created ==
true && camera_found ==
true) {
1852 for (
unsigned int i = 0; i < num_cameras; i++) {
1854 dc1394_feature_set features;
1856 if(dc1394_get_camera_feature_set(handles[i],
1858 &features) != DC1394_SUCCESS) {
1862 "Unable to get feature set") );
1865 dc1394_print_feature_set(&features);
1870 getImageCharacteristics(pformat[i],
1876 if (dc1394_get_iso_channel_and_speed(handles[i],
1879 &speed) != DC1394_SUCCESS) {
1882 "Unable to get the iso channel number") );
1885 if (pformat[i] == FORMAT_SCALABLE_IMAGE_SIZE) {
1886 if( dc1394_dma_setup_format7_capture(handles[i],
1898 &cameras[i]) != DC1394_SUCCESS) {
1901 vpERROR_TRACE(
"Unable to setup camera in format 7 mode 0-\n"
1902 "check line %d of %s to"
1903 "make sure that the video mode,framerate and format are "
1904 "supported by your camera.\n",
1908 "Unable to setup camera in format 7 ") );
1913 if (dc1394_query_format7_byte_per_packet(handles[i],
1916 &qpp) != DC1394_SUCCESS) {
1920 "Unable to query format7 byte_per_packet ") );
1927 if (dc1394_dma_setup_capture(handles[i],
1937 &cameras[i]) != DC1394_SUCCESS) {
1938 vpERROR_TRACE(
"Unable to setup camera- check line %d of %s to"
1939 "make sure that the video mode,framerate and format are "
1940 "supported by your camera.\n",
1945 "Unable to setup camera ") );
1974 vp1394Grabber::getImageCharacteristics(
int _format,
int _mode,
1975 int &width,
int &height,
1976 vp1394ImageFormatType &_image_format)
1980 case FORMAT_VGA_NONCOMPRESSED:
1983 case MODE_160x120_YUV444:
1984 width = 160; height = 120;
1987 case MODE_320x240_YUV422:
1988 width = 320; height = 240;
1991 case MODE_640x480_YUV411:
1992 width = 640; height = 480;
1995 case MODE_640x480_YUV422:
1996 width = 640; height = 480;
1999 case MODE_640x480_RGB:
2000 width = 640; height = 480;
2001 _image_format =
RGB;
2003 case MODE_640x480_MONO:
2004 width = 640; height = 480;
2005 _image_format =
MONO;
2007 case MODE_640x480_MONO16:
2008 width = 640; height = 480;
2009 _image_format =
MONO;
2013 vpERROR_TRACE(
"Error: camera image format and camera mode are uncompatible...\n");
2016 "Wrong mode for format 0") );
2020 case FORMAT_SVGA_NONCOMPRESSED_1:
2023 case MODE_800x600_YUV422:
2024 width = 800; height = 600;
2027 case MODE_800x600_RGB:
2028 width = 800; height = 600;
2029 _image_format =
RGB;
2031 case MODE_800x600_MONO:
2032 width = 800; height = 600;
2033 _image_format =
MONO;
2035 case MODE_800x600_MONO16:
2036 width = 800; height = 600;
2039 case MODE_1024x768_YUV422:
2040 width = 1024; height = 768;
2043 case MODE_1024x768_RGB:
2044 width = 1024; height = 768;
2045 _image_format =
RGB;
2047 case MODE_1024x768_MONO:
2048 width = 1024; height = 768;
2049 _image_format =
MONO;
2051 case MODE_1024x768_MONO16:
2052 width = 1024; height = 768;
2057 vpERROR_TRACE(
"Error: camera image format and camera mode are uncompatible...\n");
2060 "Wrong mode for format 1") );
2064 case FORMAT_SVGA_NONCOMPRESSED_2:
2067 case MODE_1280x960_YUV422:
2068 width = 1280; height = 960;
2071 case MODE_1280x960_RGB:
2072 width = 1280; height = 960;
2073 _image_format =
RGB;
2075 case MODE_1280x960_MONO:
2076 width = 1280; height = 960;
2077 _image_format =
MONO;
2079 case MODE_1280x960_MONO16:
2080 width = 1280; height = 960;
2083 case MODE_1600x1200_YUV422:
2084 width = 1600; height = 1200;
2087 case MODE_1600x1200_RGB:
2088 width = 1600; height = 1200;
2089 _image_format =
RGB;
2091 case MODE_1600x1200_MONO:
2092 width = 1600; height = 1200;
2093 _image_format =
MONO;
2095 case MODE_1600x1200_MONO16:
2096 width = 1600; height = 1200;
2101 vpERROR_TRACE(
"Error: camera image format and camera mode are uncompatible...\n");
2104 "Wrong mode for format 2") );
2108 case FORMAT_SCALABLE_IMAGE_SIZE:
2112 case MODE_FORMAT7_0:
2113 width = 656; height = 492;
2117 case MODE_FORMAT7_1:
2118 width = 328; height = 492;
2119 _image_format =
MONO;
2121 case MODE_FORMAT7_2:
2122 width = 656; height = 244;
2123 _image_format =
MONO;
2125 case MODE_FORMAT7_3:
2126 case MODE_FORMAT7_4:
2127 case MODE_FORMAT7_5:
2128 case MODE_FORMAT7_6:
2129 case MODE_FORMAT7_7:
2130 width = 656; height = 244;
2131 _image_format =
MONO;
2141 case MODE_FORMAT7_0:
2146 case MODE_FORMAT7_1:
2148 _image_format =
MONO;
2150 case MODE_FORMAT7_2:
2152 _image_format =
MONO;
2157 if (dc1394_query_format7_max_image_size(handles[camera],
2158 cameras[camera].node,
2161 &_eight) != DC1394_SUCCESS) {
2163 vpERROR_TRACE(
"Unable to get maximal image size for format 7\n");
2165 "Unable to get maximal image size for format 7 ") );
2167 std::cout <<
"max width=" << width <<
" height: " << height << std::endl;
2173 vpERROR_TRACE(
"Error: camera image format and camera mode are uncompatible...\n");
2205 vp1394Grabber::dmaCapture(
bool waiting)
2208 if (camera >= num_cameras) {
2209 std::cout <<
"The required camera is not present..."
2214 if ( handle_created ==
true && camera_found ==
true) {
2216 if (num_cameras == 1) {
2218 if (dc1394_dma_single_capture(&cameras[camera]) != DC1394_SUCCESS) {
2221 "No frame is available...") );
2227 if (dc1394_dma_multi_capture(cameras, num_cameras) != DC1394_SUCCESS) {
2230 "No frame is available...") );
2237 if (num_cameras == 1) {
2239 if (dc1394_dma_single_capture_poll(&cameras[camera]) != DC1394_SUCCESS) {
2242 "No frame is available...") );
2248 if (dc1394_dma_multi_capture_poll(cameras, num_cameras)
2249 != DC1394_SUCCESS) {
2252 "No frame is available...") );
2260 return cameras[camera].capture_buffer;
2280 vp1394Grabber::dmaDoneWithBuffer()
2283 if (camera >= num_cameras) {
2287 "The required camera is not present") );
2290 if ( handle_created ==
true && camera_found ==
true) {
2291 if (dc1394_dma_done_with_buffer(&cameras[camera]) != DC1394_SUCCESS) {
2293 "Can't done the dma") );
2308 if (iso_transmission_started ==
true) {
2310 stopIsoTransmission();
2312 for (
unsigned int i=0; i < num_cameras; i++)
2313 dc1394_dma_unlisten( handles[i], &cameras[i] );
2314 iso_transmission_started =
false;
2316 if ((camera_found ==
true) && (dma_started ==
true)) {
2317 for (
unsigned int i=0; i < num_cameras; i++)
2318 dc1394_dma_release_camera( handles[i], &cameras[i]);
2319 camera_found =
false;
2320 dma_started =
false;
2322 if (handle_created ==
true) {
2323 for (
unsigned int i=0; i < num_cameras; i++)
2324 dc1394_destroy_handle(handles[i]);
2325 handle_created =
false;
2328 if (handles != NULL) {
delete [] handles; handles = NULL; }
2329 if (cameras != NULL) {
delete [] cameras; cameras = NULL; }
2330 if (cam_count != NULL) {
delete [] cam_count; cam_count = NULL; }
2331 if (pformat != NULL) {
delete [] pformat; pformat = NULL; }
2332 if (pmode != NULL) {
delete [] pmode; pmode = NULL; }
2333 if (pframerate != NULL) {
delete [] pframerate; pframerate = NULL; }
2334 if (_width != NULL) {
delete [] _width; _width = NULL; }
2335 if (_height != NULL) {
delete [] _height; _height = NULL; }
2336 if (image_format != NULL) {
delete [] image_format; image_format = NULL; }
2348 void vp1394Grabber::startIsoTransmission()
2350 if ( handle_created ==
true && camera_found ==
true) {
2352 for (
unsigned int i = 0; i < num_cameras; i ++) {
2353 if (dc1394_start_iso_transmission(handles[i],
2354 cameras[i].node) !=DC1394_SUCCESS) {
2357 "Unable to start camera iso transmission") );
2360 iso_transmission_started =
true;
2373 void vp1394Grabber::stopIsoTransmission()
2376 if (iso_transmission_started ==
true) {
2377 if (handle_created ==
true && camera_found ==
true) {
2378 for (
unsigned int i = 0; i < num_cameras; i ++) {
2379 if (dc1394_stop_iso_transmission(handles[i],
2380 cameras[i].node) != DC1394_SUCCESS) {
2383 "Can't stop the camera") );
2387 iso_transmission_started =
false;
void setGain(unsigned int gain)
static const char * strModesInFormat2[NUM_FORMAT2_MODES]
static void RGBToGrey(unsigned char *rgb, unsigned char *grey, unsigned int size)
unsigned int getWidth() const
void getFormat(int &format)
static void RGBToRGBa(unsigned char *rgb, unsigned char *rgba, unsigned int size)
Provide simple list management.
Type * bitmap
points toward the bitmap
static const char * strModesInFormat7[NUM_MODE_FORMAT7]
void getShutter(unsigned int &min_shutter, unsigned int &shutter, unsigned int &max_shutter)
static const char * strModesInFormat0[NUM_FORMAT0_MODES]
void resize(const unsigned int height, const unsigned int width)
set the size of the image
static const int MAX_PORTS
void getFramerate(int &framerate)
static void GreyToRGBa(unsigned char *grey, unsigned char *rgba, unsigned int size)
vp_deprecated vp1394Grabber()
static void YUV422ToRGBa(unsigned char *yuv, unsigned char *rgba, unsigned int size)
void kill()
Destroy the list.
static const char * strModesInFormat6[NUM_FORMAT6_MODES]
Class for firewire ieee1394 video devices using libdc1394-1.x api.
int getModeSupported(int format, vpList< int > &modes)
void open(vpImage< unsigned char > &I)
static const char * strColorsInFormat7[NUM_COLOR_FORMAT7]
static const int DROP_FRAMES
Error that can be emited by the vpFrameGrabber class and its derivates.
void setFramerate(int framerate)
int getFormatSupported(vpList< int > &formats)
int convertMode(std::string mode)
void getCamera(unsigned int &camera)
static void YUV422ToGrey(unsigned char *yuv, unsigned char *grey, unsigned int size)
void getGain(unsigned int &min_gain, unsigned int &gain, unsigned int &max_gain)
static const char * strFramerates[NUM_FRAMERATES]
unsigned int getWidth() const
Return the number of columns in the image.
unsigned int height
Number of rows in the image.
static const int MAX_CAMERAS
int getFramerateSupported(int format, int mode, vpList< int > &framerates)
void getNumCameras(unsigned int &cameras)
void addRight(const type &el)
add a new element in the list, at the right of the current one
static const char * strModesInFormat1[NUM_FORMAT1_MODES]
static const char * strFormats[NUM_FORMATS]
bool init
Set to true if the frame grabber has been initialized.
int convertFormat(std::string format)
static void YUV411ToRGBa(unsigned char *yuv, unsigned char *rgba, unsigned int size)
unsigned int getHeight() const
int convertFramerate(std::string framerate)
static void YUV411ToGrey(unsigned char *yuv, unsigned char *grey, unsigned int size)
void acquire(vpImage< unsigned char > &I)
unsigned int width
Number of columns in the image.
static void RGBaToGrey(unsigned char *rgba, unsigned char *grey, unsigned int size)
unsigned int getHeight() const
Return the number of rows in the image.
void setCamera(unsigned int camera)
static const int NUM_BUFFERS
void setFormat(int format)
void setShutter(unsigned int shutter)