ViSP  2.9.0
vp1394TwoGrabber.cpp
1 /****************************************************************************
2  *
3  * $Id: vp1394TwoGrabber.cpp 4649 2014-02-07 14:57:11Z fspindle $
4  *
5  * This file is part of the ViSP software.
6  * Copyright (C) 2005 - 2014 by INRIA. All rights reserved.
7  *
8  * This software is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU General Public License
10  * ("GPL") version 2 as published by the Free Software Foundation.
11  * See the file LICENSE.txt at the root directory of this source
12  * distribution for additional information about the GNU GPL.
13  *
14  * For using ViSP with software that can not be combined with the GNU
15  * GPL, please contact INRIA about acquiring a ViSP Professional
16  * Edition License.
17  *
18  * See http://www.irisa.fr/lagadic/visp/visp.html for more information.
19  *
20  * This software was developed at:
21  * INRIA Rennes - Bretagne Atlantique
22  * Campus Universitaire de Beaulieu
23  * 35042 Rennes Cedex
24  * France
25  * http://www.irisa.fr/lagadic
26  *
27  * If you have questions regarding the use of this file, please contact
28  * INRIA at visp@inria.fr
29  *
30  * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
31  * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
32  *
33  *
34  * Description:
35  * Firewire cameras video capture.
36  *
37  * Authors:
38  * Fabien Spindler
39  *
40  *****************************************************************************/
41 
42 
48 #include <iostream>
49 
50 #include <visp/vpConfig.h>
51 
52 /*
53  * Interface with libdc1394 2.x
54  */
55 #if defined(VISP_HAVE_DC1394_2)
56 #include <unistd.h>
57 
58 #include <visp/vp1394TwoGrabber.h>
59 #include <visp/vpFrameGrabberException.h>
60 #include <visp/vpImageIo.h>
61 #include <visp/vpImageConvert.h>
62 #include <visp/vpTime.h>
63 
64 const char * vp1394TwoGrabber::strVideoMode[DC1394_VIDEO_MODE_NUM]= {
65  "MODE_160x120_YUV444",
66  "MODE_320x240_YUV422",
67  "MODE_640x480_YUV411",
68  "MODE_640x480_YUV422",
69  "MODE_640x480_RGB8",
70  "MODE_640x480_MONO8",
71  "MODE_640x480_MONO16",
72  "MODE_800x600_YUV422",
73  "MODE_800x600_RGB8",
74  "MODE_800x600_MONO8",
75  "MODE_1024x768_YUV422",
76  "MODE_1024x768_RGB8",
77  "MODE_1024x768_MONO8",
78  "MODE_800x600_MONO16",
79  "MODE_1024x768_MONO16",
80  "MODE_1280x960_YUV422",
81  "MODE_1280x960_RGB8",
82  "MODE_1280x960_MONO8",
83  "MODE_1600x1200_YUV422",
84  "MODE_1600x1200_RGB8",
85  "MODE_1600x1200_MONO8",
86  "MODE_1280x960_MONO16",
87  "MODE_1600x1200_MONO16",
88  "MODE_EXIF",
89  "MODE_FORMAT7_0",
90  "MODE_FORMAT7_1",
91  "MODE_FORMAT7_2",
92  "MODE_FORMAT7_3",
93  "MODE_FORMAT7_4",
94  "MODE_FORMAT7_5",
95  "MODE_FORMAT7_6",
96  "MODE_FORMAT7_7"
97 };
98 
99 const char * vp1394TwoGrabber::strFramerate[DC1394_FRAMERATE_NUM]= {
100  "FRAMERATE_1_875",
101  "FRAMERATE_3_75",
102  "FRAMERATE_7_5",
103  "FRAMERATE_15",
104  "FRAMERATE_30",
105  "FRAMERATE_60",
106  "FRAMERATE_120",
107  "FRAMERATE_240"
108 };
109 
110 const char * vp1394TwoGrabber::strColorCoding[DC1394_COLOR_CODING_NUM]= {
111  "COLOR_CODING_MONO8",
112  "COLOR_CODING_YUV411",
113  "COLOR_CODING_YUV422",
114  "COLOR_CODING_YUV444",
115  "COLOR_CODING_RGB8",
116  "COLOR_CODING_MONO16",
117  "COLOR_CODING_RGB16",
118  "COLOR_CODING_MONO16S",
119  "COLOR_CODING_RGB16S",
120  "COLOR_CODING_RAW8",
121  "COLOR_CODING_RAW16",
122 };
123 
124 
125 
171  : camera(NULL), cameras(NULL), num_cameras(0), camera_id(0), verbose(false), camIsOpen(NULL),
172  num_buffers(4), // ring buffer size
173  isDataModified(NULL), initialShutterMode(NULL), dataCam(NULL)
174  #ifdef VISP_HAVE_DC1394_2_CAMERA_ENUMERATE // new API > libdc1394-2.0.0-rc7
175  , d(NULL),
176  list(NULL)
177  #endif
178 {
179  // protected members
180  width = height = 0;
181 
182  // private members
183  init = false;
184 
185  reset = false;
186  initialize(reset);
187 
188  // open();
189 }
190 
201 {
202 /* if(num_cameras >= 1){
203  delete[] isDataModified;
204  delete[] initialShutterMode;
205  delete[] dataCam;
206  }*/
207  close();
208 }
209 
330 void
332 {
333  // Suppose that if camera_id is a camera GUID, this value is greater
334  // than the number of cameras connected to the bus
335  if (cam_id >= num_cameras) {
336  // Check if camera_id is a camera guid
337  bool is_guid = false;
338  // check if the camera_id is a guid
339  for (unsigned int i=0; i< num_cameras; i++) {
340  if (cameras[i]->guid == camera_id) {
341  this->camera_id = i;
342  is_guid = true;
343  break;
344  }
345  }
346  if (is_guid == false) {
347  close();
348  vpERROR_TRACE("The camera with GUID 0x%x or id %u is not present",
349  camera_id, camera_id);
350  vpERROR_TRACE("Only %u camera on the bus.", num_cameras);
352  "The required camera is not present") );
353  }
354  }
355  else {
356  this->camera_id = cam_id;
357  }
358 
359  // create a pointer to the working camera
360  camera = cameras[this->camera_id];
361 }
362 
363 
378 void
380 {
381  if (num_cameras) {
382  cam_id = this->camera_id;
383  }
384  else {
385  close();
386  vpERROR_TRACE("No cameras found");
388  "No cameras found") );
389  }
390 }
391 
406 uint64_t
408 {
409  if (num_cameras) {
410  return this->camera_id;
411  }
412  else {
413  close();
414  vpERROR_TRACE("No cameras found");
416  "No cameras found") );
417  }
418 }
419 
427 void
428 vp1394TwoGrabber::getNumCameras(unsigned int &ncameras) const
429 {
430  if (! num_cameras) {
431  vpCTRACE << "No camera found..."<< std::endl;
432  ncameras = 0;
433  }
434 
435  ncameras = num_cameras;
436 }
437 
445 unsigned int
447 {
448  unsigned int ncameras = 0;
449  if (! num_cameras) {
450  vpCTRACE << "No camera found..."<< std::endl;
451  ncameras = 0;
452  }
453 
454  ncameras = num_cameras;
455  return ncameras;
456 }
457 
503 void
505 {
506  open();
507  if (! num_cameras) {
508  close();
509  vpERROR_TRACE("No camera found");
511  "No camera found") );
512  }
513  if (!isVideoModeSupported(videomode)){
514  vpERROR_TRACE("Video mode not supported by camera %d",camera_id);
516  "Video mode not supported") );
517  return ;
518  }
519  // Stop dma capture if started
520  setTransmission(DC1394_OFF);
521  setCapture(DC1394_OFF);
522 
523  if (dc1394_video_set_mode(camera, (dc1394video_mode_t) videomode) != DC1394_SUCCESS) {
524 
525  close();
526  vpERROR_TRACE("Can't set video mode");
528  "Can't set video mode") );
529  }
530 
531  setCapture(DC1394_ON);
532  setTransmission(DC1394_ON);
533 
534  // Updates image size from new video mode
535  if (dc1394_get_image_size_from_video_mode(camera,
536  (dc1394video_mode_t) videomode,
537  &this->width, &this->height)
538  != DC1394_SUCCESS) {
539 
540  close();
541  vpERROR_TRACE("Can't set video mode");
543  "Can't get image size") );
544  }
545 
546 }
547 
564 void
566 {
567  if (! num_cameras) {
568  close();
569  vpERROR_TRACE("No camera found");
571  "No camera found") );
572  }
573 
574  dc1394video_mode_t _videomode;
575  if (dc1394_video_get_mode(camera, &_videomode) != DC1394_SUCCESS) {
576 
577  close();
578  vpERROR_TRACE("Can't get current video mode");
580  "Can't get current video mode") );
581  }
582  videomode = (vp1394TwoVideoModeType) _videomode;
583 
584 }
585 
586 
587 
605 uint32_t
606 vp1394TwoGrabber::getVideoModeSupported(std::list<vp1394TwoVideoModeType> & videomodes)
607 {
608  // Refresh the list of supported modes
609  videomodes.clear();
610 
611  if (! num_cameras) {
612  close();
613  vpERROR_TRACE("No camera found");
615  "No camera found") );
616  }
617  dc1394video_modes_t _videomodes;
618 
619  // get video modes:
620  if (dc1394_video_get_supported_modes(camera, &_videomodes)!=DC1394_SUCCESS) {
621 
622  close();
623  vpERROR_TRACE("Can't get video modes");
625  "Can't get video modes") );
626  }
627 
628  // parse the video modes to add in the list
629  for (unsigned i=0; i < _videomodes.num; i++) {
630  vp1394TwoVideoModeType _mode = (vp1394TwoVideoModeType) _videomodes.modes[i];
631  videomodes.push_back( _mode );
632  }
633 
634  // return the number of available video modes
635  return _videomodes.num;
636 }
652 bool
654 {
655  if (! num_cameras) {
656  close();
657  vpERROR_TRACE("No camera found");
659  "No camera found") );
660  }
661  dc1394video_modes_t _videomodes;
662 
663  // get video modes:
664  if (dc1394_video_get_supported_modes(camera, &_videomodes)!=DC1394_SUCCESS) {
665 
666  close();
667  vpERROR_TRACE("Can't get video modes");
669  "Can't get video modes") );
670  }
671 
672  // parse the video modes to check with the desired
673  for (unsigned i=0; i < _videomodes.num; i++) {
674  if ((vp1394TwoVideoModeType) _videomodes.modes[i] == videomode)
675  return true;
676  }
677  return false;
678 }
679 
692 bool
694 {
695 
696  if (dc1394_is_video_mode_scalable((dc1394video_mode_t) videomode))
697  return true;
698 
699  return false;
700 }
701 
717 bool
719 {
721  getColorCoding(coding);
722 
723  switch (coding) {
727  case vpCOLOR_CODING_RAW8:
729  return false;
733  case vpCOLOR_CODING_RGB8:
736  return true;
737  }
738  return false;
739 }
740 
765 void
767 {
768  open();
769  if (! num_cameras) {
770  close();
771  vpERROR_TRACE("No camera found");
773  "No camera found") );
774  }
775 
776  vp1394TwoVideoModeType cur_videomode;
777  getVideoMode(cur_videomode);
778  if (isVideoModeFormat7(cur_videomode))
779  return;
780 
781  if (!isFramerateSupported(cur_videomode,fps)){
782  vpERROR_TRACE("Framerate not supported by camera %d",camera_id);
784  "Framerate not supported") );
785  return ;
786  }
787 
788  // Stop dma capture if started
789  setTransmission(DC1394_OFF);
790  setCapture(DC1394_OFF);
791 
792  if (dc1394_video_set_framerate(camera, (dc1394framerate_t) fps) != DC1394_SUCCESS) {
793 
794  close();
795  vpERROR_TRACE("Can't set framerate");
797  "Can't set framerate") );
798  }
799 
800  setCapture(DC1394_ON);
801  setTransmission(DC1394_ON);
802 }
803 
820 void
822 {
823  if (! num_cameras) {
824  close();
825  vpERROR_TRACE("No camera found");
827  "No camera found") );
828  }
829  dc1394framerate_t _fps;
830  if (dc1394_video_get_framerate(camera, &_fps) != DC1394_SUCCESS) {
831 
832  close();
833  vpERROR_TRACE("Can't get current framerate");
835  "Can't get current framerate") );
836  }
837  fps = (vp1394TwoFramerateType) _fps;
838 
839 }
840 
872 uint32_t
874  std::list<vp1394TwoFramerateType> & fps)
875 {
876  if (! num_cameras) {
877  close();
878  vpERROR_TRACE("No camera found");
880  "No camera found") );
881  }
882 
883  // Refresh the list of supported framerates
884  fps.clear();
885 
886  switch (mode) {
887  // Framerate not available for:
888  // - vpVIDEO_MODE_EXIF ie Format_6
889  // - vpVIDEO_MODE_FORMAT7... ie the Format_7
890  case vpVIDEO_MODE_EXIF:
899  return 0;
900  break;
901  default:
902  {
903  dc1394framerates_t _fps;
904  if (dc1394_video_get_supported_framerates(camera,
905  (dc1394video_mode_t)mode,
906  &_fps) != DC1394_SUCCESS) {
907  close();
908  vpERROR_TRACE("Could not query supported frametates for mode %d\n",
909  mode);
911  "Could not query supported framerates") );
912  }
913  if (_fps.num == 0)
914  return 0;
915 
916  for (unsigned int i = 0; i < _fps.num; i ++)
917  fps.push_back((vp1394TwoFramerateType)_fps.framerates[i]);
918 
919  return _fps.num;
920  }
921  break;
922  }
923 }
957 bool
960 {
961  if (! num_cameras) {
962  close();
963  vpERROR_TRACE("No camera found");
965  "No camera found") );
966  }
967 
968  switch (mode) {
969  // Framerate not available for:
970  // - vpVIDEO_MODE_EXIF ie Format_6
971  // - vpVIDEO_MODE_FORMAT7... ie the Format_7
972  case vpVIDEO_MODE_EXIF:
981  return 0;
982  break;
983  default:
984  {
985  dc1394framerates_t _fps;
986  if (dc1394_video_get_supported_framerates(camera,
987  (dc1394video_mode_t)mode,
988  &_fps) != DC1394_SUCCESS) {
989  close();
990  vpERROR_TRACE("Could not query supported frametates for mode %d\n",
991  mode);
993  "Could not query supported framerates") );
994  }
995  if (_fps.num == 0)
996  return 0;
997 
998  for (unsigned int i = 0; i < _fps.num; i ++){
999  if (fps==(vp1394TwoFramerateType)_fps.framerates[i]){
1000  return true;
1001  }
1002  }
1003  return false;
1004  }
1005  break;
1006  }
1007 }
1008 
1057 void
1059 {
1060  if (! num_cameras) {
1061  close();
1062  vpERROR_TRACE("No camera found");
1064  "No camera found") );
1065  }
1066 
1067  dc1394video_mode_t _videomode;
1068  if (dc1394_video_get_mode(camera, &_videomode) != DC1394_SUCCESS) {
1069 
1070  close();
1071  vpERROR_TRACE("Can't get current video mode");
1073  "Can't get current video mode") );
1074  }
1075 
1076  if (!isColorCodingSupported((vp1394TwoVideoModeType)_videomode,coding)){
1077  vpERROR_TRACE("Color coding not supported by camera %d",camera_id);
1079  "Color coding not supported") );
1080  return ;
1081  }
1082 
1083  // Format 7 video mode
1084  if (dc1394_is_video_mode_scalable(_videomode)) {
1085  setTransmission(DC1394_OFF);
1086  setCapture(DC1394_OFF);
1087 
1088  if (dc1394_format7_set_color_coding(camera, _videomode,
1089  (dc1394color_coding_t) coding)
1090  != DC1394_SUCCESS) {
1091 
1092  close();
1093  vpERROR_TRACE("Can't set color coding");
1095  "Can't set color coding") );
1096  }
1097 
1098  setCapture(DC1394_ON);
1099  setTransmission(DC1394_ON);
1100  }
1101 }
1102 
1120 void
1122 {
1123  if (! num_cameras) {
1124  close();
1125  vpERROR_TRACE("No camera found");
1127  "No camera found") );
1128  }
1129  dc1394video_mode_t _videomode;
1130  if (dc1394_video_get_mode(camera, &_videomode) != DC1394_SUCCESS) {
1131 
1132  close();
1133  vpERROR_TRACE("Can't get current video mode");
1135  "Can't get current video mode") );
1136  }
1137 
1138  dc1394color_coding_t _coding;
1139  if (dc1394_is_video_mode_scalable(_videomode)) {
1140  // Format 7 video mode
1141  if (dc1394_format7_get_color_coding(camera, _videomode, &_coding)
1142  != DC1394_SUCCESS) {
1143 
1144  close();
1145  vpERROR_TRACE("Can't get current color coding");
1147  "Can't query current color coding") );
1148  }
1149  }
1150  else if (dc1394_is_video_mode_still_image((dc1394video_mode_t)_videomode)) {
1152  "No color coding for format 6 video mode"));
1153  }
1154  else {
1155  // Not Format 7 and not Format 6 video modes
1156  if (dc1394_get_color_coding_from_video_mode(camera,
1157  (dc1394video_mode_t)_videomode,
1158  &_coding) != DC1394_SUCCESS) {
1159  close();
1160  vpERROR_TRACE("Could not query supported color coding for mode %d\n",
1161  _videomode);
1163  "Can't query current color coding"));
1164  }
1165  }
1166  coding = (vp1394TwoColorCodingType) _coding;
1167 }
1168 
1190 uint32_t
1192  std::list<vp1394TwoColorCodingType> & codings)
1193 {
1194  if (! num_cameras) {
1195  close();
1196  vpERROR_TRACE("No camera found");
1198  "No camera found") );
1199  }
1200 
1201  // Refresh the list of supported framerates
1202  codings.clear();
1203 
1204  if (dc1394_is_video_mode_scalable((dc1394video_mode_t)mode)) {
1205  // Format 7 video mode
1206  dc1394color_codings_t _codings;
1207  if (dc1394_format7_get_color_codings(camera,
1208  (dc1394video_mode_t)mode,
1209  &_codings) != DC1394_SUCCESS) {
1210  close();
1211  vpERROR_TRACE("Could not query supported color codings for mode %d\n",
1212  mode);
1214  "Could not query supported color codings") );
1215  }
1216  if (_codings.num == 0)
1217  return 0;
1218 
1219  for (unsigned int i = 0; i < _codings.num; i ++)
1220  codings.push_back((vp1394TwoColorCodingType)_codings.codings[i]);
1221 
1222  return _codings.num;
1223  }
1224  else if (dc1394_is_video_mode_still_image((dc1394video_mode_t)mode)) {
1225  // Format 6 video mode
1226  return 0;
1227  }
1228  else {
1229  // Not Format 7 and not Format 6 video modes
1230  dc1394color_coding_t _coding;
1231  if (dc1394_get_color_coding_from_video_mode(camera,
1232  (dc1394video_mode_t)mode,
1233  &_coding) != DC1394_SUCCESS) {
1234  close();
1235  vpERROR_TRACE("Could not query supported color coding for mode %d\n",
1236  mode);
1238  "Could not query supported color coding") );
1239  }
1240  codings.push_back((vp1394TwoColorCodingType)_coding);
1241  return 1;
1242  }
1243 }
1265 bool
1267  vp1394TwoColorCodingType coding)
1268 {
1269  if (! num_cameras) {
1270  close();
1271  vpERROR_TRACE("No camera found");
1273  "No camera found") );
1274  }
1275 
1276 
1277  if (dc1394_is_video_mode_scalable((dc1394video_mode_t)mode)) {
1278  // Format 7 video mode
1279  dc1394color_codings_t _codings;
1280  if (dc1394_format7_get_color_codings(camera,
1281  (dc1394video_mode_t)mode,
1282  &_codings) != DC1394_SUCCESS) {
1283  close();
1284  vpERROR_TRACE("Could not query supported color codings for mode %d\n",
1285  mode);
1287  "Could not query supported color codings") );
1288  }
1289  if (_codings.num == 0)
1290  return 0;
1291 
1292  for (unsigned int i = 0; i < _codings.num; i ++){
1293  if (coding==(vp1394TwoColorCodingType)_codings.codings[i])
1294  return true;
1295  }
1296  return false;
1297  }
1298  else if (dc1394_is_video_mode_still_image((dc1394video_mode_t)mode)) {
1299  // Format 6 video mode
1300  return false;
1301  }
1302  else {
1303  // Not Format 7 and not Format 6 video modes
1304  dc1394color_coding_t _coding;
1305  if (dc1394_get_color_coding_from_video_mode(camera,
1306  (dc1394video_mode_t)mode,
1307  &_coding) != DC1394_SUCCESS) {
1308  close();
1309  vpERROR_TRACE("Could not query supported color coding for mode %d\n",
1310  mode);
1312  "Could not query supported color coding") );
1313  return false;
1314  }
1315  if (coding==(vp1394TwoColorCodingType)_coding)
1316  return true;
1317 
1318  return false;
1319  }
1320 }
1321 
1322 
1354 void
1355 vp1394TwoGrabber::setFormat7ROI(unsigned int left, unsigned int top,
1356  unsigned int w, unsigned int h)
1357 {
1358  open();
1359  if (! num_cameras) {
1360  close();
1361  vpERROR_TRACE("No camera found");
1363  "No camera found") );
1364  }
1365 
1366  dc1394video_mode_t _videomode;
1367  if (dc1394_video_get_mode(camera, &_videomode) != DC1394_SUCCESS) {
1368 
1369  close();
1370  vpERROR_TRACE("Can't get current video mode");
1372  "Can't get current video mode") );
1373  }
1374  if (dc1394_is_video_mode_scalable(_videomode)) {
1375  // Stop dma capture if started
1376  setTransmission(DC1394_OFF);
1377  setCapture(DC1394_OFF);
1378  // Format 7 video mode
1379  unsigned int max_width, max_height;
1380  if (dc1394_format7_get_max_image_size(camera, _videomode,
1381  &max_width, &max_height)
1382  != DC1394_SUCCESS) {
1383 
1384  close();
1385  vpERROR_TRACE("Can't get format7 max image size");
1387  "Can't get format7 max image size") );
1388  }
1389 #if 0
1390  vpTRACE("left: %d top: %d width: %d height: %d", left, top,
1391  width == 0 ? DC1394_USE_MAX_AVAIL: w,
1392  height == 0 ? DC1394_USE_MAX_AVAIL : h);
1393  vpTRACE("max_width: %d max_height: %d", max_width, max_height);
1394 #endif
1395 
1396  if (left > max_width) {
1397  vpERROR_TRACE("Can't set format7 ROI");
1399  "Can't set format7 ROI") );
1400  }
1401  if (top > max_height) {
1402  vpERROR_TRACE("Can't set format7 ROI");
1404  "Can't set format7 ROI") );
1405  }
1406 
1407  int32_t roi_width;
1408  int32_t roi_height;
1409 
1410  if (w != 0) {
1411  // Check if roi width is acceptable (ie roi is contained in the image)
1412  if (w > (max_width - left))
1413  w = (max_width - left);
1414  roi_width = (int32_t)w;
1415  }
1416  else {
1417  roi_width = DC1394_USE_MAX_AVAIL;
1418  }
1419 
1420  if (h != 0) {
1421  // Check if roi height is acceptable (ie roi is contained in the image)
1422  if (h > (max_height - top))
1423  h = (max_height - top);
1424  roi_height = (int32_t)h;
1425  }
1426  else {
1427  roi_height = DC1394_USE_MAX_AVAIL;
1428  }
1429 
1430  if (dc1394_format7_set_roi(camera, _videomode,
1431  (dc1394color_coding_t) DC1394_QUERY_FROM_CAMERA, // color_coding
1432  DC1394_USE_MAX_AVAIL/*DC1394_QUERY_FROM_CAMERA*/, // bytes_per_packet
1433  (int32_t)left, // left
1434  (int32_t)top, // top
1435  roi_width,
1436  roi_height)
1437  != DC1394_SUCCESS) {
1438  close();
1439  vpERROR_TRACE("Can't set format7 roi");
1441  "Can't get current video mode") );
1442  }
1443  // Update the image size
1444  if (dc1394_format7_get_image_size(camera, _videomode,
1445  &this->width,
1446  &this->height)
1447  != DC1394_SUCCESS) {
1448  close();
1449  vpERROR_TRACE("Can't get format7 image size");
1451  "Can't get format7 image size") );
1452  }
1453 
1454  setCapture(DC1394_ON);
1455  setTransmission(DC1394_ON);
1456  }
1457 }
1472 void
1473 vp1394TwoGrabber::initialize(bool reset)
1474 {
1475  if (init == false){
1476  // Find cameras
1477 #ifdef VISP_HAVE_DC1394_2_CAMERA_ENUMERATE // new API > libdc1394-2.0.0-rc7
1478  if (d != NULL)
1479  dc1394_free (d);
1480 
1481  d = dc1394_new ();
1482  if (dc1394_camera_enumerate (d, &list) != DC1394_SUCCESS) {
1483  dc1394_camera_free_list (list);
1484  close();
1485  vpERROR_TRACE("Failed to enumerate cameras\n");
1487  "Failed to enumerate cameras") );
1488  }
1489 
1490  if (list->num == 0) {
1491  dc1394_camera_free_list (list);
1492  close();
1493  vpERROR_TRACE("No cameras found");
1495  "No cameras found") );
1496  }
1497 
1498  if (cameras != NULL)
1499  delete [] cameras;
1500 
1501  cameras = new dc1394camera_t * [list->num];
1502 
1503  num_cameras = 0;
1504 
1505  for (unsigned int i=0; i < list->num; i ++) {
1506  cameras[i] = dc1394_camera_new (d, list->ids[i].guid);
1507  if (!cameras[i]) {
1508  vpTRACE ("Failed to initialize camera with guid \"%ld\"\n",
1509  list->ids[i].guid);
1510  continue;
1511  }
1512  // Update the number of working cameras
1513  num_cameras ++;
1514  }
1515 
1516  if (reset) {
1517  // Reset the bus to make firewire working if the program was not properly
1518  // stopped by a CTRL-C. We reset here only the bus attached to the first
1519  // camera
1520  dc1394_reset_bus(cameras[0]);
1521  }
1522 
1523  // if (list != NULL)
1524  dc1394_camera_free_list (list);
1525  list = NULL;
1526 
1527 #elif defined VISP_HAVE_DC1394_2_FIND_CAMERAS // old API <= libdc1394-2.0.0-rc7
1528  if (cameras != NULL)
1529  free(cameras);
1530  cameras = NULL;
1531  int err = dc1394_find_cameras(&cameras, &num_cameras);
1532 
1533  if (err!=DC1394_SUCCESS && err != DC1394_NO_CAMERA) {
1534  close();
1535  vpERROR_TRACE("Unable to look for cameras\n\n"
1536  "Please check \n"
1537  " - if the kernel modules `ieee1394',`raw1394' and `ohci1394' are loaded \n"
1538  " - if you have read/write access to /dev/raw1394\n\n");
1540  "Unable to look for cameras") );
1541 
1542  }
1543 #endif
1544 
1545  if (num_cameras == 0) {
1546  close();
1547  vpERROR_TRACE("No cameras found");
1549  "No cameras found") );
1550  }
1551 
1552  // allocation for the parameters
1553  isDataModified = new bool[num_cameras];
1554  for(unsigned int i=0; i<num_cameras; i++)
1555  isDataModified[i] = false;
1556  initialShutterMode = new dc1394feature_mode_t[num_cameras];
1557  dataCam = new vpDc1394TwoCameraParametersData[num_cameras];
1558 
1559  if (camera_id >= num_cameras) {
1560  // Bad camera id
1561  close();
1562  vpERROR_TRACE("Bad camera id: %u", camera_id);
1563  vpERROR_TRACE("Only %u camera on the bus.", num_cameras);
1565  "Bad camera id") );
1566  }
1567 
1568  if (verbose) {
1569  std::cout << "------ Bus information ------" << std::endl;
1570  std::cout << "Number of camera(s) on the bus : " << num_cameras <<std::endl;
1571  std::cout << "-----------------------------" << std::endl;
1572  }
1573 
1574  if (camIsOpen != NULL) delete [] camIsOpen;
1575  camIsOpen = new bool [num_cameras];
1576  for (unsigned int i = 0;i<num_cameras;i++){
1577  camIsOpen[i]=false;
1578  }
1579 
1580  init = true;
1581  }
1582 }
1592 void
1594 {
1595  if (init == false) initialize(false);
1596  if (camIsOpen[camera_id] == false){
1597  dc1394switch_t status = DC1394_OFF;
1598 
1599  //#ifdef VISP_HAVE_DC1394_2_CAMERA_ENUMERATE // new API > libdc1394-2.0.0-rc7
1600  dc1394_video_get_transmission(cameras[camera_id], &status);
1601  if (status != DC1394_OFF){
1602  //#endif
1603  if (dc1394_video_set_transmission(cameras[camera_id],DC1394_OFF)!=DC1394_SUCCESS)
1604  vpTRACE("Could not stop ISO transmission");
1605  else {
1606  vpTime::wait(500);
1607  if (dc1394_video_get_transmission(cameras[camera_id], &status)!=DC1394_SUCCESS)
1608  vpTRACE("Could get ISO status");
1609  else {
1610  if (status==DC1394_ON) {
1611  vpTRACE("ISO transmission refuses to stop");
1612  }
1613 #ifdef VISP_HAVE_DC1394_2_FIND_CAMERAS // old API <= libdc1394-2.0.0-rc7
1614  // No yet in the new API
1615  cameras[camera_id]->is_iso_on=status;
1616 #endif
1617  }
1618  //#ifdef VISP_HAVE_DC1394_2_CAMERA_ENUMERATE // new API > libdc1394-2.0.0-rc7
1619  }
1620  //#endif
1621  }
1622  setCamera(camera_id);
1623  //setIsoSpeed(DC1394_ISO_SPEED_400);
1624  setCapture(DC1394_ON);
1625  setTransmission(DC1394_ON);
1626  camIsOpen[camera_id] = true;
1627  }
1628 }
1637 void
1639 {
1640  if (init){
1641  if (num_cameras) {
1642  for (unsigned int i = 0; i < num_cameras;i++) {
1643  if (camIsOpen[i]) {
1644  camera = cameras[i];
1645  this->camera_id = i;// set camera id for the function updateDataStructToCam
1646  setTransmission(DC1394_OFF);
1647  setCapture(DC1394_OFF);
1648  if(isDataModified[i]){
1649  // reset values
1650  try{
1651  updateDataStructToCam();
1652  }
1653  catch(...){
1654  }
1655  // reset mode (manual, auto, ...)
1656  if (dc1394_feature_set_mode(camera, DC1394_FEATURE_BRIGHTNESS, initialShutterMode[i]) != DC1394_SUCCESS ||
1657  dc1394_feature_set_mode(camera, DC1394_FEATURE_EXPOSURE, initialShutterMode[i]) != DC1394_SUCCESS ||
1658  dc1394_feature_set_mode(camera, DC1394_FEATURE_SHARPNESS, initialShutterMode[i]) != DC1394_SUCCESS ||
1659  dc1394_feature_set_mode(camera, DC1394_FEATURE_HUE, initialShutterMode[i]) != DC1394_SUCCESS ||
1660  dc1394_feature_set_mode(camera, DC1394_FEATURE_SATURATION, initialShutterMode[i]) != DC1394_SUCCESS ||
1661  dc1394_feature_set_mode(camera, DC1394_FEATURE_GAMMA, initialShutterMode[i]) != DC1394_SUCCESS ||
1662  dc1394_feature_set_mode(camera, DC1394_FEATURE_SHUTTER, initialShutterMode[i]) != DC1394_SUCCESS ||
1663  dc1394_feature_set_mode(camera, DC1394_FEATURE_GAIN, initialShutterMode[i]) != DC1394_SUCCESS ||
1664  dc1394_feature_set_mode(camera, DC1394_FEATURE_IRIS, initialShutterMode[i])){
1665 
1666  vpERROR_TRACE("Unable to reset the initial mode");
1668  "Unable to reset the initial mode"));
1669  }
1670  }
1671  if (dc1394_camera_set_power(camera, DC1394_OFF) != DC1394_SUCCESS)
1672  std::cout << "Unable to turn camera off" << std::endl;
1673  }
1674 #ifdef VISP_HAVE_DC1394_2_CAMERA_ENUMERATE // new API > libdc1394-2.0.0-rc7
1675  dc1394_camera_free(cameras[i]);
1676 #elif defined VISP_HAVE_DC1394_2_FIND_CAMERAS // old API <= libdc1394-2.0.0-rc7
1677  dc1394_free_camera(cameras[i]);
1678 #endif
1679  }
1680  }
1681  if (camIsOpen != NULL) {
1682  delete [] camIsOpen;
1683  camIsOpen = NULL;
1684  }
1685 
1686 #ifdef VISP_HAVE_DC1394_2_CAMERA_ENUMERATE // new API > libdc1394-2.0.0-rc7
1687  if (cameras != NULL) {
1688  delete [] cameras;
1689  cameras = NULL;
1690  }
1691  if (d != NULL) {
1692  dc1394_free (d);
1693  d = NULL;
1694  }
1695 
1696 #elif defined VISP_HAVE_DC1394_2_FIND_CAMERAS // old API <= libdc1394-2.0.0-rc7
1697  if (cameras != NULL) {
1698  free(cameras);
1699  cameras = NULL;
1700  }
1701 #endif
1702 
1703  camIsOpen = NULL;
1704  num_cameras = 0;
1705 
1706  // remove data for the parameters
1707  if(isDataModified != NULL){
1708  delete[] isDataModified;
1709  isDataModified = NULL;
1710  }
1711  if(initialShutterMode != NULL){
1712  delete[] initialShutterMode;
1713  initialShutterMode = NULL;
1714  }
1715  if(dataCam != NULL){
1716  delete[] dataCam;
1717  dataCam = NULL;
1718  }
1719 
1720  init = false;
1721  }
1722 }
1723 
1735 void
1737 {
1738  if (size < 1) {
1739  close();
1741  "Could not set ring buffer size") );
1742  }
1743 
1744  if (size != num_buffers) {
1745  // We need to change the ring buffer size
1746  num_buffers = size;
1747  if(camIsOpen[camera_id]){
1748  setCapture(DC1394_OFF);
1749  setCapture(DC1394_ON);
1750  }
1751  }
1752 }
1753 
1763 unsigned int
1765 {
1766  return num_buffers;
1767 }
1768 
1808 void
1810 {
1811  if (! num_cameras) {
1812  close();
1813  vpERROR_TRACE("No camera found");
1815  "No camera found") );
1816  }
1817 
1818  dc1394feature_mode_t mode;
1819  if (enable) {
1820  mode = DC1394_FEATURE_MODE_AUTO;
1821  }
1822  else {
1823  mode = DC1394_FEATURE_MODE_MANUAL;
1824  }
1825 
1826  if (dc1394_feature_set_power(camera, DC1394_FEATURE_SHUTTER, DC1394_ON)
1827  != DC1394_SUCCESS) {
1828  // vpERROR_TRACE("Cannot set shutter on. \n");
1829  close();
1831  "Cannot set shutter on") );
1832  }
1833 
1834  if (dc1394_feature_set_mode(camera,
1835  DC1394_FEATURE_SHUTTER,
1836  mode)
1837  != DC1394_SUCCESS) {
1838  // vpERROR_TRACE("Cannot set auto shutter. \n");
1839  close();
1841  "Cannot set auto shutter") );
1842  }
1843 }
1884 void
1885 vp1394TwoGrabber::setAutoShutter(unsigned int minvalue, unsigned int maxvalue)
1886 {
1887  setAutoShutter();
1888 
1889  if (dc1394_avt_set_auto_shutter(camera, minvalue, maxvalue)
1890  != DC1394_SUCCESS) {
1891  // vpERROR_TRACE("Cannot set auto shutter min and max values. Is the camera an AVT one?\n");
1892  close();
1894  "Cannot set auto shutter min and max values") );
1895  }
1896 }
1897 
1910 void
1911 vp1394TwoGrabber::getAutoShutter(unsigned int &minvalue, unsigned int &maxvalue)
1912 {
1913  if (! num_cameras) {
1914  close();
1915  vpERROR_TRACE("No camera found");
1917  "No camera found") );
1918  }
1919 
1920  if (dc1394_avt_get_auto_shutter(camera, &minvalue, &maxvalue)
1921  != DC1394_SUCCESS) {
1922  // vpERROR_TRACE("Cannot get auto shutter min and max values. Is the camera an AVT one?\n");
1923  close();
1925  "Cannot get auto shutter min and max values") );
1926  }
1927 }
1928 
1968 void
1970 {
1971  if (! num_cameras) {
1972  close();
1973  vpERROR_TRACE("No camera found");
1975  "No camera found") );
1976  }
1977 
1978  dc1394feature_mode_t mode;
1979  if (enable) {
1980  mode = DC1394_FEATURE_MODE_AUTO;
1981  }
1982  else {
1983  mode = DC1394_FEATURE_MODE_MANUAL;
1984  }
1985 
1986  if (dc1394_feature_set_power(camera, DC1394_FEATURE_GAIN, DC1394_ON)
1987  != DC1394_SUCCESS) {
1988  // vpERROR_TRACE("Cannot set shutter on. \n");
1989  close();
1991  "Cannot set shutter on") );
1992  }
1993 
1994  if (dc1394_feature_set_mode(camera,
1995  DC1394_FEATURE_GAIN,
1996  mode)
1997  != DC1394_SUCCESS) {
1998  // vpERROR_TRACE("Cannot set auto gain. \n");
1999  close();
2001  "Cannot set auto gain") );
2002  }
2003 }
2044 void
2045 vp1394TwoGrabber::setAutoGain(unsigned int minvalue, unsigned int maxvalue)
2046 {
2047  setAutoGain();
2048 
2049  if (dc1394_avt_set_auto_gain(camera, minvalue, maxvalue)
2050  != DC1394_SUCCESS) {
2051  // vpERROR_TRACE("Cannot set auto gain min and max values. Is the camera an AVT one?\n");
2052  close();
2054  "Cannot set auto gain min and max values") );
2055  }
2056 }
2057 
2070 void
2071 vp1394TwoGrabber::getAutoGain(unsigned int &minvalue, unsigned int &maxvalue)
2072 {
2073  if (! num_cameras) {
2074  close();
2075  vpERROR_TRACE("No camera found");
2077  "No camera found") );
2078  }
2079 
2080  if (dc1394_avt_get_auto_gain(camera, &minvalue, &maxvalue)
2081  != DC1394_SUCCESS) {
2082  // vpERROR_TRACE("Cannot get auto gain min and max values. Is the camera an AVT one?\n");
2083  close();
2085  "Cannot get auto gain min and max values") );
2086  }
2087 }
2088 
2089 
2107 void
2108 vp1394TwoGrabber::setCapture(dc1394switch_t _switch)
2109 {
2110  if (! num_cameras) {
2111  close();
2112  vpERROR_TRACE("No camera found");
2114  "No camera found") );
2115  }
2116 
2117  if (_switch == DC1394_ON) {
2118  //if (dc1394_capture_setup(camera, num_buffers) != DC1394_SUCCESS) {
2119  // To be compatible with libdc1394 svn 382 version
2120  if (dc1394_capture_setup(camera, num_buffers,
2121  DC1394_CAPTURE_FLAGS_DEFAULT) != DC1394_SUCCESS) {
2122  vpERROR_TRACE("Unable to setup camera capture-\n"
2123  "make sure that the video mode and framerate are "
2124  "supported by your camera.\n");
2125  close();
2127  "Could not setup dma capture") );
2128  }
2129  }
2130  else { // _switch == DC1394_OFF
2131  dc1394error_t code = dc1394_capture_stop(camera);
2132 
2133  if (code != DC1394_SUCCESS && code != DC1394_CAPTURE_IS_NOT_SET) {
2134  vpERROR_TRACE("Unable to stop camera capture\n");
2135  close();
2137  "Could not setup dma capture") );
2138  }
2139  }
2140 }
2141 
2142 
2157 void
2158 vp1394TwoGrabber::setTransmission(dc1394switch_t _switch)
2159 {
2160  if (! num_cameras) {
2161  close();
2162  vpERROR_TRACE("No camera found");
2164  "No camera found") );
2165  }
2166 
2167  dc1394switch_t status = DC1394_OFF;
2168 
2169  if (dc1394_video_get_transmission(camera, &status)!=DC1394_SUCCESS) {
2170  vpERROR_TRACE("Unable to get transmision status");
2171  close();
2173  "Could not setup dma capture") );
2174  }
2175 
2176  // if (status!=_switch){
2177  // Start dma capture if halted
2178  if (dc1394_video_set_transmission(camera, _switch) != DC1394_SUCCESS) {
2179  vpERROR_TRACE("Unable to setup camera capture-\n"
2180  "make sure that the video mode and framerate are "
2181  "supported by your camera.\n");
2182  close();
2184  "Could not setup dma capture") );
2185  }
2186 
2187  if (_switch == DC1394_ON) {
2188  status = DC1394_OFF;
2189 
2190  int i = 0;
2191  while ( status == DC1394_OFF && i++ < 5 ) {
2192  usleep(50000);
2193  if (dc1394_video_get_transmission(camera, &status)!=DC1394_SUCCESS) {
2194  vpERROR_TRACE("Unable to get transmision status");
2195  close();
2197  "Could not setup dma capture") );
2198  }
2199  }
2200  }
2201  // }
2202 }
2203 
2238 void
2240 {
2241  if (! num_cameras) {
2242  close();
2243  vpERROR_TRACE("No camera found");
2245  "No camera found") );
2246  }
2247 
2248  dc1394operation_mode_t op_mode;
2249  dc1394speed_t speed;
2250 
2251  // Check the speed to configure in B-mode or A-mode
2252  if (isospeed >= vpISO_SPEED_800) {
2253  if (camera->bmode_capable != DC1394_TRUE) {
2254 // vpERROR_TRACE("Camera is not 1394B mode capable. \n"
2255 // "Set the iso speed lower or equal to 400Mbps");
2256  close();
2258  "Camera is not 1394B mode capable") );
2259  }
2260 
2261  if(dc1394_video_set_operation_mode(camera,
2262  DC1394_OPERATION_MODE_1394B)
2263  != DC1394_SUCCESS) {
2264 // vpERROR_TRACE("Cannot set camera to 1394B mode. \n");
2265  close();
2267  "Cannot set camera to 1394B mode") );
2268  }
2269 
2270  if (dc1394_video_get_operation_mode(camera, &op_mode) != DC1394_SUCCESS) {
2271 // vpERROR_TRACE("Failed to set 1394B mode. \n");
2272  close();
2274  "Failed to set 1394B mode") );
2275  }
2276  }
2277  else {
2278  if (dc1394_video_set_operation_mode(camera,
2279  DC1394_OPERATION_MODE_LEGACY)
2280  != DC1394_SUCCESS) {
2281 // vpERROR_TRACE("Cannot set camera to 1394A mode. \n");
2282  close();
2284  "Cannot set camera to 1394A mode") );
2285  }
2286 
2287  if (dc1394_video_get_operation_mode(camera, &op_mode) != DC1394_SUCCESS) {
2288 // vpERROR_TRACE("Failed to set 1394A mode. \n");
2289  close();
2291  "Failed to set 1394A mode") );
2292  }
2293  }
2294 
2295  if (dc1394_video_set_iso_speed(camera, (dc1394speed_t) isospeed)
2296  != DC1394_SUCCESS) {
2297 // vpERROR_TRACE("Cannot set requested iso speed. \n");
2298  close();
2300  "Cannot set requested iso speed") );
2301  }
2302 
2303  if (dc1394_video_get_iso_speed(camera, &speed) != DC1394_SUCCESS) {
2304 // vpERROR_TRACE("Failed to set iso speed. \n");
2305  close();
2307  "Failed to set iso speed") );
2308  }
2309 }
2310 
2321 void
2323 {
2324  open();
2325  acquire(I);
2326 }
2327 
2338 void
2340 {
2341  open();
2342  acquire(I);
2343 }
2344 
2345 
2384 dc1394video_frame_t *
2386 {
2387 
2388  if (! num_cameras) {
2389  close();
2390  vpERROR_TRACE("No camera found");
2392  "No camera found") );
2393  }
2394 
2395  dc1394video_frame_t *frame = NULL;
2396 
2397  if (dc1394_capture_dequeue(camera, DC1394_CAPTURE_POLICY_WAIT, &frame)
2398  !=DC1394_SUCCESS) {
2399  vpERROR_TRACE ("Error: Failed to capture from camera %d\n", camera_id);
2400  }
2401 
2402  return frame;
2403 }
2404 
2446 dc1394video_frame_t *
2448 {
2449  uint64_t timestamp;
2450  uint32_t id;
2451 
2452  dc1394video_frame_t *frame;
2453 
2454  frame = dequeue(I, timestamp, id);
2455 
2456  return frame;
2457 }
2458 
2507 dc1394video_frame_t *
2509  uint64_t &timestamp,
2510  uint32_t &id)
2511 {
2512 
2513  open();
2514 
2515  dc1394video_frame_t *frame;
2516 
2517  frame = dequeue();
2518 
2519  // Timeval data structure providing the unix time
2520  // [microseconds] at which the frame was captured in the ring buffer.
2521  timestamp = frame->timestamp;
2522  id = frame->id;
2523 
2524  this->width = frame->size[0];
2525  this->height = frame->size[1];
2526  unsigned int size = this->width * this->height;
2527 
2528  if ((I.getWidth() != this->width)||(I.getHeight() != this->height))
2529  I.resize(this->height, this->width);
2530 
2531  switch(frame->color_coding) {
2532  case DC1394_COLOR_CODING_MONO8:
2533  case DC1394_COLOR_CODING_RAW8:
2534  memcpy(I.bitmap, (unsigned char *) frame->image,
2535  size*sizeof(unsigned char));
2536  break;
2537  case DC1394_COLOR_CODING_MONO16:
2538  case DC1394_COLOR_CODING_RAW16:
2539  vpImageConvert::MONO16ToGrey( (unsigned char *) frame->image,
2540  I.bitmap, size);
2541  break;
2542 
2543  case DC1394_COLOR_CODING_YUV411:
2544  vpImageConvert::YUV411ToGrey( (unsigned char *) frame->image,
2545  I.bitmap, size);
2546  break;
2547 
2548  case DC1394_COLOR_CODING_YUV422:
2549  vpImageConvert::YUV422ToGrey( (unsigned char *) frame->image,
2550  I.bitmap, size);
2551  break;
2552 
2553  case DC1394_COLOR_CODING_YUV444:
2554  vpImageConvert::YUV444ToGrey( (unsigned char *) frame->image,
2555  I.bitmap, size);
2556  break;
2557 
2558  case DC1394_COLOR_CODING_RGB8:
2559  vpImageConvert::RGBToGrey((unsigned char *) frame->image, I.bitmap, size);
2560  break;
2561 
2562 
2563  default:
2564  close();
2565  vpERROR_TRACE("Format conversion not implemented. Acquisition failed.");
2567  "Format conversion not implemented. "
2568  "Acquisition failed.") );
2569  break;
2570  };
2571 
2572  return frame;
2573 }
2574 
2615 dc1394video_frame_t *
2617 {
2618  uint64_t timestamp;
2619  uint32_t id;
2620 
2621  dc1394video_frame_t *frame;
2622 
2623  frame = dequeue(I, timestamp, id);
2624 
2625  return frame;
2626 }
2627 
2676 dc1394video_frame_t *
2678  uint64_t &timestamp,
2679  uint32_t &id)
2680 {
2681 
2682  open();
2683 
2684  dc1394video_frame_t *frame;
2685 
2686  frame = dequeue();
2687 
2688  // Timeval data structure providing the unix time
2689  // [microseconds] at which the frame was captured in the ring buffer.
2690  timestamp = frame->timestamp;
2691  id = frame->id;
2692 
2693  this->width = frame->size[0];
2694  this->height = frame->size[1];
2695  unsigned int size = this->width * this->height;
2696 
2697  if ((I.getWidth() != width)||(I.getHeight() != height))
2698  I.resize(height, width);
2699 
2700  switch (frame->color_coding) {
2701  case DC1394_COLOR_CODING_MONO8:
2702  case DC1394_COLOR_CODING_RAW8:
2703  vpImageConvert::GreyToRGBa((unsigned char *) frame->image,
2704  (unsigned char *) I.bitmap, size);
2705  break;
2706 
2707  case DC1394_COLOR_CODING_MONO16:
2708  case DC1394_COLOR_CODING_RAW16:
2709  vpImageConvert::MONO16ToRGBa((unsigned char *) frame->image,
2710  (unsigned char *) I.bitmap, size);
2711  break;
2712 
2713  case DC1394_COLOR_CODING_YUV411:
2714  vpImageConvert::YUV411ToRGBa( (unsigned char *) frame->image,
2715  (unsigned char *) I.bitmap, size);
2716  break;
2717 
2718  case DC1394_COLOR_CODING_YUV422:
2719  vpImageConvert::YUV422ToRGBa( (unsigned char *) frame->image,
2720  (unsigned char *) I.bitmap, size);
2721  break;
2722 
2723  case DC1394_COLOR_CODING_YUV444:
2724  vpImageConvert::YUV444ToRGBa( (unsigned char *) frame->image,
2725  (unsigned char *) I.bitmap, size);
2726  break;
2727 
2728  case DC1394_COLOR_CODING_RGB8:
2729  vpImageConvert::RGBToRGBa((unsigned char *) frame->image,
2730  (unsigned char *) I.bitmap, size);
2731  break;
2732 
2733 
2734  default:
2735  close();
2736  vpERROR_TRACE("Format conversion not implemented. Acquisition failed.");
2738  "Format conversion not implemented. "
2739  "Acquisition failed.") );
2740  break;
2741  };
2742 
2743  return frame;
2744 }
2745 
2756 void
2757 vp1394TwoGrabber::enqueue(dc1394video_frame_t *frame)
2758 {
2759 
2760  if (! num_cameras) {
2761  close();
2762  vpERROR_TRACE("No camera found");
2764  "No camera found") );
2765  }
2766 
2767  if (frame)
2768  dc1394_capture_enqueue(camera, frame);
2769 }
2770 
2771 
2785 void
2787 {
2788  uint64_t timestamp;
2789  uint32_t id;
2790 
2791  dc1394video_frame_t *frame;
2792 
2793  frame = dequeue(I, timestamp, id);
2794  enqueue(frame);
2795 }
2796 
2815 void
2817  uint64_t &timestamp,
2818  uint32_t &id)
2819 {
2820  dc1394video_frame_t *frame;
2821 
2822  open();
2823  frame = dequeue(I, timestamp, id);
2824  enqueue(frame);
2825 }
2826 
2827 
2828 
2842 void
2844 {
2845  uint64_t timestamp;
2846  uint32_t id;
2847  dc1394video_frame_t *frame;
2848 
2849  open();
2850  frame = dequeue(I, timestamp, id);
2851  enqueue(frame);
2852 }
2853 
2872 void
2874  uint64_t &timestamp,
2875  uint32_t &id)
2876 {
2877  dc1394video_frame_t *frame;
2878 
2879  open();
2880  frame = dequeue();
2881  // Timeval data structure providing the unix time
2882  // [microseconds] at which the frame was captured in the ring buffer.
2883  timestamp = frame->timestamp;
2884  id = frame->id;
2885 
2886  this->width = frame->size[0];
2887  this->height = frame->size[1];
2888  unsigned int size = this->width * this->height;
2889 
2890  if ((I.getWidth() != width)||(I.getHeight() != height))
2891  I.resize(height, width);
2892 
2893  switch (frame->color_coding) {
2894  case DC1394_COLOR_CODING_MONO8:
2895  case DC1394_COLOR_CODING_RAW8:
2896  vpImageConvert::GreyToRGBa((unsigned char *) frame->image,
2897  (unsigned char *) I.bitmap, size);
2898  break;
2899 
2900  case DC1394_COLOR_CODING_YUV411:
2901  vpImageConvert::YUV411ToRGBa( (unsigned char *) frame->image,
2902  (unsigned char *) I.bitmap, size);
2903  break;
2904 
2905  case DC1394_COLOR_CODING_YUV422:
2906  vpImageConvert::YUV422ToRGBa( (unsigned char *) frame->image,
2907  (unsigned char *) I.bitmap, size);
2908  break;
2909 
2910  case DC1394_COLOR_CODING_YUV444:
2911  vpImageConvert::YUV444ToRGBa( (unsigned char *) frame->image,
2912  (unsigned char *) I.bitmap, size);
2913  break;
2914 
2915  case DC1394_COLOR_CODING_RGB8:
2916  vpImageConvert::RGBToRGBa((unsigned char *) frame->image,
2917  (unsigned char *) I.bitmap, size);
2918  break;
2919 
2920 
2921  default:
2922  close();
2923  vpERROR_TRACE("Format conversion not implemented. Acquisition failed.");
2925  "Format conversion not implemented. "
2926  "Acquisition failed.") );
2927  break;
2928  };
2929 
2930  enqueue(frame);
2931 
2932 }
2933 
2950 void vp1394TwoGrabber::getWidth(unsigned int &w)
2951 {
2952  if (! num_cameras) {
2953  close();
2954  vpERROR_TRACE("No camera found");
2956  "No camera found") );
2957  }
2958 
2959  w = this->width;
2960 }
2961 
2979 {
2980  if (! num_cameras) {
2981  close();
2982  vpERROR_TRACE("No camera found");
2984  "No camera found") );
2985  }
2986 
2987  return this->width;
2988 }
2989 
3007 void vp1394TwoGrabber::getHeight(unsigned int &h)
3008 {
3009  if (! num_cameras) {
3010  close();
3011  vpERROR_TRACE("No camera found");
3013  "No camera found") );
3014  }
3015 
3016  h = this->height;
3017 }
3036 {
3037  if (! num_cameras) {
3038  close();
3039  vpERROR_TRACE("No camera found");
3041  "No camera found") );
3042  }
3043 
3044  return this->height;
3045 }
3046 
3052 void
3054 {
3055  std::cout << "----------------------------------------------------------"
3056  << std::endl
3057  << "----- Information for camera " << camera_id
3058  << " -----" << std::endl
3059  << "----------------------------------------------------------" << std::endl;
3060 
3061 #ifdef VISP_HAVE_DC1394_2_CAMERA_ENUMERATE // new API > libdc1394-2.0.0-rc7
3062  dc1394_camera_print_info( camera, stdout);
3063 #elif defined VISP_HAVE_DC1394_2_FIND_CAMERAS // old API <= libdc1394-2.0.0-rc7
3064  dc1394_print_camera_info( camera);
3065 #endif
3066 
3067  dc1394featureset_t features;
3068 #ifdef VISP_HAVE_DC1394_2_CAMERA_ENUMERATE // new API > libdc1394-2.0.0-rc7
3069  if (dc1394_feature_get_all(camera, &features) != DC1394_SUCCESS)
3070 #elif defined VISP_HAVE_DC1394_2_FIND_CAMERAS // old API <= libdc1394-2.0.0-rc7
3071  if (dc1394_get_camera_feature_set(camera, &features) != DC1394_SUCCESS)
3072 #endif
3073  {
3074  close();
3075  vpERROR_TRACE("unable to get feature set for camera %d\n", camera_id);
3077  "Cannot get camera features") );
3078 
3079  } else {
3080 #ifdef VISP_HAVE_DC1394_2_CAMERA_ENUMERATE // new API > libdc1394-2.0.0-rc7
3081  dc1394_feature_print_all(&features, stdout);
3082 #elif defined VISP_HAVE_DC1394_2_FIND_CAMERAS // old API <= libdc1394-2.0.0-rc7
3083  dc1394_print_feature_set(&features);
3084 #endif
3085  }
3086  std::cout << "----------------------------------------------------------" << std::endl;
3087 }
3088 
3102 {
3103  std::string _str = "";
3104  dc1394video_mode_t _videomode = (dc1394video_mode_t) videomode;
3105 
3106  if ((_videomode >= DC1394_VIDEO_MODE_MIN)
3107  && (_videomode <= DC1394_VIDEO_MODE_MAX)) {
3108  _str = strVideoMode[_videomode - DC1394_VIDEO_MODE_MIN];
3109  }
3110  else {
3111  vpCERROR << "The video mode " << (int)videomode
3112  << " is not supported by the camera" << std::endl;
3113  }
3114 
3115  return _str;
3116 }
3117 
3131 {
3132  std::string _str = "";
3133  dc1394framerate_t _fps = (dc1394framerate_t) fps;
3134 
3135  if ((_fps >= DC1394_FRAMERATE_MIN)
3136  && (_fps <= DC1394_FRAMERATE_MAX)) {
3137  _str = strFramerate[_fps - DC1394_FRAMERATE_MIN];
3138  }
3139  else {
3140  vpCERROR << "The framerate " << (int)fps
3141  << " is not supported by the camera" << std::endl;
3142  }
3143 
3144  return _str;
3145 }
3146 
3160 {
3161  std::string _str = "";
3162  dc1394color_coding_t _coding = (dc1394color_coding_t) colorcoding;
3163 
3164  if ((_coding >= DC1394_COLOR_CODING_MIN)
3165  && (_coding <= DC1394_COLOR_CODING_MAX)) {
3166  _str = strColorCoding[_coding - DC1394_COLOR_CODING_MIN];
3167 
3168  }
3169  else {
3170  vpCERROR << "The color coding " << (int)colorcoding
3171  << " is not supported by the camera" << std::endl;
3172  }
3173 
3174  return _str;
3175 }
3176 
3196 {
3198 
3199  for (int i = DC1394_VIDEO_MODE_MIN; i <= DC1394_VIDEO_MODE_MAX; i ++) {
3200  _id = (vp1394TwoVideoModeType) i;
3201  if (videomode.compare(videoMode2string(_id)) == 0)
3202  return _id;
3203  };
3204 
3206  "The required videomode is not valid") );
3207 
3208  return (vp1394TwoVideoModeType) 0;
3209 }
3210 
3211 
3231 {
3233 
3234  for (int i = DC1394_FRAMERATE_MIN; i <= DC1394_FRAMERATE_MAX; i ++) {
3235  _id = (vp1394TwoFramerateType) i;
3236  if (framerate.compare(framerate2string(_id)) == 0)
3237  return _id;
3238  };
3239 
3241  "The required framerate is not valid") );
3242 
3243  return (vp1394TwoFramerateType) 0;
3244 }
3245 
3265 {
3267 
3268  for (int i = DC1394_COLOR_CODING_MIN; i <= DC1394_COLOR_CODING_MAX; i ++) {
3269  _id = (vp1394TwoColorCodingType) i;
3270  if (colorcoding.compare(colorCoding2string(_id)) == 0)
3271  return _id;
3272  };
3273 
3275  "The required color coding is not valid") );
3276 
3277  return (vp1394TwoColorCodingType) 0;
3278 }
3279 
3313 {
3314  for (unsigned int i = 0; i < num_cameras;i++) {
3315  if (camIsOpen[i]) {
3316  camera = cameras[i];
3317  setTransmission(DC1394_OFF);
3318  setCapture(DC1394_OFF);
3319  }
3320  }
3321 #ifdef VISP_HAVE_DC1394_2_CAMERA_ENUMERATE // new API > libdc1394-2.0.0-rc7
3322  setCamera(camera_id);
3323  // free the other cameras
3324  for (unsigned int i=0;i<num_cameras;i++){
3325  if (i!=camera_id) dc1394_camera_free(cameras[i]);
3326  }
3327 
3328  printf ("Reseting bus...\n");
3329  dc1394_reset_bus (camera);
3330 
3331  dc1394_camera_free (camera);
3332  dc1394_free (d);
3333  d = NULL;
3334  //if (cameras != NULL)
3335  delete [] cameras;
3336  cameras = NULL ;
3337 #elif defined VISP_HAVE_DC1394_2_FIND_CAMERAS // old API <= libdc1394-2.0.0-rc7
3338 
3339  setCamera(camera_id);
3340  // free the other cameras
3341  for (unsigned int i=0;i<num_cameras;i++){
3342  if (i!=camera_id) dc1394_free_camera(cameras[i]);
3343  }
3344  free(cameras);
3345  cameras = NULL;
3346 
3347  dc1394_reset_bus(camera);
3348  dc1394_free_camera(camera);
3349 
3350 #endif
3351  if (camIsOpen != NULL)
3352  delete [] camIsOpen;
3353  camIsOpen = NULL ;
3354 
3355  num_cameras = 0;
3356 
3357  init = false;
3358  vpTime::wait(1000);
3359  initialize(false);
3360 }
3361 
3391 void vp1394TwoGrabber::setPanControl(unsigned int panControlValue)
3392 {
3393  open();
3394  if (! num_cameras) {
3395  close();
3396  vpERROR_TRACE("No camera found");
3398  "No camera found") );
3399  }
3400  uint64_t offset = 0x884;
3401  uint32_t value = 0x82000000 + (uint32_t)panControlValue;
3402  dc1394error_t err;
3403  err = dc1394_set_control_register(camera, offset, value);
3404  if (err != DC1394_SUCCESS) {
3405  vpERROR_TRACE("Unable to set PAN register");
3406  close();
3408  "Unable to set PAN register") );
3409  }
3410 }
3411 
3412 
3430 {
3431  if (! num_cameras) {
3432  close();
3433  vpERROR_TRACE("No camera found");
3435  "No camera found") );
3436  }
3437 
3438  uint32_t value;
3439  dc1394feature_t feature = (dc1394feature_t)param;
3440  dc1394error_t err;
3441  err = dc1394_feature_get_value(camera, feature, &value);
3442  if (err != DC1394_SUCCESS) {
3443  vpERROR_TRACE("Unable to get the information");
3444  close();
3446  "Unable to get the information") );
3447  }
3448  return (unsigned int)value;
3449 }
3450 
3451 
3473  unsigned int val)
3474 {
3475  if (! num_cameras) {
3476  close();
3477  vpERROR_TRACE("No camera found");
3479  "No camera found") );
3480  }
3481  uint32_t value = (uint32_t)val;
3482  dc1394feature_t feature = (dc1394feature_t)param;
3483  dc1394error_t err;
3484  dc1394bool_t hasManualMode = DC1394_FALSE;
3485  dc1394feature_modes_t modesAvailable;
3486 
3487  // test wether we can set the shutter value (manual mode available or not)
3488  err = dc1394_feature_get_modes(camera, feature, &modesAvailable);
3489  if (err != DC1394_SUCCESS) {
3490  vpERROR_TRACE("Unable to detect the manual mode information");
3491  close();
3493  "Unable to detect the manual mode information"));
3494  }
3495 
3496  for(unsigned int i=0; i<modesAvailable.num; i++){
3497  if(modesAvailable.modes[i] == DC1394_FEATURE_MODE_MANUAL){
3498  hasManualMode = DC1394_TRUE;
3499  }
3500  }
3501 
3502  if(hasManualMode == DC1394_TRUE){
3503 
3504  if(!isDataModified[camera_id]){// to ensure we save the first mode even after several set
3505  /* we update the structure */
3506  updateDataCamToStruct();
3507  err = dc1394_feature_get_mode(camera, feature, &(initialShutterMode[camera_id]));
3508  if (err != DC1394_SUCCESS) {
3509  vpERROR_TRACE("Unable to get the initial mode");
3510  close();
3512  "Unable to get the initial mode"));
3513  }
3514  isDataModified[camera_id] = true;
3515  }
3516 
3517  dc1394feature_mode_t manualMode = DC1394_FEATURE_MODE_MANUAL;
3518  err = dc1394_feature_set_mode(camera, feature, manualMode);
3519  if (err != DC1394_SUCCESS) {
3520  vpERROR_TRACE("Unable to set the muanual mode");
3521  close();
3523  "Unable to set the manual mode") );
3524  }
3525  err = dc1394_feature_set_value(camera, feature, value);
3526  if (err != DC1394_SUCCESS) {
3527  vpERROR_TRACE("Unable to set the shutter information");
3528  close();
3530  "Unable to set the shutter information") );
3531  }
3532  }
3533  else{
3534  vpERROR_TRACE("The camera does not have a manual mode.\nCannot change the value");
3536  "The camera does not have a manual mode"));
3537  }
3538 }
3546 void
3548 {
3549  if (! num_cameras) {
3550  close();
3551  vpERROR_TRACE("No camera found");
3553  "No camera found") );
3554  }
3555 
3556  guid = camera->guid;
3557 }
3558 
3566 uint64_t
3568 {
3569  if (! num_cameras) {
3570  close();
3571  vpERROR_TRACE("No camera found");
3573  "No camera found") );
3574  }
3575 
3576  return camera->guid;
3577 }
3578 
3579 
3584 inline void
3585 vp1394TwoGrabber::updateDataCamToStruct()
3586 {
3587  dataCam[camera_id].brightness = getParameterValue(vpFEATURE_BRIGHTNESS);
3588  dataCam[camera_id].exposure = getParameterValue(vpFEATURE_EXPOSURE);
3589  dataCam[camera_id].sharpness = getParameterValue(vpFEATURE_SHARPNESS);
3590  dataCam[camera_id].hue = getParameterValue(vpFEATURE_HUE);
3591  dataCam[camera_id].saturation = getParameterValue(vpFEATURE_SATURATION);
3592  dataCam[camera_id].gamma = getParameterValue(vpFEATURE_GAMMA);
3593  dataCam[camera_id].shutter = getParameterValue(vpFEATURE_SHUTTER);
3594  dataCam[camera_id].gain = getParameterValue(vpFEATURE_GAIN);
3595  dataCam[camera_id].iris = getParameterValue(vpFEATURE_IRIS);
3596 }
3597 
3602 inline void
3603 vp1394TwoGrabber::updateDataStructToCam()
3604 {
3605  setParameterValue(vpFEATURE_BRIGHTNESS, dataCam[camera_id].brightness);
3606  setParameterValue(vpFEATURE_EXPOSURE, dataCam[camera_id].exposure);
3607  setParameterValue(vpFEATURE_SHARPNESS, dataCam[camera_id].sharpness);
3608  setParameterValue(vpFEATURE_HUE, dataCam[camera_id].hue);
3609  setParameterValue(vpFEATURE_SATURATION, dataCam[camera_id].saturation);
3610  setParameterValue(vpFEATURE_GAMMA, dataCam[camera_id].gamma);
3611  setParameterValue(vpFEATURE_SHUTTER, dataCam[camera_id].shutter);
3612  setParameterValue(vpFEATURE_GAIN, dataCam[camera_id].gain);
3613  setParameterValue(vpFEATURE_IRIS, dataCam[camera_id].iris);
3614 }
3615 
3616 #ifdef VISP_BUILD_DEPRECATED_FUNCTIONS
3617 
3635 uint32_t
3637 {
3638  // Refresh the list of supported modes
3639  videomodes.kill();
3640 
3641  if (! num_cameras) {
3642  close();
3643  vpERROR_TRACE("No camera found");
3645  "No camera found") );
3646  }
3647  dc1394video_modes_t _videomodes;
3648 
3649  // get video modes:
3650  if (dc1394_video_get_supported_modes(camera, &_videomodes)!=DC1394_SUCCESS) {
3651 
3652  close();
3653  vpERROR_TRACE("Can't get video modes");
3655  "Can't get video modes") );
3656  }
3657 
3658  // parse the video modes to add in the list
3659  for (unsigned i=0; i < _videomodes.num; i++) {
3660  vp1394TwoVideoModeType _mode = (vp1394TwoVideoModeType) _videomodes.modes[i];
3661  videomodes.addRight( _mode );
3662  }
3663 
3664  // return the number of available video modes
3665  return _videomodes.num;
3666 }
3667 
3700 uint32_t
3703 {
3704  if (! num_cameras) {
3705  close();
3706  vpERROR_TRACE("No camera found");
3708  "No camera found") );
3709  }
3710 
3711  // Refresh the list of supported framerates
3712  fps.kill();
3713 
3714  switch (mode) {
3715  // Framerate not available for:
3716  // - vpVIDEO_MODE_EXIF ie Format_6
3717  // - vpVIDEO_MODE_FORMAT7... ie the Format_7
3718  case vpVIDEO_MODE_EXIF:
3727  return 0;
3728  break;
3729  default:
3730  {
3731  dc1394framerates_t _fps;
3732  if (dc1394_video_get_supported_framerates(camera,
3733  (dc1394video_mode_t)mode,
3734  &_fps) != DC1394_SUCCESS) {
3735  close();
3736  vpERROR_TRACE("Could not query supported frametates for mode %d\n",
3737  mode);
3739  "Could not query supported framerates") );
3740  }
3741  if (_fps.num == 0)
3742  return 0;
3743 
3744  for (unsigned int i = 0; i < _fps.num; i ++)
3745  fps.addRight((vp1394TwoFramerateType)_fps.framerates[i]);
3746 
3747  return _fps.num;
3748  }
3749  break;
3750  }
3751 }
3752 
3777 uint32_t
3780 {
3781  if (! num_cameras) {
3782  close();
3783  vpERROR_TRACE("No camera found");
3785  "No camera found") );
3786  }
3787 
3788  // Refresh the list of supported framerates
3789  codings.kill();
3790 
3791  if (dc1394_is_video_mode_scalable((dc1394video_mode_t)mode)) {
3792  // Format 7 video mode
3793  dc1394color_codings_t _codings;
3794  if (dc1394_format7_get_color_codings(camera,
3795  (dc1394video_mode_t)mode,
3796  &_codings) != DC1394_SUCCESS) {
3797  close();
3798  vpERROR_TRACE("Could not query supported color codings for mode %d\n",
3799  mode);
3801  "Could not query supported color codings") );
3802  }
3803  if (_codings.num == 0)
3804  return 0;
3805 
3806  for (unsigned int i = 0; i < _codings.num; i ++)
3807  codings.addRight((vp1394TwoColorCodingType)_codings.codings[i]);
3808 
3809  return _codings.num;
3810  }
3811  else if (dc1394_is_video_mode_still_image((dc1394video_mode_t)mode)) {
3812  // Format 6 video mode
3813  return 0;
3814  }
3815  else {
3816  // Not Format 7 and not Format 6 video modes
3817  dc1394color_coding_t _coding;
3818  if (dc1394_get_color_coding_from_video_mode(camera,
3819  (dc1394video_mode_t)mode,
3820  &_coding) != DC1394_SUCCESS) {
3821  close();
3822  vpERROR_TRACE("Could not query supported color coding for mode %d\n",
3823  mode);
3825  "Could not query supported color coding") );
3826  }
3827  codings.addRight((vp1394TwoColorCodingType)_coding);
3828  return 1;
3829  }
3830 }
3831 #endif
3832 
3833 #endif
3834 
void getColorCoding(vp1394TwoColorCodingType &coding)
static const char * strFramerate[DC1394_FRAMERATE_NUM]
uint32_t getColorCodingSupported(vp1394TwoVideoModeType videomode, std::list< vp1394TwoColorCodingType > &codings)
static std::string colorCoding2string(vp1394TwoColorCodingType colorcoding)
static void RGBToGrey(unsigned char *rgb, unsigned char *grey, unsigned int size)
void 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:159
#define vpERROR_TRACE
Definition: vpDebug.h:395
static void RGBToRGBa(unsigned char *rgb, unsigned char *rgba, unsigned int size)
#define vpTRACE
Definition: vpDebug.h:418
Provide simple list management.
Definition: vpList.h:113
Type * bitmap
points toward the bitmap
Definition: vpImage.h:120
static void MONO16ToGrey(unsigned char *grey16, unsigned char *grey, unsigned int size)
#define vpCERROR
Definition: vpDebug.h:369
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)
void kill()
Destroy the list.
Definition: vpList.h:692
static int wait(double t0, double t)
Definition: vpTime.cpp:149
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)
#define vpCTRACE
Definition: vpDebug.h:341
void setColorCoding(vp1394TwoColorCodingType coding)
void open(vpImage< unsigned char > &I)
static void YUV422ToGrey(unsigned char *yuv, unsigned char *grey, unsigned int size)
void setRingBufferSize(unsigned int size)
static vp1394TwoVideoModeType string2videoMode(std::string videomode)
void setFormat7ROI(unsigned int left=0, unsigned int top=0, unsigned int width=0, unsigned int height=0)
unsigned int height
Number of rows in the image.
void setCamera(uint64_t camera)
static const char * strVideoMode[DC1394_VIDEO_MODE_NUM]
void addRight(const type &el)
add a new element in the list, at the right of the current one
Definition: vpList.h:478
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
Definition: vpImage.h:532
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)
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:150
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.
unsigned int getHeight()
void setAutoShutter(bool enable=true)