Visual Servoing Platform  version 3.0.1
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
vp1394TwoGrabber.cpp
1 /****************************************************************************
2  *
3  * This file is part of the ViSP software.
4  * Copyright (C) 2005 - 2017 by Inria. All rights reserved.
5  *
6  * This software is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * ("GPL") version 2 as published by the Free Software Foundation.
9  * See the file LICENSE.txt at the root directory of this source
10  * distribution for additional information about the GNU GPL.
11  *
12  * For using ViSP with software that can not be combined with the GNU
13  * GPL, please contact Inria about acquiring a ViSP Professional
14  * Edition License.
15  *
16  * See http://visp.inria.fr for more information.
17  *
18  * This software was developed at:
19  * Inria Rennes - Bretagne Atlantique
20  * Campus Universitaire de Beaulieu
21  * 35042 Rennes Cedex
22  * France
23  *
24  * If you have questions regarding the use of this file, please contact
25  * Inria at visp@inria.fr
26  *
27  * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
28  * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
29  *
30  * Description:
31  * Firewire cameras video capture.
32  *
33  * Authors:
34  * Fabien Spindler
35  *
36  *****************************************************************************/
37 
38 
44 #include <iostream>
45 
46 #include <visp3/core/vpConfig.h>
47 
48 /*
49  * Interface with libdc1394 2.x
50  */
51 #if defined(VISP_HAVE_DC1394)
52 #include <unistd.h>
53 
54 #include <visp3/sensor/vp1394TwoGrabber.h>
55 #include <visp3/core/vpFrameGrabberException.h>
56 #include <visp3/core/vpImageConvert.h>
57 #include <visp3/core/vpTime.h>
58 
59 const char * vp1394TwoGrabber::strVideoMode[DC1394_VIDEO_MODE_NUM]= {
60  "MODE_160x120_YUV444",
61  "MODE_320x240_YUV422",
62  "MODE_640x480_YUV411",
63  "MODE_640x480_YUV422",
64  "MODE_640x480_RGB8",
65  "MODE_640x480_MONO8",
66  "MODE_640x480_MONO16",
67  "MODE_800x600_YUV422",
68  "MODE_800x600_RGB8",
69  "MODE_800x600_MONO8",
70  "MODE_1024x768_YUV422",
71  "MODE_1024x768_RGB8",
72  "MODE_1024x768_MONO8",
73  "MODE_800x600_MONO16",
74  "MODE_1024x768_MONO16",
75  "MODE_1280x960_YUV422",
76  "MODE_1280x960_RGB8",
77  "MODE_1280x960_MONO8",
78  "MODE_1600x1200_YUV422",
79  "MODE_1600x1200_RGB8",
80  "MODE_1600x1200_MONO8",
81  "MODE_1280x960_MONO16",
82  "MODE_1600x1200_MONO16",
83  "MODE_EXIF",
84  "MODE_FORMAT7_0",
85  "MODE_FORMAT7_1",
86  "MODE_FORMAT7_2",
87  "MODE_FORMAT7_3",
88  "MODE_FORMAT7_4",
89  "MODE_FORMAT7_5",
90  "MODE_FORMAT7_6",
91  "MODE_FORMAT7_7"
92 };
93 
94 const char * vp1394TwoGrabber::strFramerate[DC1394_FRAMERATE_NUM]= {
95  "FRAMERATE_1_875",
96  "FRAMERATE_3_75",
97  "FRAMERATE_7_5",
98  "FRAMERATE_15",
99  "FRAMERATE_30",
100  "FRAMERATE_60",
101  "FRAMERATE_120",
102  "FRAMERATE_240"
103 };
104 
105 const char * vp1394TwoGrabber::strColorCoding[DC1394_COLOR_CODING_NUM]= {
106  "COLOR_CODING_MONO8",
107  "COLOR_CODING_YUV411",
108  "COLOR_CODING_YUV422",
109  "COLOR_CODING_YUV444",
110  "COLOR_CODING_RGB8",
111  "COLOR_CODING_MONO16",
112  "COLOR_CODING_RGB16",
113  "COLOR_CODING_MONO16S",
114  "COLOR_CODING_RGB16S",
115  "COLOR_CODING_RAW8",
116  "COLOR_CODING_RAW16",
117 };
118 
119 
120 
166  : camera(NULL), cameras(NULL), num_cameras(0), camera_id(0), verbose(false), camIsOpen(NULL),
167  num_buffers(4), // ring buffer size
168  isDataModified(NULL), initialShutterMode(NULL), dataCam(NULL)
169  #ifdef VISP_HAVE_DC1394_CAMERA_ENUMERATE // new API > libdc1394-2.0.0-rc7
170  , d(NULL),
171  list(NULL)
172  #endif
173 {
174  // protected members
175  width = height = 0;
176 
177  // private members
178  init = false;
179 
180  reset = false;
181  initialize(reset);
182 
183  // open();
184 }
185 
196 {
197 /* if(num_cameras >= 1){
198  delete[] isDataModified;
199  delete[] initialShutterMode;
200  delete[] dataCam;
201  }*/
202  close();
203 }
204 
325 void
327 {
328  // Suppose that if camera_id is a camera GUID, this value is greater
329  // than the number of cameras connected to the bus
330  if (cam_id >= num_cameras) {
331  // Check if camera_id is a camera guid
332  bool is_guid = false;
333  // check if the camera_id is a guid
334  for (unsigned int i=0; i< num_cameras; i++) {
335  if (cameras[i]->guid == cam_id) {
336  this->camera_id = i;
337  is_guid = true;
338  break;
339  }
340  }
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;
346  }
347  close();
349  "The required camera is not present") );
350  }
351  }
352  else {
353  this->camera_id = (unsigned int) cam_id; // The input cam_id is not a uint64_t guid, but the index of the camera
354  }
355 
356  // create a pointer to the working camera
357  camera = cameras[this->camera_id];
358 }
359 
360 
375 void
377 {
378  if (num_cameras) {
379  cam_id = this->camera_id;
380  }
381  else {
382  close();
383  vpERROR_TRACE("No cameras found");
385  "No cameras found") );
386  }
387 }
388 
403 uint64_t
405 {
406  if (num_cameras) {
407  return this->camera_id;
408  }
409  else {
410  close();
411  vpERROR_TRACE("No cameras found");
413  "No cameras found") );
414  }
415 }
416 
424 void
425 vp1394TwoGrabber::getNumCameras(unsigned int &ncameras) const
426 {
427  if (! num_cameras) {
428  vpCTRACE << "No camera found..."<< std::endl;
429  ncameras = 0;
430  }
431 
432  ncameras = num_cameras;
433 }
434 
442 unsigned int
444 {
445  unsigned int ncameras = 0;
446  if (! num_cameras) {
447  vpCTRACE << "No camera found..."<< std::endl;
448  ncameras = 0;
449  }
450 
451  ncameras = num_cameras;
452  return ncameras;
453 }
454 
500 void
502 {
503  open();
504  if (! num_cameras) {
505  close();
507  "No camera found") );
508  }
509  if (!isVideoModeSupported(videomode)){
511  "Video mode not supported by camera %d",camera_id) );
512  }
513  // Stop dma capture if started
514  setTransmission(DC1394_OFF);
515  setCapture(DC1394_OFF);
516 
517  if (dc1394_video_set_mode(camera, (dc1394video_mode_t) videomode) != DC1394_SUCCESS) {
518  close();
520  "Can't set video mode") );
521  }
522 
523  setCapture(DC1394_ON);
524  setTransmission(DC1394_ON);
525 
526  // Updates image size from new video mode
527  if (dc1394_get_image_size_from_video_mode(camera,
528  (dc1394video_mode_t) videomode,
529  &this->width, &this->height)
530  != DC1394_SUCCESS) {
531 
532  close();
534  "Can't get image size") );
535  }
536 }
537 
554 void
556 {
557  if (! num_cameras) {
558  close();
559  vpERROR_TRACE("No camera found");
561  "No camera found") );
562  }
563 
564  dc1394video_mode_t _videomode;
565  if (dc1394_video_get_mode(camera, &_videomode) != DC1394_SUCCESS) {
566 
567  close();
568  vpERROR_TRACE("Can't get current video mode");
570  "Can't get current video mode") );
571  }
572  videomode = (vp1394TwoVideoModeType) _videomode;
573 
574 }
575 
576 
577 
595 uint32_t
596 vp1394TwoGrabber::getVideoModeSupported(std::list<vp1394TwoVideoModeType> & videomodes)
597 {
598  // Refresh the list of supported modes
599  videomodes.clear();
600 
601  if (! num_cameras) {
602  close();
603  vpERROR_TRACE("No camera found");
605  "No camera found") );
606  }
607  dc1394video_modes_t _videomodes;
608 
609  // get video modes:
610  if (dc1394_video_get_supported_modes(camera, &_videomodes)!=DC1394_SUCCESS) {
611 
612  close();
613  vpERROR_TRACE("Can't get video modes");
615  "Can't get video modes") );
616  }
617 
618  // parse the video modes to add in the list
619  for (unsigned i=0; i < _videomodes.num; i++) {
620  vp1394TwoVideoModeType _mode = (vp1394TwoVideoModeType) _videomodes.modes[i];
621  videomodes.push_back( _mode );
622  }
623 
624  // return the number of available video modes
625  return _videomodes.num;
626 }
642 bool
644 {
645  if (! num_cameras) {
646  close();
647  vpERROR_TRACE("No camera found");
649  "No camera found") );
650  }
651  dc1394video_modes_t _videomodes;
652 
653  // get video modes:
654  if (dc1394_video_get_supported_modes(camera, &_videomodes)!=DC1394_SUCCESS) {
655 
656  close();
657  vpERROR_TRACE("Can't get video modes");
659  "Can't get video modes") );
660  }
661 
662  // parse the video modes to check with the desired
663  for (unsigned i=0; i < _videomodes.num; i++) {
664  if ((vp1394TwoVideoModeType) _videomodes.modes[i] == videomode)
665  return true;
666  }
667  return false;
668 }
669 
682 bool
684 {
685 
686  if (dc1394_is_video_mode_scalable((dc1394video_mode_t) videomode))
687  return true;
688 
689  return false;
690 }
691 
707 bool
709 {
711  getColorCoding(coding);
712 
713  switch (coding) {
717  case vpCOLOR_CODING_RAW8:
719  return false;
723  case vpCOLOR_CODING_RGB8:
726  return true;
727  }
728  return false;
729 }
730 
755 void
757 {
758  open();
759  if (! num_cameras) {
760  close();
762  "No camera found") );
763  }
764 
765  vp1394TwoVideoModeType cur_videomode;
766  getVideoMode(cur_videomode);
767  if (isVideoModeFormat7(cur_videomode))
768  return;
769 
770  if (!isFramerateSupported(cur_videomode,fps)){
772  "Framerate not supported by camera %d",camera_id) );
773  }
774 
775  // Stop dma capture if started
776  setTransmission(DC1394_OFF);
777  setCapture(DC1394_OFF);
778 
779  if (dc1394_video_set_framerate(camera, (dc1394framerate_t) fps) != DC1394_SUCCESS) {
780 
781  close();
783  "Can't set framerate") );
784  }
785 
786  setCapture(DC1394_ON);
787  setTransmission(DC1394_ON);
788 }
789 
806 void
808 {
809  if (! num_cameras) {
810  close();
811  vpERROR_TRACE("No camera found");
813  "No camera found") );
814  }
815  dc1394framerate_t _fps;
816  if (dc1394_video_get_framerate(camera, &_fps) != DC1394_SUCCESS) {
817 
818  close();
819  vpERROR_TRACE("Can't get current framerate");
821  "Can't get current framerate") );
822  }
823  fps = (vp1394TwoFramerateType) _fps;
824 
825 }
826 
858 uint32_t
860  std::list<vp1394TwoFramerateType> & fps)
861 {
862  if (! num_cameras) {
863  close();
864  vpERROR_TRACE("No camera found");
866  "No camera found") );
867  }
868 
869  // Refresh the list of supported framerates
870  fps.clear();
871 
872  switch (mode) {
873  // Framerate not available for:
874  // - vpVIDEO_MODE_EXIF ie Format_6
875  // - vpVIDEO_MODE_FORMAT7... ie the Format_7
876  case vpVIDEO_MODE_EXIF:
885  return 0;
886  break;
887  default:
888  {
889  dc1394framerates_t _fps;
890  if (dc1394_video_get_supported_framerates(camera,
891  (dc1394video_mode_t)mode,
892  &_fps) != DC1394_SUCCESS) {
893  close();
894  vpERROR_TRACE("Could not query supported frametates for mode %d\n",
895  mode);
897  "Could not query supported framerates") );
898  }
899  if (_fps.num == 0)
900  return 0;
901 
902  for (unsigned int i = 0; i < _fps.num; i ++)
903  fps.push_back((vp1394TwoFramerateType)_fps.framerates[i]);
904 
905  return _fps.num;
906  }
907  break;
908  }
909 }
943 bool
946 {
947  if (! num_cameras) {
948  close();
949  vpERROR_TRACE("No camera found");
951  "No camera found") );
952  }
953 
954  switch (mode) {
955  // Framerate not available for:
956  // - vpVIDEO_MODE_EXIF ie Format_6
957  // - vpVIDEO_MODE_FORMAT7... ie the Format_7
958  case vpVIDEO_MODE_EXIF:
967  return 0;
968  break;
969  default:
970  {
971  dc1394framerates_t _fps;
972  if (dc1394_video_get_supported_framerates(camera,
973  (dc1394video_mode_t)mode,
974  &_fps) != DC1394_SUCCESS) {
975  close();
976  vpERROR_TRACE("Could not query supported frametates for mode %d\n",
977  mode);
979  "Could not query supported framerates") );
980  }
981  if (_fps.num == 0)
982  return 0;
983 
984  for (unsigned int i = 0; i < _fps.num; i ++){
985  if (fps==(vp1394TwoFramerateType)_fps.framerates[i]){
986  return true;
987  }
988  }
989  return false;
990  }
991  break;
992  }
993 }
994 
1043 void
1045 {
1046  if (! num_cameras) {
1047  close();
1049  "No camera found") );
1050  }
1051 
1052  dc1394video_mode_t _videomode;
1053  if (dc1394_video_get_mode(camera, &_videomode) != DC1394_SUCCESS) {
1054 
1055  close();
1057  "Can't get current video mode") );
1058  }
1059 
1060  if (!isColorCodingSupported((vp1394TwoVideoModeType)_videomode,coding)){
1062  "Color coding not supported by camera %d", camera_id) );
1063  }
1064 
1065  // Format 7 video mode
1066  if (dc1394_is_video_mode_scalable(_videomode)) {
1067  setTransmission(DC1394_OFF);
1068  setCapture(DC1394_OFF);
1069 
1070  if (dc1394_format7_set_color_coding(camera, _videomode,
1071  (dc1394color_coding_t) coding)
1072  != DC1394_SUCCESS) {
1073 
1074  close();
1076  "Can't set color coding") );
1077  }
1078 
1079  setCapture(DC1394_ON);
1080  setTransmission(DC1394_ON);
1081  }
1082 }
1083 
1101 void
1103 {
1104  if (! num_cameras) {
1105  close();
1106  vpERROR_TRACE("No camera found");
1108  "No camera found") );
1109  }
1110  dc1394video_mode_t _videomode;
1111  if (dc1394_video_get_mode(camera, &_videomode) != DC1394_SUCCESS) {
1112 
1113  close();
1114  vpERROR_TRACE("Can't get current video mode");
1116  "Can't get current video mode") );
1117  }
1118 
1119  dc1394color_coding_t _coding;
1120  if (dc1394_is_video_mode_scalable(_videomode)) {
1121  // Format 7 video mode
1122  if (dc1394_format7_get_color_coding(camera, _videomode, &_coding)
1123  != DC1394_SUCCESS) {
1124 
1125  close();
1126  vpERROR_TRACE("Can't get current color coding");
1128  "Can't query current color coding") );
1129  }
1130  }
1131  else if (dc1394_is_video_mode_still_image((dc1394video_mode_t)_videomode)) {
1133  "No color coding for format 6 video mode"));
1134  }
1135  else {
1136  // Not Format 7 and not Format 6 video modes
1137  if (dc1394_get_color_coding_from_video_mode(camera,
1138  (dc1394video_mode_t)_videomode,
1139  &_coding) != DC1394_SUCCESS) {
1140  close();
1141  vpERROR_TRACE("Could not query supported color coding for mode %d\n",
1142  _videomode);
1144  "Can't query current color coding"));
1145  }
1146  }
1147  coding = (vp1394TwoColorCodingType) _coding;
1148 }
1149 
1171 uint32_t
1173  std::list<vp1394TwoColorCodingType> & codings)
1174 {
1175  if (! num_cameras) {
1176  close();
1177  vpERROR_TRACE("No camera found");
1179  "No camera found") );
1180  }
1181 
1182  // Refresh the list of supported framerates
1183  codings.clear();
1184 
1185  if (dc1394_is_video_mode_scalable((dc1394video_mode_t)mode)) {
1186  // Format 7 video mode
1187  dc1394color_codings_t _codings;
1188  if (dc1394_format7_get_color_codings(camera,
1189  (dc1394video_mode_t)mode,
1190  &_codings) != DC1394_SUCCESS) {
1191  close();
1192  vpERROR_TRACE("Could not query supported color codings for mode %d\n",
1193  mode);
1195  "Could not query supported color codings") );
1196  }
1197  if (_codings.num == 0)
1198  return 0;
1199 
1200  for (unsigned int i = 0; i < _codings.num; i ++)
1201  codings.push_back((vp1394TwoColorCodingType)_codings.codings[i]);
1202 
1203  return _codings.num;
1204  }
1205  else if (dc1394_is_video_mode_still_image((dc1394video_mode_t)mode)) {
1206  // Format 6 video mode
1207  return 0;
1208  }
1209  else {
1210  // Not Format 7 and not Format 6 video modes
1211  dc1394color_coding_t _coding;
1212  if (dc1394_get_color_coding_from_video_mode(camera,
1213  (dc1394video_mode_t)mode,
1214  &_coding) != DC1394_SUCCESS) {
1215  close();
1216  vpERROR_TRACE("Could not query supported color coding for mode %d\n",
1217  mode);
1219  "Could not query supported color coding") );
1220  }
1221  codings.push_back((vp1394TwoColorCodingType)_coding);
1222  return 1;
1223  }
1224 }
1246 bool
1248  vp1394TwoColorCodingType coding)
1249 {
1250  if (! num_cameras) {
1251  close();
1252  vpERROR_TRACE("No camera found");
1254  "No camera found") );
1255  }
1256 
1257 
1258  if (dc1394_is_video_mode_scalable((dc1394video_mode_t)mode)) {
1259  // Format 7 video mode
1260  dc1394color_codings_t _codings;
1261  if (dc1394_format7_get_color_codings(camera,
1262  (dc1394video_mode_t)mode,
1263  &_codings) != DC1394_SUCCESS) {
1264  close();
1265  vpERROR_TRACE("Could not query supported color codings for mode %d\n",
1266  mode);
1268  "Could not query supported color codings") );
1269  }
1270  if (_codings.num == 0)
1271  return 0;
1272 
1273  for (unsigned int i = 0; i < _codings.num; i ++){
1274  if (coding==(vp1394TwoColorCodingType)_codings.codings[i])
1275  return true;
1276  }
1277  return false;
1278  }
1279  else if (dc1394_is_video_mode_still_image((dc1394video_mode_t)mode)) {
1280  // Format 6 video mode
1281  return false;
1282  }
1283  else {
1284  // Not Format 7 and not Format 6 video modes
1285  dc1394color_coding_t _coding;
1286  if (dc1394_get_color_coding_from_video_mode(camera,
1287  (dc1394video_mode_t)mode,
1288  &_coding) != DC1394_SUCCESS) {
1289  close();
1290  vpERROR_TRACE("Could not query supported color coding for mode %d\n",
1291  mode);
1293  "Could not query supported color coding") );
1294  return false;
1295  }
1296  if (coding==(vp1394TwoColorCodingType)_coding)
1297  return true;
1298 
1299  return false;
1300  }
1301 }
1302 
1303 
1335 void
1336 vp1394TwoGrabber::setFormat7ROI(unsigned int left, unsigned int top,
1337  unsigned int w, unsigned int h)
1338 {
1339  open();
1340  if (! num_cameras) {
1341  close();
1342  vpERROR_TRACE("No camera found");
1344  "No camera found") );
1345  }
1346 
1347  dc1394video_mode_t _videomode;
1348  if (dc1394_video_get_mode(camera, &_videomode) != DC1394_SUCCESS) {
1349 
1350  close();
1351  vpERROR_TRACE("Can't get current video mode");
1353  "Can't get current video mode") );
1354  }
1355  if (dc1394_is_video_mode_scalable(_videomode)) {
1356  // Stop dma capture if started
1357  setTransmission(DC1394_OFF);
1358  setCapture(DC1394_OFF);
1359  // Format 7 video mode
1360  unsigned int max_width, max_height;
1361  if (dc1394_format7_get_max_image_size(camera, _videomode,
1362  &max_width, &max_height)
1363  != DC1394_SUCCESS) {
1364 
1365  close();
1366  vpERROR_TRACE("Can't get format7 max image size");
1368  "Can't get format7 max image size") );
1369  }
1370 #if 0
1371  vpTRACE("left: %d top: %d width: %d height: %d", left, top,
1372  width == 0 ? DC1394_USE_MAX_AVAIL: w,
1373  height == 0 ? DC1394_USE_MAX_AVAIL : h);
1374  vpTRACE("max_width: %d max_height: %d", max_width, max_height);
1375 #endif
1376 
1377  if (left > max_width) {
1378  vpERROR_TRACE("Can't set format7 ROI");
1380  "Can't set format7 ROI") );
1381  }
1382  if (top > max_height) {
1383  vpERROR_TRACE("Can't set format7 ROI");
1385  "Can't set format7 ROI") );
1386  }
1387 
1388  int32_t roi_width;
1389  int32_t roi_height;
1390 
1391  if (w != 0) {
1392  // Check if roi width is acceptable (ie roi is contained in the image)
1393  if (w > (max_width - left))
1394  w = (max_width - left);
1395  roi_width = (int32_t)w;
1396  }
1397  else {
1398  roi_width = DC1394_USE_MAX_AVAIL;
1399  }
1400 
1401  if (h != 0) {
1402  // Check if roi height is acceptable (ie roi is contained in the image)
1403  if (h > (max_height - top))
1404  h = (max_height - top);
1405  roi_height = (int32_t)h;
1406  }
1407  else {
1408  roi_height = DC1394_USE_MAX_AVAIL;
1409  }
1410 
1411  if (dc1394_format7_set_roi(camera, _videomode,
1412  (dc1394color_coding_t) DC1394_QUERY_FROM_CAMERA, // color_coding
1413  DC1394_USE_MAX_AVAIL/*DC1394_QUERY_FROM_CAMERA*/, // bytes_per_packet
1414  (int32_t)left, // left
1415  (int32_t)top, // top
1416  roi_width,
1417  roi_height)
1418  != DC1394_SUCCESS) {
1419  close();
1420  vpERROR_TRACE("Can't set format7 roi");
1422  "Can't get current video mode") );
1423  }
1424  // Update the image size
1425  if (dc1394_format7_get_image_size(camera, _videomode,
1426  &this->width,
1427  &this->height)
1428  != DC1394_SUCCESS) {
1429  close();
1430  vpERROR_TRACE("Can't get format7 image size");
1432  "Can't get format7 image size") );
1433  }
1434 
1435  setCapture(DC1394_ON);
1436  setTransmission(DC1394_ON);
1437  }
1438 }
1453 void
1454 vp1394TwoGrabber::initialize(bool reset)
1455 {
1456  if (init == false){
1457  // Find cameras
1458 #ifdef VISP_HAVE_DC1394_CAMERA_ENUMERATE // new API > libdc1394-2.0.0-rc7
1459  if (d != NULL)
1460  dc1394_free (d);
1461 
1462  d = dc1394_new ();
1463  if (dc1394_camera_enumerate (d, &list) != DC1394_SUCCESS) {
1464  dc1394_camera_free_list (list);
1465  close();
1466  vpERROR_TRACE("Failed to enumerate cameras\n");
1468  "Failed to enumerate cameras") );
1469  }
1470 
1471  if (list->num == 0) {
1472  dc1394_camera_free_list (list);
1473  close();
1474  vpERROR_TRACE("No cameras found");
1476  "No cameras found") );
1477  }
1478 
1479  if (cameras != NULL)
1480  delete [] cameras;
1481 
1482  cameras = new dc1394camera_t * [list->num];
1483 
1484  num_cameras = 0;
1485 
1486  for (unsigned int i=0; i < list->num; i ++) {
1487  cameras[i] = dc1394_camera_new (d, list->ids[i].guid);
1488  if (!cameras[i]) {
1489  vpTRACE ("Failed to initialize camera with guid \"%ld\"\n",
1490  list->ids[i].guid);
1491  continue;
1492  }
1493  // Update the number of working cameras
1494  num_cameras ++;
1495  }
1496 
1497  if (reset) {
1498  // Reset the bus to make firewire working if the program was not properly
1499  // stopped by a CTRL-C. We reset here only the bus attached to the first
1500  // camera
1501  dc1394_reset_bus(cameras[0]);
1502  }
1503 
1504  // if (list != NULL)
1505  dc1394_camera_free_list (list);
1506  list = NULL;
1507 
1508 #elif defined VISP_HAVE_DC1394_FIND_CAMERAS // old API <= libdc1394-2.0.0-rc7
1509  if (cameras != NULL)
1510  free(cameras);
1511  cameras = NULL;
1512  int err = dc1394_find_cameras(&cameras, &num_cameras);
1513 
1514  if (err!=DC1394_SUCCESS && err != DC1394_NO_CAMERA) {
1515  close();
1516  vpERROR_TRACE("Unable to look for cameras\n\n"
1517  "Please check \n"
1518  " - if the kernel modules `ieee1394',`raw1394' and `ohci1394' are loaded \n"
1519  " - if you have read/write access to /dev/raw1394\n\n");
1521  "Unable to look for cameras") );
1522 
1523  }
1524 #endif
1525 
1526  if (num_cameras == 0) {
1527  close();
1528  vpERROR_TRACE("No cameras found");
1530  "No cameras found") );
1531  }
1532 
1533  // allocation for the parameters
1534  isDataModified = new bool[num_cameras];
1535  for(unsigned int i=0; i<num_cameras; i++)
1536  isDataModified[i] = false;
1537  initialShutterMode = new dc1394feature_mode_t[num_cameras];
1538  dataCam = new vpDc1394TwoCameraParametersData[num_cameras];
1539 
1540  if (camera_id >= num_cameras) {
1541  // Bad camera id
1542  close();
1543  vpERROR_TRACE("Bad camera id: %u", camera_id);
1544  vpERROR_TRACE("Only %u camera on the bus.", num_cameras);
1546  "Bad camera id") );
1547  }
1548 
1549  if (verbose) {
1550  std::cout << "------ Bus information ------" << std::endl;
1551  std::cout << "Number of camera(s) on the bus : " << num_cameras <<std::endl;
1552  std::cout << "-----------------------------" << std::endl;
1553  }
1554 
1555  if (camIsOpen != NULL) delete [] camIsOpen;
1556  camIsOpen = new bool [num_cameras];
1557  for (unsigned int i = 0;i<num_cameras;i++){
1558  camIsOpen[i]=false;
1559  }
1560 
1561  init = true;
1562  }
1563 }
1573 void
1575 {
1576  if (init == false) initialize(false);
1577  if (camIsOpen[camera_id] == false){
1578  dc1394switch_t status = DC1394_OFF;
1579 
1580  //#ifdef VISP_HAVE_DC1394_CAMERA_ENUMERATE // new API > libdc1394-2.0.0-rc7
1581  dc1394_video_get_transmission(cameras[camera_id], &status);
1582  if (status != DC1394_OFF){
1583  //#endif
1584  if (dc1394_video_set_transmission(cameras[camera_id],DC1394_OFF)!=DC1394_SUCCESS)
1585  vpTRACE("Could not stop ISO transmission");
1586  else {
1587  vpTime::wait(500);
1588  if (dc1394_video_get_transmission(cameras[camera_id], &status)!=DC1394_SUCCESS)
1589  vpTRACE("Could get ISO status");
1590  else {
1591  if (status==DC1394_ON) {
1592  vpTRACE("ISO transmission refuses to stop");
1593  }
1594 #ifdef VISP_HAVE_DC1394_FIND_CAMERAS // old API <= libdc1394-2.0.0-rc7
1595  // No yet in the new API
1596  cameras[camera_id]->is_iso_on=status;
1597 #endif
1598  }
1599  //#ifdef VISP_HAVE_DC1394_CAMERA_ENUMERATE // new API > libdc1394-2.0.0-rc7
1600  }
1601  //#endif
1602  }
1603  setCamera(camera_id);
1604  //setIsoSpeed(DC1394_ISO_SPEED_400);
1605  setCapture(DC1394_ON);
1606  setTransmission(DC1394_ON);
1607  camIsOpen[camera_id] = true;
1608  }
1609 }
1618 void
1620 {
1621  if (init){
1622  if (num_cameras) {
1623  for (unsigned int i = 0; i < num_cameras;i++) {
1624  if (camIsOpen[i]) {
1625  camera = cameras[i];
1626  this->camera_id = i;// set camera id for the function updateDataStructToCam
1627  setTransmission(DC1394_OFF);
1628  setCapture(DC1394_OFF);
1629  if(isDataModified[i]){
1630  // reset values
1631  try{
1632  updateDataStructToCam();
1633  }
1634  catch(...){
1635  }
1636  // reset mode (manual, auto, ...)
1637  if (dc1394_feature_set_mode(camera, DC1394_FEATURE_BRIGHTNESS, initialShutterMode[i]) != DC1394_SUCCESS ||
1638  dc1394_feature_set_mode(camera, DC1394_FEATURE_EXPOSURE, initialShutterMode[i]) != DC1394_SUCCESS ||
1639  dc1394_feature_set_mode(camera, DC1394_FEATURE_SHARPNESS, initialShutterMode[i]) != DC1394_SUCCESS ||
1640  dc1394_feature_set_mode(camera, DC1394_FEATURE_HUE, initialShutterMode[i]) != DC1394_SUCCESS ||
1641  dc1394_feature_set_mode(camera, DC1394_FEATURE_SATURATION, initialShutterMode[i]) != DC1394_SUCCESS ||
1642  dc1394_feature_set_mode(camera, DC1394_FEATURE_GAMMA, initialShutterMode[i]) != DC1394_SUCCESS ||
1643  dc1394_feature_set_mode(camera, DC1394_FEATURE_SHUTTER, initialShutterMode[i]) != DC1394_SUCCESS ||
1644  dc1394_feature_set_mode(camera, DC1394_FEATURE_GAIN, initialShutterMode[i]) != DC1394_SUCCESS ||
1645  dc1394_feature_set_mode(camera, DC1394_FEATURE_IRIS, initialShutterMode[i])){
1646 
1647  vpERROR_TRACE("Unable to reset the initial mode");
1649  "Unable to reset the initial mode"));
1650  }
1651  }
1652  if (dc1394_camera_set_power(camera, DC1394_OFF) != DC1394_SUCCESS)
1653  std::cout << "Unable to turn camera off" << std::endl;
1654  }
1655 #ifdef VISP_HAVE_DC1394_CAMERA_ENUMERATE // new API > libdc1394-2.0.0-rc7
1656  dc1394_camera_free(cameras[i]);
1657 #elif defined VISP_HAVE_DC1394_FIND_CAMERAS // old API <= libdc1394-2.0.0-rc7
1658  dc1394_free_camera(cameras[i]);
1659 #endif
1660  }
1661  }
1662  if (camIsOpen != NULL) {
1663  delete [] camIsOpen;
1664  camIsOpen = NULL;
1665  }
1666 
1667 #ifdef VISP_HAVE_DC1394_CAMERA_ENUMERATE // new API > libdc1394-2.0.0-rc7
1668  if (cameras != NULL) {
1669  delete [] cameras;
1670  cameras = NULL;
1671  }
1672  if (d != NULL) {
1673  dc1394_free (d);
1674  d = NULL;
1675  }
1676 
1677 #elif defined VISP_HAVE_DC1394_FIND_CAMERAS // old API <= libdc1394-2.0.0-rc7
1678  if (cameras != NULL) {
1679  free(cameras);
1680  cameras = NULL;
1681  }
1682 #endif
1683 
1684  camIsOpen = NULL;
1685  num_cameras = 0;
1686 
1687  // remove data for the parameters
1688  if(isDataModified != NULL){
1689  delete[] isDataModified;
1690  isDataModified = NULL;
1691  }
1692  if(initialShutterMode != NULL){
1693  delete[] initialShutterMode;
1694  initialShutterMode = NULL;
1695  }
1696  if(dataCam != NULL){
1697  delete[] dataCam;
1698  dataCam = NULL;
1699  }
1700 
1701  init = false;
1702  }
1703 }
1704 
1716 void
1718 {
1719  if (size < 1) {
1720  close();
1722  "Could not set ring buffer size") );
1723  }
1724 
1725  if (size != num_buffers) {
1726  // We need to change the ring buffer size
1727  num_buffers = size;
1728  if(camIsOpen[camera_id]){
1729  setCapture(DC1394_OFF);
1730  setCapture(DC1394_ON);
1731  }
1732  }
1733 }
1734 
1744 unsigned int
1746 {
1747  return num_buffers;
1748 }
1749 
1789 void
1791 {
1792  if (! num_cameras) {
1793  close();
1794  vpERROR_TRACE("No camera found");
1796  "No camera found") );
1797  }
1798 
1799  dc1394feature_mode_t mode;
1800  if (enable) {
1801  mode = DC1394_FEATURE_MODE_AUTO;
1802  }
1803  else {
1804  mode = DC1394_FEATURE_MODE_MANUAL;
1805  }
1806 
1807  if (dc1394_feature_set_power(camera, DC1394_FEATURE_SHUTTER, DC1394_ON)
1808  != DC1394_SUCCESS) {
1809  // vpERROR_TRACE("Cannot set shutter on. \n");
1810  close();
1812  "Cannot set shutter on") );
1813  }
1814 
1815  if (dc1394_feature_set_mode(camera,
1816  DC1394_FEATURE_SHUTTER,
1817  mode)
1818  != DC1394_SUCCESS) {
1819  // vpERROR_TRACE("Cannot set auto shutter. \n");
1820  close();
1822  "Cannot set auto shutter") );
1823  }
1824 }
1865 void
1866 vp1394TwoGrabber::setAutoShutter(unsigned int minvalue, unsigned int maxvalue)
1867 {
1868  setAutoShutter();
1869 
1870  if (dc1394_avt_set_auto_shutter(camera, minvalue, maxvalue)
1871  != DC1394_SUCCESS) {
1872  // vpERROR_TRACE("Cannot set auto shutter min and max values. Is the camera an AVT one?\n");
1873  close();
1875  "Cannot set auto shutter min and max values") );
1876  }
1877 }
1878 
1891 void
1892 vp1394TwoGrabber::getAutoShutter(unsigned int &minvalue, unsigned int &maxvalue)
1893 {
1894  if (! num_cameras) {
1895  close();
1896  vpERROR_TRACE("No camera found");
1898  "No camera found") );
1899  }
1900 
1901  if (dc1394_avt_get_auto_shutter(camera, &minvalue, &maxvalue)
1902  != DC1394_SUCCESS) {
1903  // vpERROR_TRACE("Cannot get auto shutter min and max values. Is the camera an AVT one?\n");
1904  close();
1906  "Cannot get auto shutter min and max values") );
1907  }
1908 }
1909 
1949 void
1951 {
1952  if (! num_cameras) {
1953  close();
1954  vpERROR_TRACE("No camera found");
1956  "No camera found") );
1957  }
1958 
1959  dc1394feature_mode_t mode;
1960  if (enable) {
1961  mode = DC1394_FEATURE_MODE_AUTO;
1962  }
1963  else {
1964  mode = DC1394_FEATURE_MODE_MANUAL;
1965  }
1966 
1967  if (dc1394_feature_set_power(camera, DC1394_FEATURE_GAIN, DC1394_ON)
1968  != DC1394_SUCCESS) {
1969  // vpERROR_TRACE("Cannot set shutter on. \n");
1970  close();
1972  "Cannot set shutter on") );
1973  }
1974 
1975  if (dc1394_feature_set_mode(camera,
1976  DC1394_FEATURE_GAIN,
1977  mode)
1978  != DC1394_SUCCESS) {
1979  // vpERROR_TRACE("Cannot set auto gain. \n");
1980  close();
1982  "Cannot set auto gain") );
1983  }
1984 }
2025 void
2026 vp1394TwoGrabber::setAutoGain(unsigned int minvalue, unsigned int maxvalue)
2027 {
2028  setAutoGain();
2029 
2030  if (dc1394_avt_set_auto_gain(camera, minvalue, maxvalue)
2031  != DC1394_SUCCESS) {
2032  // vpERROR_TRACE("Cannot set auto gain min and max values. Is the camera an AVT one?\n");
2033  close();
2035  "Cannot set auto gain min and max values") );
2036  }
2037 }
2038 
2051 void
2052 vp1394TwoGrabber::getAutoGain(unsigned int &minvalue, unsigned int &maxvalue)
2053 {
2054  if (! num_cameras) {
2055  close();
2056  vpERROR_TRACE("No camera found");
2058  "No camera found") );
2059  }
2060 
2061  if (dc1394_avt_get_auto_gain(camera, &minvalue, &maxvalue)
2062  != DC1394_SUCCESS) {
2063  // vpERROR_TRACE("Cannot get auto gain min and max values. Is the camera an AVT one?\n");
2064  close();
2066  "Cannot get auto gain min and max values") );
2067  }
2068 }
2069 
2070 
2088 void
2089 vp1394TwoGrabber::setCapture(dc1394switch_t _switch)
2090 {
2091  if (! num_cameras) {
2092  close();
2093  vpERROR_TRACE("No camera found");
2095  "No camera found") );
2096  }
2097 
2098  if (_switch == DC1394_ON) {
2099  //if (dc1394_capture_setup(camera, num_buffers) != DC1394_SUCCESS) {
2100  // To be compatible with libdc1394 svn 382 version
2101  if (dc1394_capture_setup(camera, num_buffers,
2102  DC1394_CAPTURE_FLAGS_DEFAULT) != DC1394_SUCCESS) {
2103  vpERROR_TRACE("Unable to setup camera capture-\n"
2104  "make sure that the video mode and framerate are "
2105  "supported by your camera.\n");
2106  close();
2108  "Could not setup dma capture") );
2109  }
2110  }
2111  else { // _switch == DC1394_OFF
2112  dc1394error_t code = dc1394_capture_stop(camera);
2113 
2114  if (code != DC1394_SUCCESS && code != DC1394_CAPTURE_IS_NOT_SET) {
2115  vpERROR_TRACE("Unable to stop camera capture\n");
2116  close();
2118  "Could not setup dma capture") );
2119  }
2120  }
2121 }
2122 
2123 
2138 void
2139 vp1394TwoGrabber::setTransmission(dc1394switch_t _switch)
2140 {
2141  if (! num_cameras) {
2142  close();
2143  vpERROR_TRACE("No camera found");
2145  "No camera found") );
2146  }
2147 
2148  dc1394switch_t status = DC1394_OFF;
2149 
2150  if (dc1394_video_get_transmission(camera, &status)!=DC1394_SUCCESS) {
2151  vpERROR_TRACE("Unable to get transmision status");
2152  close();
2154  "Could not setup dma capture") );
2155  }
2156 
2157  // if (status!=_switch){
2158  // Start dma capture if halted
2159  if (dc1394_video_set_transmission(camera, _switch) != DC1394_SUCCESS) {
2160  vpERROR_TRACE("Unable to setup camera capture-\n"
2161  "make sure that the video mode and framerate are "
2162  "supported by your camera.\n");
2163  close();
2165  "Could not setup dma capture") );
2166  }
2167 
2168  if (_switch == DC1394_ON) {
2169  status = DC1394_OFF;
2170 
2171  int i = 0;
2172  while ( status == DC1394_OFF && i++ < 5 ) {
2173  usleep(50000);
2174  if (dc1394_video_get_transmission(camera, &status)!=DC1394_SUCCESS) {
2175  vpERROR_TRACE("Unable to get transmision status");
2176  close();
2178  "Could not setup dma capture") );
2179  }
2180  }
2181  }
2182  // }
2183 }
2184 
2219 void
2221 {
2222  if (! num_cameras) {
2223  close();
2224  vpERROR_TRACE("No camera found");
2226  "No camera found") );
2227  }
2228 
2229  dc1394operation_mode_t op_mode;
2230  dc1394speed_t speed;
2231 
2232  // Check the speed to configure in B-mode or A-mode
2233  if (isospeed >= vpISO_SPEED_800) {
2234  if (camera->bmode_capable != DC1394_TRUE) {
2235 // vpERROR_TRACE("Camera is not 1394B mode capable. \n"
2236 // "Set the iso speed lower or equal to 400Mbps");
2237  close();
2239  "Camera is not 1394B mode capable") );
2240  }
2241 
2242  if(dc1394_video_set_operation_mode(camera,
2243  DC1394_OPERATION_MODE_1394B)
2244  != DC1394_SUCCESS) {
2245 // vpERROR_TRACE("Cannot set camera to 1394B mode. \n");
2246  close();
2248  "Cannot set camera to 1394B mode") );
2249  }
2250 
2251  if (dc1394_video_get_operation_mode(camera, &op_mode) != DC1394_SUCCESS) {
2252 // vpERROR_TRACE("Failed to set 1394B mode. \n");
2253  close();
2255  "Failed to set 1394B mode") );
2256  }
2257  }
2258  else {
2259  if (dc1394_video_set_operation_mode(camera,
2260  DC1394_OPERATION_MODE_LEGACY)
2261  != DC1394_SUCCESS) {
2262 // vpERROR_TRACE("Cannot set camera to 1394A mode. \n");
2263  close();
2265  "Cannot set camera to 1394A mode") );
2266  }
2267 
2268  if (dc1394_video_get_operation_mode(camera, &op_mode) != DC1394_SUCCESS) {
2269 // vpERROR_TRACE("Failed to set 1394A mode. \n");
2270  close();
2272  "Failed to set 1394A mode") );
2273  }
2274  }
2275 
2276  if (dc1394_video_set_iso_speed(camera, (dc1394speed_t) isospeed)
2277  != DC1394_SUCCESS) {
2278 // vpERROR_TRACE("Cannot set requested iso speed. \n");
2279  close();
2281  "Cannot set requested iso speed") );
2282  }
2283 
2284  if (dc1394_video_get_iso_speed(camera, &speed) != DC1394_SUCCESS) {
2285 // vpERROR_TRACE("Failed to set iso speed. \n");
2286  close();
2288  "Failed to set iso speed") );
2289  }
2290 }
2291 
2302 void
2304 {
2305  open();
2306  acquire(I);
2307 }
2308 
2319 void
2321 {
2322  open();
2323  acquire(I);
2324 }
2325 
2326 
2365 dc1394video_frame_t *
2367 {
2368 
2369  if (! num_cameras) {
2370  close();
2371  vpERROR_TRACE("No camera found");
2373  "No camera found") );
2374  }
2375 
2376  dc1394video_frame_t *frame = NULL;
2377 
2378  if (dc1394_capture_dequeue(camera, DC1394_CAPTURE_POLICY_WAIT, &frame)
2379  !=DC1394_SUCCESS) {
2380  vpERROR_TRACE ("Error: Failed to capture from camera %d\n", camera_id);
2381  }
2382 
2383  return frame;
2384 }
2385 
2427 dc1394video_frame_t *
2429 {
2430  uint64_t timestamp;
2431  uint32_t id;
2432 
2433  dc1394video_frame_t *frame;
2434 
2435  frame = dequeue(I, timestamp, id);
2436 
2437  return frame;
2438 }
2439 
2488 dc1394video_frame_t *
2490  uint64_t &timestamp,
2491  uint32_t &id)
2492 {
2493 
2494  open();
2495 
2496  dc1394video_frame_t *frame;
2497 
2498  frame = dequeue();
2499 
2500  // Timeval data structure providing the unix time
2501  // [microseconds] at which the frame was captured in the ring buffer.
2502  timestamp = frame->timestamp;
2503  id = frame->id;
2504 
2505  this->width = frame->size[0];
2506  this->height = frame->size[1];
2507  unsigned int size = this->width * this->height;
2508 
2509  if ((I.getWidth() != this->width)||(I.getHeight() != this->height))
2510  I.resize(this->height, this->width);
2511 
2512  switch(frame->color_coding) {
2513  case DC1394_COLOR_CODING_MONO8:
2514  case DC1394_COLOR_CODING_RAW8:
2515  memcpy(I.bitmap, (unsigned char *) frame->image,
2516  size*sizeof(unsigned char));
2517  break;
2518  case DC1394_COLOR_CODING_MONO16:
2519  case DC1394_COLOR_CODING_RAW16:
2520  vpImageConvert::MONO16ToGrey( (unsigned char *) frame->image,
2521  I.bitmap, size);
2522  break;
2523 
2524  case DC1394_COLOR_CODING_YUV411:
2525  vpImageConvert::YUV411ToGrey( (unsigned char *) frame->image,
2526  I.bitmap, size);
2527  break;
2528 
2529  case DC1394_COLOR_CODING_YUV422:
2530  vpImageConvert::YUV422ToGrey( (unsigned char *) frame->image,
2531  I.bitmap, size);
2532  break;
2533 
2534  case DC1394_COLOR_CODING_YUV444:
2535  vpImageConvert::YUV444ToGrey( (unsigned char *) frame->image,
2536  I.bitmap, size);
2537  break;
2538 
2539  case DC1394_COLOR_CODING_RGB8:
2540  vpImageConvert::RGBToGrey((unsigned char *) frame->image, I.bitmap, size);
2541  break;
2542 
2543 
2544  default:
2545  close();
2546  vpERROR_TRACE("Format conversion not implemented. Acquisition failed.");
2548  "Format conversion not implemented. "
2549  "Acquisition failed.") );
2550  break;
2551  };
2552 
2553  return frame;
2554 }
2555 
2596 dc1394video_frame_t *
2598 {
2599  uint64_t timestamp;
2600  uint32_t id;
2601 
2602  dc1394video_frame_t *frame;
2603 
2604  frame = dequeue(I, timestamp, id);
2605 
2606  return frame;
2607 }
2608 
2657 dc1394video_frame_t *
2659  uint64_t &timestamp,
2660  uint32_t &id)
2661 {
2662 
2663  open();
2664 
2665  dc1394video_frame_t *frame;
2666 
2667  frame = dequeue();
2668 
2669  // Timeval data structure providing the unix time
2670  // [microseconds] at which the frame was captured in the ring buffer.
2671  timestamp = frame->timestamp;
2672  id = frame->id;
2673 
2674  this->width = frame->size[0];
2675  this->height = frame->size[1];
2676  unsigned int size = this->width * this->height;
2677 
2678  if ((I.getWidth() != width)||(I.getHeight() != height))
2679  I.resize(height, width);
2680 
2681  switch (frame->color_coding) {
2682  case DC1394_COLOR_CODING_MONO8:
2683  case DC1394_COLOR_CODING_RAW8:
2684  vpImageConvert::GreyToRGBa((unsigned char *) frame->image,
2685  (unsigned char *) I.bitmap, size);
2686  break;
2687 
2688  case DC1394_COLOR_CODING_MONO16:
2689  case DC1394_COLOR_CODING_RAW16:
2690  vpImageConvert::MONO16ToRGBa((unsigned char *) frame->image,
2691  (unsigned char *) I.bitmap, size);
2692  break;
2693 
2694  case DC1394_COLOR_CODING_YUV411:
2695  vpImageConvert::YUV411ToRGBa( (unsigned char *) frame->image,
2696  (unsigned char *) I.bitmap, size);
2697  break;
2698 
2699  case DC1394_COLOR_CODING_YUV422:
2700  vpImageConvert::YUV422ToRGBa( (unsigned char *) frame->image,
2701  (unsigned char *) I.bitmap, size);
2702  break;
2703 
2704  case DC1394_COLOR_CODING_YUV444:
2705  vpImageConvert::YUV444ToRGBa( (unsigned char *) frame->image,
2706  (unsigned char *) I.bitmap, size);
2707  break;
2708 
2709  case DC1394_COLOR_CODING_RGB8:
2710  vpImageConvert::RGBToRGBa((unsigned char *) frame->image,
2711  (unsigned char *) I.bitmap, size);
2712  break;
2713 
2714 
2715  default:
2716  close();
2717  vpERROR_TRACE("Format conversion not implemented. Acquisition failed.");
2719  "Format conversion not implemented. "
2720  "Acquisition failed.") );
2721  break;
2722  };
2723 
2724  return frame;
2725 }
2726 
2737 void
2738 vp1394TwoGrabber::enqueue(dc1394video_frame_t *frame)
2739 {
2740 
2741  if (! num_cameras) {
2742  close();
2743  vpERROR_TRACE("No camera found");
2745  "No camera found") );
2746  }
2747 
2748  if (frame)
2749  dc1394_capture_enqueue(camera, frame);
2750 }
2751 
2752 
2766 void
2768 {
2769  uint64_t timestamp;
2770  uint32_t id;
2771 
2772  dc1394video_frame_t *frame;
2773 
2774  frame = dequeue(I, timestamp, id);
2775  enqueue(frame);
2776 }
2777 
2796 void
2798  uint64_t &timestamp,
2799  uint32_t &id)
2800 {
2801  dc1394video_frame_t *frame;
2802 
2803  open();
2804  frame = dequeue(I, timestamp, id);
2805  enqueue(frame);
2806 }
2807 
2808 
2809 
2823 void
2825 {
2826  uint64_t timestamp;
2827  uint32_t id;
2828  dc1394video_frame_t *frame;
2829 
2830  open();
2831  frame = dequeue(I, timestamp, id);
2832  enqueue(frame);
2833 }
2834 
2853 void
2855  uint64_t &timestamp,
2856  uint32_t &id)
2857 {
2858  dc1394video_frame_t *frame;
2859 
2860  open();
2861  frame = dequeue();
2862  // Timeval data structure providing the unix time
2863  // [microseconds] at which the frame was captured in the ring buffer.
2864  timestamp = frame->timestamp;
2865  id = frame->id;
2866 
2867  this->width = frame->size[0];
2868  this->height = frame->size[1];
2869  unsigned int size = this->width * this->height;
2870 
2871  if ((I.getWidth() != width)||(I.getHeight() != height))
2872  I.resize(height, width);
2873 
2874  switch (frame->color_coding) {
2875  case DC1394_COLOR_CODING_MONO8:
2876  case DC1394_COLOR_CODING_RAW8:
2877  vpImageConvert::GreyToRGBa((unsigned char *) frame->image,
2878  (unsigned char *) I.bitmap, size);
2879  break;
2880 
2881  case DC1394_COLOR_CODING_YUV411:
2882  vpImageConvert::YUV411ToRGBa( (unsigned char *) frame->image,
2883  (unsigned char *) I.bitmap, size);
2884  break;
2885 
2886  case DC1394_COLOR_CODING_YUV422:
2887  vpImageConvert::YUV422ToRGBa( (unsigned char *) frame->image,
2888  (unsigned char *) I.bitmap, size);
2889  break;
2890 
2891  case DC1394_COLOR_CODING_YUV444:
2892  vpImageConvert::YUV444ToRGBa( (unsigned char *) frame->image,
2893  (unsigned char *) I.bitmap, size);
2894  break;
2895 
2896  case DC1394_COLOR_CODING_RGB8:
2897  vpImageConvert::RGBToRGBa((unsigned char *) frame->image,
2898  (unsigned char *) I.bitmap, size);
2899  break;
2900 
2901 
2902  default:
2903  close();
2904  vpERROR_TRACE("Format conversion not implemented. Acquisition failed.");
2906  "Format conversion not implemented. "
2907  "Acquisition failed.") );
2908  break;
2909  };
2910 
2911  enqueue(frame);
2912 
2913 }
2914 
2931 void vp1394TwoGrabber::getWidth(unsigned int &w)
2932 {
2933  if (! num_cameras) {
2934  close();
2935  vpERROR_TRACE("No camera found");
2937  "No camera found") );
2938  }
2939 
2940  w = this->width;
2941 }
2942 
2960 {
2961  if (! num_cameras) {
2962  close();
2963  vpERROR_TRACE("No camera found");
2965  "No camera found") );
2966  }
2967 
2968  return this->width;
2969 }
2970 
2988 void vp1394TwoGrabber::getHeight(unsigned int &h)
2989 {
2990  if (! num_cameras) {
2991  close();
2992  vpERROR_TRACE("No camera found");
2994  "No camera found") );
2995  }
2996 
2997  h = this->height;
2998 }
3017 {
3018  if (! num_cameras) {
3019  close();
3020  vpERROR_TRACE("No camera found");
3022  "No camera found") );
3023  }
3024 
3025  return this->height;
3026 }
3027 
3033 void
3035 {
3036  std::cout << "----------------------------------------------------------"
3037  << std::endl
3038  << "----- Information for camera " << camera_id
3039  << " -----" << std::endl
3040  << "----------------------------------------------------------" << std::endl;
3041 
3042 #ifdef VISP_HAVE_DC1394_CAMERA_ENUMERATE // new API > libdc1394-2.0.0-rc7
3043  dc1394_camera_print_info( camera, stdout);
3044 #elif defined VISP_HAVE_DC1394_FIND_CAMERAS // old API <= libdc1394-2.0.0-rc7
3045  dc1394_print_camera_info( camera);
3046 #endif
3047 
3048  dc1394featureset_t features;
3049 #ifdef VISP_HAVE_DC1394_CAMERA_ENUMERATE // new API > libdc1394-2.0.0-rc7
3050  if (dc1394_feature_get_all(camera, &features) != DC1394_SUCCESS)
3051 #elif defined VISP_HAVE_DC1394_FIND_CAMERAS // old API <= libdc1394-2.0.0-rc7
3052  if (dc1394_get_camera_feature_set(camera, &features) != DC1394_SUCCESS)
3053 #endif
3054  {
3055  close();
3056  vpERROR_TRACE("unable to get feature set for camera %d\n", camera_id);
3058  "Cannot get camera features") );
3059 
3060  } else {
3061 #ifdef VISP_HAVE_DC1394_CAMERA_ENUMERATE // new API > libdc1394-2.0.0-rc7
3062  dc1394_feature_print_all(&features, stdout);
3063 #elif defined VISP_HAVE_DC1394_FIND_CAMERAS // old API <= libdc1394-2.0.0-rc7
3064  dc1394_print_feature_set(&features);
3065 #endif
3066  }
3067  std::cout << "----------------------------------------------------------" << std::endl;
3068 }
3069 
3083 {
3084  std::string _str = "";
3085  dc1394video_mode_t _videomode = (dc1394video_mode_t) videomode;
3086 
3087  if ((_videomode >= DC1394_VIDEO_MODE_MIN)
3088  && (_videomode <= DC1394_VIDEO_MODE_MAX)) {
3089  _str = strVideoMode[_videomode - DC1394_VIDEO_MODE_MIN];
3090  }
3091  else {
3092  vpCERROR << "The video mode " << (int)videomode
3093  << " is not supported by the camera" << std::endl;
3094  }
3095 
3096  return _str;
3097 }
3098 
3112 {
3113  std::string _str = "";
3114  dc1394framerate_t _fps = (dc1394framerate_t) fps;
3115 
3116  if ((_fps >= DC1394_FRAMERATE_MIN)
3117  && (_fps <= DC1394_FRAMERATE_MAX)) {
3118  _str = strFramerate[_fps - DC1394_FRAMERATE_MIN];
3119  }
3120  else {
3121  vpCERROR << "The framerate " << (int)fps
3122  << " is not supported by the camera" << std::endl;
3123  }
3124 
3125  return _str;
3126 }
3127 
3141 {
3142  std::string _str = "";
3143  dc1394color_coding_t _coding = (dc1394color_coding_t) colorcoding;
3144 
3145  if ((_coding >= DC1394_COLOR_CODING_MIN)
3146  && (_coding <= DC1394_COLOR_CODING_MAX)) {
3147  _str = strColorCoding[_coding - DC1394_COLOR_CODING_MIN];
3148 
3149  }
3150  else {
3151  vpCERROR << "The color coding " << (int)colorcoding
3152  << " is not supported by the camera" << std::endl;
3153  }
3154 
3155  return _str;
3156 }
3157 
3177 {
3179 
3180  for (int i = DC1394_VIDEO_MODE_MIN; i <= DC1394_VIDEO_MODE_MAX; i ++) {
3181  _id = (vp1394TwoVideoModeType) i;
3182  if (videomode.compare(videoMode2string(_id)) == 0)
3183  return _id;
3184  };
3185 
3187  "The required videomode is not valid") );
3188 
3189  return (vp1394TwoVideoModeType) 0;
3190 }
3191 
3192 
3212 {
3214 
3215  for (int i = DC1394_FRAMERATE_MIN; i <= DC1394_FRAMERATE_MAX; i ++) {
3216  _id = (vp1394TwoFramerateType) i;
3217  if (framerate.compare(framerate2string(_id)) == 0)
3218  return _id;
3219  };
3220 
3222  "The required framerate is not valid") );
3223 
3224  return (vp1394TwoFramerateType) 0;
3225 }
3226 
3246 {
3248 
3249  for (int i = DC1394_COLOR_CODING_MIN; i <= DC1394_COLOR_CODING_MAX; i ++) {
3250  _id = (vp1394TwoColorCodingType) i;
3251  if (colorcoding.compare(colorCoding2string(_id)) == 0)
3252  return _id;
3253  };
3254 
3256  "The required color coding is not valid") );
3257 
3258  return (vp1394TwoColorCodingType) 0;
3259 }
3260 
3294 {
3295  for (unsigned int i = 0; i < num_cameras;i++) {
3296  if (camIsOpen[i]) {
3297  camera = cameras[i];
3298  setTransmission(DC1394_OFF);
3299  setCapture(DC1394_OFF);
3300  }
3301  }
3302 #ifdef VISP_HAVE_DC1394_CAMERA_ENUMERATE // new API > libdc1394-2.0.0-rc7
3303  setCamera(camera_id);
3304  // free the other cameras
3305  for (unsigned int i=0;i<num_cameras;i++){
3306  if (i!=camera_id) dc1394_camera_free(cameras[i]);
3307  }
3308 
3309  printf ("Reseting bus...\n");
3310  dc1394_reset_bus (camera);
3311 
3312  dc1394_camera_free (camera);
3313  dc1394_free (d);
3314  d = NULL;
3315  //if (cameras != NULL)
3316  delete [] cameras;
3317  cameras = NULL ;
3318 #elif defined VISP_HAVE_DC1394_FIND_CAMERAS // old API <= libdc1394-2.0.0-rc7
3319 
3320  setCamera(camera_id);
3321  // free the other cameras
3322  for (unsigned int i=0;i<num_cameras;i++){
3323  if (i!=camera_id) dc1394_free_camera(cameras[i]);
3324  }
3325  free(cameras);
3326  cameras = NULL;
3327 
3328  dc1394_reset_bus(camera);
3329  dc1394_free_camera(camera);
3330 
3331 #endif
3332  if (camIsOpen != NULL)
3333  delete [] camIsOpen;
3334  camIsOpen = NULL ;
3335 
3336  num_cameras = 0;
3337 
3338  init = false;
3339  vpTime::wait(1000);
3340  initialize(false);
3341 }
3342 
3372 void vp1394TwoGrabber::setPanControl(unsigned int panControlValue)
3373 {
3374  open();
3375  if (! num_cameras) {
3376  close();
3377  vpERROR_TRACE("No camera found");
3379  "No camera found") );
3380  }
3381  uint64_t offset = 0x884;
3382  uint32_t value = 0x82000000 + (uint32_t)panControlValue;
3383  dc1394error_t err;
3384  err = dc1394_set_control_register(camera, offset, value);
3385  if (err != DC1394_SUCCESS) {
3386  vpERROR_TRACE("Unable to set PAN register");
3387  close();
3389  "Unable to set PAN register") );
3390  }
3391 }
3392 
3393 
3411 {
3412  if (! num_cameras) {
3413  close();
3414  vpERROR_TRACE("No camera found");
3416  "No camera found") );
3417  }
3418 
3419  uint32_t value;
3420  dc1394feature_t feature = DC1394_FEATURE_BRIGHTNESS;// = (dc1394feature_t)param;
3421  switch(param) {
3422  case vpFEATURE_BRIGHTNESS: feature = DC1394_FEATURE_BRIGHTNESS; break;
3423  case vpFEATURE_EXPOSURE: feature = DC1394_FEATURE_EXPOSURE; break;
3424  case vpFEATURE_SHARPNESS: feature = DC1394_FEATURE_SHARPNESS; break;
3425 // vpFEATURE_WHITE_BALANCE = DC1394_FEATURE_WHITE_BALANCE,
3426  case vpFEATURE_HUE: feature = DC1394_FEATURE_HUE; break;
3427  case vpFEATURE_SATURATION: feature = DC1394_FEATURE_SATURATION; break;
3428  case vpFEATURE_GAMMA: feature = DC1394_FEATURE_GAMMA; break;
3429  case vpFEATURE_SHUTTER: feature = DC1394_FEATURE_SHUTTER; break;
3430  case vpFEATURE_GAIN: feature = DC1394_FEATURE_GAIN; break;
3431  case vpFEATURE_IRIS: feature = DC1394_FEATURE_IRIS; break;
3432 // vpFEATURE_FOCUS = DC1394_FEATURE_FOCUS,
3433 // vpFEATURE_TEMPERATURE = DC1394_FEATURE_TEMPERATURE,
3434 // vpFEATURE_TRIGGER = DC1394_FEATURE_TRIGGER,
3435 // vpFEATURE_TRIGGER_DELAY = DC1394_FEATURE_TRIGGER_DELAY,
3436 // vpFEATURE_WHITE_SHADING = DC1394_FEATURE_WHITE_SHADING,
3437 // vpFEATURE_FRAME_RATE = DC1394_FEATURE_FRAME_RATE,
3438 // vpFEATURE_ZOOM = DC1394_FEATURE_ZOOM,
3439 // vpFEATURE_PAN = DC1394_FEATURE_PAN,
3440 // vpFEATURE_TILT = DC1394_FEATURE_TILT,
3441 // vpFEATURE_OPTICAL_FILTER = DC1394_FEATURE_OPTICAL_FILTER,
3442 // vpFEATURE_CAPTURE_SIZE = DC1394_FEATURE_CAPTURE_SIZE,
3443 // vpFEATURE_CAPTURE_QUALITY = DC1394_FEATURE_CAPTURE_QUALITY
3444  }
3445 
3446  dc1394error_t err;
3447  err = dc1394_feature_get_value(camera, feature, &value);
3448  if (err != DC1394_SUCCESS) {
3449  vpERROR_TRACE("Unable to get the information");
3450  close();
3452  "Unable to get the information") );
3453  }
3454  return (unsigned int)value;
3455 }
3456 
3457 
3479  unsigned int val)
3480 {
3481  if (! num_cameras) {
3482  close();
3483  vpERROR_TRACE("No camera found");
3485  "No camera found") );
3486  }
3487  uint32_t value = (uint32_t)val;
3488  dc1394feature_t feature = DC1394_FEATURE_BRIGHTNESS;// = (dc1394feature_t)param;
3489  switch(param) {
3490  case vpFEATURE_BRIGHTNESS: feature = DC1394_FEATURE_BRIGHTNESS; break;
3491  case vpFEATURE_EXPOSURE: feature = DC1394_FEATURE_EXPOSURE; break;
3492  case vpFEATURE_SHARPNESS: feature = DC1394_FEATURE_SHARPNESS; break;
3493 // vpFEATURE_WHITE_BALANCE = DC1394_FEATURE_WHITE_BALANCE,
3494  case vpFEATURE_HUE: feature = DC1394_FEATURE_HUE; break;
3495  case vpFEATURE_SATURATION: feature = DC1394_FEATURE_SATURATION; break;
3496  case vpFEATURE_GAMMA: feature = DC1394_FEATURE_GAMMA; break;
3497  case vpFEATURE_SHUTTER: feature = DC1394_FEATURE_SHUTTER; break;
3498  case vpFEATURE_GAIN: feature = DC1394_FEATURE_GAIN; break;
3499  case vpFEATURE_IRIS: feature = DC1394_FEATURE_IRIS; break;
3500 // vpFEATURE_FOCUS = DC1394_FEATURE_FOCUS,
3501 // vpFEATURE_TEMPERATURE = DC1394_FEATURE_TEMPERATURE,
3502 // vpFEATURE_TRIGGER = DC1394_FEATURE_TRIGGER,
3503 // vpFEATURE_TRIGGER_DELAY = DC1394_FEATURE_TRIGGER_DELAY,
3504 // vpFEATURE_WHITE_SHADING = DC1394_FEATURE_WHITE_SHADING,
3505 // vpFEATURE_FRAME_RATE = DC1394_FEATURE_FRAME_RATE,
3506 // vpFEATURE_ZOOM = DC1394_FEATURE_ZOOM,
3507 // vpFEATURE_PAN = DC1394_FEATURE_PAN,
3508 // vpFEATURE_TILT = DC1394_FEATURE_TILT,
3509 // vpFEATURE_OPTICAL_FILTER = DC1394_FEATURE_OPTICAL_FILTER,
3510 // vpFEATURE_CAPTURE_SIZE = DC1394_FEATURE_CAPTURE_SIZE,
3511 // vpFEATURE_CAPTURE_QUALITY = DC1394_FEATURE_CAPTURE_QUALITY
3512  }
3513 
3514  dc1394error_t err;
3515  dc1394bool_t hasManualMode = DC1394_FALSE;
3516  dc1394feature_modes_t modesAvailable;
3517 
3518  // test wether we can set the shutter value (manual mode available or not)
3519  err = dc1394_feature_get_modes(camera, feature, &modesAvailable);
3520  if (err != DC1394_SUCCESS) {
3521  vpERROR_TRACE("Unable to detect the manual mode information");
3522  close();
3524  "Unable to detect the manual mode information"));
3525  }
3526 
3527  for(unsigned int i=0; i<modesAvailable.num; i++){
3528  if(modesAvailable.modes[i] == DC1394_FEATURE_MODE_MANUAL){
3529  hasManualMode = DC1394_TRUE;
3530  }
3531  }
3532 
3533  if(hasManualMode == DC1394_TRUE){
3534 
3535  if(!isDataModified[camera_id]){// to ensure we save the first mode even after several set
3536  /* we update the structure */
3537  updateDataCamToStruct();
3538  err = dc1394_feature_get_mode(camera, feature, &(initialShutterMode[camera_id]));
3539  if (err != DC1394_SUCCESS) {
3540  vpERROR_TRACE("Unable to get the initial mode");
3541  close();
3543  "Unable to get the initial mode"));
3544  }
3545  isDataModified[camera_id] = true;
3546  }
3547 
3548  dc1394feature_mode_t manualMode = DC1394_FEATURE_MODE_MANUAL;
3549  err = dc1394_feature_set_mode(camera, feature, manualMode);
3550  if (err != DC1394_SUCCESS) {
3551  vpERROR_TRACE("Unable to set the muanual mode");
3552  close();
3554  "Unable to set the manual mode") );
3555  }
3556  err = dc1394_feature_set_value(camera, feature, value);
3557  if (err != DC1394_SUCCESS) {
3558  vpERROR_TRACE("Unable to set the shutter information");
3559  close();
3561  "Unable to set the shutter information") );
3562  }
3563  }
3564  else{
3565  vpERROR_TRACE("The camera does not have a manual mode.\nCannot change the value");
3567  "The camera does not have a manual mode"));
3568  }
3569 }
3577 void
3579 {
3580  if (! num_cameras) {
3581  close();
3582  vpERROR_TRACE("No camera found");
3584  "No camera found") );
3585  }
3586 
3587  guid = camera->guid;
3588 }
3589 
3597 uint64_t
3599 {
3600  if (! num_cameras) {
3601  close();
3602  vpERROR_TRACE("No camera found");
3604  "No camera found") );
3605  }
3606 
3607  return camera->guid;
3608 }
3609 
3610 
3615 inline void
3616 vp1394TwoGrabber::updateDataCamToStruct()
3617 {
3618  dataCam[camera_id].brightness = getParameterValue(vpFEATURE_BRIGHTNESS);
3619  dataCam[camera_id].exposure = getParameterValue(vpFEATURE_EXPOSURE);
3620  dataCam[camera_id].sharpness = getParameterValue(vpFEATURE_SHARPNESS);
3621  dataCam[camera_id].hue = getParameterValue(vpFEATURE_HUE);
3622  dataCam[camera_id].saturation = getParameterValue(vpFEATURE_SATURATION);
3623  dataCam[camera_id].gamma = getParameterValue(vpFEATURE_GAMMA);
3624  dataCam[camera_id].shutter = getParameterValue(vpFEATURE_SHUTTER);
3625  dataCam[camera_id].gain = getParameterValue(vpFEATURE_GAIN);
3626  dataCam[camera_id].iris = getParameterValue(vpFEATURE_IRIS);
3627 }
3628 
3633 inline void
3634 vp1394TwoGrabber::updateDataStructToCam()
3635 {
3636  setParameterValue(vpFEATURE_BRIGHTNESS, dataCam[camera_id].brightness);
3637  setParameterValue(vpFEATURE_EXPOSURE, dataCam[camera_id].exposure);
3638  setParameterValue(vpFEATURE_SHARPNESS, dataCam[camera_id].sharpness);
3639  setParameterValue(vpFEATURE_HUE, dataCam[camera_id].hue);
3640  setParameterValue(vpFEATURE_SATURATION, dataCam[camera_id].saturation);
3641  setParameterValue(vpFEATURE_GAMMA, dataCam[camera_id].gamma);
3642  setParameterValue(vpFEATURE_SHUTTER, dataCam[camera_id].shutter);
3643  setParameterValue(vpFEATURE_GAIN, dataCam[camera_id].gain);
3644  setParameterValue(vpFEATURE_IRIS, dataCam[camera_id].iris);
3645 }
3646 
3664 {
3665  this->acquire(I);
3666  return *this;
3667 }
3668 
3686 {
3687  this->acquire(I);
3688  return *this;
3689 }
3690 
3691 #elif !defined(VISP_BUILD_SHARED_LIBS)
3692 // Work arround to avoid warning: libvisp_sensor.a(vp1394TwoGrabber.cpp.o) has no symbols
3693 void dummy_vp1394TwoGrabber() {};
3694 #endif
3695 
void getColorCoding(vp1394TwoColorCodingType &coding)
static const char * strFramerate[DC1394_FRAMERATE_NUM]
VISP_EXPORT int wait(double t0, double t)
Definition: vpTime.cpp:157
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
Definition: vpImage.h:226
#define vpCERROR
Definition: vpDebug.h:365
static void RGBToRGBa(unsigned char *rgb, unsigned char *rgba, unsigned int size)
Type * bitmap
points toward the bitmap
Definition: vpImage.h:134
static void MONO16ToGrey(unsigned char *grey16, unsigned char *grey, unsigned int size)
#define vpERROR_TRACE
Definition: vpDebug.h:391
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)
vp1394TwoGrabber & operator>>(vpImage< unsigned char > &I)
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)
#define vpTRACE
Definition: vpDebug.h:414
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)
resize the image : Image initialization
Definition: vpImage.h:903
void enqueue(dc1394video_frame_t *frame)
static vp1394TwoFramerateType string2framerate(std::string fps)
unsigned int getWidth()
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)
#define vpCTRACE
Definition: vpDebug.h:337
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
Definition: vpImage.h:175
bool isVideoModeSupported(vp1394TwoVideoModeType videomode)
Class for firewire ieee1394 video devices using libdc1394-2.x api.
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.
unsigned int getHeight()
void setAutoShutter(bool enable=true)