Visual Servoing Platform  version 3.6.1 under development (2024-12-03)
vp1394TwoGrabber.cpp
1 /****************************************************************************
2  *
3  * ViSP, open source Visual Servoing Platform software.
4  * Copyright (C) 2005 - 2023 by Inria. All rights reserved.
5  *
6  * This software is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  * See the file LICENSE.txt at the root directory of this source
11  * distribution for additional information about the GNU GPL.
12  *
13  * For using ViSP with software that can not be combined with the GNU
14  * GPL, please contact Inria about acquiring a ViSP Professional
15  * Edition License.
16  *
17  * See https://visp.inria.fr for more information.
18  *
19  * This software was developed at:
20  * Inria Rennes - Bretagne Atlantique
21  * Campus Universitaire de Beaulieu
22  * 35042 Rennes Cedex
23  * France
24  *
25  * If you have questions regarding the use of this file, please contact
26  * Inria at visp@inria.fr
27  *
28  * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
29  * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
30  *
31  * Description:
32  * Firewire cameras video capture.
33  *
34 *****************************************************************************/
35 
40 #include <iostream>
41 
42 #include <visp3/core/vpConfig.h>
43 #include <visp3/core/vpDebug.h>
44 
45 /*
46  * Interface with libdc1394 2.x
47  */
48 #if defined(VISP_HAVE_DC1394)
49 #include <unistd.h>
50 
51 #include <visp3/core/vpFrameGrabberException.h>
52 #include <visp3/core/vpImageConvert.h>
53 #include <visp3/core/vpTime.h>
54 #include <visp3/sensor/vp1394TwoGrabber.h>
55 
56 BEGIN_VISP_NAMESPACE
57 const char *vp1394TwoGrabber::strVideoMode[DC1394_VIDEO_MODE_NUM] = {
58  "MODE_160x120_YUV444", "MODE_320x240_YUV422", "MODE_640x480_YUV411", "MODE_640x480_YUV422",
59  "MODE_640x480_RGB8", "MODE_640x480_MONO8", "MODE_640x480_MONO16", "MODE_800x600_YUV422",
60  "MODE_800x600_RGB8", "MODE_800x600_MONO8", "MODE_1024x768_YUV422", "MODE_1024x768_RGB8",
61  "MODE_1024x768_MONO8", "MODE_800x600_MONO16", "MODE_1024x768_MONO16", "MODE_1280x960_YUV422",
62  "MODE_1280x960_RGB8", "MODE_1280x960_MONO8", "MODE_1600x1200_YUV422", "MODE_1600x1200_RGB8",
63  "MODE_1600x1200_MONO8", "MODE_1280x960_MONO16", "MODE_1600x1200_MONO16", "MODE_EXIF",
64  "MODE_FORMAT7_0", "MODE_FORMAT7_1", "MODE_FORMAT7_2", "MODE_FORMAT7_3",
65  "MODE_FORMAT7_4", "MODE_FORMAT7_5", "MODE_FORMAT7_6", "MODE_FORMAT7_7" };
66 
67 const char *vp1394TwoGrabber::strFramerate[DC1394_FRAMERATE_NUM] = {
68  "FRAMERATE_1_875", "FRAMERATE_3_75", "FRAMERATE_7_5", "FRAMERATE_15",
69  "FRAMERATE_30", "FRAMERATE_60", "FRAMERATE_120", "FRAMERATE_240" };
70 
71 const char *vp1394TwoGrabber::strColorCoding[DC1394_COLOR_CODING_NUM] = {
72  "COLOR_CODING_MONO8", "COLOR_CODING_YUV411", "COLOR_CODING_YUV422", "COLOR_CODING_YUV444",
73  "COLOR_CODING_RGB8", "COLOR_CODING_MONO16", "COLOR_CODING_RGB16", "COLOR_CODING_MONO16S",
74  "COLOR_CODING_RGB16S", "COLOR_CODING_RAW8", "COLOR_CODING_RAW16",
75 };
76 
126  : camera(nullptr), cameras(nullptr), num_cameras(0), camera_id(0), verbose(false), camIsOpen(nullptr),
127  num_buffers(4), // ring buffer size
128  isDataModified(nullptr), initialShutterMode(nullptr), dataCam(nullptr)
129 #ifdef VISP_HAVE_DC1394_CAMERA_ENUMERATE // new API > libdc1394-2.0.0-rc7
130  ,
131  d(nullptr), list(nullptr)
132 #endif
133 {
134  // protected members
135  width = height = 0;
136 
137  // private members
138  init = false;
139 
140  reset = false;
141  initialize(reset);
142 
143  // open();
144 }
145 
156 {
157  /* if(num_cameras >= 1){
158  delete[] isDataModified;
159  delete[] initialShutterMode;
160  delete[] dataCam;
161  }*/
162  close();
163 }
164 
295 void vp1394TwoGrabber::setCamera(uint64_t cam_id)
296 {
297  // Suppose that if camera_id is a camera GUID, this value is greater
298  // than the number of cameras connected to the bus
299  if (cam_id >= num_cameras) {
300  // Check if camera_id is a camera guid
301  bool is_guid = false;
302  // check if the camera_id is a guid
303  for (unsigned int i = 0; i < num_cameras; i++) {
304  if (cameras[i]->guid == cam_id) {
305  this->camera_id = i;
306  is_guid = true;
307  break;
308  }
309  }
310  if (is_guid == false) {
311  std::cout << "Error: The camera with guid 0x" << std::hex << cam_id << " is not present" << std::endl;
312  std::cout << num_cameras << " camera(s) connected" << std::endl;
313  for (unsigned int i = 0; i < num_cameras; i++) {
314  std::cout << " - camera " << i << " with guid 0x" << std::hex << cameras[i]->guid << std::endl;
315  }
316  close();
317  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "The required camera is not present"));
318  }
319  }
320  else {
321  this->camera_id = (unsigned int)cam_id; // The input cam_id is not a
322  // uint64_t guid, but the index of
323  // the camera
324  }
325 
326  // create a pointer to the working camera
327  camera = cameras[this->camera_id];
328 }
329 
344 void vp1394TwoGrabber::getCamera(uint64_t &cam_id)
345 {
346  if (num_cameras) {
347  cam_id = this->camera_id;
348  }
349  else {
350  close();
351  vpERROR_TRACE("No cameras found");
353  }
354 }
355 
371 {
372  if (num_cameras) {
373  return this->camera_id;
374  }
375  else {
376  close();
377  vpERROR_TRACE("No cameras found");
379  }
380 }
381 
389 void vp1394TwoGrabber::getNumCameras(unsigned int &ncameras) const
390 {
391  if (!num_cameras) {
392  vpCTRACE << "No camera found..." << std::endl;
393  ncameras = 0;
394  }
395 
396  ncameras = num_cameras;
397 }
398 
407 {
408  unsigned int ncameras = 0;
409  if (!num_cameras) {
410  vpCTRACE << "No camera found..." << std::endl;
411  ncameras = 0;
412  }
413 
414  ncameras = num_cameras;
415  return ncameras;
416 }
417 
467 {
468  open();
469  if (!num_cameras) {
470  close();
472  }
473  if (!isVideoModeSupported(videomode)) {
474  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Video mode not supported by camera %d",
475  camera_id));
476  }
477  // Stop dma capture if started
478  setTransmission(DC1394_OFF);
479  setCapture(DC1394_OFF);
480 
481  if (dc1394_video_set_mode(camera, (dc1394video_mode_t)videomode) != DC1394_SUCCESS) {
482  close();
483  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Can't set video mode"));
484  }
485 
486  setCapture(DC1394_ON);
487  setTransmission(DC1394_ON);
488 
489  // Updates image size from new video mode
490  if (dc1394_get_image_size_from_video_mode(camera, (dc1394video_mode_t)videomode, &this->width, &this->height) !=
491  DC1394_SUCCESS) {
492 
493  close();
494  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Can't get image size"));
495  }
496 }
497 
515 {
516  if (!num_cameras) {
517  close();
518  vpERROR_TRACE("No camera found");
520  }
521 
522  dc1394video_mode_t _videomode;
523  if (dc1394_video_get_mode(camera, &_videomode) != DC1394_SUCCESS) {
524 
525  close();
526  vpERROR_TRACE("Can't get current video mode");
527  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Can't get current video mode"));
528  }
529  videomode = (vp1394TwoVideoModeType)_videomode;
530 }
531 
548 uint32_t vp1394TwoGrabber::getVideoModeSupported(std::list<vp1394TwoVideoModeType> &videomodes)
549 {
550  // Refresh the list of supported modes
551  videomodes.clear();
552 
553  if (!num_cameras) {
554  close();
555  vpERROR_TRACE("No camera found");
557  }
558  dc1394video_modes_t _videomodes;
559 
560  // get video modes:
561  if (dc1394_video_get_supported_modes(camera, &_videomodes) != DC1394_SUCCESS) {
562 
563  close();
564  vpERROR_TRACE("Can't get video modes");
565  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Can't get video modes"));
566  }
567 
568  // parse the video modes to add in the list
569  for (unsigned i = 0; i < _videomodes.num; i++) {
570  vp1394TwoVideoModeType _mode = (vp1394TwoVideoModeType)_videomodes.modes[i];
571  videomodes.push_back(_mode);
572  }
573 
574  // return the number of available video modes
575  return _videomodes.num;
576 }
593 {
594  if (!num_cameras) {
595  close();
596  vpERROR_TRACE("No camera found");
598  }
599  dc1394video_modes_t _videomodes;
600 
601  // get video modes:
602  if (dc1394_video_get_supported_modes(camera, &_videomodes) != DC1394_SUCCESS) {
603 
604  close();
605  vpERROR_TRACE("Can't get video modes");
606  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Can't get video modes"));
607  }
608 
609  // parse the video modes to check with the desired
610  for (unsigned i = 0; i < _videomodes.num; i++) {
611  if ((vp1394TwoVideoModeType)_videomodes.modes[i] == videomode) {
612  return true;
613  }
614  }
615  return false;
616 }
617 
631 {
632 
633  if (dc1394_is_video_mode_scalable((dc1394video_mode_t)videomode))
634  return true;
635 
636  return false;
637 }
638 
655 {
657  getColorCoding(coding);
658 
659  switch (coding) {
663  case vpCOLOR_CODING_RAW8:
665  return false;
669  case vpCOLOR_CODING_RGB8:
672  return true;
673  }
674  return false;
675 }
676 
702 {
703  open();
704  if (!num_cameras) {
705  close();
707  }
708 
709  vp1394TwoVideoModeType cur_videomode;
710  getVideoMode(cur_videomode);
711  if (isVideoModeFormat7(cur_videomode))
712  return;
713 
714  if (!isFramerateSupported(cur_videomode, fps)) {
715  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Framerate not supported by camera %d",
716  camera_id));
717  }
718 
719  // Stop dma capture if started
720  setTransmission(DC1394_OFF);
721  setCapture(DC1394_OFF);
722 
723  if (dc1394_video_set_framerate(camera, (dc1394framerate_t)fps) != DC1394_SUCCESS) {
724 
725  close();
726  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Can't set framerate"));
727  }
728 
729  setCapture(DC1394_ON);
730  setTransmission(DC1394_ON);
731 }
732 
750 {
751  if (!num_cameras) {
752  close();
753  vpERROR_TRACE("No camera found");
755  }
756  dc1394framerate_t _fps;
757  if (dc1394_video_get_framerate(camera, &_fps) != DC1394_SUCCESS) {
758 
759  close();
760  vpERROR_TRACE("Can't get current framerate");
761  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Can't get current framerate"));
762  }
763  fps = (vp1394TwoFramerateType)_fps;
764 }
765 
797 uint32_t vp1394TwoGrabber::getFramerateSupported(vp1394TwoVideoModeType mode, std::list<vp1394TwoFramerateType> &fps)
798 {
799  if (!num_cameras) {
800  close();
801  vpERROR_TRACE("No camera found");
803  }
804 
805  // Refresh the list of supported framerates
806  fps.clear();
807 
808  switch (mode) {
809  // Framerate not available for:
810  // - vpVIDEO_MODE_EXIF ie Format_6
811  // - vpVIDEO_MODE_FORMAT7... ie the Format_7
812  case vpVIDEO_MODE_EXIF:
821  return 0;
822  break;
823  default: {
824  dc1394framerates_t _fps;
825  if (dc1394_video_get_supported_framerates(camera, (dc1394video_mode_t)mode, &_fps) != DC1394_SUCCESS) {
826  close();
827  vpERROR_TRACE("Could not query supported frametates for mode %d\n", mode);
828  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Could not query supported framerates"));
829  }
830  if (_fps.num == 0)
831  return 0;
832 
833  for (unsigned int i = 0; i < _fps.num; i++)
834  fps.push_back((vp1394TwoFramerateType)_fps.framerates[i]);
835 
836  return _fps.num;
837  } break;
838  }
839 }
874 {
875  if (!num_cameras) {
876  close();
877  vpERROR_TRACE("No camera found");
879  }
880 
881  switch (mode) {
882  // Framerate not available for:
883  // - vpVIDEO_MODE_EXIF ie Format_6
884  // - vpVIDEO_MODE_FORMAT7... ie the Format_7
885  case vpVIDEO_MODE_EXIF:
894  return 0;
895  break;
896  default: {
897  dc1394framerates_t _fps;
898  if (dc1394_video_get_supported_framerates(camera, (dc1394video_mode_t)mode, &_fps) != DC1394_SUCCESS) {
899  close();
900  vpERROR_TRACE("Could not query supported frametates for mode %d\n", mode);
901  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Could not query supported framerates"));
902  }
903  if (_fps.num == 0)
904  return 0;
905 
906  for (unsigned int i = 0; i < _fps.num; i++) {
907  if (fps == (vp1394TwoFramerateType)_fps.framerates[i]) {
908  return true;
909  }
910  }
911  return false;
912  } break;
913  }
914 }
915 
968 {
969  if (!num_cameras) {
970  close();
972  }
973 
974  dc1394video_mode_t _videomode;
975  if (dc1394_video_get_mode(camera, &_videomode) != DC1394_SUCCESS) {
976 
977  close();
978  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Can't get current video mode"));
979  }
980 
981  if (!isColorCodingSupported((vp1394TwoVideoModeType)_videomode, coding)) {
982  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Color coding not supported by camera %d",
983  camera_id));
984  }
985 
986  // Format 7 video mode
987  if (dc1394_is_video_mode_scalable(_videomode)) {
988  setTransmission(DC1394_OFF);
989  setCapture(DC1394_OFF);
990 
991  if (dc1394_format7_set_color_coding(camera, _videomode, (dc1394color_coding_t)coding) != DC1394_SUCCESS) {
992 
993  close();
994  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Can't set color coding"));
995  }
996 
997  setCapture(DC1394_ON);
998  setTransmission(DC1394_ON);
999  }
1000 }
1001 
1020 {
1021  if (!num_cameras) {
1022  close();
1023  vpERROR_TRACE("No camera found");
1025  }
1026  dc1394video_mode_t _videomode;
1027  if (dc1394_video_get_mode(camera, &_videomode) != DC1394_SUCCESS) {
1028 
1029  close();
1030  vpERROR_TRACE("Can't get current video mode");
1031  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Can't get current video mode"));
1032  }
1033 
1034  dc1394color_coding_t _coding;
1035  if (dc1394_is_video_mode_scalable(_videomode)) {
1036  // Format 7 video mode
1037  if (dc1394_format7_get_color_coding(camera, _videomode, &_coding) != DC1394_SUCCESS) {
1038 
1039  close();
1040  vpERROR_TRACE("Can't get current color coding");
1041  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Can't query current color coding"));
1042  }
1043  }
1044  else if (dc1394_is_video_mode_still_image((dc1394video_mode_t)_videomode)) {
1045  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "No color coding for format 6 video mode"));
1046  }
1047  else {
1048  // Not Format 7 and not Format 6 video modes
1049  if (dc1394_get_color_coding_from_video_mode(camera, (dc1394video_mode_t)_videomode, &_coding) != DC1394_SUCCESS) {
1050  close();
1051  vpERROR_TRACE("Could not query supported color coding for mode %d\n", _videomode);
1052  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Can't query current color coding"));
1053  }
1054  }
1055  coding = (vp1394TwoColorCodingType)_coding;
1056 }
1057 
1080  std::list<vp1394TwoColorCodingType> &codings)
1081 {
1082  if (!num_cameras) {
1083  close();
1084  vpERROR_TRACE("No camera found");
1086  }
1087 
1088  // Refresh the list of supported framerates
1089  codings.clear();
1090 
1091  if (dc1394_is_video_mode_scalable((dc1394video_mode_t)mode)) {
1092  // Format 7 video mode
1093  dc1394color_codings_t _codings;
1094  if (dc1394_format7_get_color_codings(camera, (dc1394video_mode_t)mode, &_codings) != DC1394_SUCCESS) {
1095  close();
1096  vpERROR_TRACE("Could not query supported color codings for mode %d\n", mode);
1097  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Could not query supported color codings"));
1098  }
1099  if (_codings.num == 0)
1100  return 0;
1101 
1102  for (unsigned int i = 0; i < _codings.num; i++)
1103  codings.push_back((vp1394TwoColorCodingType)_codings.codings[i]);
1104 
1105  return _codings.num;
1106  }
1107  else if (dc1394_is_video_mode_still_image((dc1394video_mode_t)mode)) {
1108  // Format 6 video mode
1109  return 0;
1110  }
1111  else {
1112  // Not Format 7 and not Format 6 video modes
1113  dc1394color_coding_t _coding;
1114  if (dc1394_get_color_coding_from_video_mode(camera, (dc1394video_mode_t)mode, &_coding) != DC1394_SUCCESS) {
1115  close();
1116  vpERROR_TRACE("Could not query supported color coding for mode %d\n", mode);
1117  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Could not query supported color coding"));
1118  }
1119  codings.push_back((vp1394TwoColorCodingType)_coding);
1120  return 1;
1121  }
1122 }
1145 {
1146  if (!num_cameras) {
1147  close();
1148  vpERROR_TRACE("No camera found");
1150  }
1151 
1152  if (dc1394_is_video_mode_scalable((dc1394video_mode_t)mode)) {
1153  // Format 7 video mode
1154  dc1394color_codings_t _codings;
1155  if (dc1394_format7_get_color_codings(camera, (dc1394video_mode_t)mode, &_codings) != DC1394_SUCCESS) {
1156  close();
1157  vpERROR_TRACE("Could not query supported color codings for mode %d\n", mode);
1158  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Could not query supported color codings"));
1159  }
1160  if (_codings.num == 0)
1161  return 0;
1162 
1163  for (unsigned int i = 0; i < _codings.num; i++) {
1164  if (coding == (vp1394TwoColorCodingType)_codings.codings[i])
1165  return true;
1166  }
1167  return false;
1168  }
1169  else if (dc1394_is_video_mode_still_image((dc1394video_mode_t)mode)) {
1170  // Format 6 video mode
1171  return false;
1172  }
1173  else {
1174  // Not Format 7 and not Format 6 video modes
1175  dc1394color_coding_t _coding;
1176  if (dc1394_get_color_coding_from_video_mode(camera, (dc1394video_mode_t)mode, &_coding) != DC1394_SUCCESS) {
1177  close();
1178  vpERROR_TRACE("Could not query supported color coding for mode %d\n", mode);
1179  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Could not query supported color coding"));
1180  return false;
1181  }
1182  if (coding == (vp1394TwoColorCodingType)_coding)
1183  return true;
1184 
1185  return false;
1186  }
1187 }
1188 
1220 void vp1394TwoGrabber::setFormat7ROI(unsigned int left, unsigned int top, unsigned int w, unsigned int h)
1221 {
1222  open();
1223  if (!num_cameras) {
1224  close();
1225  vpERROR_TRACE("No camera found");
1227  }
1228 
1229  dc1394video_mode_t _videomode;
1230  if (dc1394_video_get_mode(camera, &_videomode) != DC1394_SUCCESS) {
1231 
1232  close();
1233  vpERROR_TRACE("Can't get current video mode");
1234  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Can't get current video mode"));
1235  }
1236  if (dc1394_is_video_mode_scalable(_videomode)) {
1237  // Stop dma capture if started
1238  setTransmission(DC1394_OFF);
1239  setCapture(DC1394_OFF);
1240  // Format 7 video mode
1241  unsigned int max_width, max_height;
1242  if (dc1394_format7_get_max_image_size(camera, _videomode, &max_width, &max_height) != DC1394_SUCCESS) {
1243 
1244  close();
1245  vpERROR_TRACE("Can't get format7 max image size");
1246  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Can't get format7 max image size"));
1247  }
1248 #if 0
1249  vpTRACE("left: %d top: %d width: %d height: %d", left, top,
1250  width == 0 ? DC1394_USE_MAX_AVAIL : w,
1251  height == 0 ? DC1394_USE_MAX_AVAIL : h);
1252  vpTRACE("max_width: %d max_height: %d", max_width, max_height);
1253 #endif
1254 
1255  if (left > max_width) {
1256  vpERROR_TRACE("Can't set format7 ROI");
1257  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Can't set format7 ROI"));
1258  }
1259  if (top > max_height) {
1260  vpERROR_TRACE("Can't set format7 ROI");
1261  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Can't set format7 ROI"));
1262  }
1263 
1264  int32_t roi_width;
1265  int32_t roi_height;
1266 
1267  if (w != 0) {
1268  // Check if roi width is acceptable (ie roi is contained in the image)
1269  if (w > (max_width - left))
1270  w = (max_width - left);
1271  roi_width = (int32_t)w;
1272  }
1273  else {
1274  roi_width = DC1394_USE_MAX_AVAIL;
1275  }
1276 
1277  if (h != 0) {
1278  // Check if roi height is acceptable (ie roi is contained in the image)
1279  if (h > (max_height - top))
1280  h = (max_height - top);
1281  roi_height = (int32_t)h;
1282  }
1283  else {
1284  roi_height = DC1394_USE_MAX_AVAIL;
1285  }
1286 
1287  if (dc1394_format7_set_roi(camera, _videomode,
1288  (dc1394color_coding_t)DC1394_QUERY_FROM_CAMERA, // color_coding
1289  DC1394_USE_MAX_AVAIL /*DC1394_QUERY_FROM_CAMERA*/
1290  , // bytes_per_packet
1291  (int32_t)left, // left
1292  (int32_t)top, // top
1293  roi_width, roi_height) != DC1394_SUCCESS) {
1294  close();
1295  vpERROR_TRACE("Can't set format7 roi");
1296  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Can't get current video mode"));
1297  }
1298  // Update the image size
1299  if (dc1394_format7_get_image_size(camera, _videomode, &this->width, &this->height) != DC1394_SUCCESS) {
1300  close();
1301  vpERROR_TRACE("Can't get format7 image size");
1302  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Can't get format7 image size"));
1303  }
1304 
1305  setCapture(DC1394_ON);
1306  setTransmission(DC1394_ON);
1307  }
1308 }
1323 void vp1394TwoGrabber::initialize(bool reset)
1324 {
1325  if (init == false) {
1326 // Find cameras
1327 #ifdef VISP_HAVE_DC1394_CAMERA_ENUMERATE // new API > libdc1394-2.0.0-rc7
1328  if (d != nullptr)
1329  dc1394_free(d);
1330 
1331  d = dc1394_new();
1332  if (dc1394_camera_enumerate(d, &list) != DC1394_SUCCESS) {
1333  dc1394_camera_free_list(list);
1334  close();
1335  vpERROR_TRACE("Failed to enumerate cameras\n");
1336  throw(vpFrameGrabberException(vpFrameGrabberException::initializationError, "Failed to enumerate cameras"));
1337  }
1338 
1339  if (list->num == 0) {
1340  dc1394_camera_free_list(list);
1341  close();
1342  vpERROR_TRACE("No cameras found");
1344  }
1345 
1346  if (cameras != nullptr)
1347  delete[] cameras;
1348 
1349  cameras = new dc1394camera_t *[list->num];
1350 
1351  num_cameras = 0;
1352 
1353  for (unsigned int i = 0; i < list->num; i++) {
1354  cameras[i] = dc1394_camera_new(d, list->ids[i].guid);
1355  if (!cameras[i]) {
1356  vpTRACE("Failed to initialize camera with guid \"%ld\"\n", list->ids[i].guid);
1357  continue;
1358  }
1359  // Update the number of working cameras
1360  num_cameras++;
1361  }
1362 
1363  if (reset) {
1364  // Reset the bus to make firewire working if the program was not
1365  // properly stopped by a CTRL-C. We reset here only the bus attached to
1366  // the first camera
1367  dc1394_reset_bus(cameras[0]);
1368  }
1369 
1370  // if (list != nullptr)
1371  dc1394_camera_free_list(list);
1372  list = nullptr;
1373 
1374 #elif defined VISP_HAVE_DC1394_FIND_CAMERAS // old API <= libdc1394-2.0.0-rc7
1375  if (cameras != nullptr)
1376  free(cameras);
1377  cameras = nullptr;
1378  int err = dc1394_find_cameras(&cameras, &num_cameras);
1379 
1380  if (err != DC1394_SUCCESS && err != DC1394_NO_CAMERA) {
1381  close();
1382  vpERROR_TRACE("Unable to look for cameras\n\n"
1383  "Please check \n"
1384  " - if the kernel modules `ieee1394',`raw1394' and "
1385  "`ohci1394' are loaded \n"
1386  " - if you have read/write access to /dev/raw1394\n\n");
1387  throw(vpFrameGrabberException(vpFrameGrabberException::initializationError, "Unable to look for cameras"));
1388  }
1389 #endif
1390 
1391  if (num_cameras == 0) {
1392  close();
1393  vpERROR_TRACE("No cameras found");
1395  }
1396 
1397  // allocation for the parameters
1398  isDataModified = new bool[num_cameras];
1399  for (unsigned int i = 0; i < num_cameras; i++)
1400  isDataModified[i] = false;
1401  initialShutterMode = new dc1394feature_mode_t[num_cameras];
1402  dataCam = new vpDc1394TwoCameraParametersData[num_cameras];
1403 
1404  if (camera_id >= num_cameras) {
1405  // Bad camera id
1406  close();
1407  vpERROR_TRACE("Bad camera id: %u", camera_id);
1408  vpERROR_TRACE("Only %u camera on the bus.", num_cameras);
1410  }
1411 
1412  if (verbose) {
1413  std::cout << "------ Bus information ------" << std::endl;
1414  std::cout << "Number of camera(s) on the bus : " << num_cameras << std::endl;
1415  std::cout << "-----------------------------" << std::endl;
1416  }
1417 
1418  if (camIsOpen != nullptr)
1419  delete[] camIsOpen;
1420  camIsOpen = new bool[num_cameras];
1421  for (unsigned int i = 0; i < num_cameras; i++) {
1422  camIsOpen[i] = false;
1423  }
1424 
1425  init = true;
1426  }
1427 }
1438 {
1439  if (init == false)
1440  initialize(false);
1441  if (camIsOpen[camera_id] == false) {
1442  dc1394switch_t status = DC1394_OFF;
1443 
1444  //#ifdef VISP_HAVE_DC1394_CAMERA_ENUMERATE // new API >
1445  // libdc1394-2.0.0-rc7
1446  dc1394_video_get_transmission(cameras[camera_id], &status);
1447  if (status != DC1394_OFF) {
1448  //#endif
1449  if (dc1394_video_set_transmission(cameras[camera_id], DC1394_OFF) != DC1394_SUCCESS)
1450  vpTRACE("Could not stop ISO transmission");
1451  else {
1452  vpTime::wait(500);
1453  if (dc1394_video_get_transmission(cameras[camera_id], &status) != DC1394_SUCCESS)
1454  vpTRACE("Could get ISO status");
1455  else {
1456  if (status == DC1394_ON) {
1457  vpTRACE("ISO transmission refuses to stop");
1458  }
1459 #ifdef VISP_HAVE_DC1394_FIND_CAMERAS // old API <= libdc1394-2.0.0-rc7
1460  // No yet in the new API
1461  cameras[camera_id]->is_iso_on = status;
1462 #endif
1463  }
1464  //#ifdef VISP_HAVE_DC1394_CAMERA_ENUMERATE // new API >
1465  // libdc1394-2.0.0-rc7
1466  }
1467  //#endif
1468  }
1469  setCamera(camera_id);
1470  // setIsoSpeed(DC1394_ISO_SPEED_400);
1471  setCapture(DC1394_ON);
1472  setTransmission(DC1394_ON);
1473  camIsOpen[camera_id] = true;
1474  }
1475 }
1485 {
1486  if (init) {
1487  if (num_cameras) {
1488  for (unsigned int i = 0; i < num_cameras; i++) {
1489  if (camIsOpen[i]) {
1490  camera = cameras[i];
1491  this->camera_id = i; // set camera id for the function updateDataStructToCam
1492  setTransmission(DC1394_OFF);
1493  setCapture(DC1394_OFF);
1494  if (isDataModified[i]) {
1495  // reset values
1496  try {
1497  updateDataStructToCam();
1498  }
1499  catch (...) {
1500  }
1501  // reset mode (manual, auto, ...)
1502  if (dc1394_feature_set_mode(camera, DC1394_FEATURE_BRIGHTNESS, initialShutterMode[i]) != DC1394_SUCCESS ||
1503  dc1394_feature_set_mode(camera, DC1394_FEATURE_EXPOSURE, initialShutterMode[i]) != DC1394_SUCCESS ||
1504  dc1394_feature_set_mode(camera, DC1394_FEATURE_SHARPNESS, initialShutterMode[i]) != DC1394_SUCCESS ||
1505  dc1394_feature_set_mode(camera, DC1394_FEATURE_HUE, initialShutterMode[i]) != DC1394_SUCCESS ||
1506  dc1394_feature_set_mode(camera, DC1394_FEATURE_SATURATION, initialShutterMode[i]) != DC1394_SUCCESS ||
1507  dc1394_feature_set_mode(camera, DC1394_FEATURE_GAMMA, initialShutterMode[i]) != DC1394_SUCCESS ||
1508  dc1394_feature_set_mode(camera, DC1394_FEATURE_SHUTTER, initialShutterMode[i]) != DC1394_SUCCESS ||
1509  dc1394_feature_set_mode(camera, DC1394_FEATURE_GAIN, initialShutterMode[i]) != DC1394_SUCCESS ||
1510  dc1394_feature_set_mode(camera, DC1394_FEATURE_IRIS, initialShutterMode[i])) {
1511 
1512  vpERROR_TRACE("Unable to reset the initial mode");
1513  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Unable to reset the initial mode"));
1514  }
1515  }
1516  if (dc1394_camera_set_power(camera, DC1394_OFF) != DC1394_SUCCESS)
1517  std::cout << "Unable to turn camera off" << std::endl;
1518  }
1519 #ifdef VISP_HAVE_DC1394_CAMERA_ENUMERATE // new API > libdc1394-2.0.0-rc7
1520  dc1394_camera_free(cameras[i]);
1521 #elif defined VISP_HAVE_DC1394_FIND_CAMERAS // old API <= libdc1394-2.0.0-rc7
1522  dc1394_free_camera(cameras[i]);
1523 #endif
1524  }
1525  }
1526  if (camIsOpen != nullptr) {
1527  delete[] camIsOpen;
1528  camIsOpen = nullptr;
1529  }
1530 
1531 #ifdef VISP_HAVE_DC1394_CAMERA_ENUMERATE // new API > libdc1394-2.0.0-rc7
1532  if (cameras != nullptr) {
1533  delete[] cameras;
1534  cameras = nullptr;
1535  }
1536  if (d != nullptr) {
1537  dc1394_free(d);
1538  d = nullptr;
1539  }
1540 
1541 #elif defined VISP_HAVE_DC1394_FIND_CAMERAS // old API <= libdc1394-2.0.0-rc7
1542  if (cameras != nullptr) {
1543  free(cameras);
1544  cameras = nullptr;
1545  }
1546 #endif
1547 
1548  camIsOpen = nullptr;
1549  num_cameras = 0;
1550 
1551  // remove data for the parameters
1552  if (isDataModified != nullptr) {
1553  delete[] isDataModified;
1554  isDataModified = nullptr;
1555  }
1556  if (initialShutterMode != nullptr) {
1557  delete[] initialShutterMode;
1558  initialShutterMode = nullptr;
1559  }
1560  if (dataCam != nullptr) {
1561  delete[] dataCam;
1562  dataCam = nullptr;
1563  }
1564 
1565  init = false;
1566  }
1567 }
1568 
1582 {
1583  if (size < 1) {
1584  close();
1585  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Could not set ring buffer size"));
1586  }
1587 
1588  if (size != num_buffers) {
1589  // We need to change the ring buffer size
1590  num_buffers = size;
1591  if (camIsOpen[camera_id]) {
1592  setCapture(DC1394_OFF);
1593  setCapture(DC1394_ON);
1594  }
1595  }
1596 }
1597 
1607 unsigned int vp1394TwoGrabber::getRingBufferSize() const { return num_buffers; }
1608 
1652 {
1653  if (!num_cameras) {
1654  close();
1655  vpERROR_TRACE("No camera found");
1657  }
1658 
1659  dc1394feature_mode_t mode;
1660  if (enable) {
1661  mode = DC1394_FEATURE_MODE_AUTO;
1662  }
1663  else {
1664  mode = DC1394_FEATURE_MODE_MANUAL;
1665  }
1666 
1667  if (dc1394_feature_set_power(camera, DC1394_FEATURE_SHUTTER, DC1394_ON) != DC1394_SUCCESS) {
1668  // vpERROR_TRACE("Cannot set shutter on. \n");
1669  close();
1670  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Cannot set shutter on"));
1671  }
1672 
1673  if (dc1394_feature_set_mode(camera, DC1394_FEATURE_SHUTTER, mode) != DC1394_SUCCESS) {
1674  // vpERROR_TRACE("Cannot set auto shutter. \n");
1675  close();
1676  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Cannot set auto shutter"));
1677  }
1678 }
1722 void vp1394TwoGrabber::setAutoShutter(unsigned int minvalue, unsigned int maxvalue)
1723 {
1724  setAutoShutter();
1725 
1726  if (dc1394_avt_set_auto_shutter(camera, minvalue, maxvalue) != DC1394_SUCCESS) {
1727  // vpERROR_TRACE("Cannot set auto shutter min and max values. Is the
1728  // camera an AVT one?\n");
1729  close();
1730  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Cannot set auto shutter min and max values"));
1731  }
1732 }
1733 
1746 void vp1394TwoGrabber::getAutoShutter(unsigned int &minvalue, unsigned int &maxvalue)
1747 {
1748  if (!num_cameras) {
1749  close();
1750  vpERROR_TRACE("No camera found");
1752  }
1753 
1754  if (dc1394_avt_get_auto_shutter(camera, &minvalue, &maxvalue) != DC1394_SUCCESS) {
1755  // vpERROR_TRACE("Cannot get auto shutter min and max values. Is the
1756  // camera an AVT one?\n");
1757  close();
1758  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Cannot get auto shutter min and max values"));
1759  }
1760 }
1761 
1805 {
1806  if (!num_cameras) {
1807  close();
1808  vpERROR_TRACE("No camera found");
1810  }
1811 
1812  dc1394feature_mode_t mode;
1813  if (enable) {
1814  mode = DC1394_FEATURE_MODE_AUTO;
1815  }
1816  else {
1817  mode = DC1394_FEATURE_MODE_MANUAL;
1818  }
1819 
1820  if (dc1394_feature_set_power(camera, DC1394_FEATURE_GAIN, DC1394_ON) != DC1394_SUCCESS) {
1821  // vpERROR_TRACE("Cannot set shutter on. \n");
1822  close();
1823  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Cannot set shutter on"));
1824  }
1825 
1826  if (dc1394_feature_set_mode(camera, DC1394_FEATURE_GAIN, mode) != DC1394_SUCCESS) {
1827  // vpERROR_TRACE("Cannot set auto gain. \n");
1828  close();
1829  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Cannot set auto gain"));
1830  }
1831 }
1875 void vp1394TwoGrabber::setAutoGain(unsigned int minvalue, unsigned int maxvalue)
1876 {
1877  setAutoGain();
1878 
1879  if (dc1394_avt_set_auto_gain(camera, minvalue, maxvalue) != DC1394_SUCCESS) {
1880  // vpERROR_TRACE("Cannot set auto gain min and max values. Is the
1881  // camera an AVT one?\n");
1882  close();
1883  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Cannot set auto gain min and max values"));
1884  }
1885 }
1886 
1899 void vp1394TwoGrabber::getAutoGain(unsigned int &minvalue, unsigned int &maxvalue)
1900 {
1901  if (!num_cameras) {
1902  close();
1903  vpERROR_TRACE("No camera found");
1905  }
1906 
1907  if (dc1394_avt_get_auto_gain(camera, &minvalue, &maxvalue) != DC1394_SUCCESS) {
1908  // vpERROR_TRACE("Cannot get auto gain min and max values. Is the
1909  // camera an AVT one?\n");
1910  close();
1911  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Cannot get auto gain min and max values"));
1912  }
1913 }
1914 
1932 void vp1394TwoGrabber::setCapture(dc1394switch_t _switch)
1933 {
1934  if (!num_cameras) {
1935  close();
1936  vpERROR_TRACE("No camera found");
1938  }
1939 
1940  if (_switch == DC1394_ON) {
1941  // if (dc1394_capture_setup(camera, num_buffers) != DC1394_SUCCESS) {
1942  // To be compatible with libdc1394 svn 382 version
1943  if (dc1394_capture_setup(camera, num_buffers, DC1394_CAPTURE_FLAGS_DEFAULT) != DC1394_SUCCESS) {
1944  vpERROR_TRACE("Unable to setup camera capture-\n"
1945  "make sure that the video mode and framerate are "
1946  "supported by your camera.\n");
1947  close();
1948  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Could not setup dma capture"));
1949  }
1950  }
1951  else { // _switch == DC1394_OFF
1952  dc1394error_t code = dc1394_capture_stop(camera);
1953 
1954  if (code != DC1394_SUCCESS && code != DC1394_CAPTURE_IS_NOT_SET) {
1955  vpERROR_TRACE("Unable to stop camera capture\n");
1956  close();
1957  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Could not setup dma capture"));
1958  }
1959  }
1960 }
1961 
1976 void vp1394TwoGrabber::setTransmission(dc1394switch_t _switch)
1977 {
1978  if (!num_cameras) {
1979  close();
1980  vpERROR_TRACE("No camera found");
1982  }
1983 
1984  dc1394switch_t status = DC1394_OFF;
1985 
1986  if (dc1394_video_get_transmission(camera, &status) != DC1394_SUCCESS) {
1987  vpERROR_TRACE("Unable to get transmision status");
1988  close();
1989  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Could not setup dma capture"));
1990  }
1991 
1992  // if (status!=_switch){
1993  // Start dma capture if halted
1994  if (dc1394_video_set_transmission(camera, _switch) != DC1394_SUCCESS) {
1995  vpERROR_TRACE("Unable to setup camera capture-\n"
1996  "make sure that the video mode and framerate are "
1997  "supported by your camera.\n");
1998  close();
1999  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Could not setup dma capture"));
2000  }
2001 
2002  if (_switch == DC1394_ON) {
2003  status = DC1394_OFF;
2004 
2005  int i = 0;
2006  while (status == DC1394_OFF && i++ < 5) {
2007  usleep(50000);
2008  if (dc1394_video_get_transmission(camera, &status) != DC1394_SUCCESS) {
2009  vpERROR_TRACE("Unable to get transmision status");
2010  close();
2011  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Could not setup dma capture"));
2012  }
2013  }
2014  }
2015  // }
2016 }
2017 
2056 {
2057  if (!num_cameras) {
2058  close();
2059  vpERROR_TRACE("No camera found");
2061  }
2062 
2063  dc1394operation_mode_t op_mode;
2064  dc1394speed_t speed;
2065 
2066  // Check the speed to configure in B-mode or A-mode
2067  if (isospeed >= vpISO_SPEED_800) {
2068  if (camera->bmode_capable != DC1394_TRUE) {
2069  close();
2070  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Camera is not 1394B mode capable"));
2071  }
2072 
2073  if (dc1394_video_set_operation_mode(camera, DC1394_OPERATION_MODE_1394B) != DC1394_SUCCESS) {
2074  close();
2075  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Cannot set camera to 1394B mode"));
2076  }
2077 
2078  if (dc1394_video_get_operation_mode(camera, &op_mode) != DC1394_SUCCESS) {
2079  close();
2080  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Failed to set 1394B mode"));
2081  }
2082  }
2083  else {
2084  if (dc1394_video_set_operation_mode(camera, DC1394_OPERATION_MODE_LEGACY) != DC1394_SUCCESS) {
2085  close();
2086  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Cannot set camera to 1394A mode"));
2087  }
2088 
2089  if (dc1394_video_get_operation_mode(camera, &op_mode) != DC1394_SUCCESS) {
2090  close();
2091  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Failed to set 1394A mode"));
2092  }
2093  }
2094 
2095  if (dc1394_video_set_iso_speed(camera, (dc1394speed_t)isospeed) != DC1394_SUCCESS) {
2096  close();
2097  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Cannot set requested iso speed"));
2098  }
2099 
2100  if (dc1394_video_get_iso_speed(camera, &speed) != DC1394_SUCCESS) {
2101  close();
2102  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Failed to set iso speed"));
2103  }
2104 }
2105 
2117 {
2118  open();
2119  acquire(I);
2120 }
2121 
2133 {
2134  open();
2135  acquire(I);
2136 }
2137 
2179 dc1394video_frame_t *vp1394TwoGrabber::dequeue()
2180 {
2181 
2182  if (!num_cameras) {
2183  close();
2184  vpERROR_TRACE("No camera found");
2186  }
2187 
2188  dc1394video_frame_t *frame = nullptr;
2189 
2190  if (dc1394_capture_dequeue(camera, DC1394_CAPTURE_POLICY_WAIT, &frame) != DC1394_SUCCESS) {
2191  vpERROR_TRACE("Error: Failed to capture from camera %d\n", camera_id);
2192  }
2193 
2194  return frame;
2195 }
2196 
2242 {
2243  uint64_t timestamp;
2244  uint32_t id;
2245 
2246  dc1394video_frame_t *frame;
2247 
2248  frame = dequeue(I, timestamp, id);
2249 
2250  return frame;
2251 }
2252 
2304 dc1394video_frame_t *vp1394TwoGrabber::dequeue(vpImage<unsigned char> &I, uint64_t &timestamp, uint32_t &id)
2305 {
2306 
2307  open();
2308 
2309  dc1394video_frame_t *frame;
2310 
2311  frame = dequeue();
2312 
2313  // Timeval data structure providing the unix time
2314  // [microseconds] at which the frame was captured in the ring buffer.
2315  timestamp = frame->timestamp;
2316  id = frame->id;
2317 
2318  this->width = frame->size[0];
2319  this->height = frame->size[1];
2320  unsigned int size = this->width * this->height;
2321 
2322  if ((I.getWidth() != this->width) || (I.getHeight() != this->height))
2323  I.resize(this->height, this->width);
2324 
2325  switch (frame->color_coding) {
2326  case DC1394_COLOR_CODING_MONO8:
2327  case DC1394_COLOR_CODING_RAW8:
2328  memcpy(I.bitmap, (unsigned char *)frame->image, size * sizeof(unsigned char));
2329  break;
2330  case DC1394_COLOR_CODING_MONO16:
2331  case DC1394_COLOR_CODING_RAW16:
2332  vpImageConvert::MONO16ToGrey((unsigned char *)frame->image, I.bitmap, size);
2333  break;
2334 
2335  case DC1394_COLOR_CODING_YUV411:
2336  vpImageConvert::YUV411ToGrey((unsigned char *)frame->image, I.bitmap, size);
2337  break;
2338 
2339  case DC1394_COLOR_CODING_YUV422:
2340  vpImageConvert::YUV422ToGrey((unsigned char *)frame->image, I.bitmap, size);
2341  break;
2342 
2343  case DC1394_COLOR_CODING_YUV444:
2344  vpImageConvert::YUV444ToGrey((unsigned char *)frame->image, I.bitmap, size);
2345  break;
2346 
2347  case DC1394_COLOR_CODING_RGB8:
2348  vpImageConvert::RGBToGrey((unsigned char *)frame->image, I.bitmap, size);
2349  break;
2350 
2351  default:
2352  close();
2353  vpERROR_TRACE("Format conversion not implemented. Acquisition failed.");
2354  throw(vpFrameGrabberException(vpFrameGrabberException::otherError, "Format conversion not implemented. "
2355  "Acquisition failed."));
2356  };
2357 
2358  return frame;
2359 }
2360 
2405 {
2406  uint64_t timestamp;
2407  uint32_t id;
2408 
2409  dc1394video_frame_t *frame;
2410 
2411  frame = dequeue(I, timestamp, id);
2412 
2413  return frame;
2414 }
2415 
2467 dc1394video_frame_t *vp1394TwoGrabber::dequeue(vpImage<vpRGBa> &I, uint64_t &timestamp, uint32_t &id)
2468 {
2469 
2470  open();
2471 
2472  dc1394video_frame_t *frame;
2473 
2474  frame = dequeue();
2475 
2476  // Timeval data structure providing the unix time
2477  // [microseconds] at which the frame was captured in the ring buffer.
2478  timestamp = frame->timestamp;
2479  id = frame->id;
2480 
2481  this->width = frame->size[0];
2482  this->height = frame->size[1];
2483  unsigned int size = this->width * this->height;
2484 
2485  if ((I.getWidth() != width) || (I.getHeight() != height))
2486  I.resize(height, width);
2487 
2488  switch (frame->color_coding) {
2489  case DC1394_COLOR_CODING_MONO8:
2490  case DC1394_COLOR_CODING_RAW8:
2491  vpImageConvert::GreyToRGBa((unsigned char *)frame->image, (unsigned char *)I.bitmap, size);
2492  break;
2493 
2494  case DC1394_COLOR_CODING_MONO16:
2495  case DC1394_COLOR_CODING_RAW16:
2496  vpImageConvert::MONO16ToRGBa((unsigned char *)frame->image, (unsigned char *)I.bitmap, size);
2497  break;
2498 
2499  case DC1394_COLOR_CODING_YUV411:
2500  vpImageConvert::YUV411ToRGBa((unsigned char *)frame->image, (unsigned char *)I.bitmap, size);
2501  break;
2502 
2503  case DC1394_COLOR_CODING_YUV422:
2504  vpImageConvert::YUV422ToRGBa((unsigned char *)frame->image, (unsigned char *)I.bitmap, size);
2505  break;
2506 
2507  case DC1394_COLOR_CODING_YUV444:
2508  vpImageConvert::YUV444ToRGBa((unsigned char *)frame->image, (unsigned char *)I.bitmap, size);
2509  break;
2510 
2511  case DC1394_COLOR_CODING_RGB8:
2512  vpImageConvert::RGBToRGBa((unsigned char *)frame->image, (unsigned char *)I.bitmap, size);
2513  break;
2514 
2515  default:
2516  close();
2517  vpERROR_TRACE("Format conversion not implemented. Acquisition failed.");
2518  throw(vpFrameGrabberException(vpFrameGrabberException::otherError, "Format conversion not implemented. "
2519  "Acquisition failed."));
2520  };
2521 
2522  return frame;
2523 }
2524 
2535 void vp1394TwoGrabber::enqueue(dc1394video_frame_t *frame)
2536 {
2537 
2538  if (!num_cameras) {
2539  close();
2540  vpERROR_TRACE("No camera found");
2542  }
2543 
2544  if (frame)
2545  dc1394_capture_enqueue(camera, frame);
2546 }
2547 
2562 {
2563  uint64_t timestamp;
2564  uint32_t id;
2565 
2566  dc1394video_frame_t *frame;
2567 
2568  frame = dequeue(I, timestamp, id);
2569  enqueue(frame);
2570 }
2571 
2590 void vp1394TwoGrabber::acquire(vpImage<unsigned char> &I, uint64_t &timestamp, uint32_t &id)
2591 {
2592  dc1394video_frame_t *frame;
2593 
2594  open();
2595  frame = dequeue(I, timestamp, id);
2596  enqueue(frame);
2597 }
2598 
2613 {
2614  uint64_t timestamp;
2615  uint32_t id;
2616  dc1394video_frame_t *frame;
2617 
2618  open();
2619  frame = dequeue(I, timestamp, id);
2620  enqueue(frame);
2621 }
2622 
2641 void vp1394TwoGrabber::acquire(vpImage<vpRGBa> &I, uint64_t &timestamp, uint32_t &id)
2642 {
2643  dc1394video_frame_t *frame;
2644 
2645  open();
2646  frame = dequeue();
2647  // Timeval data structure providing the unix time
2648  // [microseconds] at which the frame was captured in the ring buffer.
2649  timestamp = frame->timestamp;
2650  id = frame->id;
2651 
2652  this->width = frame->size[0];
2653  this->height = frame->size[1];
2654  unsigned int size = this->width * this->height;
2655 
2656  if ((I.getWidth() != width) || (I.getHeight() != height))
2657  I.resize(height, width);
2658 
2659  switch (frame->color_coding) {
2660  case DC1394_COLOR_CODING_MONO8:
2661  case DC1394_COLOR_CODING_RAW8:
2662  vpImageConvert::GreyToRGBa((unsigned char *)frame->image, (unsigned char *)I.bitmap, size);
2663  break;
2664 
2665  case DC1394_COLOR_CODING_YUV411:
2666  vpImageConvert::YUV411ToRGBa((unsigned char *)frame->image, (unsigned char *)I.bitmap, size);
2667  break;
2668 
2669  case DC1394_COLOR_CODING_YUV422:
2670  vpImageConvert::YUV422ToRGBa((unsigned char *)frame->image, (unsigned char *)I.bitmap, size);
2671  break;
2672 
2673  case DC1394_COLOR_CODING_YUV444:
2674  vpImageConvert::YUV444ToRGBa((unsigned char *)frame->image, (unsigned char *)I.bitmap, size);
2675  break;
2676 
2677  case DC1394_COLOR_CODING_RGB8:
2678  vpImageConvert::RGBToRGBa((unsigned char *)frame->image, (unsigned char *)I.bitmap, size);
2679  break;
2680 
2681  default:
2682  close();
2683  vpERROR_TRACE("Format conversion not implemented. Acquisition failed.");
2684  throw(vpFrameGrabberException(vpFrameGrabberException::otherError, "Format conversion not implemented. "
2685  "Acquisition failed."));
2686  };
2687 
2688  enqueue(frame);
2689 }
2690 
2707 void vp1394TwoGrabber::getWidth(unsigned int &w)
2708 {
2709  if (!num_cameras) {
2710  close();
2711  vpERROR_TRACE("No camera found");
2713  }
2714 
2715  w = this->width;
2716 }
2717 
2736 {
2737  if (!num_cameras) {
2738  close();
2739  vpERROR_TRACE("No camera found");
2741  }
2742 
2743  return this->width;
2744 }
2745 
2763 void vp1394TwoGrabber::getHeight(unsigned int &h)
2764 {
2765  if (!num_cameras) {
2766  close();
2767  vpERROR_TRACE("No camera found");
2769  }
2770 
2771  h = this->height;
2772 }
2791 {
2792  if (!num_cameras) {
2793  close();
2794  vpERROR_TRACE("No camera found");
2796  }
2797 
2798  return this->height;
2799 }
2800 
2807 {
2808  std::cout << "----------------------------------------------------------" << std::endl
2809  << "----- Information for camera " << camera_id << " -----" << std::endl
2810  << "----------------------------------------------------------" << std::endl;
2811 
2812 #ifdef VISP_HAVE_DC1394_CAMERA_ENUMERATE // new API > libdc1394-2.0.0-rc7
2813  dc1394_camera_print_info(camera, stdout);
2814 #elif defined VISP_HAVE_DC1394_FIND_CAMERAS // old API <= libdc1394-2.0.0-rc7
2815  dc1394_print_camera_info(camera);
2816 #endif
2817 
2818  dc1394featureset_t features;
2819 #ifdef VISP_HAVE_DC1394_CAMERA_ENUMERATE // new API > libdc1394-2.0.0-rc7
2820  if (dc1394_feature_get_all(camera, &features) != DC1394_SUCCESS)
2821 #elif defined VISP_HAVE_DC1394_FIND_CAMERAS // old API <= libdc1394-2.0.0-rc7
2822  if (dc1394_get_camera_feature_set(camera, &features) != DC1394_SUCCESS)
2823 #endif
2824  {
2825  close();
2826  vpERROR_TRACE("unable to get feature set for camera %d\n", camera_id);
2827  throw(vpFrameGrabberException(vpFrameGrabberException::initializationError, "Cannot get camera features"));
2828 
2829  }
2830  else {
2831 #ifdef VISP_HAVE_DC1394_CAMERA_ENUMERATE // new API > libdc1394-2.0.0-rc7
2832  dc1394_feature_print_all(&features, stdout);
2833 #elif defined VISP_HAVE_DC1394_FIND_CAMERAS // old API <= libdc1394-2.0.0-rc7
2834  dc1394_print_feature_set(&features);
2835 #endif
2836  }
2837  std::cout << "----------------------------------------------------------" << std::endl;
2838 }
2839 
2853 {
2854  std::string _str = "";
2855  dc1394video_mode_t _videomode = (dc1394video_mode_t)videomode;
2856 
2857  if ((_videomode >= DC1394_VIDEO_MODE_MIN) && (_videomode <= DC1394_VIDEO_MODE_MAX)) {
2858  _str = strVideoMode[_videomode - DC1394_VIDEO_MODE_MIN];
2859  }
2860  else {
2861  vpCERROR << "The video mode " << (int)videomode << " is not supported by the camera" << std::endl;
2862  }
2863 
2864  return _str;
2865 }
2866 
2880 {
2881  std::string _str = "";
2882  dc1394framerate_t _fps = (dc1394framerate_t)fps;
2883 
2884  if ((_fps >= DC1394_FRAMERATE_MIN) && (_fps <= DC1394_FRAMERATE_MAX)) {
2885  _str = strFramerate[_fps - DC1394_FRAMERATE_MIN];
2886  }
2887  else {
2888  vpCERROR << "The framerate " << (int)fps << " is not supported by the camera" << std::endl;
2889  }
2890 
2891  return _str;
2892 }
2893 
2907 {
2908  std::string _str = "";
2909  dc1394color_coding_t _coding = (dc1394color_coding_t)colorcoding;
2910 
2911  if ((_coding >= DC1394_COLOR_CODING_MIN) && (_coding <= DC1394_COLOR_CODING_MAX)) {
2912  _str = strColorCoding[_coding - DC1394_COLOR_CODING_MIN];
2913 
2914  }
2915  else {
2916  vpCERROR << "The color coding " << (int)colorcoding << " is not supported by the camera" << std::endl;
2917  }
2918 
2919  return _str;
2920 }
2921 
2940 {
2942 
2943  for (int i = DC1394_VIDEO_MODE_MIN; i <= DC1394_VIDEO_MODE_MAX; i++) {
2944  _id = (vp1394TwoVideoModeType)i;
2945  if (videomode.compare(videoMode2string(_id)) == 0)
2946  return _id;
2947  };
2948 
2949  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "The required videomode is not valid"));
2950 
2951  return (vp1394TwoVideoModeType)0;
2952 }
2953 
2972 {
2974 
2975  for (int i = DC1394_FRAMERATE_MIN; i <= DC1394_FRAMERATE_MAX; i++) {
2976  _id = (vp1394TwoFramerateType)i;
2977  if (framerate.compare(framerate2string(_id)) == 0)
2978  return _id;
2979  };
2980 
2981  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "The required framerate is not valid"));
2982 
2983  return (vp1394TwoFramerateType)0;
2984 }
2985 
3004 {
3006 
3007  for (int i = DC1394_COLOR_CODING_MIN; i <= DC1394_COLOR_CODING_MAX; i++) {
3008  _id = (vp1394TwoColorCodingType)i;
3009  if (colorcoding.compare(colorCoding2string(_id)) == 0)
3010  return _id;
3011  };
3012 
3013  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "The required color coding is not valid"));
3014 
3015  return (vp1394TwoColorCodingType)0;
3016 }
3017 
3054 {
3055  for (unsigned int i = 0; i < num_cameras; i++) {
3056  if (camIsOpen[i]) {
3057  camera = cameras[i];
3058  setTransmission(DC1394_OFF);
3059  setCapture(DC1394_OFF);
3060  }
3061  }
3062 #ifdef VISP_HAVE_DC1394_CAMERA_ENUMERATE // new API > libdc1394-2.0.0-rc7
3063  setCamera(camera_id);
3064  // free the other cameras
3065  for (unsigned int i = 0; i < num_cameras; i++) {
3066  if (i != camera_id)
3067  dc1394_camera_free(cameras[i]);
3068  }
3069 
3070  printf("Resetting bus...\n");
3071  dc1394_reset_bus(camera);
3072 
3073  dc1394_camera_free(camera);
3074  dc1394_free(d);
3075  d = nullptr;
3076  // if (cameras != nullptr)
3077  delete[] cameras;
3078  cameras = nullptr;
3079 #elif defined VISP_HAVE_DC1394_FIND_CAMERAS // old API <= libdc1394-2.0.0-rc7
3080 
3081  setCamera(camera_id);
3082  // free the other cameras
3083  for (unsigned int i = 0; i < num_cameras; i++) {
3084  if (i != camera_id)
3085  dc1394_free_camera(cameras[i]);
3086  }
3087  free(cameras);
3088  cameras = nullptr;
3089 
3090  dc1394_reset_bus(camera);
3091  dc1394_free_camera(camera);
3092 
3093 #endif
3094  if (camIsOpen != nullptr)
3095  delete[] camIsOpen;
3096  camIsOpen = nullptr;
3097 
3098  num_cameras = 0;
3099 
3100  init = false;
3101  vpTime::wait(1000);
3102  initialize(false);
3103 }
3104 
3135 void vp1394TwoGrabber::setPanControl(unsigned int panControlValue)
3136 {
3137  open();
3138  if (!num_cameras) {
3139  close();
3140  vpERROR_TRACE("No camera found");
3142  }
3143  uint64_t offset = 0x884;
3144  uint32_t value = 0x82000000 + (uint32_t)panControlValue;
3145  dc1394error_t err;
3146  err = dc1394_set_control_register(camera, offset, value);
3147  if (err != DC1394_SUCCESS) {
3148  vpERROR_TRACE("Unable to set PAN register");
3149  close();
3150  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Unable to set PAN register"));
3151  }
3152 }
3153 
3171 {
3172  if (!num_cameras) {
3173  close();
3174  vpERROR_TRACE("No camera found");
3176  }
3177 
3178  uint32_t value;
3179  dc1394feature_t feature = DC1394_FEATURE_BRIGHTNESS; // = (dc1394feature_t)param;
3180  switch (param) {
3181  case vpFEATURE_BRIGHTNESS:
3182  feature = DC1394_FEATURE_BRIGHTNESS;
3183  break;
3184  case vpFEATURE_EXPOSURE:
3185  feature = DC1394_FEATURE_EXPOSURE;
3186  break;
3187  case vpFEATURE_SHARPNESS:
3188  feature = DC1394_FEATURE_SHARPNESS;
3189  break;
3190  // vpFEATURE_WHITE_BALANCE = DC1394_FEATURE_WHITE_BALANCE,
3191  case vpFEATURE_HUE:
3192  feature = DC1394_FEATURE_HUE;
3193  break;
3194  case vpFEATURE_SATURATION:
3195  feature = DC1394_FEATURE_SATURATION;
3196  break;
3197  case vpFEATURE_GAMMA:
3198  feature = DC1394_FEATURE_GAMMA;
3199  break;
3200  case vpFEATURE_SHUTTER:
3201  feature = DC1394_FEATURE_SHUTTER;
3202  break;
3203  case vpFEATURE_GAIN:
3204  feature = DC1394_FEATURE_GAIN;
3205  break;
3206  case vpFEATURE_IRIS:
3207  feature = DC1394_FEATURE_IRIS;
3208  break;
3209  // vpFEATURE_FOCUS = DC1394_FEATURE_FOCUS,
3210  // vpFEATURE_TEMPERATURE = DC1394_FEATURE_TEMPERATURE,
3211  // vpFEATURE_TRIGGER = DC1394_FEATURE_TRIGGER,
3212  // vpFEATURE_TRIGGER_DELAY = DC1394_FEATURE_TRIGGER_DELAY,
3213  // vpFEATURE_WHITE_SHADING = DC1394_FEATURE_WHITE_SHADING,
3214  // vpFEATURE_FRAME_RATE = DC1394_FEATURE_FRAME_RATE,
3215  // vpFEATURE_ZOOM = DC1394_FEATURE_ZOOM,
3216  // vpFEATURE_PAN = DC1394_FEATURE_PAN,
3217  // vpFEATURE_TILT = DC1394_FEATURE_TILT,
3218  // vpFEATURE_OPTICAL_FILTER = DC1394_FEATURE_OPTICAL_FILTER,
3219  // vpFEATURE_CAPTURE_SIZE = DC1394_FEATURE_CAPTURE_SIZE,
3220  // vpFEATURE_CAPTURE_QUALITY = DC1394_FEATURE_CAPTURE_QUALITY
3221  }
3222 
3223  dc1394error_t err;
3224  err = dc1394_feature_get_value(camera, feature, &value);
3225  if (err != DC1394_SUCCESS) {
3226  vpERROR_TRACE("Unable to get the information");
3227  close();
3228  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Unable to get the information"));
3229  }
3230  return (unsigned int)value;
3231 }
3232 
3255 {
3256  if (!num_cameras) {
3257  close();
3258  vpERROR_TRACE("No camera found");
3260  }
3261  uint32_t value = (uint32_t)val;
3262  dc1394feature_t feature = DC1394_FEATURE_BRIGHTNESS; // = (dc1394feature_t)param;
3263  switch (param) {
3264  case vpFEATURE_BRIGHTNESS:
3265  feature = DC1394_FEATURE_BRIGHTNESS;
3266  break;
3267  case vpFEATURE_EXPOSURE:
3268  feature = DC1394_FEATURE_EXPOSURE;
3269  break;
3270  case vpFEATURE_SHARPNESS:
3271  feature = DC1394_FEATURE_SHARPNESS;
3272  break;
3273  // vpFEATURE_WHITE_BALANCE = DC1394_FEATURE_WHITE_BALANCE,
3274  case vpFEATURE_HUE:
3275  feature = DC1394_FEATURE_HUE;
3276  break;
3277  case vpFEATURE_SATURATION:
3278  feature = DC1394_FEATURE_SATURATION;
3279  break;
3280  case vpFEATURE_GAMMA:
3281  feature = DC1394_FEATURE_GAMMA;
3282  break;
3283  case vpFEATURE_SHUTTER:
3284  feature = DC1394_FEATURE_SHUTTER;
3285  break;
3286  case vpFEATURE_GAIN:
3287  feature = DC1394_FEATURE_GAIN;
3288  break;
3289  case vpFEATURE_IRIS:
3290  feature = DC1394_FEATURE_IRIS;
3291  break;
3292  // vpFEATURE_FOCUS = DC1394_FEATURE_FOCUS,
3293  // vpFEATURE_TEMPERATURE = DC1394_FEATURE_TEMPERATURE,
3294  // vpFEATURE_TRIGGER = DC1394_FEATURE_TRIGGER,
3295  // vpFEATURE_TRIGGER_DELAY = DC1394_FEATURE_TRIGGER_DELAY,
3296  // vpFEATURE_WHITE_SHADING = DC1394_FEATURE_WHITE_SHADING,
3297  // vpFEATURE_FRAME_RATE = DC1394_FEATURE_FRAME_RATE,
3298  // vpFEATURE_ZOOM = DC1394_FEATURE_ZOOM,
3299  // vpFEATURE_PAN = DC1394_FEATURE_PAN,
3300  // vpFEATURE_TILT = DC1394_FEATURE_TILT,
3301  // vpFEATURE_OPTICAL_FILTER = DC1394_FEATURE_OPTICAL_FILTER,
3302  // vpFEATURE_CAPTURE_SIZE = DC1394_FEATURE_CAPTURE_SIZE,
3303  // vpFEATURE_CAPTURE_QUALITY = DC1394_FEATURE_CAPTURE_QUALITY
3304  }
3305 
3306  dc1394error_t err;
3307  dc1394bool_t hasManualMode = DC1394_FALSE;
3308  dc1394feature_modes_t modesAvailable;
3309 
3310  // test wether we can set the shutter value (manual mode available or not)
3311  err = dc1394_feature_get_modes(camera, feature, &modesAvailable);
3312  if (err != DC1394_SUCCESS) {
3313  vpERROR_TRACE("Unable to detect the manual mode information");
3314  close();
3315  throw(
3316  vpFrameGrabberException(vpFrameGrabberException::settingError, "Unable to detect the manual mode information"));
3317  }
3318 
3319  for (unsigned int i = 0; i < modesAvailable.num; i++) {
3320  if (modesAvailable.modes[i] == DC1394_FEATURE_MODE_MANUAL) {
3321  hasManualMode = DC1394_TRUE;
3322  }
3323  }
3324 
3325  if (hasManualMode == DC1394_TRUE) {
3326 
3327  if (!isDataModified[camera_id]) { // to ensure we save the first mode
3328  // even after several set
3329  /* we update the structure */
3330  updateDataCamToStruct();
3331  err = dc1394_feature_get_mode(camera, feature, &(initialShutterMode[camera_id]));
3332  if (err != DC1394_SUCCESS) {
3333  vpERROR_TRACE("Unable to get the initial mode");
3334  close();
3335  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Unable to get the initial mode"));
3336  }
3337  isDataModified[camera_id] = true;
3338  }
3339 
3340  dc1394feature_mode_t manualMode = DC1394_FEATURE_MODE_MANUAL;
3341  err = dc1394_feature_set_mode(camera, feature, manualMode);
3342  if (err != DC1394_SUCCESS) {
3343  vpERROR_TRACE("Unable to set the muanual mode");
3344  close();
3345  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Unable to set the manual mode"));
3346  }
3347  err = dc1394_feature_set_value(camera, feature, value);
3348  if (err != DC1394_SUCCESS) {
3349  vpERROR_TRACE("Unable to set the shutter information");
3350  close();
3351  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Unable to set the shutter information"));
3352  }
3353  }
3354  else {
3355  vpERROR_TRACE("The camera does not have a manual mode.\nCannot change the value");
3356  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "The camera does not have a manual mode"));
3357  }
3358 }
3366 void vp1394TwoGrabber::getGuid(uint64_t &guid)
3367 {
3368  if (!num_cameras) {
3369  close();
3370  vpERROR_TRACE("No camera found");
3372  }
3373 
3374  guid = camera->guid;
3375 }
3376 
3385 {
3386  if (!num_cameras) {
3387  close();
3388  vpERROR_TRACE("No camera found");
3390  }
3391 
3392  return camera->guid;
3393 }
3394 
3399 inline void vp1394TwoGrabber::updateDataCamToStruct()
3400 {
3401  dataCam[camera_id].brightness = getParameterValue(vpFEATURE_BRIGHTNESS);
3402  dataCam[camera_id].exposure = getParameterValue(vpFEATURE_EXPOSURE);
3403  dataCam[camera_id].sharpness = getParameterValue(vpFEATURE_SHARPNESS);
3404  dataCam[camera_id].hue = getParameterValue(vpFEATURE_HUE);
3405  dataCam[camera_id].saturation = getParameterValue(vpFEATURE_SATURATION);
3406  dataCam[camera_id].gamma = getParameterValue(vpFEATURE_GAMMA);
3407  dataCam[camera_id].shutter = getParameterValue(vpFEATURE_SHUTTER);
3408  dataCam[camera_id].gain = getParameterValue(vpFEATURE_GAIN);
3409  dataCam[camera_id].iris = getParameterValue(vpFEATURE_IRIS);
3410 }
3411 
3416 inline void vp1394TwoGrabber::updateDataStructToCam()
3417 {
3418  setParameterValue(vpFEATURE_BRIGHTNESS, dataCam[camera_id].brightness);
3419  setParameterValue(vpFEATURE_EXPOSURE, dataCam[camera_id].exposure);
3420  setParameterValue(vpFEATURE_SHARPNESS, dataCam[camera_id].sharpness);
3421  setParameterValue(vpFEATURE_HUE, dataCam[camera_id].hue);
3422  setParameterValue(vpFEATURE_SATURATION, dataCam[camera_id].saturation);
3423  setParameterValue(vpFEATURE_GAMMA, dataCam[camera_id].gamma);
3424  setParameterValue(vpFEATURE_SHUTTER, dataCam[camera_id].shutter);
3425  setParameterValue(vpFEATURE_GAIN, dataCam[camera_id].gain);
3426  setParameterValue(vpFEATURE_IRIS, dataCam[camera_id].iris);
3427 }
3428 
3450 {
3451  this->acquire(I);
3452  return *this;
3453 }
3454 
3475 {
3476  this->acquire(I);
3477  return *this;
3478 }
3479 END_VISP_NAMESPACE
3480 #elif !defined(VISP_BUILD_SHARED_LIBS)
3481 // Work around to avoid warning: libvisp_sensor.a(vp1394TwoGrabber.cpp.o) has
3482 // no symbols
3483 void dummy_vp1394TwoGrabber() { };
3484 #endif
Class for firewire ieee1394 video devices using libdc1394-2.x api.
void setAutoShutter(bool enable=true)
static const char * strColorCoding[DC1394_COLOR_CODING_NUM]
void getVideoMode(vp1394TwoVideoModeType &videomode)
void setAutoGain(bool enable=true)
void setParameterValue(vp1394TwoParametersType param, unsigned int val)
static std::string colorCoding2string(vp1394TwoColorCodingType colorcoding)
void setRingBufferSize(unsigned int size)
void getFramerate(vp1394TwoFramerateType &fps)
uint32_t getFramerateSupported(vp1394TwoVideoModeType videomode, std::list< vp1394TwoFramerateType > &fps)
void acquire(vpImage< unsigned char > &I)
void setPanControl(unsigned int panControlValue)
static vp1394TwoColorCodingType string2colorCoding(std::string colorcoding)
static vp1394TwoVideoModeType string2videoMode(std::string videomode)
void setColorCoding(vp1394TwoColorCodingType coding)
bool isVideoModeFormat7(vp1394TwoVideoModeType videomode)
void setVideoMode(vp1394TwoVideoModeType videomode)
unsigned int getRingBufferSize() const
void setFormat7ROI(unsigned int left=0, unsigned int top=0, unsigned int width=0, unsigned int height=0)
void getAutoShutter(unsigned int &minvalue, unsigned int &maxvalue)
unsigned int getNumCameras() const
void setCamera(uint64_t camera)
unsigned int getWidth()
static vp1394TwoFramerateType string2framerate(std::string fps)
void enqueue(dc1394video_frame_t *frame)
vp1394TwoGrabber & operator>>(vpImage< unsigned char > &I)
unsigned int getParameterValue(vp1394TwoParametersType param)
void getAutoGain(unsigned int &minvalue, unsigned int &maxvalue)
void getColorCoding(vp1394TwoColorCodingType &coding)
void setIsoTransmissionSpeed(vp1394TwoIsoSpeedType isospeed)
uint32_t getColorCodingSupported(vp1394TwoVideoModeType videomode, std::list< vp1394TwoColorCodingType > &codings)
void setFramerate(vp1394TwoFramerateType fps)
static std::string framerate2string(vp1394TwoFramerateType fps)
unsigned int getHeight()
bool isColorCodingSupported(vp1394TwoVideoModeType videomode, vp1394TwoColorCodingType coding)
bool isFramerateSupported(vp1394TwoVideoModeType videomode, vp1394TwoFramerateType fps)
dc1394video_frame_t * dequeue()
static std::string videoMode2string(vp1394TwoVideoModeType videomode)
static const char * strVideoMode[DC1394_VIDEO_MODE_NUM]
VP_EXPLICIT vp1394TwoGrabber(bool reset=true)
bool isVideoModeSupported(vp1394TwoVideoModeType videomode)
uint32_t getVideoModeSupported(std::list< vp1394TwoVideoModeType > &videomodes)
void open(vpImage< unsigned char > &I)
static const char * strFramerate[DC1394_FRAMERATE_NUM]
Error that can be emitted by the vpFrameGrabber class and its derivates.
@ settingError
Grabber settings error.
@ initializationError
Grabber initialization error.
@ otherError
Grabber returned an other error.
unsigned int height
Number of rows in the image.
bool init
Set to true if the frame grabber has been initialized.
unsigned int width
Number of columns in the image.
static void YUV411ToGrey(unsigned char *yuv, unsigned char *grey, unsigned int size)
static void MONO16ToGrey(unsigned char *grey16, unsigned char *grey, unsigned int size)
static void YUV422ToGrey(unsigned char *yuv, unsigned char *grey, unsigned int size)
static void YUV411ToRGBa(unsigned char *yuv, unsigned char *rgba, unsigned int size)
static void GreyToRGBa(unsigned char *grey, unsigned char *rgba, unsigned int width, unsigned int height)
static void MONO16ToRGBa(unsigned char *grey16, unsigned char *rgba, unsigned int size)
static void RGBToGrey(unsigned char *rgb, unsigned char *grey, unsigned int width, unsigned int height, bool flip=false)
static void RGBToRGBa(unsigned char *rgb, unsigned char *rgba, unsigned int size)
static void YUV422ToRGBa(unsigned char *yuv, unsigned char *rgba, unsigned int size)
static void YUV444ToRGBa(unsigned char *yuv, unsigned char *rgba, unsigned int size)
static void YUV444ToGrey(unsigned char *yuv, unsigned char *grey, unsigned int size)
unsigned int getWidth() const
Definition: vpImage.h:242
void resize(unsigned int h, unsigned int w)
resize the image : Image initialization
Definition: vpImage.h:544
Type * bitmap
points toward the bitmap
Definition: vpImage.h:135
unsigned int getHeight() const
Definition: vpImage.h:181
VISP_EXPORT int wait(double t0, double t)