ViSP  2.10.0
vp1394TwoGrabber.cpp
1 /****************************************************************************
2  *
3  * $Id: vp1394TwoGrabber.cpp 4728 2014-04-23 12:26:44Z 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 == cam_id) {
341  this->camera_id = i;
342  is_guid = true;
343  break;
344  }
345  }
346  if (is_guid == false) {
347  std::cout << "Error: The camera with guid 0x" << std::hex << cam_id << " is not present" << std::endl;
348  std::cout << num_cameras << " camera(s) connected" << std::endl;
349  for (unsigned int i=0; i< num_cameras; i++) {
350  std::cout << " - camera " << i << " with guid 0x" << std::hex << cameras[i]->guid << std::endl;
351  }
352  close();
354  "The required camera is not present") );
355  }
356  }
357  else {
358  this->camera_id = (unsigned int) cam_id; // The input cam_id is not a uint64_t guid, but the index of the camera
359  }
360 
361  // create a pointer to the working camera
362  camera = cameras[this->camera_id];
363 }
364 
365 
380 void
382 {
383  if (num_cameras) {
384  cam_id = this->camera_id;
385  }
386  else {
387  close();
388  vpERROR_TRACE("No cameras found");
390  "No cameras found") );
391  }
392 }
393 
408 uint64_t
410 {
411  if (num_cameras) {
412  return this->camera_id;
413  }
414  else {
415  close();
416  vpERROR_TRACE("No cameras found");
418  "No cameras found") );
419  }
420 }
421 
429 void
430 vp1394TwoGrabber::getNumCameras(unsigned int &ncameras) const
431 {
432  if (! num_cameras) {
433  vpCTRACE << "No camera found..."<< std::endl;
434  ncameras = 0;
435  }
436 
437  ncameras = num_cameras;
438 }
439 
447 unsigned int
449 {
450  unsigned int ncameras = 0;
451  if (! num_cameras) {
452  vpCTRACE << "No camera found..."<< std::endl;
453  ncameras = 0;
454  }
455 
456  ncameras = num_cameras;
457  return ncameras;
458 }
459 
505 void
507 {
508  open();
509  if (! num_cameras) {
510  close();
511  vpERROR_TRACE("No camera found");
513  "No camera found") );
514  }
515  if (!isVideoModeSupported(videomode)){
516  vpERROR_TRACE("Video mode not supported by camera %d",camera_id);
518  "Video mode not supported") );
519  return ;
520  }
521  // Stop dma capture if started
522  setTransmission(DC1394_OFF);
523  setCapture(DC1394_OFF);
524 
525  if (dc1394_video_set_mode(camera, (dc1394video_mode_t) videomode) != DC1394_SUCCESS) {
526 
527  close();
528  vpERROR_TRACE("Can't set video mode");
530  "Can't set video mode") );
531  }
532 
533  setCapture(DC1394_ON);
534  setTransmission(DC1394_ON);
535 
536  // Updates image size from new video mode
537  if (dc1394_get_image_size_from_video_mode(camera,
538  (dc1394video_mode_t) videomode,
539  &this->width, &this->height)
540  != DC1394_SUCCESS) {
541 
542  close();
543  vpERROR_TRACE("Can't set video mode");
545  "Can't get image size") );
546  }
547 
548 }
549 
566 void
568 {
569  if (! num_cameras) {
570  close();
571  vpERROR_TRACE("No camera found");
573  "No camera found") );
574  }
575 
576  dc1394video_mode_t _videomode;
577  if (dc1394_video_get_mode(camera, &_videomode) != DC1394_SUCCESS) {
578 
579  close();
580  vpERROR_TRACE("Can't get current video mode");
582  "Can't get current video mode") );
583  }
584  videomode = (vp1394TwoVideoModeType) _videomode;
585 
586 }
587 
588 
589 
607 uint32_t
608 vp1394TwoGrabber::getVideoModeSupported(std::list<vp1394TwoVideoModeType> & videomodes)
609 {
610  // Refresh the list of supported modes
611  videomodes.clear();
612 
613  if (! num_cameras) {
614  close();
615  vpERROR_TRACE("No camera found");
617  "No camera found") );
618  }
619  dc1394video_modes_t _videomodes;
620 
621  // get video modes:
622  if (dc1394_video_get_supported_modes(camera, &_videomodes)!=DC1394_SUCCESS) {
623 
624  close();
625  vpERROR_TRACE("Can't get video modes");
627  "Can't get video modes") );
628  }
629 
630  // parse the video modes to add in the list
631  for (unsigned i=0; i < _videomodes.num; i++) {
632  vp1394TwoVideoModeType _mode = (vp1394TwoVideoModeType) _videomodes.modes[i];
633  videomodes.push_back( _mode );
634  }
635 
636  // return the number of available video modes
637  return _videomodes.num;
638 }
654 bool
656 {
657  if (! num_cameras) {
658  close();
659  vpERROR_TRACE("No camera found");
661  "No camera found") );
662  }
663  dc1394video_modes_t _videomodes;
664 
665  // get video modes:
666  if (dc1394_video_get_supported_modes(camera, &_videomodes)!=DC1394_SUCCESS) {
667 
668  close();
669  vpERROR_TRACE("Can't get video modes");
671  "Can't get video modes") );
672  }
673 
674  // parse the video modes to check with the desired
675  for (unsigned i=0; i < _videomodes.num; i++) {
676  if ((vp1394TwoVideoModeType) _videomodes.modes[i] == videomode)
677  return true;
678  }
679  return false;
680 }
681 
694 bool
696 {
697 
698  if (dc1394_is_video_mode_scalable((dc1394video_mode_t) videomode))
699  return true;
700 
701  return false;
702 }
703 
719 bool
721 {
723  getColorCoding(coding);
724 
725  switch (coding) {
729  case vpCOLOR_CODING_RAW8:
731  return false;
735  case vpCOLOR_CODING_RGB8:
738  return true;
739  }
740  return false;
741 }
742 
767 void
769 {
770  open();
771  if (! num_cameras) {
772  close();
773  vpERROR_TRACE("No camera found");
775  "No camera found") );
776  }
777 
778  vp1394TwoVideoModeType cur_videomode;
779  getVideoMode(cur_videomode);
780  if (isVideoModeFormat7(cur_videomode))
781  return;
782 
783  if (!isFramerateSupported(cur_videomode,fps)){
784  vpERROR_TRACE("Framerate not supported by camera %d",camera_id);
786  "Framerate not supported") );
787  return ;
788  }
789 
790  // Stop dma capture if started
791  setTransmission(DC1394_OFF);
792  setCapture(DC1394_OFF);
793 
794  if (dc1394_video_set_framerate(camera, (dc1394framerate_t) fps) != DC1394_SUCCESS) {
795 
796  close();
797  vpERROR_TRACE("Can't set framerate");
799  "Can't set framerate") );
800  }
801 
802  setCapture(DC1394_ON);
803  setTransmission(DC1394_ON);
804 }
805 
822 void
824 {
825  if (! num_cameras) {
826  close();
827  vpERROR_TRACE("No camera found");
829  "No camera found") );
830  }
831  dc1394framerate_t _fps;
832  if (dc1394_video_get_framerate(camera, &_fps) != DC1394_SUCCESS) {
833 
834  close();
835  vpERROR_TRACE("Can't get current framerate");
837  "Can't get current framerate") );
838  }
839  fps = (vp1394TwoFramerateType) _fps;
840 
841 }
842 
874 uint32_t
876  std::list<vp1394TwoFramerateType> & fps)
877 {
878  if (! num_cameras) {
879  close();
880  vpERROR_TRACE("No camera found");
882  "No camera found") );
883  }
884 
885  // Refresh the list of supported framerates
886  fps.clear();
887 
888  switch (mode) {
889  // Framerate not available for:
890  // - vpVIDEO_MODE_EXIF ie Format_6
891  // - vpVIDEO_MODE_FORMAT7... ie the Format_7
892  case vpVIDEO_MODE_EXIF:
901  return 0;
902  break;
903  default:
904  {
905  dc1394framerates_t _fps;
906  if (dc1394_video_get_supported_framerates(camera,
907  (dc1394video_mode_t)mode,
908  &_fps) != DC1394_SUCCESS) {
909  close();
910  vpERROR_TRACE("Could not query supported frametates for mode %d\n",
911  mode);
913  "Could not query supported framerates") );
914  }
915  if (_fps.num == 0)
916  return 0;
917 
918  for (unsigned int i = 0; i < _fps.num; i ++)
919  fps.push_back((vp1394TwoFramerateType)_fps.framerates[i]);
920 
921  return _fps.num;
922  }
923  break;
924  }
925 }
959 bool
962 {
963  if (! num_cameras) {
964  close();
965  vpERROR_TRACE("No camera found");
967  "No camera found") );
968  }
969 
970  switch (mode) {
971  // Framerate not available for:
972  // - vpVIDEO_MODE_EXIF ie Format_6
973  // - vpVIDEO_MODE_FORMAT7... ie the Format_7
974  case vpVIDEO_MODE_EXIF:
983  return 0;
984  break;
985  default:
986  {
987  dc1394framerates_t _fps;
988  if (dc1394_video_get_supported_framerates(camera,
989  (dc1394video_mode_t)mode,
990  &_fps) != DC1394_SUCCESS) {
991  close();
992  vpERROR_TRACE("Could not query supported frametates for mode %d\n",
993  mode);
995  "Could not query supported framerates") );
996  }
997  if (_fps.num == 0)
998  return 0;
999 
1000  for (unsigned int i = 0; i < _fps.num; i ++){
1001  if (fps==(vp1394TwoFramerateType)_fps.framerates[i]){
1002  return true;
1003  }
1004  }
1005  return false;
1006  }
1007  break;
1008  }
1009 }
1010 
1059 void
1061 {
1062  if (! num_cameras) {
1063  close();
1064  vpERROR_TRACE("No camera found");
1066  "No camera found") );
1067  }
1068 
1069  dc1394video_mode_t _videomode;
1070  if (dc1394_video_get_mode(camera, &_videomode) != DC1394_SUCCESS) {
1071 
1072  close();
1073  vpERROR_TRACE("Can't get current video mode");
1075  "Can't get current video mode") );
1076  }
1077 
1078  if (!isColorCodingSupported((vp1394TwoVideoModeType)_videomode,coding)){
1079  vpERROR_TRACE("Color coding not supported by camera %d",camera_id);
1081  "Color coding not supported") );
1082  return ;
1083  }
1084 
1085  // Format 7 video mode
1086  if (dc1394_is_video_mode_scalable(_videomode)) {
1087  setTransmission(DC1394_OFF);
1088  setCapture(DC1394_OFF);
1089 
1090  if (dc1394_format7_set_color_coding(camera, _videomode,
1091  (dc1394color_coding_t) coding)
1092  != DC1394_SUCCESS) {
1093 
1094  close();
1095  vpERROR_TRACE("Can't set color coding");
1097  "Can't set color coding") );
1098  }
1099 
1100  setCapture(DC1394_ON);
1101  setTransmission(DC1394_ON);
1102  }
1103 }
1104 
1122 void
1124 {
1125  if (! num_cameras) {
1126  close();
1127  vpERROR_TRACE("No camera found");
1129  "No camera found") );
1130  }
1131  dc1394video_mode_t _videomode;
1132  if (dc1394_video_get_mode(camera, &_videomode) != DC1394_SUCCESS) {
1133 
1134  close();
1135  vpERROR_TRACE("Can't get current video mode");
1137  "Can't get current video mode") );
1138  }
1139 
1140  dc1394color_coding_t _coding;
1141  if (dc1394_is_video_mode_scalable(_videomode)) {
1142  // Format 7 video mode
1143  if (dc1394_format7_get_color_coding(camera, _videomode, &_coding)
1144  != DC1394_SUCCESS) {
1145 
1146  close();
1147  vpERROR_TRACE("Can't get current color coding");
1149  "Can't query current color coding") );
1150  }
1151  }
1152  else if (dc1394_is_video_mode_still_image((dc1394video_mode_t)_videomode)) {
1154  "No color coding for format 6 video mode"));
1155  }
1156  else {
1157  // Not Format 7 and not Format 6 video modes
1158  if (dc1394_get_color_coding_from_video_mode(camera,
1159  (dc1394video_mode_t)_videomode,
1160  &_coding) != DC1394_SUCCESS) {
1161  close();
1162  vpERROR_TRACE("Could not query supported color coding for mode %d\n",
1163  _videomode);
1165  "Can't query current color coding"));
1166  }
1167  }
1168  coding = (vp1394TwoColorCodingType) _coding;
1169 }
1170 
1192 uint32_t
1194  std::list<vp1394TwoColorCodingType> & codings)
1195 {
1196  if (! num_cameras) {
1197  close();
1198  vpERROR_TRACE("No camera found");
1200  "No camera found") );
1201  }
1202 
1203  // Refresh the list of supported framerates
1204  codings.clear();
1205 
1206  if (dc1394_is_video_mode_scalable((dc1394video_mode_t)mode)) {
1207  // Format 7 video mode
1208  dc1394color_codings_t _codings;
1209  if (dc1394_format7_get_color_codings(camera,
1210  (dc1394video_mode_t)mode,
1211  &_codings) != DC1394_SUCCESS) {
1212  close();
1213  vpERROR_TRACE("Could not query supported color codings for mode %d\n",
1214  mode);
1216  "Could not query supported color codings") );
1217  }
1218  if (_codings.num == 0)
1219  return 0;
1220 
1221  for (unsigned int i = 0; i < _codings.num; i ++)
1222  codings.push_back((vp1394TwoColorCodingType)_codings.codings[i]);
1223 
1224  return _codings.num;
1225  }
1226  else if (dc1394_is_video_mode_still_image((dc1394video_mode_t)mode)) {
1227  // Format 6 video mode
1228  return 0;
1229  }
1230  else {
1231  // Not Format 7 and not Format 6 video modes
1232  dc1394color_coding_t _coding;
1233  if (dc1394_get_color_coding_from_video_mode(camera,
1234  (dc1394video_mode_t)mode,
1235  &_coding) != DC1394_SUCCESS) {
1236  close();
1237  vpERROR_TRACE("Could not query supported color coding for mode %d\n",
1238  mode);
1240  "Could not query supported color coding") );
1241  }
1242  codings.push_back((vp1394TwoColorCodingType)_coding);
1243  return 1;
1244  }
1245 }
1267 bool
1269  vp1394TwoColorCodingType coding)
1270 {
1271  if (! num_cameras) {
1272  close();
1273  vpERROR_TRACE("No camera found");
1275  "No camera found") );
1276  }
1277 
1278 
1279  if (dc1394_is_video_mode_scalable((dc1394video_mode_t)mode)) {
1280  // Format 7 video mode
1281  dc1394color_codings_t _codings;
1282  if (dc1394_format7_get_color_codings(camera,
1283  (dc1394video_mode_t)mode,
1284  &_codings) != DC1394_SUCCESS) {
1285  close();
1286  vpERROR_TRACE("Could not query supported color codings for mode %d\n",
1287  mode);
1289  "Could not query supported color codings") );
1290  }
1291  if (_codings.num == 0)
1292  return 0;
1293 
1294  for (unsigned int i = 0; i < _codings.num; i ++){
1295  if (coding==(vp1394TwoColorCodingType)_codings.codings[i])
1296  return true;
1297  }
1298  return false;
1299  }
1300  else if (dc1394_is_video_mode_still_image((dc1394video_mode_t)mode)) {
1301  // Format 6 video mode
1302  return false;
1303  }
1304  else {
1305  // Not Format 7 and not Format 6 video modes
1306  dc1394color_coding_t _coding;
1307  if (dc1394_get_color_coding_from_video_mode(camera,
1308  (dc1394video_mode_t)mode,
1309  &_coding) != DC1394_SUCCESS) {
1310  close();
1311  vpERROR_TRACE("Could not query supported color coding for mode %d\n",
1312  mode);
1314  "Could not query supported color coding") );
1315  return false;
1316  }
1317  if (coding==(vp1394TwoColorCodingType)_coding)
1318  return true;
1319 
1320  return false;
1321  }
1322 }
1323 
1324 
1356 void
1357 vp1394TwoGrabber::setFormat7ROI(unsigned int left, unsigned int top,
1358  unsigned int w, unsigned int h)
1359 {
1360  open();
1361  if (! num_cameras) {
1362  close();
1363  vpERROR_TRACE("No camera found");
1365  "No camera found") );
1366  }
1367 
1368  dc1394video_mode_t _videomode;
1369  if (dc1394_video_get_mode(camera, &_videomode) != DC1394_SUCCESS) {
1370 
1371  close();
1372  vpERROR_TRACE("Can't get current video mode");
1374  "Can't get current video mode") );
1375  }
1376  if (dc1394_is_video_mode_scalable(_videomode)) {
1377  // Stop dma capture if started
1378  setTransmission(DC1394_OFF);
1379  setCapture(DC1394_OFF);
1380  // Format 7 video mode
1381  unsigned int max_width, max_height;
1382  if (dc1394_format7_get_max_image_size(camera, _videomode,
1383  &max_width, &max_height)
1384  != DC1394_SUCCESS) {
1385 
1386  close();
1387  vpERROR_TRACE("Can't get format7 max image size");
1389  "Can't get format7 max image size") );
1390  }
1391 #if 0
1392  vpTRACE("left: %d top: %d width: %d height: %d", left, top,
1393  width == 0 ? DC1394_USE_MAX_AVAIL: w,
1394  height == 0 ? DC1394_USE_MAX_AVAIL : h);
1395  vpTRACE("max_width: %d max_height: %d", max_width, max_height);
1396 #endif
1397 
1398  if (left > max_width) {
1399  vpERROR_TRACE("Can't set format7 ROI");
1401  "Can't set format7 ROI") );
1402  }
1403  if (top > max_height) {
1404  vpERROR_TRACE("Can't set format7 ROI");
1406  "Can't set format7 ROI") );
1407  }
1408 
1409  int32_t roi_width;
1410  int32_t roi_height;
1411 
1412  if (w != 0) {
1413  // Check if roi width is acceptable (ie roi is contained in the image)
1414  if (w > (max_width - left))
1415  w = (max_width - left);
1416  roi_width = (int32_t)w;
1417  }
1418  else {
1419  roi_width = DC1394_USE_MAX_AVAIL;
1420  }
1421 
1422  if (h != 0) {
1423  // Check if roi height is acceptable (ie roi is contained in the image)
1424  if (h > (max_height - top))
1425  h = (max_height - top);
1426  roi_height = (int32_t)h;
1427  }
1428  else {
1429  roi_height = DC1394_USE_MAX_AVAIL;
1430  }
1431 
1432  if (dc1394_format7_set_roi(camera, _videomode,
1433  (dc1394color_coding_t) DC1394_QUERY_FROM_CAMERA, // color_coding
1434  DC1394_USE_MAX_AVAIL/*DC1394_QUERY_FROM_CAMERA*/, // bytes_per_packet
1435  (int32_t)left, // left
1436  (int32_t)top, // top
1437  roi_width,
1438  roi_height)
1439  != DC1394_SUCCESS) {
1440  close();
1441  vpERROR_TRACE("Can't set format7 roi");
1443  "Can't get current video mode") );
1444  }
1445  // Update the image size
1446  if (dc1394_format7_get_image_size(camera, _videomode,
1447  &this->width,
1448  &this->height)
1449  != DC1394_SUCCESS) {
1450  close();
1451  vpERROR_TRACE("Can't get format7 image size");
1453  "Can't get format7 image size") );
1454  }
1455 
1456  setCapture(DC1394_ON);
1457  setTransmission(DC1394_ON);
1458  }
1459 }
1474 void
1475 vp1394TwoGrabber::initialize(bool reset)
1476 {
1477  if (init == false){
1478  // Find cameras
1479 #ifdef VISP_HAVE_DC1394_2_CAMERA_ENUMERATE // new API > libdc1394-2.0.0-rc7
1480  if (d != NULL)
1481  dc1394_free (d);
1482 
1483  d = dc1394_new ();
1484  if (dc1394_camera_enumerate (d, &list) != DC1394_SUCCESS) {
1485  dc1394_camera_free_list (list);
1486  close();
1487  vpERROR_TRACE("Failed to enumerate cameras\n");
1489  "Failed to enumerate cameras") );
1490  }
1491 
1492  if (list->num == 0) {
1493  dc1394_camera_free_list (list);
1494  close();
1495  vpERROR_TRACE("No cameras found");
1497  "No cameras found") );
1498  }
1499 
1500  if (cameras != NULL)
1501  delete [] cameras;
1502 
1503  cameras = new dc1394camera_t * [list->num];
1504 
1505  num_cameras = 0;
1506 
1507  for (unsigned int i=0; i < list->num; i ++) {
1508  cameras[i] = dc1394_camera_new (d, list->ids[i].guid);
1509  if (!cameras[i]) {
1510  vpTRACE ("Failed to initialize camera with guid \"%ld\"\n",
1511  list->ids[i].guid);
1512  continue;
1513  }
1514  // Update the number of working cameras
1515  num_cameras ++;
1516  }
1517 
1518  if (reset) {
1519  // Reset the bus to make firewire working if the program was not properly
1520  // stopped by a CTRL-C. We reset here only the bus attached to the first
1521  // camera
1522  dc1394_reset_bus(cameras[0]);
1523  }
1524 
1525  // if (list != NULL)
1526  dc1394_camera_free_list (list);
1527  list = NULL;
1528 
1529 #elif defined VISP_HAVE_DC1394_2_FIND_CAMERAS // old API <= libdc1394-2.0.0-rc7
1530  if (cameras != NULL)
1531  free(cameras);
1532  cameras = NULL;
1533  int err = dc1394_find_cameras(&cameras, &num_cameras);
1534 
1535  if (err!=DC1394_SUCCESS && err != DC1394_NO_CAMERA) {
1536  close();
1537  vpERROR_TRACE("Unable to look for cameras\n\n"
1538  "Please check \n"
1539  " - if the kernel modules `ieee1394',`raw1394' and `ohci1394' are loaded \n"
1540  " - if you have read/write access to /dev/raw1394\n\n");
1542  "Unable to look for cameras") );
1543 
1544  }
1545 #endif
1546 
1547  if (num_cameras == 0) {
1548  close();
1549  vpERROR_TRACE("No cameras found");
1551  "No cameras found") );
1552  }
1553 
1554  // allocation for the parameters
1555  isDataModified = new bool[num_cameras];
1556  for(unsigned int i=0; i<num_cameras; i++)
1557  isDataModified[i] = false;
1558  initialShutterMode = new dc1394feature_mode_t[num_cameras];
1559  dataCam = new vpDc1394TwoCameraParametersData[num_cameras];
1560 
1561  if (camera_id >= num_cameras) {
1562  // Bad camera id
1563  close();
1564  vpERROR_TRACE("Bad camera id: %u", camera_id);
1565  vpERROR_TRACE("Only %u camera on the bus.", num_cameras);
1567  "Bad camera id") );
1568  }
1569 
1570  if (verbose) {
1571  std::cout << "------ Bus information ------" << std::endl;
1572  std::cout << "Number of camera(s) on the bus : " << num_cameras <<std::endl;
1573  std::cout << "-----------------------------" << std::endl;
1574  }
1575 
1576  if (camIsOpen != NULL) delete [] camIsOpen;
1577  camIsOpen = new bool [num_cameras];
1578  for (unsigned int i = 0;i<num_cameras;i++){
1579  camIsOpen[i]=false;
1580  }
1581 
1582  init = true;
1583  }
1584 }
1594 void
1596 {
1597  if (init == false) initialize(false);
1598  if (camIsOpen[camera_id] == false){
1599  dc1394switch_t status = DC1394_OFF;
1600 
1601  //#ifdef VISP_HAVE_DC1394_2_CAMERA_ENUMERATE // new API > libdc1394-2.0.0-rc7
1602  dc1394_video_get_transmission(cameras[camera_id], &status);
1603  if (status != DC1394_OFF){
1604  //#endif
1605  if (dc1394_video_set_transmission(cameras[camera_id],DC1394_OFF)!=DC1394_SUCCESS)
1606  vpTRACE("Could not stop ISO transmission");
1607  else {
1608  vpTime::wait(500);
1609  if (dc1394_video_get_transmission(cameras[camera_id], &status)!=DC1394_SUCCESS)
1610  vpTRACE("Could get ISO status");
1611  else {
1612  if (status==DC1394_ON) {
1613  vpTRACE("ISO transmission refuses to stop");
1614  }
1615 #ifdef VISP_HAVE_DC1394_2_FIND_CAMERAS // old API <= libdc1394-2.0.0-rc7
1616  // No yet in the new API
1617  cameras[camera_id]->is_iso_on=status;
1618 #endif
1619  }
1620  //#ifdef VISP_HAVE_DC1394_2_CAMERA_ENUMERATE // new API > libdc1394-2.0.0-rc7
1621  }
1622  //#endif
1623  }
1624  setCamera(camera_id);
1625  //setIsoSpeed(DC1394_ISO_SPEED_400);
1626  setCapture(DC1394_ON);
1627  setTransmission(DC1394_ON);
1628  camIsOpen[camera_id] = true;
1629  }
1630 }
1639 void
1641 {
1642  if (init){
1643  if (num_cameras) {
1644  for (unsigned int i = 0; i < num_cameras;i++) {
1645  if (camIsOpen[i]) {
1646  camera = cameras[i];
1647  this->camera_id = i;// set camera id for the function updateDataStructToCam
1648  setTransmission(DC1394_OFF);
1649  setCapture(DC1394_OFF);
1650  if(isDataModified[i]){
1651  // reset values
1652  try{
1653  updateDataStructToCam();
1654  }
1655  catch(...){
1656  }
1657  // reset mode (manual, auto, ...)
1658  if (dc1394_feature_set_mode(camera, DC1394_FEATURE_BRIGHTNESS, initialShutterMode[i]) != DC1394_SUCCESS ||
1659  dc1394_feature_set_mode(camera, DC1394_FEATURE_EXPOSURE, initialShutterMode[i]) != DC1394_SUCCESS ||
1660  dc1394_feature_set_mode(camera, DC1394_FEATURE_SHARPNESS, initialShutterMode[i]) != DC1394_SUCCESS ||
1661  dc1394_feature_set_mode(camera, DC1394_FEATURE_HUE, initialShutterMode[i]) != DC1394_SUCCESS ||
1662  dc1394_feature_set_mode(camera, DC1394_FEATURE_SATURATION, initialShutterMode[i]) != DC1394_SUCCESS ||
1663  dc1394_feature_set_mode(camera, DC1394_FEATURE_GAMMA, initialShutterMode[i]) != DC1394_SUCCESS ||
1664  dc1394_feature_set_mode(camera, DC1394_FEATURE_SHUTTER, initialShutterMode[i]) != DC1394_SUCCESS ||
1665  dc1394_feature_set_mode(camera, DC1394_FEATURE_GAIN, initialShutterMode[i]) != DC1394_SUCCESS ||
1666  dc1394_feature_set_mode(camera, DC1394_FEATURE_IRIS, initialShutterMode[i])){
1667 
1668  vpERROR_TRACE("Unable to reset the initial mode");
1670  "Unable to reset the initial mode"));
1671  }
1672  }
1673  if (dc1394_camera_set_power(camera, DC1394_OFF) != DC1394_SUCCESS)
1674  std::cout << "Unable to turn camera off" << std::endl;
1675  }
1676 #ifdef VISP_HAVE_DC1394_2_CAMERA_ENUMERATE // new API > libdc1394-2.0.0-rc7
1677  dc1394_camera_free(cameras[i]);
1678 #elif defined VISP_HAVE_DC1394_2_FIND_CAMERAS // old API <= libdc1394-2.0.0-rc7
1679  dc1394_free_camera(cameras[i]);
1680 #endif
1681  }
1682  }
1683  if (camIsOpen != NULL) {
1684  delete [] camIsOpen;
1685  camIsOpen = NULL;
1686  }
1687 
1688 #ifdef VISP_HAVE_DC1394_2_CAMERA_ENUMERATE // new API > libdc1394-2.0.0-rc7
1689  if (cameras != NULL) {
1690  delete [] cameras;
1691  cameras = NULL;
1692  }
1693  if (d != NULL) {
1694  dc1394_free (d);
1695  d = NULL;
1696  }
1697 
1698 #elif defined VISP_HAVE_DC1394_2_FIND_CAMERAS // old API <= libdc1394-2.0.0-rc7
1699  if (cameras != NULL) {
1700  free(cameras);
1701  cameras = NULL;
1702  }
1703 #endif
1704 
1705  camIsOpen = NULL;
1706  num_cameras = 0;
1707 
1708  // remove data for the parameters
1709  if(isDataModified != NULL){
1710  delete[] isDataModified;
1711  isDataModified = NULL;
1712  }
1713  if(initialShutterMode != NULL){
1714  delete[] initialShutterMode;
1715  initialShutterMode = NULL;
1716  }
1717  if(dataCam != NULL){
1718  delete[] dataCam;
1719  dataCam = NULL;
1720  }
1721 
1722  init = false;
1723  }
1724 }
1725 
1737 void
1739 {
1740  if (size < 1) {
1741  close();
1743  "Could not set ring buffer size") );
1744  }
1745 
1746  if (size != num_buffers) {
1747  // We need to change the ring buffer size
1748  num_buffers = size;
1749  if(camIsOpen[camera_id]){
1750  setCapture(DC1394_OFF);
1751  setCapture(DC1394_ON);
1752  }
1753  }
1754 }
1755 
1765 unsigned int
1767 {
1768  return num_buffers;
1769 }
1770 
1810 void
1812 {
1813  if (! num_cameras) {
1814  close();
1815  vpERROR_TRACE("No camera found");
1817  "No camera found") );
1818  }
1819 
1820  dc1394feature_mode_t mode;
1821  if (enable) {
1822  mode = DC1394_FEATURE_MODE_AUTO;
1823  }
1824  else {
1825  mode = DC1394_FEATURE_MODE_MANUAL;
1826  }
1827 
1828  if (dc1394_feature_set_power(camera, DC1394_FEATURE_SHUTTER, DC1394_ON)
1829  != DC1394_SUCCESS) {
1830  // vpERROR_TRACE("Cannot set shutter on. \n");
1831  close();
1833  "Cannot set shutter on") );
1834  }
1835 
1836  if (dc1394_feature_set_mode(camera,
1837  DC1394_FEATURE_SHUTTER,
1838  mode)
1839  != DC1394_SUCCESS) {
1840  // vpERROR_TRACE("Cannot set auto shutter. \n");
1841  close();
1843  "Cannot set auto shutter") );
1844  }
1845 }
1886 void
1887 vp1394TwoGrabber::setAutoShutter(unsigned int minvalue, unsigned int maxvalue)
1888 {
1889  setAutoShutter();
1890 
1891  if (dc1394_avt_set_auto_shutter(camera, minvalue, maxvalue)
1892  != DC1394_SUCCESS) {
1893  // vpERROR_TRACE("Cannot set auto shutter min and max values. Is the camera an AVT one?\n");
1894  close();
1896  "Cannot set auto shutter min and max values") );
1897  }
1898 }
1899 
1912 void
1913 vp1394TwoGrabber::getAutoShutter(unsigned int &minvalue, unsigned int &maxvalue)
1914 {
1915  if (! num_cameras) {
1916  close();
1917  vpERROR_TRACE("No camera found");
1919  "No camera found") );
1920  }
1921 
1922  if (dc1394_avt_get_auto_shutter(camera, &minvalue, &maxvalue)
1923  != DC1394_SUCCESS) {
1924  // vpERROR_TRACE("Cannot get auto shutter min and max values. Is the camera an AVT one?\n");
1925  close();
1927  "Cannot get auto shutter min and max values") );
1928  }
1929 }
1930 
1970 void
1972 {
1973  if (! num_cameras) {
1974  close();
1975  vpERROR_TRACE("No camera found");
1977  "No camera found") );
1978  }
1979 
1980  dc1394feature_mode_t mode;
1981  if (enable) {
1982  mode = DC1394_FEATURE_MODE_AUTO;
1983  }
1984  else {
1985  mode = DC1394_FEATURE_MODE_MANUAL;
1986  }
1987 
1988  if (dc1394_feature_set_power(camera, DC1394_FEATURE_GAIN, DC1394_ON)
1989  != DC1394_SUCCESS) {
1990  // vpERROR_TRACE("Cannot set shutter on. \n");
1991  close();
1993  "Cannot set shutter on") );
1994  }
1995 
1996  if (dc1394_feature_set_mode(camera,
1997  DC1394_FEATURE_GAIN,
1998  mode)
1999  != DC1394_SUCCESS) {
2000  // vpERROR_TRACE("Cannot set auto gain. \n");
2001  close();
2003  "Cannot set auto gain") );
2004  }
2005 }
2046 void
2047 vp1394TwoGrabber::setAutoGain(unsigned int minvalue, unsigned int maxvalue)
2048 {
2049  setAutoGain();
2050 
2051  if (dc1394_avt_set_auto_gain(camera, minvalue, maxvalue)
2052  != DC1394_SUCCESS) {
2053  // vpERROR_TRACE("Cannot set auto gain min and max values. Is the camera an AVT one?\n");
2054  close();
2056  "Cannot set auto gain min and max values") );
2057  }
2058 }
2059 
2072 void
2073 vp1394TwoGrabber::getAutoGain(unsigned int &minvalue, unsigned int &maxvalue)
2074 {
2075  if (! num_cameras) {
2076  close();
2077  vpERROR_TRACE("No camera found");
2079  "No camera found") );
2080  }
2081 
2082  if (dc1394_avt_get_auto_gain(camera, &minvalue, &maxvalue)
2083  != DC1394_SUCCESS) {
2084  // vpERROR_TRACE("Cannot get auto gain min and max values. Is the camera an AVT one?\n");
2085  close();
2087  "Cannot get auto gain min and max values") );
2088  }
2089 }
2090 
2091 
2109 void
2110 vp1394TwoGrabber::setCapture(dc1394switch_t _switch)
2111 {
2112  if (! num_cameras) {
2113  close();
2114  vpERROR_TRACE("No camera found");
2116  "No camera found") );
2117  }
2118 
2119  if (_switch == DC1394_ON) {
2120  //if (dc1394_capture_setup(camera, num_buffers) != DC1394_SUCCESS) {
2121  // To be compatible with libdc1394 svn 382 version
2122  if (dc1394_capture_setup(camera, num_buffers,
2123  DC1394_CAPTURE_FLAGS_DEFAULT) != DC1394_SUCCESS) {
2124  vpERROR_TRACE("Unable to setup camera capture-\n"
2125  "make sure that the video mode and framerate are "
2126  "supported by your camera.\n");
2127  close();
2129  "Could not setup dma capture") );
2130  }
2131  }
2132  else { // _switch == DC1394_OFF
2133  dc1394error_t code = dc1394_capture_stop(camera);
2134 
2135  if (code != DC1394_SUCCESS && code != DC1394_CAPTURE_IS_NOT_SET) {
2136  vpERROR_TRACE("Unable to stop camera capture\n");
2137  close();
2139  "Could not setup dma capture") );
2140  }
2141  }
2142 }
2143 
2144 
2159 void
2160 vp1394TwoGrabber::setTransmission(dc1394switch_t _switch)
2161 {
2162  if (! num_cameras) {
2163  close();
2164  vpERROR_TRACE("No camera found");
2166  "No camera found") );
2167  }
2168 
2169  dc1394switch_t status = DC1394_OFF;
2170 
2171  if (dc1394_video_get_transmission(camera, &status)!=DC1394_SUCCESS) {
2172  vpERROR_TRACE("Unable to get transmision status");
2173  close();
2175  "Could not setup dma capture") );
2176  }
2177 
2178  // if (status!=_switch){
2179  // Start dma capture if halted
2180  if (dc1394_video_set_transmission(camera, _switch) != DC1394_SUCCESS) {
2181  vpERROR_TRACE("Unable to setup camera capture-\n"
2182  "make sure that the video mode and framerate are "
2183  "supported by your camera.\n");
2184  close();
2186  "Could not setup dma capture") );
2187  }
2188 
2189  if (_switch == DC1394_ON) {
2190  status = DC1394_OFF;
2191 
2192  int i = 0;
2193  while ( status == DC1394_OFF && i++ < 5 ) {
2194  usleep(50000);
2195  if (dc1394_video_get_transmission(camera, &status)!=DC1394_SUCCESS) {
2196  vpERROR_TRACE("Unable to get transmision status");
2197  close();
2199  "Could not setup dma capture") );
2200  }
2201  }
2202  }
2203  // }
2204 }
2205 
2240 void
2242 {
2243  if (! num_cameras) {
2244  close();
2245  vpERROR_TRACE("No camera found");
2247  "No camera found") );
2248  }
2249 
2250  dc1394operation_mode_t op_mode;
2251  dc1394speed_t speed;
2252 
2253  // Check the speed to configure in B-mode or A-mode
2254  if (isospeed >= vpISO_SPEED_800) {
2255  if (camera->bmode_capable != DC1394_TRUE) {
2256 // vpERROR_TRACE("Camera is not 1394B mode capable. \n"
2257 // "Set the iso speed lower or equal to 400Mbps");
2258  close();
2260  "Camera is not 1394B mode capable") );
2261  }
2262 
2263  if(dc1394_video_set_operation_mode(camera,
2264  DC1394_OPERATION_MODE_1394B)
2265  != DC1394_SUCCESS) {
2266 // vpERROR_TRACE("Cannot set camera to 1394B mode. \n");
2267  close();
2269  "Cannot set camera to 1394B mode") );
2270  }
2271 
2272  if (dc1394_video_get_operation_mode(camera, &op_mode) != DC1394_SUCCESS) {
2273 // vpERROR_TRACE("Failed to set 1394B mode. \n");
2274  close();
2276  "Failed to set 1394B mode") );
2277  }
2278  }
2279  else {
2280  if (dc1394_video_set_operation_mode(camera,
2281  DC1394_OPERATION_MODE_LEGACY)
2282  != DC1394_SUCCESS) {
2283 // vpERROR_TRACE("Cannot set camera to 1394A mode. \n");
2284  close();
2286  "Cannot set camera to 1394A mode") );
2287  }
2288 
2289  if (dc1394_video_get_operation_mode(camera, &op_mode) != DC1394_SUCCESS) {
2290 // vpERROR_TRACE("Failed to set 1394A mode. \n");
2291  close();
2293  "Failed to set 1394A mode") );
2294  }
2295  }
2296 
2297  if (dc1394_video_set_iso_speed(camera, (dc1394speed_t) isospeed)
2298  != DC1394_SUCCESS) {
2299 // vpERROR_TRACE("Cannot set requested iso speed. \n");
2300  close();
2302  "Cannot set requested iso speed") );
2303  }
2304 
2305  if (dc1394_video_get_iso_speed(camera, &speed) != DC1394_SUCCESS) {
2306 // vpERROR_TRACE("Failed to set iso speed. \n");
2307  close();
2309  "Failed to set iso speed") );
2310  }
2311 }
2312 
2323 void
2325 {
2326  open();
2327  acquire(I);
2328 }
2329 
2340 void
2342 {
2343  open();
2344  acquire(I);
2345 }
2346 
2347 
2386 dc1394video_frame_t *
2388 {
2389 
2390  if (! num_cameras) {
2391  close();
2392  vpERROR_TRACE("No camera found");
2394  "No camera found") );
2395  }
2396 
2397  dc1394video_frame_t *frame = NULL;
2398 
2399  if (dc1394_capture_dequeue(camera, DC1394_CAPTURE_POLICY_WAIT, &frame)
2400  !=DC1394_SUCCESS) {
2401  vpERROR_TRACE ("Error: Failed to capture from camera %d\n", camera_id);
2402  }
2403 
2404  return frame;
2405 }
2406 
2448 dc1394video_frame_t *
2450 {
2451  uint64_t timestamp;
2452  uint32_t id;
2453 
2454  dc1394video_frame_t *frame;
2455 
2456  frame = dequeue(I, timestamp, id);
2457 
2458  return frame;
2459 }
2460 
2509 dc1394video_frame_t *
2511  uint64_t &timestamp,
2512  uint32_t &id)
2513 {
2514 
2515  open();
2516 
2517  dc1394video_frame_t *frame;
2518 
2519  frame = dequeue();
2520 
2521  // Timeval data structure providing the unix time
2522  // [microseconds] at which the frame was captured in the ring buffer.
2523  timestamp = frame->timestamp;
2524  id = frame->id;
2525 
2526  this->width = frame->size[0];
2527  this->height = frame->size[1];
2528  unsigned int size = this->width * this->height;
2529 
2530  if ((I.getWidth() != this->width)||(I.getHeight() != this->height))
2531  I.resize(this->height, this->width);
2532 
2533  switch(frame->color_coding) {
2534  case DC1394_COLOR_CODING_MONO8:
2535  case DC1394_COLOR_CODING_RAW8:
2536  memcpy(I.bitmap, (unsigned char *) frame->image,
2537  size*sizeof(unsigned char));
2538  break;
2539  case DC1394_COLOR_CODING_MONO16:
2540  case DC1394_COLOR_CODING_RAW16:
2541  vpImageConvert::MONO16ToGrey( (unsigned char *) frame->image,
2542  I.bitmap, size);
2543  break;
2544 
2545  case DC1394_COLOR_CODING_YUV411:
2546  vpImageConvert::YUV411ToGrey( (unsigned char *) frame->image,
2547  I.bitmap, size);
2548  break;
2549 
2550  case DC1394_COLOR_CODING_YUV422:
2551  vpImageConvert::YUV422ToGrey( (unsigned char *) frame->image,
2552  I.bitmap, size);
2553  break;
2554 
2555  case DC1394_COLOR_CODING_YUV444:
2556  vpImageConvert::YUV444ToGrey( (unsigned char *) frame->image,
2557  I.bitmap, size);
2558  break;
2559 
2560  case DC1394_COLOR_CODING_RGB8:
2561  vpImageConvert::RGBToGrey((unsigned char *) frame->image, I.bitmap, size);
2562  break;
2563 
2564 
2565  default:
2566  close();
2567  vpERROR_TRACE("Format conversion not implemented. Acquisition failed.");
2569  "Format conversion not implemented. "
2570  "Acquisition failed.") );
2571  break;
2572  };
2573 
2574  return frame;
2575 }
2576 
2617 dc1394video_frame_t *
2619 {
2620  uint64_t timestamp;
2621  uint32_t id;
2622 
2623  dc1394video_frame_t *frame;
2624 
2625  frame = dequeue(I, timestamp, id);
2626 
2627  return frame;
2628 }
2629 
2678 dc1394video_frame_t *
2680  uint64_t &timestamp,
2681  uint32_t &id)
2682 {
2683 
2684  open();
2685 
2686  dc1394video_frame_t *frame;
2687 
2688  frame = dequeue();
2689 
2690  // Timeval data structure providing the unix time
2691  // [microseconds] at which the frame was captured in the ring buffer.
2692  timestamp = frame->timestamp;
2693  id = frame->id;
2694 
2695  this->width = frame->size[0];
2696  this->height = frame->size[1];
2697  unsigned int size = this->width * this->height;
2698 
2699  if ((I.getWidth() != width)||(I.getHeight() != height))
2700  I.resize(height, width);
2701 
2702  switch (frame->color_coding) {
2703  case DC1394_COLOR_CODING_MONO8:
2704  case DC1394_COLOR_CODING_RAW8:
2705  vpImageConvert::GreyToRGBa((unsigned char *) frame->image,
2706  (unsigned char *) I.bitmap, size);
2707  break;
2708 
2709  case DC1394_COLOR_CODING_MONO16:
2710  case DC1394_COLOR_CODING_RAW16:
2711  vpImageConvert::MONO16ToRGBa((unsigned char *) frame->image,
2712  (unsigned char *) I.bitmap, size);
2713  break;
2714 
2715  case DC1394_COLOR_CODING_YUV411:
2716  vpImageConvert::YUV411ToRGBa( (unsigned char *) frame->image,
2717  (unsigned char *) I.bitmap, size);
2718  break;
2719 
2720  case DC1394_COLOR_CODING_YUV422:
2721  vpImageConvert::YUV422ToRGBa( (unsigned char *) frame->image,
2722  (unsigned char *) I.bitmap, size);
2723  break;
2724 
2725  case DC1394_COLOR_CODING_YUV444:
2726  vpImageConvert::YUV444ToRGBa( (unsigned char *) frame->image,
2727  (unsigned char *) I.bitmap, size);
2728  break;
2729 
2730  case DC1394_COLOR_CODING_RGB8:
2731  vpImageConvert::RGBToRGBa((unsigned char *) frame->image,
2732  (unsigned char *) I.bitmap, size);
2733  break;
2734 
2735 
2736  default:
2737  close();
2738  vpERROR_TRACE("Format conversion not implemented. Acquisition failed.");
2740  "Format conversion not implemented. "
2741  "Acquisition failed.") );
2742  break;
2743  };
2744 
2745  return frame;
2746 }
2747 
2758 void
2759 vp1394TwoGrabber::enqueue(dc1394video_frame_t *frame)
2760 {
2761 
2762  if (! num_cameras) {
2763  close();
2764  vpERROR_TRACE("No camera found");
2766  "No camera found") );
2767  }
2768 
2769  if (frame)
2770  dc1394_capture_enqueue(camera, frame);
2771 }
2772 
2773 
2787 void
2789 {
2790  uint64_t timestamp;
2791  uint32_t id;
2792 
2793  dc1394video_frame_t *frame;
2794 
2795  frame = dequeue(I, timestamp, id);
2796  enqueue(frame);
2797 }
2798 
2817 void
2819  uint64_t &timestamp,
2820  uint32_t &id)
2821 {
2822  dc1394video_frame_t *frame;
2823 
2824  open();
2825  frame = dequeue(I, timestamp, id);
2826  enqueue(frame);
2827 }
2828 
2829 
2830 
2844 void
2846 {
2847  uint64_t timestamp;
2848  uint32_t id;
2849  dc1394video_frame_t *frame;
2850 
2851  open();
2852  frame = dequeue(I, timestamp, id);
2853  enqueue(frame);
2854 }
2855 
2874 void
2876  uint64_t &timestamp,
2877  uint32_t &id)
2878 {
2879  dc1394video_frame_t *frame;
2880 
2881  open();
2882  frame = dequeue();
2883  // Timeval data structure providing the unix time
2884  // [microseconds] at which the frame was captured in the ring buffer.
2885  timestamp = frame->timestamp;
2886  id = frame->id;
2887 
2888  this->width = frame->size[0];
2889  this->height = frame->size[1];
2890  unsigned int size = this->width * this->height;
2891 
2892  if ((I.getWidth() != width)||(I.getHeight() != height))
2893  I.resize(height, width);
2894 
2895  switch (frame->color_coding) {
2896  case DC1394_COLOR_CODING_MONO8:
2897  case DC1394_COLOR_CODING_RAW8:
2898  vpImageConvert::GreyToRGBa((unsigned char *) frame->image,
2899  (unsigned char *) I.bitmap, size);
2900  break;
2901 
2902  case DC1394_COLOR_CODING_YUV411:
2903  vpImageConvert::YUV411ToRGBa( (unsigned char *) frame->image,
2904  (unsigned char *) I.bitmap, size);
2905  break;
2906 
2907  case DC1394_COLOR_CODING_YUV422:
2908  vpImageConvert::YUV422ToRGBa( (unsigned char *) frame->image,
2909  (unsigned char *) I.bitmap, size);
2910  break;
2911 
2912  case DC1394_COLOR_CODING_YUV444:
2913  vpImageConvert::YUV444ToRGBa( (unsigned char *) frame->image,
2914  (unsigned char *) I.bitmap, size);
2915  break;
2916 
2917  case DC1394_COLOR_CODING_RGB8:
2918  vpImageConvert::RGBToRGBa((unsigned char *) frame->image,
2919  (unsigned char *) I.bitmap, size);
2920  break;
2921 
2922 
2923  default:
2924  close();
2925  vpERROR_TRACE("Format conversion not implemented. Acquisition failed.");
2927  "Format conversion not implemented. "
2928  "Acquisition failed.") );
2929  break;
2930  };
2931 
2932  enqueue(frame);
2933 
2934 }
2935 
2952 void vp1394TwoGrabber::getWidth(unsigned int &w)
2953 {
2954  if (! num_cameras) {
2955  close();
2956  vpERROR_TRACE("No camera found");
2958  "No camera found") );
2959  }
2960 
2961  w = this->width;
2962 }
2963 
2981 {
2982  if (! num_cameras) {
2983  close();
2984  vpERROR_TRACE("No camera found");
2986  "No camera found") );
2987  }
2988 
2989  return this->width;
2990 }
2991 
3009 void vp1394TwoGrabber::getHeight(unsigned int &h)
3010 {
3011  if (! num_cameras) {
3012  close();
3013  vpERROR_TRACE("No camera found");
3015  "No camera found") );
3016  }
3017 
3018  h = this->height;
3019 }
3038 {
3039  if (! num_cameras) {
3040  close();
3041  vpERROR_TRACE("No camera found");
3043  "No camera found") );
3044  }
3045 
3046  return this->height;
3047 }
3048 
3054 void
3056 {
3057  std::cout << "----------------------------------------------------------"
3058  << std::endl
3059  << "----- Information for camera " << camera_id
3060  << " -----" << std::endl
3061  << "----------------------------------------------------------" << std::endl;
3062 
3063 #ifdef VISP_HAVE_DC1394_2_CAMERA_ENUMERATE // new API > libdc1394-2.0.0-rc7
3064  dc1394_camera_print_info( camera, stdout);
3065 #elif defined VISP_HAVE_DC1394_2_FIND_CAMERAS // old API <= libdc1394-2.0.0-rc7
3066  dc1394_print_camera_info( camera);
3067 #endif
3068 
3069  dc1394featureset_t features;
3070 #ifdef VISP_HAVE_DC1394_2_CAMERA_ENUMERATE // new API > libdc1394-2.0.0-rc7
3071  if (dc1394_feature_get_all(camera, &features) != DC1394_SUCCESS)
3072 #elif defined VISP_HAVE_DC1394_2_FIND_CAMERAS // old API <= libdc1394-2.0.0-rc7
3073  if (dc1394_get_camera_feature_set(camera, &features) != DC1394_SUCCESS)
3074 #endif
3075  {
3076  close();
3077  vpERROR_TRACE("unable to get feature set for camera %d\n", camera_id);
3079  "Cannot get camera features") );
3080 
3081  } else {
3082 #ifdef VISP_HAVE_DC1394_2_CAMERA_ENUMERATE // new API > libdc1394-2.0.0-rc7
3083  dc1394_feature_print_all(&features, stdout);
3084 #elif defined VISP_HAVE_DC1394_2_FIND_CAMERAS // old API <= libdc1394-2.0.0-rc7
3085  dc1394_print_feature_set(&features);
3086 #endif
3087  }
3088  std::cout << "----------------------------------------------------------" << std::endl;
3089 }
3090 
3104 {
3105  std::string _str = "";
3106  dc1394video_mode_t _videomode = (dc1394video_mode_t) videomode;
3107 
3108  if ((_videomode >= DC1394_VIDEO_MODE_MIN)
3109  && (_videomode <= DC1394_VIDEO_MODE_MAX)) {
3110  _str = strVideoMode[_videomode - DC1394_VIDEO_MODE_MIN];
3111  }
3112  else {
3113  vpCERROR << "The video mode " << (int)videomode
3114  << " is not supported by the camera" << std::endl;
3115  }
3116 
3117  return _str;
3118 }
3119 
3133 {
3134  std::string _str = "";
3135  dc1394framerate_t _fps = (dc1394framerate_t) fps;
3136 
3137  if ((_fps >= DC1394_FRAMERATE_MIN)
3138  && (_fps <= DC1394_FRAMERATE_MAX)) {
3139  _str = strFramerate[_fps - DC1394_FRAMERATE_MIN];
3140  }
3141  else {
3142  vpCERROR << "The framerate " << (int)fps
3143  << " is not supported by the camera" << std::endl;
3144  }
3145 
3146  return _str;
3147 }
3148 
3162 {
3163  std::string _str = "";
3164  dc1394color_coding_t _coding = (dc1394color_coding_t) colorcoding;
3165 
3166  if ((_coding >= DC1394_COLOR_CODING_MIN)
3167  && (_coding <= DC1394_COLOR_CODING_MAX)) {
3168  _str = strColorCoding[_coding - DC1394_COLOR_CODING_MIN];
3169 
3170  }
3171  else {
3172  vpCERROR << "The color coding " << (int)colorcoding
3173  << " is not supported by the camera" << std::endl;
3174  }
3175 
3176  return _str;
3177 }
3178 
3198 {
3200 
3201  for (int i = DC1394_VIDEO_MODE_MIN; i <= DC1394_VIDEO_MODE_MAX; i ++) {
3202  _id = (vp1394TwoVideoModeType) i;
3203  if (videomode.compare(videoMode2string(_id)) == 0)
3204  return _id;
3205  };
3206 
3208  "The required videomode is not valid") );
3209 
3210  return (vp1394TwoVideoModeType) 0;
3211 }
3212 
3213 
3233 {
3235 
3236  for (int i = DC1394_FRAMERATE_MIN; i <= DC1394_FRAMERATE_MAX; i ++) {
3237  _id = (vp1394TwoFramerateType) i;
3238  if (framerate.compare(framerate2string(_id)) == 0)
3239  return _id;
3240  };
3241 
3243  "The required framerate is not valid") );
3244 
3245  return (vp1394TwoFramerateType) 0;
3246 }
3247 
3267 {
3269 
3270  for (int i = DC1394_COLOR_CODING_MIN; i <= DC1394_COLOR_CODING_MAX; i ++) {
3271  _id = (vp1394TwoColorCodingType) i;
3272  if (colorcoding.compare(colorCoding2string(_id)) == 0)
3273  return _id;
3274  };
3275 
3277  "The required color coding is not valid") );
3278 
3279  return (vp1394TwoColorCodingType) 0;
3280 }
3281 
3315 {
3316  for (unsigned int i = 0; i < num_cameras;i++) {
3317  if (camIsOpen[i]) {
3318  camera = cameras[i];
3319  setTransmission(DC1394_OFF);
3320  setCapture(DC1394_OFF);
3321  }
3322  }
3323 #ifdef VISP_HAVE_DC1394_2_CAMERA_ENUMERATE // new API > libdc1394-2.0.0-rc7
3324  setCamera(camera_id);
3325  // free the other cameras
3326  for (unsigned int i=0;i<num_cameras;i++){
3327  if (i!=camera_id) dc1394_camera_free(cameras[i]);
3328  }
3329 
3330  printf ("Reseting bus...\n");
3331  dc1394_reset_bus (camera);
3332 
3333  dc1394_camera_free (camera);
3334  dc1394_free (d);
3335  d = NULL;
3336  //if (cameras != NULL)
3337  delete [] cameras;
3338  cameras = NULL ;
3339 #elif defined VISP_HAVE_DC1394_2_FIND_CAMERAS // old API <= libdc1394-2.0.0-rc7
3340 
3341  setCamera(camera_id);
3342  // free the other cameras
3343  for (unsigned int i=0;i<num_cameras;i++){
3344  if (i!=camera_id) dc1394_free_camera(cameras[i]);
3345  }
3346  free(cameras);
3347  cameras = NULL;
3348 
3349  dc1394_reset_bus(camera);
3350  dc1394_free_camera(camera);
3351 
3352 #endif
3353  if (camIsOpen != NULL)
3354  delete [] camIsOpen;
3355  camIsOpen = NULL ;
3356 
3357  num_cameras = 0;
3358 
3359  init = false;
3360  vpTime::wait(1000);
3361  initialize(false);
3362 }
3363 
3393 void vp1394TwoGrabber::setPanControl(unsigned int panControlValue)
3394 {
3395  open();
3396  if (! num_cameras) {
3397  close();
3398  vpERROR_TRACE("No camera found");
3400  "No camera found") );
3401  }
3402  uint64_t offset = 0x884;
3403  uint32_t value = 0x82000000 + (uint32_t)panControlValue;
3404  dc1394error_t err;
3405  err = dc1394_set_control_register(camera, offset, value);
3406  if (err != DC1394_SUCCESS) {
3407  vpERROR_TRACE("Unable to set PAN register");
3408  close();
3410  "Unable to set PAN register") );
3411  }
3412 }
3413 
3414 
3432 {
3433  if (! num_cameras) {
3434  close();
3435  vpERROR_TRACE("No camera found");
3437  "No camera found") );
3438  }
3439 
3440  uint32_t value;
3441  dc1394feature_t feature = (dc1394feature_t)param;
3442  dc1394error_t err;
3443  err = dc1394_feature_get_value(camera, feature, &value);
3444  if (err != DC1394_SUCCESS) {
3445  vpERROR_TRACE("Unable to get the information");
3446  close();
3448  "Unable to get the information") );
3449  }
3450  return (unsigned int)value;
3451 }
3452 
3453 
3475  unsigned int val)
3476 {
3477  if (! num_cameras) {
3478  close();
3479  vpERROR_TRACE("No camera found");
3481  "No camera found") );
3482  }
3483  uint32_t value = (uint32_t)val;
3484  dc1394feature_t feature = (dc1394feature_t)param;
3485  dc1394error_t err;
3486  dc1394bool_t hasManualMode = DC1394_FALSE;
3487  dc1394feature_modes_t modesAvailable;
3488 
3489  // test wether we can set the shutter value (manual mode available or not)
3490  err = dc1394_feature_get_modes(camera, feature, &modesAvailable);
3491  if (err != DC1394_SUCCESS) {
3492  vpERROR_TRACE("Unable to detect the manual mode information");
3493  close();
3495  "Unable to detect the manual mode information"));
3496  }
3497 
3498  for(unsigned int i=0; i<modesAvailable.num; i++){
3499  if(modesAvailable.modes[i] == DC1394_FEATURE_MODE_MANUAL){
3500  hasManualMode = DC1394_TRUE;
3501  }
3502  }
3503 
3504  if(hasManualMode == DC1394_TRUE){
3505 
3506  if(!isDataModified[camera_id]){// to ensure we save the first mode even after several set
3507  /* we update the structure */
3508  updateDataCamToStruct();
3509  err = dc1394_feature_get_mode(camera, feature, &(initialShutterMode[camera_id]));
3510  if (err != DC1394_SUCCESS) {
3511  vpERROR_TRACE("Unable to get the initial mode");
3512  close();
3514  "Unable to get the initial mode"));
3515  }
3516  isDataModified[camera_id] = true;
3517  }
3518 
3519  dc1394feature_mode_t manualMode = DC1394_FEATURE_MODE_MANUAL;
3520  err = dc1394_feature_set_mode(camera, feature, manualMode);
3521  if (err != DC1394_SUCCESS) {
3522  vpERROR_TRACE("Unable to set the muanual mode");
3523  close();
3525  "Unable to set the manual mode") );
3526  }
3527  err = dc1394_feature_set_value(camera, feature, value);
3528  if (err != DC1394_SUCCESS) {
3529  vpERROR_TRACE("Unable to set the shutter information");
3530  close();
3532  "Unable to set the shutter information") );
3533  }
3534  }
3535  else{
3536  vpERROR_TRACE("The camera does not have a manual mode.\nCannot change the value");
3538  "The camera does not have a manual mode"));
3539  }
3540 }
3548 void
3550 {
3551  if (! num_cameras) {
3552  close();
3553  vpERROR_TRACE("No camera found");
3555  "No camera found") );
3556  }
3557 
3558  guid = camera->guid;
3559 }
3560 
3568 uint64_t
3570 {
3571  if (! num_cameras) {
3572  close();
3573  vpERROR_TRACE("No camera found");
3575  "No camera found") );
3576  }
3577 
3578  return camera->guid;
3579 }
3580 
3581 
3586 inline void
3587 vp1394TwoGrabber::updateDataCamToStruct()
3588 {
3589  dataCam[camera_id].brightness = getParameterValue(vpFEATURE_BRIGHTNESS);
3590  dataCam[camera_id].exposure = getParameterValue(vpFEATURE_EXPOSURE);
3591  dataCam[camera_id].sharpness = getParameterValue(vpFEATURE_SHARPNESS);
3592  dataCam[camera_id].hue = getParameterValue(vpFEATURE_HUE);
3593  dataCam[camera_id].saturation = getParameterValue(vpFEATURE_SATURATION);
3594  dataCam[camera_id].gamma = getParameterValue(vpFEATURE_GAMMA);
3595  dataCam[camera_id].shutter = getParameterValue(vpFEATURE_SHUTTER);
3596  dataCam[camera_id].gain = getParameterValue(vpFEATURE_GAIN);
3597  dataCam[camera_id].iris = getParameterValue(vpFEATURE_IRIS);
3598 }
3599 
3604 inline void
3605 vp1394TwoGrabber::updateDataStructToCam()
3606 {
3607  setParameterValue(vpFEATURE_BRIGHTNESS, dataCam[camera_id].brightness);
3608  setParameterValue(vpFEATURE_EXPOSURE, dataCam[camera_id].exposure);
3609  setParameterValue(vpFEATURE_SHARPNESS, dataCam[camera_id].sharpness);
3610  setParameterValue(vpFEATURE_HUE, dataCam[camera_id].hue);
3611  setParameterValue(vpFEATURE_SATURATION, dataCam[camera_id].saturation);
3612  setParameterValue(vpFEATURE_GAMMA, dataCam[camera_id].gamma);
3613  setParameterValue(vpFEATURE_SHUTTER, dataCam[camera_id].shutter);
3614  setParameterValue(vpFEATURE_GAIN, dataCam[camera_id].gain);
3615  setParameterValue(vpFEATURE_IRIS, dataCam[camera_id].iris);
3616 }
3617 
3618 #ifdef VISP_BUILD_DEPRECATED_FUNCTIONS
3619 
3637 uint32_t
3639 {
3640  // Refresh the list of supported modes
3641  videomodes.kill();
3642 
3643  if (! num_cameras) {
3644  close();
3645  vpERROR_TRACE("No camera found");
3647  "No camera found") );
3648  }
3649  dc1394video_modes_t _videomodes;
3650 
3651  // get video modes:
3652  if (dc1394_video_get_supported_modes(camera, &_videomodes)!=DC1394_SUCCESS) {
3653 
3654  close();
3655  vpERROR_TRACE("Can't get video modes");
3657  "Can't get video modes") );
3658  }
3659 
3660  // parse the video modes to add in the list
3661  for (unsigned i=0; i < _videomodes.num; i++) {
3662  vp1394TwoVideoModeType _mode = (vp1394TwoVideoModeType) _videomodes.modes[i];
3663  videomodes.addRight( _mode );
3664  }
3665 
3666  // return the number of available video modes
3667  return _videomodes.num;
3668 }
3669 
3702 uint32_t
3705 {
3706  if (! num_cameras) {
3707  close();
3708  vpERROR_TRACE("No camera found");
3710  "No camera found") );
3711  }
3712 
3713  // Refresh the list of supported framerates
3714  fps.kill();
3715 
3716  switch (mode) {
3717  // Framerate not available for:
3718  // - vpVIDEO_MODE_EXIF ie Format_6
3719  // - vpVIDEO_MODE_FORMAT7... ie the Format_7
3720  case vpVIDEO_MODE_EXIF:
3729  return 0;
3730  break;
3731  default:
3732  {
3733  dc1394framerates_t _fps;
3734  if (dc1394_video_get_supported_framerates(camera,
3735  (dc1394video_mode_t)mode,
3736  &_fps) != DC1394_SUCCESS) {
3737  close();
3738  vpERROR_TRACE("Could not query supported frametates for mode %d\n",
3739  mode);
3741  "Could not query supported framerates") );
3742  }
3743  if (_fps.num == 0)
3744  return 0;
3745 
3746  for (unsigned int i = 0; i < _fps.num; i ++)
3747  fps.addRight((vp1394TwoFramerateType)_fps.framerates[i]);
3748 
3749  return _fps.num;
3750  }
3751  break;
3752  }
3753 }
3754 
3779 uint32_t
3782 {
3783  if (! num_cameras) {
3784  close();
3785  vpERROR_TRACE("No camera found");
3787  "No camera found") );
3788  }
3789 
3790  // Refresh the list of supported framerates
3791  codings.kill();
3792 
3793  if (dc1394_is_video_mode_scalable((dc1394video_mode_t)mode)) {
3794  // Format 7 video mode
3795  dc1394color_codings_t _codings;
3796  if (dc1394_format7_get_color_codings(camera,
3797  (dc1394video_mode_t)mode,
3798  &_codings) != DC1394_SUCCESS) {
3799  close();
3800  vpERROR_TRACE("Could not query supported color codings for mode %d\n",
3801  mode);
3803  "Could not query supported color codings") );
3804  }
3805  if (_codings.num == 0)
3806  return 0;
3807 
3808  for (unsigned int i = 0; i < _codings.num; i ++)
3809  codings.addRight((vp1394TwoColorCodingType)_codings.codings[i]);
3810 
3811  return _codings.num;
3812  }
3813  else if (dc1394_is_video_mode_still_image((dc1394video_mode_t)mode)) {
3814  // Format 6 video mode
3815  return 0;
3816  }
3817  else {
3818  // Not Format 7 and not Format 6 video modes
3819  dc1394color_coding_t _coding;
3820  if (dc1394_get_color_coding_from_video_mode(camera,
3821  (dc1394video_mode_t)mode,
3822  &_coding) != DC1394_SUCCESS) {
3823  close();
3824  vpERROR_TRACE("Could not query supported color coding for mode %d\n",
3825  mode);
3827  "Could not query supported color coding") );
3828  }
3829  codings.addRight((vp1394TwoColorCodingType)_coding);
3830  return 1;
3831  }
3832 }
3833 #endif
3834 
3835 #endif
3836 
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:161
#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 without initializing it.
Definition: vpImage.h:536
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: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)