Visual Servoing Platform  version 3.0.0
vp1394TwoGrabber.cpp
1 /****************************************************************************
2  *
3  * This file is part of the ViSP software.
4  * Copyright (C) 2005 - 2015 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();
506  vpERROR_TRACE("No camera found");
508  "No camera found") );
509  }
510  if (!isVideoModeSupported(videomode)){
511  vpERROR_TRACE("Video mode not supported by camera %d",camera_id);
513  "Video mode not supported") );
514  return ;
515  }
516  // Stop dma capture if started
517  setTransmission(DC1394_OFF);
518  setCapture(DC1394_OFF);
519 
520  if (dc1394_video_set_mode(camera, (dc1394video_mode_t) videomode) != DC1394_SUCCESS) {
521 
522  close();
523  vpERROR_TRACE("Can't set video mode");
525  "Can't set video mode") );
526  }
527 
528  setCapture(DC1394_ON);
529  setTransmission(DC1394_ON);
530 
531  // Updates image size from new video mode
532  if (dc1394_get_image_size_from_video_mode(camera,
533  (dc1394video_mode_t) videomode,
534  &this->width, &this->height)
535  != DC1394_SUCCESS) {
536 
537  close();
538  vpERROR_TRACE("Can't set video mode");
540  "Can't get image size") );
541  }
542 
543 }
544 
561 void
563 {
564  if (! num_cameras) {
565  close();
566  vpERROR_TRACE("No camera found");
568  "No camera found") );
569  }
570 
571  dc1394video_mode_t _videomode;
572  if (dc1394_video_get_mode(camera, &_videomode) != DC1394_SUCCESS) {
573 
574  close();
575  vpERROR_TRACE("Can't get current video mode");
577  "Can't get current video mode") );
578  }
579  videomode = (vp1394TwoVideoModeType) _videomode;
580 
581 }
582 
583 
584 
602 uint32_t
603 vp1394TwoGrabber::getVideoModeSupported(std::list<vp1394TwoVideoModeType> & videomodes)
604 {
605  // Refresh the list of supported modes
606  videomodes.clear();
607 
608  if (! num_cameras) {
609  close();
610  vpERROR_TRACE("No camera found");
612  "No camera found") );
613  }
614  dc1394video_modes_t _videomodes;
615 
616  // get video modes:
617  if (dc1394_video_get_supported_modes(camera, &_videomodes)!=DC1394_SUCCESS) {
618 
619  close();
620  vpERROR_TRACE("Can't get video modes");
622  "Can't get video modes") );
623  }
624 
625  // parse the video modes to add in the list
626  for (unsigned i=0; i < _videomodes.num; i++) {
627  vp1394TwoVideoModeType _mode = (vp1394TwoVideoModeType) _videomodes.modes[i];
628  videomodes.push_back( _mode );
629  }
630 
631  // return the number of available video modes
632  return _videomodes.num;
633 }
649 bool
651 {
652  if (! num_cameras) {
653  close();
654  vpERROR_TRACE("No camera found");
656  "No camera found") );
657  }
658  dc1394video_modes_t _videomodes;
659 
660  // get video modes:
661  if (dc1394_video_get_supported_modes(camera, &_videomodes)!=DC1394_SUCCESS) {
662 
663  close();
664  vpERROR_TRACE("Can't get video modes");
666  "Can't get video modes") );
667  }
668 
669  // parse the video modes to check with the desired
670  for (unsigned i=0; i < _videomodes.num; i++) {
671  if ((vp1394TwoVideoModeType) _videomodes.modes[i] == videomode)
672  return true;
673  }
674  return false;
675 }
676 
689 bool
691 {
692 
693  if (dc1394_is_video_mode_scalable((dc1394video_mode_t) videomode))
694  return true;
695 
696  return false;
697 }
698 
714 bool
716 {
718  getColorCoding(coding);
719 
720  switch (coding) {
724  case vpCOLOR_CODING_RAW8:
726  return false;
730  case vpCOLOR_CODING_RGB8:
733  return true;
734  }
735  return false;
736 }
737 
762 void
764 {
765  open();
766  if (! num_cameras) {
767  close();
768  vpERROR_TRACE("No camera found");
770  "No camera found") );
771  }
772 
773  vp1394TwoVideoModeType cur_videomode;
774  getVideoMode(cur_videomode);
775  if (isVideoModeFormat7(cur_videomode))
776  return;
777 
778  if (!isFramerateSupported(cur_videomode,fps)){
779  vpERROR_TRACE("Framerate not supported by camera %d",camera_id);
781  "Framerate not supported") );
782  return ;
783  }
784 
785  // Stop dma capture if started
786  setTransmission(DC1394_OFF);
787  setCapture(DC1394_OFF);
788 
789  if (dc1394_video_set_framerate(camera, (dc1394framerate_t) fps) != DC1394_SUCCESS) {
790 
791  close();
792  vpERROR_TRACE("Can't set framerate");
794  "Can't set framerate") );
795  }
796 
797  setCapture(DC1394_ON);
798  setTransmission(DC1394_ON);
799 }
800 
817 void
819 {
820  if (! num_cameras) {
821  close();
822  vpERROR_TRACE("No camera found");
824  "No camera found") );
825  }
826  dc1394framerate_t _fps;
827  if (dc1394_video_get_framerate(camera, &_fps) != DC1394_SUCCESS) {
828 
829  close();
830  vpERROR_TRACE("Can't get current framerate");
832  "Can't get current framerate") );
833  }
834  fps = (vp1394TwoFramerateType) _fps;
835 
836 }
837 
869 uint32_t
871  std::list<vp1394TwoFramerateType> & fps)
872 {
873  if (! num_cameras) {
874  close();
875  vpERROR_TRACE("No camera found");
877  "No camera found") );
878  }
879 
880  // Refresh the list of supported framerates
881  fps.clear();
882 
883  switch (mode) {
884  // Framerate not available for:
885  // - vpVIDEO_MODE_EXIF ie Format_6
886  // - vpVIDEO_MODE_FORMAT7... ie the Format_7
887  case vpVIDEO_MODE_EXIF:
896  return 0;
897  break;
898  default:
899  {
900  dc1394framerates_t _fps;
901  if (dc1394_video_get_supported_framerates(camera,
902  (dc1394video_mode_t)mode,
903  &_fps) != DC1394_SUCCESS) {
904  close();
905  vpERROR_TRACE("Could not query supported frametates for mode %d\n",
906  mode);
908  "Could not query supported framerates") );
909  }
910  if (_fps.num == 0)
911  return 0;
912 
913  for (unsigned int i = 0; i < _fps.num; i ++)
914  fps.push_back((vp1394TwoFramerateType)_fps.framerates[i]);
915 
916  return _fps.num;
917  }
918  break;
919  }
920 }
954 bool
957 {
958  if (! num_cameras) {
959  close();
960  vpERROR_TRACE("No camera found");
962  "No camera found") );
963  }
964 
965  switch (mode) {
966  // Framerate not available for:
967  // - vpVIDEO_MODE_EXIF ie Format_6
968  // - vpVIDEO_MODE_FORMAT7... ie the Format_7
969  case vpVIDEO_MODE_EXIF:
978  return 0;
979  break;
980  default:
981  {
982  dc1394framerates_t _fps;
983  if (dc1394_video_get_supported_framerates(camera,
984  (dc1394video_mode_t)mode,
985  &_fps) != DC1394_SUCCESS) {
986  close();
987  vpERROR_TRACE("Could not query supported frametates for mode %d\n",
988  mode);
990  "Could not query supported framerates") );
991  }
992  if (_fps.num == 0)
993  return 0;
994 
995  for (unsigned int i = 0; i < _fps.num; i ++){
996  if (fps==(vp1394TwoFramerateType)_fps.framerates[i]){
997  return true;
998  }
999  }
1000  return false;
1001  }
1002  break;
1003  }
1004 }
1005 
1054 void
1056 {
1057  if (! num_cameras) {
1058  close();
1059  vpERROR_TRACE("No camera found");
1061  "No camera found") );
1062  }
1063 
1064  dc1394video_mode_t _videomode;
1065  if (dc1394_video_get_mode(camera, &_videomode) != DC1394_SUCCESS) {
1066 
1067  close();
1068  vpERROR_TRACE("Can't get current video mode");
1070  "Can't get current video mode") );
1071  }
1072 
1073  if (!isColorCodingSupported((vp1394TwoVideoModeType)_videomode,coding)){
1074  vpERROR_TRACE("Color coding not supported by camera %d",camera_id);
1076  "Color coding not supported") );
1077  return ;
1078  }
1079 
1080  // Format 7 video mode
1081  if (dc1394_is_video_mode_scalable(_videomode)) {
1082  setTransmission(DC1394_OFF);
1083  setCapture(DC1394_OFF);
1084 
1085  if (dc1394_format7_set_color_coding(camera, _videomode,
1086  (dc1394color_coding_t) coding)
1087  != DC1394_SUCCESS) {
1088 
1089  close();
1090  vpERROR_TRACE("Can't set color coding");
1092  "Can't set color coding") );
1093  }
1094 
1095  setCapture(DC1394_ON);
1096  setTransmission(DC1394_ON);
1097  }
1098 }
1099 
1117 void
1119 {
1120  if (! num_cameras) {
1121  close();
1122  vpERROR_TRACE("No camera found");
1124  "No camera found") );
1125  }
1126  dc1394video_mode_t _videomode;
1127  if (dc1394_video_get_mode(camera, &_videomode) != DC1394_SUCCESS) {
1128 
1129  close();
1130  vpERROR_TRACE("Can't get current video mode");
1132  "Can't get current video mode") );
1133  }
1134 
1135  dc1394color_coding_t _coding;
1136  if (dc1394_is_video_mode_scalable(_videomode)) {
1137  // Format 7 video mode
1138  if (dc1394_format7_get_color_coding(camera, _videomode, &_coding)
1139  != DC1394_SUCCESS) {
1140 
1141  close();
1142  vpERROR_TRACE("Can't get current color coding");
1144  "Can't query current color coding") );
1145  }
1146  }
1147  else if (dc1394_is_video_mode_still_image((dc1394video_mode_t)_videomode)) {
1149  "No color coding for format 6 video mode"));
1150  }
1151  else {
1152  // Not Format 7 and not Format 6 video modes
1153  if (dc1394_get_color_coding_from_video_mode(camera,
1154  (dc1394video_mode_t)_videomode,
1155  &_coding) != DC1394_SUCCESS) {
1156  close();
1157  vpERROR_TRACE("Could not query supported color coding for mode %d\n",
1158  _videomode);
1160  "Can't query current color coding"));
1161  }
1162  }
1163  coding = (vp1394TwoColorCodingType) _coding;
1164 }
1165 
1187 uint32_t
1189  std::list<vp1394TwoColorCodingType> & codings)
1190 {
1191  if (! num_cameras) {
1192  close();
1193  vpERROR_TRACE("No camera found");
1195  "No camera found") );
1196  }
1197 
1198  // Refresh the list of supported framerates
1199  codings.clear();
1200 
1201  if (dc1394_is_video_mode_scalable((dc1394video_mode_t)mode)) {
1202  // Format 7 video mode
1203  dc1394color_codings_t _codings;
1204  if (dc1394_format7_get_color_codings(camera,
1205  (dc1394video_mode_t)mode,
1206  &_codings) != DC1394_SUCCESS) {
1207  close();
1208  vpERROR_TRACE("Could not query supported color codings for mode %d\n",
1209  mode);
1211  "Could not query supported color codings") );
1212  }
1213  if (_codings.num == 0)
1214  return 0;
1215 
1216  for (unsigned int i = 0; i < _codings.num; i ++)
1217  codings.push_back((vp1394TwoColorCodingType)_codings.codings[i]);
1218 
1219  return _codings.num;
1220  }
1221  else if (dc1394_is_video_mode_still_image((dc1394video_mode_t)mode)) {
1222  // Format 6 video mode
1223  return 0;
1224  }
1225  else {
1226  // Not Format 7 and not Format 6 video modes
1227  dc1394color_coding_t _coding;
1228  if (dc1394_get_color_coding_from_video_mode(camera,
1229  (dc1394video_mode_t)mode,
1230  &_coding) != DC1394_SUCCESS) {
1231  close();
1232  vpERROR_TRACE("Could not query supported color coding for mode %d\n",
1233  mode);
1235  "Could not query supported color coding") );
1236  }
1237  codings.push_back((vp1394TwoColorCodingType)_coding);
1238  return 1;
1239  }
1240 }
1262 bool
1264  vp1394TwoColorCodingType coding)
1265 {
1266  if (! num_cameras) {
1267  close();
1268  vpERROR_TRACE("No camera found");
1270  "No camera found") );
1271  }
1272 
1273 
1274  if (dc1394_is_video_mode_scalable((dc1394video_mode_t)mode)) {
1275  // Format 7 video mode
1276  dc1394color_codings_t _codings;
1277  if (dc1394_format7_get_color_codings(camera,
1278  (dc1394video_mode_t)mode,
1279  &_codings) != DC1394_SUCCESS) {
1280  close();
1281  vpERROR_TRACE("Could not query supported color codings for mode %d\n",
1282  mode);
1284  "Could not query supported color codings") );
1285  }
1286  if (_codings.num == 0)
1287  return 0;
1288 
1289  for (unsigned int i = 0; i < _codings.num; i ++){
1290  if (coding==(vp1394TwoColorCodingType)_codings.codings[i])
1291  return true;
1292  }
1293  return false;
1294  }
1295  else if (dc1394_is_video_mode_still_image((dc1394video_mode_t)mode)) {
1296  // Format 6 video mode
1297  return false;
1298  }
1299  else {
1300  // Not Format 7 and not Format 6 video modes
1301  dc1394color_coding_t _coding;
1302  if (dc1394_get_color_coding_from_video_mode(camera,
1303  (dc1394video_mode_t)mode,
1304  &_coding) != DC1394_SUCCESS) {
1305  close();
1306  vpERROR_TRACE("Could not query supported color coding for mode %d\n",
1307  mode);
1309  "Could not query supported color coding") );
1310  return false;
1311  }
1312  if (coding==(vp1394TwoColorCodingType)_coding)
1313  return true;
1314 
1315  return false;
1316  }
1317 }
1318 
1319 
1351 void
1352 vp1394TwoGrabber::setFormat7ROI(unsigned int left, unsigned int top,
1353  unsigned int w, unsigned int h)
1354 {
1355  open();
1356  if (! num_cameras) {
1357  close();
1358  vpERROR_TRACE("No camera found");
1360  "No camera found") );
1361  }
1362 
1363  dc1394video_mode_t _videomode;
1364  if (dc1394_video_get_mode(camera, &_videomode) != DC1394_SUCCESS) {
1365 
1366  close();
1367  vpERROR_TRACE("Can't get current video mode");
1369  "Can't get current video mode") );
1370  }
1371  if (dc1394_is_video_mode_scalable(_videomode)) {
1372  // Stop dma capture if started
1373  setTransmission(DC1394_OFF);
1374  setCapture(DC1394_OFF);
1375  // Format 7 video mode
1376  unsigned int max_width, max_height;
1377  if (dc1394_format7_get_max_image_size(camera, _videomode,
1378  &max_width, &max_height)
1379  != DC1394_SUCCESS) {
1380 
1381  close();
1382  vpERROR_TRACE("Can't get format7 max image size");
1384  "Can't get format7 max image size") );
1385  }
1386 #if 0
1387  vpTRACE("left: %d top: %d width: %d height: %d", left, top,
1388  width == 0 ? DC1394_USE_MAX_AVAIL: w,
1389  height == 0 ? DC1394_USE_MAX_AVAIL : h);
1390  vpTRACE("max_width: %d max_height: %d", max_width, max_height);
1391 #endif
1392 
1393  if (left > max_width) {
1394  vpERROR_TRACE("Can't set format7 ROI");
1396  "Can't set format7 ROI") );
1397  }
1398  if (top > max_height) {
1399  vpERROR_TRACE("Can't set format7 ROI");
1401  "Can't set format7 ROI") );
1402  }
1403 
1404  int32_t roi_width;
1405  int32_t roi_height;
1406 
1407  if (w != 0) {
1408  // Check if roi width is acceptable (ie roi is contained in the image)
1409  if (w > (max_width - left))
1410  w = (max_width - left);
1411  roi_width = (int32_t)w;
1412  }
1413  else {
1414  roi_width = DC1394_USE_MAX_AVAIL;
1415  }
1416 
1417  if (h != 0) {
1418  // Check if roi height is acceptable (ie roi is contained in the image)
1419  if (h > (max_height - top))
1420  h = (max_height - top);
1421  roi_height = (int32_t)h;
1422  }
1423  else {
1424  roi_height = DC1394_USE_MAX_AVAIL;
1425  }
1426 
1427  if (dc1394_format7_set_roi(camera, _videomode,
1428  (dc1394color_coding_t) DC1394_QUERY_FROM_CAMERA, // color_coding
1429  DC1394_USE_MAX_AVAIL/*DC1394_QUERY_FROM_CAMERA*/, // bytes_per_packet
1430  (int32_t)left, // left
1431  (int32_t)top, // top
1432  roi_width,
1433  roi_height)
1434  != DC1394_SUCCESS) {
1435  close();
1436  vpERROR_TRACE("Can't set format7 roi");
1438  "Can't get current video mode") );
1439  }
1440  // Update the image size
1441  if (dc1394_format7_get_image_size(camera, _videomode,
1442  &this->width,
1443  &this->height)
1444  != DC1394_SUCCESS) {
1445  close();
1446  vpERROR_TRACE("Can't get format7 image size");
1448  "Can't get format7 image size") );
1449  }
1450 
1451  setCapture(DC1394_ON);
1452  setTransmission(DC1394_ON);
1453  }
1454 }
1469 void
1470 vp1394TwoGrabber::initialize(bool reset)
1471 {
1472  if (init == false){
1473  // Find cameras
1474 #ifdef VISP_HAVE_DC1394_CAMERA_ENUMERATE // new API > libdc1394-2.0.0-rc7
1475  if (d != NULL)
1476  dc1394_free (d);
1477 
1478  d = dc1394_new ();
1479  if (dc1394_camera_enumerate (d, &list) != DC1394_SUCCESS) {
1480  dc1394_camera_free_list (list);
1481  close();
1482  vpERROR_TRACE("Failed to enumerate cameras\n");
1484  "Failed to enumerate cameras") );
1485  }
1486 
1487  if (list->num == 0) {
1488  dc1394_camera_free_list (list);
1489  close();
1490  vpERROR_TRACE("No cameras found");
1492  "No cameras found") );
1493  }
1494 
1495  if (cameras != NULL)
1496  delete [] cameras;
1497 
1498  cameras = new dc1394camera_t * [list->num];
1499 
1500  num_cameras = 0;
1501 
1502  for (unsigned int i=0; i < list->num; i ++) {
1503  cameras[i] = dc1394_camera_new (d, list->ids[i].guid);
1504  if (!cameras[i]) {
1505  vpTRACE ("Failed to initialize camera with guid \"%ld\"\n",
1506  list->ids[i].guid);
1507  continue;
1508  }
1509  // Update the number of working cameras
1510  num_cameras ++;
1511  }
1512 
1513  if (reset) {
1514  // Reset the bus to make firewire working if the program was not properly
1515  // stopped by a CTRL-C. We reset here only the bus attached to the first
1516  // camera
1517  dc1394_reset_bus(cameras[0]);
1518  }
1519 
1520  // if (list != NULL)
1521  dc1394_camera_free_list (list);
1522  list = NULL;
1523 
1524 #elif defined VISP_HAVE_DC1394_FIND_CAMERAS // old API <= libdc1394-2.0.0-rc7
1525  if (cameras != NULL)
1526  free(cameras);
1527  cameras = NULL;
1528  int err = dc1394_find_cameras(&cameras, &num_cameras);
1529 
1530  if (err!=DC1394_SUCCESS && err != DC1394_NO_CAMERA) {
1531  close();
1532  vpERROR_TRACE("Unable to look for cameras\n\n"
1533  "Please check \n"
1534  " - if the kernel modules `ieee1394',`raw1394' and `ohci1394' are loaded \n"
1535  " - if you have read/write access to /dev/raw1394\n\n");
1537  "Unable to look for cameras") );
1538 
1539  }
1540 #endif
1541 
1542  if (num_cameras == 0) {
1543  close();
1544  vpERROR_TRACE("No cameras found");
1546  "No cameras found") );
1547  }
1548 
1549  // allocation for the parameters
1550  isDataModified = new bool[num_cameras];
1551  for(unsigned int i=0; i<num_cameras; i++)
1552  isDataModified[i] = false;
1553  initialShutterMode = new dc1394feature_mode_t[num_cameras];
1554  dataCam = new vpDc1394TwoCameraParametersData[num_cameras];
1555 
1556  if (camera_id >= num_cameras) {
1557  // Bad camera id
1558  close();
1559  vpERROR_TRACE("Bad camera id: %u", camera_id);
1560  vpERROR_TRACE("Only %u camera on the bus.", num_cameras);
1562  "Bad camera id") );
1563  }
1564 
1565  if (verbose) {
1566  std::cout << "------ Bus information ------" << std::endl;
1567  std::cout << "Number of camera(s) on the bus : " << num_cameras <<std::endl;
1568  std::cout << "-----------------------------" << std::endl;
1569  }
1570 
1571  if (camIsOpen != NULL) delete [] camIsOpen;
1572  camIsOpen = new bool [num_cameras];
1573  for (unsigned int i = 0;i<num_cameras;i++){
1574  camIsOpen[i]=false;
1575  }
1576 
1577  init = true;
1578  }
1579 }
1589 void
1591 {
1592  if (init == false) initialize(false);
1593  if (camIsOpen[camera_id] == false){
1594  dc1394switch_t status = DC1394_OFF;
1595 
1596  //#ifdef VISP_HAVE_DC1394_CAMERA_ENUMERATE // new API > libdc1394-2.0.0-rc7
1597  dc1394_video_get_transmission(cameras[camera_id], &status);
1598  if (status != DC1394_OFF){
1599  //#endif
1600  if (dc1394_video_set_transmission(cameras[camera_id],DC1394_OFF)!=DC1394_SUCCESS)
1601  vpTRACE("Could not stop ISO transmission");
1602  else {
1603  vpTime::wait(500);
1604  if (dc1394_video_get_transmission(cameras[camera_id], &status)!=DC1394_SUCCESS)
1605  vpTRACE("Could get ISO status");
1606  else {
1607  if (status==DC1394_ON) {
1608  vpTRACE("ISO transmission refuses to stop");
1609  }
1610 #ifdef VISP_HAVE_DC1394_FIND_CAMERAS // old API <= libdc1394-2.0.0-rc7
1611  // No yet in the new API
1612  cameras[camera_id]->is_iso_on=status;
1613 #endif
1614  }
1615  //#ifdef VISP_HAVE_DC1394_CAMERA_ENUMERATE // new API > libdc1394-2.0.0-rc7
1616  }
1617  //#endif
1618  }
1619  setCamera(camera_id);
1620  //setIsoSpeed(DC1394_ISO_SPEED_400);
1621  setCapture(DC1394_ON);
1622  setTransmission(DC1394_ON);
1623  camIsOpen[camera_id] = true;
1624  }
1625 }
1634 void
1636 {
1637  if (init){
1638  if (num_cameras) {
1639  for (unsigned int i = 0; i < num_cameras;i++) {
1640  if (camIsOpen[i]) {
1641  camera = cameras[i];
1642  this->camera_id = i;// set camera id for the function updateDataStructToCam
1643  setTransmission(DC1394_OFF);
1644  setCapture(DC1394_OFF);
1645  if(isDataModified[i]){
1646  // reset values
1647  try{
1648  updateDataStructToCam();
1649  }
1650  catch(...){
1651  }
1652  // reset mode (manual, auto, ...)
1653  if (dc1394_feature_set_mode(camera, DC1394_FEATURE_BRIGHTNESS, initialShutterMode[i]) != DC1394_SUCCESS ||
1654  dc1394_feature_set_mode(camera, DC1394_FEATURE_EXPOSURE, initialShutterMode[i]) != DC1394_SUCCESS ||
1655  dc1394_feature_set_mode(camera, DC1394_FEATURE_SHARPNESS, initialShutterMode[i]) != DC1394_SUCCESS ||
1656  dc1394_feature_set_mode(camera, DC1394_FEATURE_HUE, initialShutterMode[i]) != DC1394_SUCCESS ||
1657  dc1394_feature_set_mode(camera, DC1394_FEATURE_SATURATION, initialShutterMode[i]) != DC1394_SUCCESS ||
1658  dc1394_feature_set_mode(camera, DC1394_FEATURE_GAMMA, initialShutterMode[i]) != DC1394_SUCCESS ||
1659  dc1394_feature_set_mode(camera, DC1394_FEATURE_SHUTTER, initialShutterMode[i]) != DC1394_SUCCESS ||
1660  dc1394_feature_set_mode(camera, DC1394_FEATURE_GAIN, initialShutterMode[i]) != DC1394_SUCCESS ||
1661  dc1394_feature_set_mode(camera, DC1394_FEATURE_IRIS, initialShutterMode[i])){
1662 
1663  vpERROR_TRACE("Unable to reset the initial mode");
1665  "Unable to reset the initial mode"));
1666  }
1667  }
1668  if (dc1394_camera_set_power(camera, DC1394_OFF) != DC1394_SUCCESS)
1669  std::cout << "Unable to turn camera off" << std::endl;
1670  }
1671 #ifdef VISP_HAVE_DC1394_CAMERA_ENUMERATE // new API > libdc1394-2.0.0-rc7
1672  dc1394_camera_free(cameras[i]);
1673 #elif defined VISP_HAVE_DC1394_FIND_CAMERAS // old API <= libdc1394-2.0.0-rc7
1674  dc1394_free_camera(cameras[i]);
1675 #endif
1676  }
1677  }
1678  if (camIsOpen != NULL) {
1679  delete [] camIsOpen;
1680  camIsOpen = NULL;
1681  }
1682 
1683 #ifdef VISP_HAVE_DC1394_CAMERA_ENUMERATE // new API > libdc1394-2.0.0-rc7
1684  if (cameras != NULL) {
1685  delete [] cameras;
1686  cameras = NULL;
1687  }
1688  if (d != NULL) {
1689  dc1394_free (d);
1690  d = NULL;
1691  }
1692 
1693 #elif defined VISP_HAVE_DC1394_FIND_CAMERAS // old API <= libdc1394-2.0.0-rc7
1694  if (cameras != NULL) {
1695  free(cameras);
1696  cameras = NULL;
1697  }
1698 #endif
1699 
1700  camIsOpen = NULL;
1701  num_cameras = 0;
1702 
1703  // remove data for the parameters
1704  if(isDataModified != NULL){
1705  delete[] isDataModified;
1706  isDataModified = NULL;
1707  }
1708  if(initialShutterMode != NULL){
1709  delete[] initialShutterMode;
1710  initialShutterMode = NULL;
1711  }
1712  if(dataCam != NULL){
1713  delete[] dataCam;
1714  dataCam = NULL;
1715  }
1716 
1717  init = false;
1718  }
1719 }
1720 
1732 void
1734 {
1735  if (size < 1) {
1736  close();
1738  "Could not set ring buffer size") );
1739  }
1740 
1741  if (size != num_buffers) {
1742  // We need to change the ring buffer size
1743  num_buffers = size;
1744  if(camIsOpen[camera_id]){
1745  setCapture(DC1394_OFF);
1746  setCapture(DC1394_ON);
1747  }
1748  }
1749 }
1750 
1760 unsigned int
1762 {
1763  return num_buffers;
1764 }
1765 
1805 void
1807 {
1808  if (! num_cameras) {
1809  close();
1810  vpERROR_TRACE("No camera found");
1812  "No camera found") );
1813  }
1814 
1815  dc1394feature_mode_t mode;
1816  if (enable) {
1817  mode = DC1394_FEATURE_MODE_AUTO;
1818  }
1819  else {
1820  mode = DC1394_FEATURE_MODE_MANUAL;
1821  }
1822 
1823  if (dc1394_feature_set_power(camera, DC1394_FEATURE_SHUTTER, DC1394_ON)
1824  != DC1394_SUCCESS) {
1825  // vpERROR_TRACE("Cannot set shutter on. \n");
1826  close();
1828  "Cannot set shutter on") );
1829  }
1830 
1831  if (dc1394_feature_set_mode(camera,
1832  DC1394_FEATURE_SHUTTER,
1833  mode)
1834  != DC1394_SUCCESS) {
1835  // vpERROR_TRACE("Cannot set auto shutter. \n");
1836  close();
1838  "Cannot set auto shutter") );
1839  }
1840 }
1881 void
1882 vp1394TwoGrabber::setAutoShutter(unsigned int minvalue, unsigned int maxvalue)
1883 {
1884  setAutoShutter();
1885 
1886  if (dc1394_avt_set_auto_shutter(camera, minvalue, maxvalue)
1887  != DC1394_SUCCESS) {
1888  // vpERROR_TRACE("Cannot set auto shutter min and max values. Is the camera an AVT one?\n");
1889  close();
1891  "Cannot set auto shutter min and max values") );
1892  }
1893 }
1894 
1907 void
1908 vp1394TwoGrabber::getAutoShutter(unsigned int &minvalue, unsigned int &maxvalue)
1909 {
1910  if (! num_cameras) {
1911  close();
1912  vpERROR_TRACE("No camera found");
1914  "No camera found") );
1915  }
1916 
1917  if (dc1394_avt_get_auto_shutter(camera, &minvalue, &maxvalue)
1918  != DC1394_SUCCESS) {
1919  // vpERROR_TRACE("Cannot get auto shutter min and max values. Is the camera an AVT one?\n");
1920  close();
1922  "Cannot get auto shutter min and max values") );
1923  }
1924 }
1925 
1965 void
1967 {
1968  if (! num_cameras) {
1969  close();
1970  vpERROR_TRACE("No camera found");
1972  "No camera found") );
1973  }
1974 
1975  dc1394feature_mode_t mode;
1976  if (enable) {
1977  mode = DC1394_FEATURE_MODE_AUTO;
1978  }
1979  else {
1980  mode = DC1394_FEATURE_MODE_MANUAL;
1981  }
1982 
1983  if (dc1394_feature_set_power(camera, DC1394_FEATURE_GAIN, DC1394_ON)
1984  != DC1394_SUCCESS) {
1985  // vpERROR_TRACE("Cannot set shutter on. \n");
1986  close();
1988  "Cannot set shutter on") );
1989  }
1990 
1991  if (dc1394_feature_set_mode(camera,
1992  DC1394_FEATURE_GAIN,
1993  mode)
1994  != DC1394_SUCCESS) {
1995  // vpERROR_TRACE("Cannot set auto gain. \n");
1996  close();
1998  "Cannot set auto gain") );
1999  }
2000 }
2041 void
2042 vp1394TwoGrabber::setAutoGain(unsigned int minvalue, unsigned int maxvalue)
2043 {
2044  setAutoGain();
2045 
2046  if (dc1394_avt_set_auto_gain(camera, minvalue, maxvalue)
2047  != DC1394_SUCCESS) {
2048  // vpERROR_TRACE("Cannot set auto gain min and max values. Is the camera an AVT one?\n");
2049  close();
2051  "Cannot set auto gain min and max values") );
2052  }
2053 }
2054 
2067 void
2068 vp1394TwoGrabber::getAutoGain(unsigned int &minvalue, unsigned int &maxvalue)
2069 {
2070  if (! num_cameras) {
2071  close();
2072  vpERROR_TRACE("No camera found");
2074  "No camera found") );
2075  }
2076 
2077  if (dc1394_avt_get_auto_gain(camera, &minvalue, &maxvalue)
2078  != DC1394_SUCCESS) {
2079  // vpERROR_TRACE("Cannot get auto gain min and max values. Is the camera an AVT one?\n");
2080  close();
2082  "Cannot get auto gain min and max values") );
2083  }
2084 }
2085 
2086 
2104 void
2105 vp1394TwoGrabber::setCapture(dc1394switch_t _switch)
2106 {
2107  if (! num_cameras) {
2108  close();
2109  vpERROR_TRACE("No camera found");
2111  "No camera found") );
2112  }
2113 
2114  if (_switch == DC1394_ON) {
2115  //if (dc1394_capture_setup(camera, num_buffers) != DC1394_SUCCESS) {
2116  // To be compatible with libdc1394 svn 382 version
2117  if (dc1394_capture_setup(camera, num_buffers,
2118  DC1394_CAPTURE_FLAGS_DEFAULT) != DC1394_SUCCESS) {
2119  vpERROR_TRACE("Unable to setup camera capture-\n"
2120  "make sure that the video mode and framerate are "
2121  "supported by your camera.\n");
2122  close();
2124  "Could not setup dma capture") );
2125  }
2126  }
2127  else { // _switch == DC1394_OFF
2128  dc1394error_t code = dc1394_capture_stop(camera);
2129 
2130  if (code != DC1394_SUCCESS && code != DC1394_CAPTURE_IS_NOT_SET) {
2131  vpERROR_TRACE("Unable to stop camera capture\n");
2132  close();
2134  "Could not setup dma capture") );
2135  }
2136  }
2137 }
2138 
2139 
2154 void
2155 vp1394TwoGrabber::setTransmission(dc1394switch_t _switch)
2156 {
2157  if (! num_cameras) {
2158  close();
2159  vpERROR_TRACE("No camera found");
2161  "No camera found") );
2162  }
2163 
2164  dc1394switch_t status = DC1394_OFF;
2165 
2166  if (dc1394_video_get_transmission(camera, &status)!=DC1394_SUCCESS) {
2167  vpERROR_TRACE("Unable to get transmision status");
2168  close();
2170  "Could not setup dma capture") );
2171  }
2172 
2173  // if (status!=_switch){
2174  // Start dma capture if halted
2175  if (dc1394_video_set_transmission(camera, _switch) != DC1394_SUCCESS) {
2176  vpERROR_TRACE("Unable to setup camera capture-\n"
2177  "make sure that the video mode and framerate are "
2178  "supported by your camera.\n");
2179  close();
2181  "Could not setup dma capture") );
2182  }
2183 
2184  if (_switch == DC1394_ON) {
2185  status = DC1394_OFF;
2186 
2187  int i = 0;
2188  while ( status == DC1394_OFF && i++ < 5 ) {
2189  usleep(50000);
2190  if (dc1394_video_get_transmission(camera, &status)!=DC1394_SUCCESS) {
2191  vpERROR_TRACE("Unable to get transmision status");
2192  close();
2194  "Could not setup dma capture") );
2195  }
2196  }
2197  }
2198  // }
2199 }
2200 
2235 void
2237 {
2238  if (! num_cameras) {
2239  close();
2240  vpERROR_TRACE("No camera found");
2242  "No camera found") );
2243  }
2244 
2245  dc1394operation_mode_t op_mode;
2246  dc1394speed_t speed;
2247 
2248  // Check the speed to configure in B-mode or A-mode
2249  if (isospeed >= vpISO_SPEED_800) {
2250  if (camera->bmode_capable != DC1394_TRUE) {
2251 // vpERROR_TRACE("Camera is not 1394B mode capable. \n"
2252 // "Set the iso speed lower or equal to 400Mbps");
2253  close();
2255  "Camera is not 1394B mode capable") );
2256  }
2257 
2258  if(dc1394_video_set_operation_mode(camera,
2259  DC1394_OPERATION_MODE_1394B)
2260  != DC1394_SUCCESS) {
2261 // vpERROR_TRACE("Cannot set camera to 1394B mode. \n");
2262  close();
2264  "Cannot set camera to 1394B mode") );
2265  }
2266 
2267  if (dc1394_video_get_operation_mode(camera, &op_mode) != DC1394_SUCCESS) {
2268 // vpERROR_TRACE("Failed to set 1394B mode. \n");
2269  close();
2271  "Failed to set 1394B mode") );
2272  }
2273  }
2274  else {
2275  if (dc1394_video_set_operation_mode(camera,
2276  DC1394_OPERATION_MODE_LEGACY)
2277  != DC1394_SUCCESS) {
2278 // vpERROR_TRACE("Cannot set camera to 1394A mode. \n");
2279  close();
2281  "Cannot set camera to 1394A mode") );
2282  }
2283 
2284  if (dc1394_video_get_operation_mode(camera, &op_mode) != DC1394_SUCCESS) {
2285 // vpERROR_TRACE("Failed to set 1394A mode. \n");
2286  close();
2288  "Failed to set 1394A mode") );
2289  }
2290  }
2291 
2292  if (dc1394_video_set_iso_speed(camera, (dc1394speed_t) isospeed)
2293  != DC1394_SUCCESS) {
2294 // vpERROR_TRACE("Cannot set requested iso speed. \n");
2295  close();
2297  "Cannot set requested iso speed") );
2298  }
2299 
2300  if (dc1394_video_get_iso_speed(camera, &speed) != DC1394_SUCCESS) {
2301 // vpERROR_TRACE("Failed to set iso speed. \n");
2302  close();
2304  "Failed to set iso speed") );
2305  }
2306 }
2307 
2318 void
2320 {
2321  open();
2322  acquire(I);
2323 }
2324 
2335 void
2337 {
2338  open();
2339  acquire(I);
2340 }
2341 
2342 
2381 dc1394video_frame_t *
2383 {
2384 
2385  if (! num_cameras) {
2386  close();
2387  vpERROR_TRACE("No camera found");
2389  "No camera found") );
2390  }
2391 
2392  dc1394video_frame_t *frame = NULL;
2393 
2394  if (dc1394_capture_dequeue(camera, DC1394_CAPTURE_POLICY_WAIT, &frame)
2395  !=DC1394_SUCCESS) {
2396  vpERROR_TRACE ("Error: Failed to capture from camera %d\n", camera_id);
2397  }
2398 
2399  return frame;
2400 }
2401 
2443 dc1394video_frame_t *
2445 {
2446  uint64_t timestamp;
2447  uint32_t id;
2448 
2449  dc1394video_frame_t *frame;
2450 
2451  frame = dequeue(I, timestamp, id);
2452 
2453  return frame;
2454 }
2455 
2504 dc1394video_frame_t *
2506  uint64_t &timestamp,
2507  uint32_t &id)
2508 {
2509 
2510  open();
2511 
2512  dc1394video_frame_t *frame;
2513 
2514  frame = dequeue();
2515 
2516  // Timeval data structure providing the unix time
2517  // [microseconds] at which the frame was captured in the ring buffer.
2518  timestamp = frame->timestamp;
2519  id = frame->id;
2520 
2521  this->width = frame->size[0];
2522  this->height = frame->size[1];
2523  unsigned int size = this->width * this->height;
2524 
2525  if ((I.getWidth() != this->width)||(I.getHeight() != this->height))
2526  I.resize(this->height, this->width);
2527 
2528  switch(frame->color_coding) {
2529  case DC1394_COLOR_CODING_MONO8:
2530  case DC1394_COLOR_CODING_RAW8:
2531  memcpy(I.bitmap, (unsigned char *) frame->image,
2532  size*sizeof(unsigned char));
2533  break;
2534  case DC1394_COLOR_CODING_MONO16:
2535  case DC1394_COLOR_CODING_RAW16:
2536  vpImageConvert::MONO16ToGrey( (unsigned char *) frame->image,
2537  I.bitmap, size);
2538  break;
2539 
2540  case DC1394_COLOR_CODING_YUV411:
2541  vpImageConvert::YUV411ToGrey( (unsigned char *) frame->image,
2542  I.bitmap, size);
2543  break;
2544 
2545  case DC1394_COLOR_CODING_YUV422:
2546  vpImageConvert::YUV422ToGrey( (unsigned char *) frame->image,
2547  I.bitmap, size);
2548  break;
2549 
2550  case DC1394_COLOR_CODING_YUV444:
2551  vpImageConvert::YUV444ToGrey( (unsigned char *) frame->image,
2552  I.bitmap, size);
2553  break;
2554 
2555  case DC1394_COLOR_CODING_RGB8:
2556  vpImageConvert::RGBToGrey((unsigned char *) frame->image, I.bitmap, size);
2557  break;
2558 
2559 
2560  default:
2561  close();
2562  vpERROR_TRACE("Format conversion not implemented. Acquisition failed.");
2564  "Format conversion not implemented. "
2565  "Acquisition failed.") );
2566  break;
2567  };
2568 
2569  return frame;
2570 }
2571 
2612 dc1394video_frame_t *
2614 {
2615  uint64_t timestamp;
2616  uint32_t id;
2617 
2618  dc1394video_frame_t *frame;
2619 
2620  frame = dequeue(I, timestamp, id);
2621 
2622  return frame;
2623 }
2624 
2673 dc1394video_frame_t *
2675  uint64_t &timestamp,
2676  uint32_t &id)
2677 {
2678 
2679  open();
2680 
2681  dc1394video_frame_t *frame;
2682 
2683  frame = dequeue();
2684 
2685  // Timeval data structure providing the unix time
2686  // [microseconds] at which the frame was captured in the ring buffer.
2687  timestamp = frame->timestamp;
2688  id = frame->id;
2689 
2690  this->width = frame->size[0];
2691  this->height = frame->size[1];
2692  unsigned int size = this->width * this->height;
2693 
2694  if ((I.getWidth() != width)||(I.getHeight() != height))
2695  I.resize(height, width);
2696 
2697  switch (frame->color_coding) {
2698  case DC1394_COLOR_CODING_MONO8:
2699  case DC1394_COLOR_CODING_RAW8:
2700  vpImageConvert::GreyToRGBa((unsigned char *) frame->image,
2701  (unsigned char *) I.bitmap, size);
2702  break;
2703 
2704  case DC1394_COLOR_CODING_MONO16:
2705  case DC1394_COLOR_CODING_RAW16:
2706  vpImageConvert::MONO16ToRGBa((unsigned char *) frame->image,
2707  (unsigned char *) I.bitmap, size);
2708  break;
2709 
2710  case DC1394_COLOR_CODING_YUV411:
2711  vpImageConvert::YUV411ToRGBa( (unsigned char *) frame->image,
2712  (unsigned char *) I.bitmap, size);
2713  break;
2714 
2715  case DC1394_COLOR_CODING_YUV422:
2716  vpImageConvert::YUV422ToRGBa( (unsigned char *) frame->image,
2717  (unsigned char *) I.bitmap, size);
2718  break;
2719 
2720  case DC1394_COLOR_CODING_YUV444:
2721  vpImageConvert::YUV444ToRGBa( (unsigned char *) frame->image,
2722  (unsigned char *) I.bitmap, size);
2723  break;
2724 
2725  case DC1394_COLOR_CODING_RGB8:
2726  vpImageConvert::RGBToRGBa((unsigned char *) frame->image,
2727  (unsigned char *) I.bitmap, size);
2728  break;
2729 
2730 
2731  default:
2732  close();
2733  vpERROR_TRACE("Format conversion not implemented. Acquisition failed.");
2735  "Format conversion not implemented. "
2736  "Acquisition failed.") );
2737  break;
2738  };
2739 
2740  return frame;
2741 }
2742 
2753 void
2754 vp1394TwoGrabber::enqueue(dc1394video_frame_t *frame)
2755 {
2756 
2757  if (! num_cameras) {
2758  close();
2759  vpERROR_TRACE("No camera found");
2761  "No camera found") );
2762  }
2763 
2764  if (frame)
2765  dc1394_capture_enqueue(camera, frame);
2766 }
2767 
2768 
2782 void
2784 {
2785  uint64_t timestamp;
2786  uint32_t id;
2787 
2788  dc1394video_frame_t *frame;
2789 
2790  frame = dequeue(I, timestamp, id);
2791  enqueue(frame);
2792 }
2793 
2812 void
2814  uint64_t &timestamp,
2815  uint32_t &id)
2816 {
2817  dc1394video_frame_t *frame;
2818 
2819  open();
2820  frame = dequeue(I, timestamp, id);
2821  enqueue(frame);
2822 }
2823 
2824 
2825 
2839 void
2841 {
2842  uint64_t timestamp;
2843  uint32_t id;
2844  dc1394video_frame_t *frame;
2845 
2846  open();
2847  frame = dequeue(I, timestamp, id);
2848  enqueue(frame);
2849 }
2850 
2869 void
2871  uint64_t &timestamp,
2872  uint32_t &id)
2873 {
2874  dc1394video_frame_t *frame;
2875 
2876  open();
2877  frame = dequeue();
2878  // Timeval data structure providing the unix time
2879  // [microseconds] at which the frame was captured in the ring buffer.
2880  timestamp = frame->timestamp;
2881  id = frame->id;
2882 
2883  this->width = frame->size[0];
2884  this->height = frame->size[1];
2885  unsigned int size = this->width * this->height;
2886 
2887  if ((I.getWidth() != width)||(I.getHeight() != height))
2888  I.resize(height, width);
2889 
2890  switch (frame->color_coding) {
2891  case DC1394_COLOR_CODING_MONO8:
2892  case DC1394_COLOR_CODING_RAW8:
2893  vpImageConvert::GreyToRGBa((unsigned char *) frame->image,
2894  (unsigned char *) I.bitmap, size);
2895  break;
2896 
2897  case DC1394_COLOR_CODING_YUV411:
2898  vpImageConvert::YUV411ToRGBa( (unsigned char *) frame->image,
2899  (unsigned char *) I.bitmap, size);
2900  break;
2901 
2902  case DC1394_COLOR_CODING_YUV422:
2903  vpImageConvert::YUV422ToRGBa( (unsigned char *) frame->image,
2904  (unsigned char *) I.bitmap, size);
2905  break;
2906 
2907  case DC1394_COLOR_CODING_YUV444:
2908  vpImageConvert::YUV444ToRGBa( (unsigned char *) frame->image,
2909  (unsigned char *) I.bitmap, size);
2910  break;
2911 
2912  case DC1394_COLOR_CODING_RGB8:
2913  vpImageConvert::RGBToRGBa((unsigned char *) frame->image,
2914  (unsigned char *) I.bitmap, size);
2915  break;
2916 
2917 
2918  default:
2919  close();
2920  vpERROR_TRACE("Format conversion not implemented. Acquisition failed.");
2922  "Format conversion not implemented. "
2923  "Acquisition failed.") );
2924  break;
2925  };
2926 
2927  enqueue(frame);
2928 
2929 }
2930 
2947 void vp1394TwoGrabber::getWidth(unsigned int &w)
2948 {
2949  if (! num_cameras) {
2950  close();
2951  vpERROR_TRACE("No camera found");
2953  "No camera found") );
2954  }
2955 
2956  w = this->width;
2957 }
2958 
2976 {
2977  if (! num_cameras) {
2978  close();
2979  vpERROR_TRACE("No camera found");
2981  "No camera found") );
2982  }
2983 
2984  return this->width;
2985 }
2986 
3004 void vp1394TwoGrabber::getHeight(unsigned int &h)
3005 {
3006  if (! num_cameras) {
3007  close();
3008  vpERROR_TRACE("No camera found");
3010  "No camera found") );
3011  }
3012 
3013  h = this->height;
3014 }
3033 {
3034  if (! num_cameras) {
3035  close();
3036  vpERROR_TRACE("No camera found");
3038  "No camera found") );
3039  }
3040 
3041  return this->height;
3042 }
3043 
3049 void
3051 {
3052  std::cout << "----------------------------------------------------------"
3053  << std::endl
3054  << "----- Information for camera " << camera_id
3055  << " -----" << std::endl
3056  << "----------------------------------------------------------" << std::endl;
3057 
3058 #ifdef VISP_HAVE_DC1394_CAMERA_ENUMERATE // new API > libdc1394-2.0.0-rc7
3059  dc1394_camera_print_info( camera, stdout);
3060 #elif defined VISP_HAVE_DC1394_FIND_CAMERAS // old API <= libdc1394-2.0.0-rc7
3061  dc1394_print_camera_info( camera);
3062 #endif
3063 
3064  dc1394featureset_t features;
3065 #ifdef VISP_HAVE_DC1394_CAMERA_ENUMERATE // new API > libdc1394-2.0.0-rc7
3066  if (dc1394_feature_get_all(camera, &features) != DC1394_SUCCESS)
3067 #elif defined VISP_HAVE_DC1394_FIND_CAMERAS // old API <= libdc1394-2.0.0-rc7
3068  if (dc1394_get_camera_feature_set(camera, &features) != DC1394_SUCCESS)
3069 #endif
3070  {
3071  close();
3072  vpERROR_TRACE("unable to get feature set for camera %d\n", camera_id);
3074  "Cannot get camera features") );
3075 
3076  } else {
3077 #ifdef VISP_HAVE_DC1394_CAMERA_ENUMERATE // new API > libdc1394-2.0.0-rc7
3078  dc1394_feature_print_all(&features, stdout);
3079 #elif defined VISP_HAVE_DC1394_FIND_CAMERAS // old API <= libdc1394-2.0.0-rc7
3080  dc1394_print_feature_set(&features);
3081 #endif
3082  }
3083  std::cout << "----------------------------------------------------------" << std::endl;
3084 }
3085 
3099 {
3100  std::string _str = "";
3101  dc1394video_mode_t _videomode = (dc1394video_mode_t) videomode;
3102 
3103  if ((_videomode >= DC1394_VIDEO_MODE_MIN)
3104  && (_videomode <= DC1394_VIDEO_MODE_MAX)) {
3105  _str = strVideoMode[_videomode - DC1394_VIDEO_MODE_MIN];
3106  }
3107  else {
3108  vpCERROR << "The video mode " << (int)videomode
3109  << " is not supported by the camera" << std::endl;
3110  }
3111 
3112  return _str;
3113 }
3114 
3128 {
3129  std::string _str = "";
3130  dc1394framerate_t _fps = (dc1394framerate_t) fps;
3131 
3132  if ((_fps >= DC1394_FRAMERATE_MIN)
3133  && (_fps <= DC1394_FRAMERATE_MAX)) {
3134  _str = strFramerate[_fps - DC1394_FRAMERATE_MIN];
3135  }
3136  else {
3137  vpCERROR << "The framerate " << (int)fps
3138  << " is not supported by the camera" << std::endl;
3139  }
3140 
3141  return _str;
3142 }
3143 
3157 {
3158  std::string _str = "";
3159  dc1394color_coding_t _coding = (dc1394color_coding_t) colorcoding;
3160 
3161  if ((_coding >= DC1394_COLOR_CODING_MIN)
3162  && (_coding <= DC1394_COLOR_CODING_MAX)) {
3163  _str = strColorCoding[_coding - DC1394_COLOR_CODING_MIN];
3164 
3165  }
3166  else {
3167  vpCERROR << "The color coding " << (int)colorcoding
3168  << " is not supported by the camera" << std::endl;
3169  }
3170 
3171  return _str;
3172 }
3173 
3193 {
3195 
3196  for (int i = DC1394_VIDEO_MODE_MIN; i <= DC1394_VIDEO_MODE_MAX; i ++) {
3197  _id = (vp1394TwoVideoModeType) i;
3198  if (videomode.compare(videoMode2string(_id)) == 0)
3199  return _id;
3200  };
3201 
3203  "The required videomode is not valid") );
3204 
3205  return (vp1394TwoVideoModeType) 0;
3206 }
3207 
3208 
3228 {
3230 
3231  for (int i = DC1394_FRAMERATE_MIN; i <= DC1394_FRAMERATE_MAX; i ++) {
3232  _id = (vp1394TwoFramerateType) i;
3233  if (framerate.compare(framerate2string(_id)) == 0)
3234  return _id;
3235  };
3236 
3238  "The required framerate is not valid") );
3239 
3240  return (vp1394TwoFramerateType) 0;
3241 }
3242 
3262 {
3264 
3265  for (int i = DC1394_COLOR_CODING_MIN; i <= DC1394_COLOR_CODING_MAX; i ++) {
3266  _id = (vp1394TwoColorCodingType) i;
3267  if (colorcoding.compare(colorCoding2string(_id)) == 0)
3268  return _id;
3269  };
3270 
3272  "The required color coding is not valid") );
3273 
3274  return (vp1394TwoColorCodingType) 0;
3275 }
3276 
3310 {
3311  for (unsigned int i = 0; i < num_cameras;i++) {
3312  if (camIsOpen[i]) {
3313  camera = cameras[i];
3314  setTransmission(DC1394_OFF);
3315  setCapture(DC1394_OFF);
3316  }
3317  }
3318 #ifdef VISP_HAVE_DC1394_CAMERA_ENUMERATE // new API > libdc1394-2.0.0-rc7
3319  setCamera(camera_id);
3320  // free the other cameras
3321  for (unsigned int i=0;i<num_cameras;i++){
3322  if (i!=camera_id) dc1394_camera_free(cameras[i]);
3323  }
3324 
3325  printf ("Reseting bus...\n");
3326  dc1394_reset_bus (camera);
3327 
3328  dc1394_camera_free (camera);
3329  dc1394_free (d);
3330  d = NULL;
3331  //if (cameras != NULL)
3332  delete [] cameras;
3333  cameras = NULL ;
3334 #elif defined VISP_HAVE_DC1394_FIND_CAMERAS // old API <= libdc1394-2.0.0-rc7
3335 
3336  setCamera(camera_id);
3337  // free the other cameras
3338  for (unsigned int i=0;i<num_cameras;i++){
3339  if (i!=camera_id) dc1394_free_camera(cameras[i]);
3340  }
3341  free(cameras);
3342  cameras = NULL;
3343 
3344  dc1394_reset_bus(camera);
3345  dc1394_free_camera(camera);
3346 
3347 #endif
3348  if (camIsOpen != NULL)
3349  delete [] camIsOpen;
3350  camIsOpen = NULL ;
3351 
3352  num_cameras = 0;
3353 
3354  init = false;
3355  vpTime::wait(1000);
3356  initialize(false);
3357 }
3358 
3388 void vp1394TwoGrabber::setPanControl(unsigned int panControlValue)
3389 {
3390  open();
3391  if (! num_cameras) {
3392  close();
3393  vpERROR_TRACE("No camera found");
3395  "No camera found") );
3396  }
3397  uint64_t offset = 0x884;
3398  uint32_t value = 0x82000000 + (uint32_t)panControlValue;
3399  dc1394error_t err;
3400  err = dc1394_set_control_register(camera, offset, value);
3401  if (err != DC1394_SUCCESS) {
3402  vpERROR_TRACE("Unable to set PAN register");
3403  close();
3405  "Unable to set PAN register") );
3406  }
3407 }
3408 
3409 
3427 {
3428  if (! num_cameras) {
3429  close();
3430  vpERROR_TRACE("No camera found");
3432  "No camera found") );
3433  }
3434 
3435  uint32_t value;
3436  dc1394feature_t feature = DC1394_FEATURE_BRIGHTNESS;// = (dc1394feature_t)param;
3437  switch(param) {
3438  case vpFEATURE_BRIGHTNESS: feature = DC1394_FEATURE_BRIGHTNESS; break;
3439  case vpFEATURE_EXPOSURE: feature = DC1394_FEATURE_EXPOSURE; break;
3440  case vpFEATURE_SHARPNESS: feature = DC1394_FEATURE_SHARPNESS; break;
3441 // vpFEATURE_WHITE_BALANCE = DC1394_FEATURE_WHITE_BALANCE,
3442  case vpFEATURE_HUE: feature = DC1394_FEATURE_HUE; break;
3443  case vpFEATURE_SATURATION: feature = DC1394_FEATURE_SATURATION; break;
3444  case vpFEATURE_GAMMA: feature = DC1394_FEATURE_GAMMA; break;
3445  case vpFEATURE_SHUTTER: feature = DC1394_FEATURE_SHUTTER; break;
3446  case vpFEATURE_GAIN: feature = DC1394_FEATURE_GAIN; break;
3447  case vpFEATURE_IRIS: feature = DC1394_FEATURE_IRIS; break;
3448 // vpFEATURE_FOCUS = DC1394_FEATURE_FOCUS,
3449 // vpFEATURE_TEMPERATURE = DC1394_FEATURE_TEMPERATURE,
3450 // vpFEATURE_TRIGGER = DC1394_FEATURE_TRIGGER,
3451 // vpFEATURE_TRIGGER_DELAY = DC1394_FEATURE_TRIGGER_DELAY,
3452 // vpFEATURE_WHITE_SHADING = DC1394_FEATURE_WHITE_SHADING,
3453 // vpFEATURE_FRAME_RATE = DC1394_FEATURE_FRAME_RATE,
3454 // vpFEATURE_ZOOM = DC1394_FEATURE_ZOOM,
3455 // vpFEATURE_PAN = DC1394_FEATURE_PAN,
3456 // vpFEATURE_TILT = DC1394_FEATURE_TILT,
3457 // vpFEATURE_OPTICAL_FILTER = DC1394_FEATURE_OPTICAL_FILTER,
3458 // vpFEATURE_CAPTURE_SIZE = DC1394_FEATURE_CAPTURE_SIZE,
3459 // vpFEATURE_CAPTURE_QUALITY = DC1394_FEATURE_CAPTURE_QUALITY
3460  }
3461 
3462  dc1394error_t err;
3463  err = dc1394_feature_get_value(camera, feature, &value);
3464  if (err != DC1394_SUCCESS) {
3465  vpERROR_TRACE("Unable to get the information");
3466  close();
3468  "Unable to get the information") );
3469  }
3470  return (unsigned int)value;
3471 }
3472 
3473 
3495  unsigned int val)
3496 {
3497  if (! num_cameras) {
3498  close();
3499  vpERROR_TRACE("No camera found");
3501  "No camera found") );
3502  }
3503  uint32_t value = (uint32_t)val;
3504  dc1394feature_t feature = DC1394_FEATURE_BRIGHTNESS;// = (dc1394feature_t)param;
3505  switch(param) {
3506  case vpFEATURE_BRIGHTNESS: feature = DC1394_FEATURE_BRIGHTNESS; break;
3507  case vpFEATURE_EXPOSURE: feature = DC1394_FEATURE_EXPOSURE; break;
3508  case vpFEATURE_SHARPNESS: feature = DC1394_FEATURE_SHARPNESS; break;
3509 // vpFEATURE_WHITE_BALANCE = DC1394_FEATURE_WHITE_BALANCE,
3510  case vpFEATURE_HUE: feature = DC1394_FEATURE_HUE; break;
3511  case vpFEATURE_SATURATION: feature = DC1394_FEATURE_SATURATION; break;
3512  case vpFEATURE_GAMMA: feature = DC1394_FEATURE_GAMMA; break;
3513  case vpFEATURE_SHUTTER: feature = DC1394_FEATURE_SHUTTER; break;
3514  case vpFEATURE_GAIN: feature = DC1394_FEATURE_GAIN; break;
3515  case vpFEATURE_IRIS: feature = DC1394_FEATURE_IRIS; break;
3516 // vpFEATURE_FOCUS = DC1394_FEATURE_FOCUS,
3517 // vpFEATURE_TEMPERATURE = DC1394_FEATURE_TEMPERATURE,
3518 // vpFEATURE_TRIGGER = DC1394_FEATURE_TRIGGER,
3519 // vpFEATURE_TRIGGER_DELAY = DC1394_FEATURE_TRIGGER_DELAY,
3520 // vpFEATURE_WHITE_SHADING = DC1394_FEATURE_WHITE_SHADING,
3521 // vpFEATURE_FRAME_RATE = DC1394_FEATURE_FRAME_RATE,
3522 // vpFEATURE_ZOOM = DC1394_FEATURE_ZOOM,
3523 // vpFEATURE_PAN = DC1394_FEATURE_PAN,
3524 // vpFEATURE_TILT = DC1394_FEATURE_TILT,
3525 // vpFEATURE_OPTICAL_FILTER = DC1394_FEATURE_OPTICAL_FILTER,
3526 // vpFEATURE_CAPTURE_SIZE = DC1394_FEATURE_CAPTURE_SIZE,
3527 // vpFEATURE_CAPTURE_QUALITY = DC1394_FEATURE_CAPTURE_QUALITY
3528  }
3529 
3530  dc1394error_t err;
3531  dc1394bool_t hasManualMode = DC1394_FALSE;
3532  dc1394feature_modes_t modesAvailable;
3533 
3534  // test wether we can set the shutter value (manual mode available or not)
3535  err = dc1394_feature_get_modes(camera, feature, &modesAvailable);
3536  if (err != DC1394_SUCCESS) {
3537  vpERROR_TRACE("Unable to detect the manual mode information");
3538  close();
3540  "Unable to detect the manual mode information"));
3541  }
3542 
3543  for(unsigned int i=0; i<modesAvailable.num; i++){
3544  if(modesAvailable.modes[i] == DC1394_FEATURE_MODE_MANUAL){
3545  hasManualMode = DC1394_TRUE;
3546  }
3547  }
3548 
3549  if(hasManualMode == DC1394_TRUE){
3550 
3551  if(!isDataModified[camera_id]){// to ensure we save the first mode even after several set
3552  /* we update the structure */
3553  updateDataCamToStruct();
3554  err = dc1394_feature_get_mode(camera, feature, &(initialShutterMode[camera_id]));
3555  if (err != DC1394_SUCCESS) {
3556  vpERROR_TRACE("Unable to get the initial mode");
3557  close();
3559  "Unable to get the initial mode"));
3560  }
3561  isDataModified[camera_id] = true;
3562  }
3563 
3564  dc1394feature_mode_t manualMode = DC1394_FEATURE_MODE_MANUAL;
3565  err = dc1394_feature_set_mode(camera, feature, manualMode);
3566  if (err != DC1394_SUCCESS) {
3567  vpERROR_TRACE("Unable to set the muanual mode");
3568  close();
3570  "Unable to set the manual mode") );
3571  }
3572  err = dc1394_feature_set_value(camera, feature, value);
3573  if (err != DC1394_SUCCESS) {
3574  vpERROR_TRACE("Unable to set the shutter information");
3575  close();
3577  "Unable to set the shutter information") );
3578  }
3579  }
3580  else{
3581  vpERROR_TRACE("The camera does not have a manual mode.\nCannot change the value");
3583  "The camera does not have a manual mode"));
3584  }
3585 }
3593 void
3595 {
3596  if (! num_cameras) {
3597  close();
3598  vpERROR_TRACE("No camera found");
3600  "No camera found") );
3601  }
3602 
3603  guid = camera->guid;
3604 }
3605 
3613 uint64_t
3615 {
3616  if (! num_cameras) {
3617  close();
3618  vpERROR_TRACE("No camera found");
3620  "No camera found") );
3621  }
3622 
3623  return camera->guid;
3624 }
3625 
3626 
3631 inline void
3632 vp1394TwoGrabber::updateDataCamToStruct()
3633 {
3634  dataCam[camera_id].brightness = getParameterValue(vpFEATURE_BRIGHTNESS);
3635  dataCam[camera_id].exposure = getParameterValue(vpFEATURE_EXPOSURE);
3636  dataCam[camera_id].sharpness = getParameterValue(vpFEATURE_SHARPNESS);
3637  dataCam[camera_id].hue = getParameterValue(vpFEATURE_HUE);
3638  dataCam[camera_id].saturation = getParameterValue(vpFEATURE_SATURATION);
3639  dataCam[camera_id].gamma = getParameterValue(vpFEATURE_GAMMA);
3640  dataCam[camera_id].shutter = getParameterValue(vpFEATURE_SHUTTER);
3641  dataCam[camera_id].gain = getParameterValue(vpFEATURE_GAIN);
3642  dataCam[camera_id].iris = getParameterValue(vpFEATURE_IRIS);
3643 }
3644 
3649 inline void
3650 vp1394TwoGrabber::updateDataStructToCam()
3651 {
3652  setParameterValue(vpFEATURE_BRIGHTNESS, dataCam[camera_id].brightness);
3653  setParameterValue(vpFEATURE_EXPOSURE, dataCam[camera_id].exposure);
3654  setParameterValue(vpFEATURE_SHARPNESS, dataCam[camera_id].sharpness);
3655  setParameterValue(vpFEATURE_HUE, dataCam[camera_id].hue);
3656  setParameterValue(vpFEATURE_SATURATION, dataCam[camera_id].saturation);
3657  setParameterValue(vpFEATURE_GAMMA, dataCam[camera_id].gamma);
3658  setParameterValue(vpFEATURE_SHUTTER, dataCam[camera_id].shutter);
3659  setParameterValue(vpFEATURE_GAIN, dataCam[camera_id].gain);
3660  setParameterValue(vpFEATURE_IRIS, dataCam[camera_id].iris);
3661 }
3662 
3663 #elif !defined(VISP_BUILD_SHARED_LIBS)
3664 // Work arround to avoid warning: libvisp_sensor.a(vp1394TwoGrabber.cpp.o) has no symbols
3665 void dummy_vp1394TwoGrabber() {};
3666 #endif
3667 
void getColorCoding(vp1394TwoColorCodingType &coding)
static const char * strFramerate[DC1394_FRAMERATE_NUM]
VISP_EXPORT int wait(double t0, double t)
Definition: vpTime.cpp:150
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:161
#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:116
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)
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)
set the size of the image without initializing it.
Definition: vpImage.h:616
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:152
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)