Visual Servoing Platform  version 3.5.1 under development (2023-03-14)
vp1394TwoGrabber.cpp
1 /****************************************************************************
2  *
3  * ViSP, open source Visual Servoing Platform software.
4  * Copyright (C) 2005 - 2019 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 http://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  * Authors:
35  * Fabien Spindler
36  *
37  *****************************************************************************/
38 
44 #include <iostream>
45 
46 #include <visp3/core/vpConfig.h>
47 
48 /*
49  * Interface with libdc1394 2.x
50  */
51 #if defined(VISP_HAVE_DC1394)
52 #include <unistd.h>
53 
54 #include <visp3/core/vpFrameGrabberException.h>
55 #include <visp3/core/vpImageConvert.h>
56 #include <visp3/core/vpTime.h>
57 #include <visp3/sensor/vp1394TwoGrabber.h>
58 
59 const char *vp1394TwoGrabber::strVideoMode[DC1394_VIDEO_MODE_NUM] = {
60  "MODE_160x120_YUV444", "MODE_320x240_YUV422", "MODE_640x480_YUV411", "MODE_640x480_YUV422",
61  "MODE_640x480_RGB8", "MODE_640x480_MONO8", "MODE_640x480_MONO16", "MODE_800x600_YUV422",
62  "MODE_800x600_RGB8", "MODE_800x600_MONO8", "MODE_1024x768_YUV422", "MODE_1024x768_RGB8",
63  "MODE_1024x768_MONO8", "MODE_800x600_MONO16", "MODE_1024x768_MONO16", "MODE_1280x960_YUV422",
64  "MODE_1280x960_RGB8", "MODE_1280x960_MONO8", "MODE_1600x1200_YUV422", "MODE_1600x1200_RGB8",
65  "MODE_1600x1200_MONO8", "MODE_1280x960_MONO16", "MODE_1600x1200_MONO16", "MODE_EXIF",
66  "MODE_FORMAT7_0", "MODE_FORMAT7_1", "MODE_FORMAT7_2", "MODE_FORMAT7_3",
67  "MODE_FORMAT7_4", "MODE_FORMAT7_5", "MODE_FORMAT7_6", "MODE_FORMAT7_7"};
68 
69 const char *vp1394TwoGrabber::strFramerate[DC1394_FRAMERATE_NUM] = {
70  "FRAMERATE_1_875", "FRAMERATE_3_75", "FRAMERATE_7_5", "FRAMERATE_15",
71  "FRAMERATE_30", "FRAMERATE_60", "FRAMERATE_120", "FRAMERATE_240"};
72 
73 const char *vp1394TwoGrabber::strColorCoding[DC1394_COLOR_CODING_NUM] = {
74  "COLOR_CODING_MONO8", "COLOR_CODING_YUV411", "COLOR_CODING_YUV422", "COLOR_CODING_YUV444",
75  "COLOR_CODING_RGB8", "COLOR_CODING_MONO16", "COLOR_CODING_RGB16", "COLOR_CODING_MONO16S",
76  "COLOR_CODING_RGB16S", "COLOR_CODING_RAW8", "COLOR_CODING_RAW16",
77 };
78 
124  : camera(NULL), cameras(NULL), num_cameras(0), camera_id(0), verbose(false), camIsOpen(NULL),
125  num_buffers(4), // ring buffer size
126  isDataModified(NULL), initialShutterMode(NULL), dataCam(NULL)
127 #ifdef VISP_HAVE_DC1394_CAMERA_ENUMERATE // new API > libdc1394-2.0.0-rc7
128  ,
129  d(NULL), list(NULL)
130 #endif
131 {
132  // protected members
133  width = height = 0;
134 
135  // private members
136  init = false;
137 
138  reset = false;
139  initialize(reset);
140 
141  // open();
142 }
143 
154 {
155  /* if(num_cameras >= 1){
156  delete[] isDataModified;
157  delete[] initialShutterMode;
158  delete[] dataCam;
159  }*/
160  close();
161 }
162 
281 void vp1394TwoGrabber::setCamera(uint64_t cam_id)
282 {
283  // Suppose that if camera_id is a camera GUID, this value is greater
284  // than the number of cameras connected to the bus
285  if (cam_id >= num_cameras) {
286  // Check if camera_id is a camera guid
287  bool is_guid = false;
288  // check if the camera_id is a guid
289  for (unsigned int i = 0; i < num_cameras; i++) {
290  if (cameras[i]->guid == cam_id) {
291  this->camera_id = i;
292  is_guid = true;
293  break;
294  }
295  }
296  if (is_guid == false) {
297  std::cout << "Error: The camera with guid 0x" << std::hex << cam_id << " is not present" << std::endl;
298  std::cout << num_cameras << " camera(s) connected" << std::endl;
299  for (unsigned int i = 0; i < num_cameras; i++) {
300  std::cout << " - camera " << i << " with guid 0x" << std::hex << cameras[i]->guid << std::endl;
301  }
302  close();
303  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "The required camera is not present"));
304  }
305  } else {
306  this->camera_id = (unsigned int)cam_id; // The input cam_id is not a
307  // uint64_t guid, but the index of
308  // the camera
309  }
310 
311  // create a pointer to the working camera
312  camera = cameras[this->camera_id];
313 }
314 
329 void vp1394TwoGrabber::getCamera(uint64_t &cam_id)
330 {
331  if (num_cameras) {
332  cam_id = this->camera_id;
333  } else {
334  close();
335  vpERROR_TRACE("No cameras found");
337  }
338 }
339 
355 {
356  if (num_cameras) {
357  return this->camera_id;
358  } else {
359  close();
360  vpERROR_TRACE("No cameras found");
362  }
363 }
364 
372 void vp1394TwoGrabber::getNumCameras(unsigned int &ncameras) const
373 {
374  if (!num_cameras) {
375  vpCTRACE << "No camera found..." << std::endl;
376  ncameras = 0;
377  }
378 
379  ncameras = num_cameras;
380 }
381 
390 {
391  unsigned int ncameras = 0;
392  if (!num_cameras) {
393  vpCTRACE << "No camera found..." << std::endl;
394  ncameras = 0;
395  }
396 
397  ncameras = num_cameras;
398  return ncameras;
399 }
400 
446 {
447  open();
448  if (!num_cameras) {
449  close();
451  }
452  if (!isVideoModeSupported(videomode)) {
453  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Video mode not supported by camera %d",
454  camera_id));
455  }
456  // Stop dma capture if started
457  setTransmission(DC1394_OFF);
458  setCapture(DC1394_OFF);
459 
460  if (dc1394_video_set_mode(camera, (dc1394video_mode_t)videomode) != DC1394_SUCCESS) {
461  close();
462  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Can't set video mode"));
463  }
464 
465  setCapture(DC1394_ON);
466  setTransmission(DC1394_ON);
467 
468  // Updates image size from new video mode
469  if (dc1394_get_image_size_from_video_mode(camera, (dc1394video_mode_t)videomode, &this->width, &this->height) !=
470  DC1394_SUCCESS) {
471 
472  close();
473  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Can't get image size"));
474  }
475 }
476 
494 {
495  if (!num_cameras) {
496  close();
497  vpERROR_TRACE("No camera found");
499  }
500 
501  dc1394video_mode_t _videomode;
502  if (dc1394_video_get_mode(camera, &_videomode) != DC1394_SUCCESS) {
503 
504  close();
505  vpERROR_TRACE("Can't get current video mode");
506  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Can't get current video mode"));
507  }
508  videomode = (vp1394TwoVideoModeType)_videomode;
509 }
510 
528 uint32_t vp1394TwoGrabber::getVideoModeSupported(std::list<vp1394TwoVideoModeType> &videomodes)
529 {
530  // Refresh the list of supported modes
531  videomodes.clear();
532 
533  if (!num_cameras) {
534  close();
535  vpERROR_TRACE("No camera found");
537  }
538  dc1394video_modes_t _videomodes;
539 
540  // get video modes:
541  if (dc1394_video_get_supported_modes(camera, &_videomodes) != DC1394_SUCCESS) {
542 
543  close();
544  vpERROR_TRACE("Can't get video modes");
545  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Can't get video modes"));
546  }
547 
548  // parse the video modes to add in the list
549  for (unsigned i = 0; i < _videomodes.num; i++) {
550  vp1394TwoVideoModeType _mode = (vp1394TwoVideoModeType)_videomodes.modes[i];
551  videomodes.push_back(_mode);
552  }
553 
554  // return the number of available video modes
555  return _videomodes.num;
556 }
573 {
574  if (!num_cameras) {
575  close();
576  vpERROR_TRACE("No camera found");
578  }
579  dc1394video_modes_t _videomodes;
580 
581  // get video modes:
582  if (dc1394_video_get_supported_modes(camera, &_videomodes) != DC1394_SUCCESS) {
583 
584  close();
585  vpERROR_TRACE("Can't get video modes");
586  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Can't get video modes"));
587  }
588 
589  // parse the video modes to check with the desired
590  for (unsigned i = 0; i < _videomodes.num; i++) {
591  if ((vp1394TwoVideoModeType)_videomodes.modes[i] == videomode)
592  return true;
593  }
594  return false;
595 }
596 
610 {
611 
612  if (dc1394_is_video_mode_scalable((dc1394video_mode_t)videomode))
613  return true;
614 
615  return false;
616 }
617 
634 {
636  getColorCoding(coding);
637 
638  switch (coding) {
642  case vpCOLOR_CODING_RAW8:
644  return false;
648  case vpCOLOR_CODING_RGB8:
651  return true;
652  }
653  return false;
654 }
655 
681 {
682  open();
683  if (!num_cameras) {
684  close();
686  }
687 
688  vp1394TwoVideoModeType cur_videomode;
689  getVideoMode(cur_videomode);
690  if (isVideoModeFormat7(cur_videomode))
691  return;
692 
693  if (!isFramerateSupported(cur_videomode, fps)) {
694  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Framerate not supported by camera %d",
695  camera_id));
696  }
697 
698  // Stop dma capture if started
699  setTransmission(DC1394_OFF);
700  setCapture(DC1394_OFF);
701 
702  if (dc1394_video_set_framerate(camera, (dc1394framerate_t)fps) != DC1394_SUCCESS) {
703 
704  close();
705  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Can't set framerate"));
706  }
707 
708  setCapture(DC1394_ON);
709  setTransmission(DC1394_ON);
710 }
711 
729 {
730  if (!num_cameras) {
731  close();
732  vpERROR_TRACE("No camera found");
734  }
735  dc1394framerate_t _fps;
736  if (dc1394_video_get_framerate(camera, &_fps) != DC1394_SUCCESS) {
737 
738  close();
739  vpERROR_TRACE("Can't get current framerate");
740  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Can't get current framerate"));
741  }
742  fps = (vp1394TwoFramerateType)_fps;
743 }
744 
776 uint32_t vp1394TwoGrabber::getFramerateSupported(vp1394TwoVideoModeType mode, std::list<vp1394TwoFramerateType> &fps)
777 {
778  if (!num_cameras) {
779  close();
780  vpERROR_TRACE("No camera found");
782  }
783 
784  // Refresh the list of supported framerates
785  fps.clear();
786 
787  switch (mode) {
788  // Framerate not available for:
789  // - vpVIDEO_MODE_EXIF ie Format_6
790  // - vpVIDEO_MODE_FORMAT7... ie the Format_7
791  case vpVIDEO_MODE_EXIF:
800  return 0;
801  break;
802  default: {
803  dc1394framerates_t _fps;
804  if (dc1394_video_get_supported_framerates(camera, (dc1394video_mode_t)mode, &_fps) != DC1394_SUCCESS) {
805  close();
806  vpERROR_TRACE("Could not query supported frametates for mode %d\n", mode);
807  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Could not query supported framerates"));
808  }
809  if (_fps.num == 0)
810  return 0;
811 
812  for (unsigned int i = 0; i < _fps.num; i++)
813  fps.push_back((vp1394TwoFramerateType)_fps.framerates[i]);
814 
815  return _fps.num;
816  } break;
817  }
818 }
853 {
854  if (!num_cameras) {
855  close();
856  vpERROR_TRACE("No camera found");
858  }
859 
860  switch (mode) {
861  // Framerate not available for:
862  // - vpVIDEO_MODE_EXIF ie Format_6
863  // - vpVIDEO_MODE_FORMAT7... ie the Format_7
864  case vpVIDEO_MODE_EXIF:
873  return 0;
874  break;
875  default: {
876  dc1394framerates_t _fps;
877  if (dc1394_video_get_supported_framerates(camera, (dc1394video_mode_t)mode, &_fps) != DC1394_SUCCESS) {
878  close();
879  vpERROR_TRACE("Could not query supported frametates for mode %d\n", mode);
880  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Could not query supported framerates"));
881  }
882  if (_fps.num == 0)
883  return 0;
884 
885  for (unsigned int i = 0; i < _fps.num; i++) {
886  if (fps == (vp1394TwoFramerateType)_fps.framerates[i]) {
887  return true;
888  }
889  }
890  return false;
891  } break;
892  }
893 }
894 
943 {
944  if (!num_cameras) {
945  close();
947  }
948 
949  dc1394video_mode_t _videomode;
950  if (dc1394_video_get_mode(camera, &_videomode) != DC1394_SUCCESS) {
951 
952  close();
953  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Can't get current video mode"));
954  }
955 
956  if (!isColorCodingSupported((vp1394TwoVideoModeType)_videomode, coding)) {
957  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Color coding not supported by camera %d",
958  camera_id));
959  }
960 
961  // Format 7 video mode
962  if (dc1394_is_video_mode_scalable(_videomode)) {
963  setTransmission(DC1394_OFF);
964  setCapture(DC1394_OFF);
965 
966  if (dc1394_format7_set_color_coding(camera, _videomode, (dc1394color_coding_t)coding) != DC1394_SUCCESS) {
967 
968  close();
969  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Can't set color coding"));
970  }
971 
972  setCapture(DC1394_ON);
973  setTransmission(DC1394_ON);
974  }
975 }
976 
995 {
996  if (!num_cameras) {
997  close();
998  vpERROR_TRACE("No camera found");
1000  }
1001  dc1394video_mode_t _videomode;
1002  if (dc1394_video_get_mode(camera, &_videomode) != DC1394_SUCCESS) {
1003 
1004  close();
1005  vpERROR_TRACE("Can't get current video mode");
1006  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Can't get current video mode"));
1007  }
1008 
1009  dc1394color_coding_t _coding;
1010  if (dc1394_is_video_mode_scalable(_videomode)) {
1011  // Format 7 video mode
1012  if (dc1394_format7_get_color_coding(camera, _videomode, &_coding) != DC1394_SUCCESS) {
1013 
1014  close();
1015  vpERROR_TRACE("Can't get current color coding");
1016  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Can't query current color coding"));
1017  }
1018  } else if (dc1394_is_video_mode_still_image((dc1394video_mode_t)_videomode)) {
1019  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "No color coding for format 6 video mode"));
1020  } else {
1021  // Not Format 7 and not Format 6 video modes
1022  if (dc1394_get_color_coding_from_video_mode(camera, (dc1394video_mode_t)_videomode, &_coding) != DC1394_SUCCESS) {
1023  close();
1024  vpERROR_TRACE("Could not query supported color coding for mode %d\n", _videomode);
1025  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Can't query current color coding"));
1026  }
1027  }
1028  coding = (vp1394TwoColorCodingType)_coding;
1029 }
1030 
1053  std::list<vp1394TwoColorCodingType> &codings)
1054 {
1055  if (!num_cameras) {
1056  close();
1057  vpERROR_TRACE("No camera found");
1059  }
1060 
1061  // Refresh the list of supported framerates
1062  codings.clear();
1063 
1064  if (dc1394_is_video_mode_scalable((dc1394video_mode_t)mode)) {
1065  // Format 7 video mode
1066  dc1394color_codings_t _codings;
1067  if (dc1394_format7_get_color_codings(camera, (dc1394video_mode_t)mode, &_codings) != DC1394_SUCCESS) {
1068  close();
1069  vpERROR_TRACE("Could not query supported color codings for mode %d\n", mode);
1070  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Could not query supported color codings"));
1071  }
1072  if (_codings.num == 0)
1073  return 0;
1074 
1075  for (unsigned int i = 0; i < _codings.num; i++)
1076  codings.push_back((vp1394TwoColorCodingType)_codings.codings[i]);
1077 
1078  return _codings.num;
1079  } else if (dc1394_is_video_mode_still_image((dc1394video_mode_t)mode)) {
1080  // Format 6 video mode
1081  return 0;
1082  } else {
1083  // Not Format 7 and not Format 6 video modes
1084  dc1394color_coding_t _coding;
1085  if (dc1394_get_color_coding_from_video_mode(camera, (dc1394video_mode_t)mode, &_coding) != DC1394_SUCCESS) {
1086  close();
1087  vpERROR_TRACE("Could not query supported color coding for mode %d\n", mode);
1088  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Could not query supported color coding"));
1089  }
1090  codings.push_back((vp1394TwoColorCodingType)_coding);
1091  return 1;
1092  }
1093 }
1116 {
1117  if (!num_cameras) {
1118  close();
1119  vpERROR_TRACE("No camera found");
1121  }
1122 
1123  if (dc1394_is_video_mode_scalable((dc1394video_mode_t)mode)) {
1124  // Format 7 video mode
1125  dc1394color_codings_t _codings;
1126  if (dc1394_format7_get_color_codings(camera, (dc1394video_mode_t)mode, &_codings) != DC1394_SUCCESS) {
1127  close();
1128  vpERROR_TRACE("Could not query supported color codings for mode %d\n", mode);
1129  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Could not query supported color codings"));
1130  }
1131  if (_codings.num == 0)
1132  return 0;
1133 
1134  for (unsigned int i = 0; i < _codings.num; i++) {
1135  if (coding == (vp1394TwoColorCodingType)_codings.codings[i])
1136  return true;
1137  }
1138  return false;
1139  } else if (dc1394_is_video_mode_still_image((dc1394video_mode_t)mode)) {
1140  // Format 6 video mode
1141  return false;
1142  } else {
1143  // Not Format 7 and not Format 6 video modes
1144  dc1394color_coding_t _coding;
1145  if (dc1394_get_color_coding_from_video_mode(camera, (dc1394video_mode_t)mode, &_coding) != DC1394_SUCCESS) {
1146  close();
1147  vpERROR_TRACE("Could not query supported color coding for mode %d\n", mode);
1148  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Could not query supported color coding"));
1149  return false;
1150  }
1151  if (coding == (vp1394TwoColorCodingType)_coding)
1152  return true;
1153 
1154  return false;
1155  }
1156 }
1157 
1189 void vp1394TwoGrabber::setFormat7ROI(unsigned int left, unsigned int top, unsigned int w, unsigned int h)
1190 {
1191  open();
1192  if (!num_cameras) {
1193  close();
1194  vpERROR_TRACE("No camera found");
1196  }
1197 
1198  dc1394video_mode_t _videomode;
1199  if (dc1394_video_get_mode(camera, &_videomode) != DC1394_SUCCESS) {
1200 
1201  close();
1202  vpERROR_TRACE("Can't get current video mode");
1203  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Can't get current video mode"));
1204  }
1205  if (dc1394_is_video_mode_scalable(_videomode)) {
1206  // Stop dma capture if started
1207  setTransmission(DC1394_OFF);
1208  setCapture(DC1394_OFF);
1209  // Format 7 video mode
1210  unsigned int max_width, max_height;
1211  if (dc1394_format7_get_max_image_size(camera, _videomode, &max_width, &max_height) != DC1394_SUCCESS) {
1212 
1213  close();
1214  vpERROR_TRACE("Can't get format7 max image size");
1215  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Can't get format7 max image size"));
1216  }
1217 #if 0
1218  vpTRACE("left: %d top: %d width: %d height: %d", left, top,
1219  width == 0 ? DC1394_USE_MAX_AVAIL: w,
1220  height == 0 ? DC1394_USE_MAX_AVAIL : h);
1221  vpTRACE("max_width: %d max_height: %d", max_width, max_height);
1222 #endif
1223 
1224  if (left > max_width) {
1225  vpERROR_TRACE("Can't set format7 ROI");
1226  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Can't set format7 ROI"));
1227  }
1228  if (top > max_height) {
1229  vpERROR_TRACE("Can't set format7 ROI");
1230  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Can't set format7 ROI"));
1231  }
1232 
1233  int32_t roi_width;
1234  int32_t roi_height;
1235 
1236  if (w != 0) {
1237  // Check if roi width is acceptable (ie roi is contained in the image)
1238  if (w > (max_width - left))
1239  w = (max_width - left);
1240  roi_width = (int32_t)w;
1241  } else {
1242  roi_width = DC1394_USE_MAX_AVAIL;
1243  }
1244 
1245  if (h != 0) {
1246  // Check if roi height is acceptable (ie roi is contained in the image)
1247  if (h > (max_height - top))
1248  h = (max_height - top);
1249  roi_height = (int32_t)h;
1250  } else {
1251  roi_height = DC1394_USE_MAX_AVAIL;
1252  }
1253 
1254  if (dc1394_format7_set_roi(camera, _videomode,
1255  (dc1394color_coding_t)DC1394_QUERY_FROM_CAMERA, // color_coding
1256  DC1394_USE_MAX_AVAIL /*DC1394_QUERY_FROM_CAMERA*/
1257  , // bytes_per_packet
1258  (int32_t)left, // left
1259  (int32_t)top, // top
1260  roi_width, roi_height) != DC1394_SUCCESS) {
1261  close();
1262  vpERROR_TRACE("Can't set format7 roi");
1263  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Can't get current video mode"));
1264  }
1265  // Update the image size
1266  if (dc1394_format7_get_image_size(camera, _videomode, &this->width, &this->height) != DC1394_SUCCESS) {
1267  close();
1268  vpERROR_TRACE("Can't get format7 image size");
1269  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Can't get format7 image size"));
1270  }
1271 
1272  setCapture(DC1394_ON);
1273  setTransmission(DC1394_ON);
1274  }
1275 }
1290 void vp1394TwoGrabber::initialize(bool reset)
1291 {
1292  if (init == false) {
1293 // Find cameras
1294 #ifdef VISP_HAVE_DC1394_CAMERA_ENUMERATE // new API > libdc1394-2.0.0-rc7
1295  if (d != NULL)
1296  dc1394_free(d);
1297 
1298  d = dc1394_new();
1299  if (dc1394_camera_enumerate(d, &list) != DC1394_SUCCESS) {
1300  dc1394_camera_free_list(list);
1301  close();
1302  vpERROR_TRACE("Failed to enumerate cameras\n");
1303  throw(vpFrameGrabberException(vpFrameGrabberException::initializationError, "Failed to enumerate cameras"));
1304  }
1305 
1306  if (list->num == 0) {
1307  dc1394_camera_free_list(list);
1308  close();
1309  vpERROR_TRACE("No cameras found");
1311  }
1312 
1313  if (cameras != NULL)
1314  delete[] cameras;
1315 
1316  cameras = new dc1394camera_t *[list->num];
1317 
1318  num_cameras = 0;
1319 
1320  for (unsigned int i = 0; i < list->num; i++) {
1321  cameras[i] = dc1394_camera_new(d, list->ids[i].guid);
1322  if (!cameras[i]) {
1323  vpTRACE("Failed to initialize camera with guid \"%ld\"\n", list->ids[i].guid);
1324  continue;
1325  }
1326  // Update the number of working cameras
1327  num_cameras++;
1328  }
1329 
1330  if (reset) {
1331  // Reset the bus to make firewire working if the program was not
1332  // properly stopped by a CTRL-C. We reset here only the bus attached to
1333  // the first camera
1334  dc1394_reset_bus(cameras[0]);
1335  }
1336 
1337  // if (list != NULL)
1338  dc1394_camera_free_list(list);
1339  list = NULL;
1340 
1341 #elif defined VISP_HAVE_DC1394_FIND_CAMERAS // old API <= libdc1394-2.0.0-rc7
1342  if (cameras != NULL)
1343  free(cameras);
1344  cameras = NULL;
1345  int err = dc1394_find_cameras(&cameras, &num_cameras);
1346 
1347  if (err != DC1394_SUCCESS && err != DC1394_NO_CAMERA) {
1348  close();
1349  vpERROR_TRACE("Unable to look for cameras\n\n"
1350  "Please check \n"
1351  " - if the kernel modules `ieee1394',`raw1394' and "
1352  "`ohci1394' are loaded \n"
1353  " - if you have read/write access to /dev/raw1394\n\n");
1354  throw(vpFrameGrabberException(vpFrameGrabberException::initializationError, "Unable to look for cameras"));
1355  }
1356 #endif
1357 
1358  if (num_cameras == 0) {
1359  close();
1360  vpERROR_TRACE("No cameras found");
1362  }
1363 
1364  // allocation for the parameters
1365  isDataModified = new bool[num_cameras];
1366  for (unsigned int i = 0; i < num_cameras; i++)
1367  isDataModified[i] = false;
1368  initialShutterMode = new dc1394feature_mode_t[num_cameras];
1369  dataCam = new vpDc1394TwoCameraParametersData[num_cameras];
1370 
1371  if (camera_id >= num_cameras) {
1372  // Bad camera id
1373  close();
1374  vpERROR_TRACE("Bad camera id: %u", camera_id);
1375  vpERROR_TRACE("Only %u camera on the bus.", num_cameras);
1377  }
1378 
1379  if (verbose) {
1380  std::cout << "------ Bus information ------" << std::endl;
1381  std::cout << "Number of camera(s) on the bus : " << num_cameras << std::endl;
1382  std::cout << "-----------------------------" << std::endl;
1383  }
1384 
1385  if (camIsOpen != NULL)
1386  delete[] camIsOpen;
1387  camIsOpen = new bool[num_cameras];
1388  for (unsigned int i = 0; i < num_cameras; i++) {
1389  camIsOpen[i] = false;
1390  }
1391 
1392  init = true;
1393  }
1394 }
1405 {
1406  if (init == false)
1407  initialize(false);
1408  if (camIsOpen[camera_id] == false) {
1409  dc1394switch_t status = DC1394_OFF;
1410 
1411  //#ifdef VISP_HAVE_DC1394_CAMERA_ENUMERATE // new API >
1412  // libdc1394-2.0.0-rc7
1413  dc1394_video_get_transmission(cameras[camera_id], &status);
1414  if (status != DC1394_OFF) {
1415  //#endif
1416  if (dc1394_video_set_transmission(cameras[camera_id], DC1394_OFF) != DC1394_SUCCESS)
1417  vpTRACE("Could not stop ISO transmission");
1418  else {
1419  vpTime::wait(500);
1420  if (dc1394_video_get_transmission(cameras[camera_id], &status) != DC1394_SUCCESS)
1421  vpTRACE("Could get ISO status");
1422  else {
1423  if (status == DC1394_ON) {
1424  vpTRACE("ISO transmission refuses to stop");
1425  }
1426 #ifdef VISP_HAVE_DC1394_FIND_CAMERAS // old API <= libdc1394-2.0.0-rc7
1427  // No yet in the new API
1428  cameras[camera_id]->is_iso_on = status;
1429 #endif
1430  }
1431  //#ifdef VISP_HAVE_DC1394_CAMERA_ENUMERATE // new API >
1432  // libdc1394-2.0.0-rc7
1433  }
1434  //#endif
1435  }
1436  setCamera(camera_id);
1437  // setIsoSpeed(DC1394_ISO_SPEED_400);
1438  setCapture(DC1394_ON);
1439  setTransmission(DC1394_ON);
1440  camIsOpen[camera_id] = true;
1441  }
1442 }
1452 {
1453  if (init) {
1454  if (num_cameras) {
1455  for (unsigned int i = 0; i < num_cameras; i++) {
1456  if (camIsOpen[i]) {
1457  camera = cameras[i];
1458  this->camera_id = i; // set camera id for the function updateDataStructToCam
1459  setTransmission(DC1394_OFF);
1460  setCapture(DC1394_OFF);
1461  if (isDataModified[i]) {
1462  // reset values
1463  try {
1464  updateDataStructToCam();
1465  } catch (...) {
1466  }
1467  // reset mode (manual, auto, ...)
1468  if (dc1394_feature_set_mode(camera, DC1394_FEATURE_BRIGHTNESS, initialShutterMode[i]) != DC1394_SUCCESS ||
1469  dc1394_feature_set_mode(camera, DC1394_FEATURE_EXPOSURE, initialShutterMode[i]) != DC1394_SUCCESS ||
1470  dc1394_feature_set_mode(camera, DC1394_FEATURE_SHARPNESS, initialShutterMode[i]) != DC1394_SUCCESS ||
1471  dc1394_feature_set_mode(camera, DC1394_FEATURE_HUE, initialShutterMode[i]) != DC1394_SUCCESS ||
1472  dc1394_feature_set_mode(camera, DC1394_FEATURE_SATURATION, initialShutterMode[i]) != DC1394_SUCCESS ||
1473  dc1394_feature_set_mode(camera, DC1394_FEATURE_GAMMA, initialShutterMode[i]) != DC1394_SUCCESS ||
1474  dc1394_feature_set_mode(camera, DC1394_FEATURE_SHUTTER, initialShutterMode[i]) != DC1394_SUCCESS ||
1475  dc1394_feature_set_mode(camera, DC1394_FEATURE_GAIN, initialShutterMode[i]) != DC1394_SUCCESS ||
1476  dc1394_feature_set_mode(camera, DC1394_FEATURE_IRIS, initialShutterMode[i])) {
1477 
1478  vpERROR_TRACE("Unable to reset the initial mode");
1479  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Unable to reset the initial mode"));
1480  }
1481  }
1482  if (dc1394_camera_set_power(camera, DC1394_OFF) != DC1394_SUCCESS)
1483  std::cout << "Unable to turn camera off" << std::endl;
1484  }
1485 #ifdef VISP_HAVE_DC1394_CAMERA_ENUMERATE // new API > libdc1394-2.0.0-rc7
1486  dc1394_camera_free(cameras[i]);
1487 #elif defined VISP_HAVE_DC1394_FIND_CAMERAS // old API <= libdc1394-2.0.0-rc7
1488  dc1394_free_camera(cameras[i]);
1489 #endif
1490  }
1491  }
1492  if (camIsOpen != NULL) {
1493  delete[] camIsOpen;
1494  camIsOpen = NULL;
1495  }
1496 
1497 #ifdef VISP_HAVE_DC1394_CAMERA_ENUMERATE // new API > libdc1394-2.0.0-rc7
1498  if (cameras != NULL) {
1499  delete[] cameras;
1500  cameras = NULL;
1501  }
1502  if (d != NULL) {
1503  dc1394_free(d);
1504  d = NULL;
1505  }
1506 
1507 #elif defined VISP_HAVE_DC1394_FIND_CAMERAS // old API <= libdc1394-2.0.0-rc7
1508  if (cameras != NULL) {
1509  free(cameras);
1510  cameras = NULL;
1511  }
1512 #endif
1513 
1514  camIsOpen = NULL;
1515  num_cameras = 0;
1516 
1517  // remove data for the parameters
1518  if (isDataModified != NULL) {
1519  delete[] isDataModified;
1520  isDataModified = NULL;
1521  }
1522  if (initialShutterMode != NULL) {
1523  delete[] initialShutterMode;
1524  initialShutterMode = NULL;
1525  }
1526  if (dataCam != NULL) {
1527  delete[] dataCam;
1528  dataCam = NULL;
1529  }
1530 
1531  init = false;
1532  }
1533 }
1534 
1548 {
1549  if (size < 1) {
1550  close();
1551  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Could not set ring buffer size"));
1552  }
1553 
1554  if (size != num_buffers) {
1555  // We need to change the ring buffer size
1556  num_buffers = size;
1557  if (camIsOpen[camera_id]) {
1558  setCapture(DC1394_OFF);
1559  setCapture(DC1394_ON);
1560  }
1561  }
1562 }
1563 
1573 unsigned int vp1394TwoGrabber::getRingBufferSize() const { return num_buffers; }
1574 
1614 {
1615  if (!num_cameras) {
1616  close();
1617  vpERROR_TRACE("No camera found");
1619  }
1620 
1621  dc1394feature_mode_t mode;
1622  if (enable) {
1623  mode = DC1394_FEATURE_MODE_AUTO;
1624  } else {
1625  mode = DC1394_FEATURE_MODE_MANUAL;
1626  }
1627 
1628  if (dc1394_feature_set_power(camera, DC1394_FEATURE_SHUTTER, DC1394_ON) != DC1394_SUCCESS) {
1629  // vpERROR_TRACE("Cannot set shutter on. \n");
1630  close();
1631  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Cannot set shutter on"));
1632  }
1633 
1634  if (dc1394_feature_set_mode(camera, DC1394_FEATURE_SHUTTER, mode) != DC1394_SUCCESS) {
1635  // vpERROR_TRACE("Cannot set auto shutter. \n");
1636  close();
1637  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Cannot set auto shutter"));
1638  }
1639 }
1679 void vp1394TwoGrabber::setAutoShutter(unsigned int minvalue, unsigned int maxvalue)
1680 {
1681  setAutoShutter();
1682 
1683  if (dc1394_avt_set_auto_shutter(camera, minvalue, maxvalue) != DC1394_SUCCESS) {
1684  // vpERROR_TRACE("Cannot set auto shutter min and max values. Is the
1685  // camera an AVT one?\n");
1686  close();
1687  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Cannot set auto shutter min and max values"));
1688  }
1689 }
1690 
1703 void vp1394TwoGrabber::getAutoShutter(unsigned int &minvalue, unsigned int &maxvalue)
1704 {
1705  if (!num_cameras) {
1706  close();
1707  vpERROR_TRACE("No camera found");
1709  }
1710 
1711  if (dc1394_avt_get_auto_shutter(camera, &minvalue, &maxvalue) != DC1394_SUCCESS) {
1712  // vpERROR_TRACE("Cannot get auto shutter min and max values. Is the
1713  // camera an AVT one?\n");
1714  close();
1715  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Cannot get auto shutter min and max values"));
1716  }
1717 }
1718 
1758 {
1759  if (!num_cameras) {
1760  close();
1761  vpERROR_TRACE("No camera found");
1763  }
1764 
1765  dc1394feature_mode_t mode;
1766  if (enable) {
1767  mode = DC1394_FEATURE_MODE_AUTO;
1768  } else {
1769  mode = DC1394_FEATURE_MODE_MANUAL;
1770  }
1771 
1772  if (dc1394_feature_set_power(camera, DC1394_FEATURE_GAIN, DC1394_ON) != DC1394_SUCCESS) {
1773  // vpERROR_TRACE("Cannot set shutter on. \n");
1774  close();
1775  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Cannot set shutter on"));
1776  }
1777 
1778  if (dc1394_feature_set_mode(camera, DC1394_FEATURE_GAIN, mode) != DC1394_SUCCESS) {
1779  // vpERROR_TRACE("Cannot set auto gain. \n");
1780  close();
1781  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Cannot set auto gain"));
1782  }
1783 }
1823 void vp1394TwoGrabber::setAutoGain(unsigned int minvalue, unsigned int maxvalue)
1824 {
1825  setAutoGain();
1826 
1827  if (dc1394_avt_set_auto_gain(camera, minvalue, maxvalue) != DC1394_SUCCESS) {
1828  // vpERROR_TRACE("Cannot set auto gain min and max values. Is the
1829  // camera an AVT one?\n");
1830  close();
1831  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Cannot set auto gain min and max values"));
1832  }
1833 }
1834 
1847 void vp1394TwoGrabber::getAutoGain(unsigned int &minvalue, unsigned int &maxvalue)
1848 {
1849  if (!num_cameras) {
1850  close();
1851  vpERROR_TRACE("No camera found");
1853  }
1854 
1855  if (dc1394_avt_get_auto_gain(camera, &minvalue, &maxvalue) != DC1394_SUCCESS) {
1856  // vpERROR_TRACE("Cannot get auto gain min and max values. Is the
1857  // camera an AVT one?\n");
1858  close();
1859  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Cannot get auto gain min and max values"));
1860  }
1861 }
1862 
1880 void vp1394TwoGrabber::setCapture(dc1394switch_t _switch)
1881 {
1882  if (!num_cameras) {
1883  close();
1884  vpERROR_TRACE("No camera found");
1886  }
1887 
1888  if (_switch == DC1394_ON) {
1889  // if (dc1394_capture_setup(camera, num_buffers) != DC1394_SUCCESS) {
1890  // To be compatible with libdc1394 svn 382 version
1891  if (dc1394_capture_setup(camera, num_buffers, DC1394_CAPTURE_FLAGS_DEFAULT) != DC1394_SUCCESS) {
1892  vpERROR_TRACE("Unable to setup camera capture-\n"
1893  "make sure that the video mode and framerate are "
1894  "supported by your camera.\n");
1895  close();
1896  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Could not setup dma capture"));
1897  }
1898  } else { // _switch == DC1394_OFF
1899  dc1394error_t code = dc1394_capture_stop(camera);
1900 
1901  if (code != DC1394_SUCCESS && code != DC1394_CAPTURE_IS_NOT_SET) {
1902  vpERROR_TRACE("Unable to stop camera capture\n");
1903  close();
1904  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Could not setup dma capture"));
1905  }
1906  }
1907 }
1908 
1923 void vp1394TwoGrabber::setTransmission(dc1394switch_t _switch)
1924 {
1925  if (!num_cameras) {
1926  close();
1927  vpERROR_TRACE("No camera found");
1929  }
1930 
1931  dc1394switch_t status = DC1394_OFF;
1932 
1933  if (dc1394_video_get_transmission(camera, &status) != DC1394_SUCCESS) {
1934  vpERROR_TRACE("Unable to get transmision status");
1935  close();
1936  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Could not setup dma capture"));
1937  }
1938 
1939  // if (status!=_switch){
1940  // Start dma capture if halted
1941  if (dc1394_video_set_transmission(camera, _switch) != DC1394_SUCCESS) {
1942  vpERROR_TRACE("Unable to setup camera capture-\n"
1943  "make sure that the video mode and framerate are "
1944  "supported by your camera.\n");
1945  close();
1946  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Could not setup dma capture"));
1947  }
1948 
1949  if (_switch == DC1394_ON) {
1950  status = DC1394_OFF;
1951 
1952  int i = 0;
1953  while (status == DC1394_OFF && i++ < 5) {
1954  usleep(50000);
1955  if (dc1394_video_get_transmission(camera, &status) != DC1394_SUCCESS) {
1956  vpERROR_TRACE("Unable to get transmision status");
1957  close();
1958  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Could not setup dma capture"));
1959  }
1960  }
1961  }
1962  // }
1963 }
1964 
1999 {
2000  if (!num_cameras) {
2001  close();
2002  vpERROR_TRACE("No camera found");
2004  }
2005 
2006  dc1394operation_mode_t op_mode;
2007  dc1394speed_t speed;
2008 
2009  // Check the speed to configure in B-mode or A-mode
2010  if (isospeed >= vpISO_SPEED_800) {
2011  if (camera->bmode_capable != DC1394_TRUE) {
2012  // vpERROR_TRACE("Camera is not 1394B mode capable. \n"
2013  // "Set the iso speed lower or equal to 400Mbps");
2014  close();
2015  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Camera is not 1394B mode capable"));
2016  }
2017 
2018  if (dc1394_video_set_operation_mode(camera, DC1394_OPERATION_MODE_1394B) != DC1394_SUCCESS) {
2019  // vpERROR_TRACE("Cannot set camera to 1394B mode. \n");
2020  close();
2021  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Cannot set camera to 1394B mode"));
2022  }
2023 
2024  if (dc1394_video_get_operation_mode(camera, &op_mode) != DC1394_SUCCESS) {
2025  // vpERROR_TRACE("Failed to set 1394B mode. \n");
2026  close();
2027  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Failed to set 1394B mode"));
2028  }
2029  } else {
2030  if (dc1394_video_set_operation_mode(camera, DC1394_OPERATION_MODE_LEGACY) != DC1394_SUCCESS) {
2031  // vpERROR_TRACE("Cannot set camera to 1394A mode. \n");
2032  close();
2033  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Cannot set camera to 1394A mode"));
2034  }
2035 
2036  if (dc1394_video_get_operation_mode(camera, &op_mode) != DC1394_SUCCESS) {
2037  // vpERROR_TRACE("Failed to set 1394A mode. \n");
2038  close();
2039  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Failed to set 1394A mode"));
2040  }
2041  }
2042 
2043  if (dc1394_video_set_iso_speed(camera, (dc1394speed_t)isospeed) != DC1394_SUCCESS) {
2044  // vpERROR_TRACE("Cannot set requested iso speed. \n");
2045  close();
2046  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Cannot set requested iso speed"));
2047  }
2048 
2049  if (dc1394_video_get_iso_speed(camera, &speed) != DC1394_SUCCESS) {
2050  // vpERROR_TRACE("Failed to set iso speed. \n");
2051  close();
2052  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Failed to set iso speed"));
2053  }
2054 }
2055 
2067 {
2068  open();
2069  acquire(I);
2070 }
2071 
2083 {
2084  open();
2085  acquire(I);
2086 }
2087 
2125 dc1394video_frame_t *vp1394TwoGrabber::dequeue()
2126 {
2127 
2128  if (!num_cameras) {
2129  close();
2130  vpERROR_TRACE("No camera found");
2132  }
2133 
2134  dc1394video_frame_t *frame = NULL;
2135 
2136  if (dc1394_capture_dequeue(camera, DC1394_CAPTURE_POLICY_WAIT, &frame) != DC1394_SUCCESS) {
2137  vpERROR_TRACE("Error: Failed to capture from camera %d\n", camera_id);
2138  }
2139 
2140  return frame;
2141 }
2142 
2184 {
2185  uint64_t timestamp;
2186  uint32_t id;
2187 
2188  dc1394video_frame_t *frame;
2189 
2190  frame = dequeue(I, timestamp, id);
2191 
2192  return frame;
2193 }
2194 
2242 dc1394video_frame_t *vp1394TwoGrabber::dequeue(vpImage<unsigned char> &I, uint64_t &timestamp, uint32_t &id)
2243 {
2244 
2245  open();
2246 
2247  dc1394video_frame_t *frame;
2248 
2249  frame = dequeue();
2250 
2251  // Timeval data structure providing the unix time
2252  // [microseconds] at which the frame was captured in the ring buffer.
2253  timestamp = frame->timestamp;
2254  id = frame->id;
2255 
2256  this->width = frame->size[0];
2257  this->height = frame->size[1];
2258  unsigned int size = this->width * this->height;
2259 
2260  if ((I.getWidth() != this->width) || (I.getHeight() != this->height))
2261  I.resize(this->height, this->width);
2262 
2263  switch (frame->color_coding) {
2264  case DC1394_COLOR_CODING_MONO8:
2265  case DC1394_COLOR_CODING_RAW8:
2266  memcpy(I.bitmap, (unsigned char *)frame->image, size * sizeof(unsigned char));
2267  break;
2268  case DC1394_COLOR_CODING_MONO16:
2269  case DC1394_COLOR_CODING_RAW16:
2270  vpImageConvert::MONO16ToGrey((unsigned char *)frame->image, I.bitmap, size);
2271  break;
2272 
2273  case DC1394_COLOR_CODING_YUV411:
2274  vpImageConvert::YUV411ToGrey((unsigned char *)frame->image, I.bitmap, size);
2275  break;
2276 
2277  case DC1394_COLOR_CODING_YUV422:
2278  vpImageConvert::YUV422ToGrey((unsigned char *)frame->image, I.bitmap, size);
2279  break;
2280 
2281  case DC1394_COLOR_CODING_YUV444:
2282  vpImageConvert::YUV444ToGrey((unsigned char *)frame->image, I.bitmap, size);
2283  break;
2284 
2285  case DC1394_COLOR_CODING_RGB8:
2286  vpImageConvert::RGBToGrey((unsigned char *)frame->image, I.bitmap, size);
2287  break;
2288 
2289  default:
2290  close();
2291  vpERROR_TRACE("Format conversion not implemented. Acquisition failed.");
2292  throw(vpFrameGrabberException(vpFrameGrabberException::otherError, "Format conversion not implemented. "
2293  "Acquisition failed."));
2294  };
2295 
2296  return frame;
2297 }
2298 
2339 {
2340  uint64_t timestamp;
2341  uint32_t id;
2342 
2343  dc1394video_frame_t *frame;
2344 
2345  frame = dequeue(I, timestamp, id);
2346 
2347  return frame;
2348 }
2349 
2397 dc1394video_frame_t *vp1394TwoGrabber::dequeue(vpImage<vpRGBa> &I, uint64_t &timestamp, uint32_t &id)
2398 {
2399 
2400  open();
2401 
2402  dc1394video_frame_t *frame;
2403 
2404  frame = dequeue();
2405 
2406  // Timeval data structure providing the unix time
2407  // [microseconds] at which the frame was captured in the ring buffer.
2408  timestamp = frame->timestamp;
2409  id = frame->id;
2410 
2411  this->width = frame->size[0];
2412  this->height = frame->size[1];
2413  unsigned int size = this->width * this->height;
2414 
2415  if ((I.getWidth() != width) || (I.getHeight() != height))
2416  I.resize(height, width);
2417 
2418  switch (frame->color_coding) {
2419  case DC1394_COLOR_CODING_MONO8:
2420  case DC1394_COLOR_CODING_RAW8:
2421  vpImageConvert::GreyToRGBa((unsigned char *)frame->image, (unsigned char *)I.bitmap, size);
2422  break;
2423 
2424  case DC1394_COLOR_CODING_MONO16:
2425  case DC1394_COLOR_CODING_RAW16:
2426  vpImageConvert::MONO16ToRGBa((unsigned char *)frame->image, (unsigned char *)I.bitmap, size);
2427  break;
2428 
2429  case DC1394_COLOR_CODING_YUV411:
2430  vpImageConvert::YUV411ToRGBa((unsigned char *)frame->image, (unsigned char *)I.bitmap, size);
2431  break;
2432 
2433  case DC1394_COLOR_CODING_YUV422:
2434  vpImageConvert::YUV422ToRGBa((unsigned char *)frame->image, (unsigned char *)I.bitmap, size);
2435  break;
2436 
2437  case DC1394_COLOR_CODING_YUV444:
2438  vpImageConvert::YUV444ToRGBa((unsigned char *)frame->image, (unsigned char *)I.bitmap, size);
2439  break;
2440 
2441  case DC1394_COLOR_CODING_RGB8:
2442  vpImageConvert::RGBToRGBa((unsigned char *)frame->image, (unsigned char *)I.bitmap, size);
2443  break;
2444 
2445  default:
2446  close();
2447  vpERROR_TRACE("Format conversion not implemented. Acquisition failed.");
2448  throw(vpFrameGrabberException(vpFrameGrabberException::otherError, "Format conversion not implemented. "
2449  "Acquisition failed."));
2450  };
2451 
2452  return frame;
2453 }
2454 
2465 void vp1394TwoGrabber::enqueue(dc1394video_frame_t *frame)
2466 {
2467 
2468  if (!num_cameras) {
2469  close();
2470  vpERROR_TRACE("No camera found");
2472  }
2473 
2474  if (frame)
2475  dc1394_capture_enqueue(camera, frame);
2476 }
2477 
2492 {
2493  uint64_t timestamp;
2494  uint32_t id;
2495 
2496  dc1394video_frame_t *frame;
2497 
2498  frame = dequeue(I, timestamp, id);
2499  enqueue(frame);
2500 }
2501 
2520 void vp1394TwoGrabber::acquire(vpImage<unsigned char> &I, uint64_t &timestamp, uint32_t &id)
2521 {
2522  dc1394video_frame_t *frame;
2523 
2524  open();
2525  frame = dequeue(I, timestamp, id);
2526  enqueue(frame);
2527 }
2528 
2543 {
2544  uint64_t timestamp;
2545  uint32_t id;
2546  dc1394video_frame_t *frame;
2547 
2548  open();
2549  frame = dequeue(I, timestamp, id);
2550  enqueue(frame);
2551 }
2552 
2571 void vp1394TwoGrabber::acquire(vpImage<vpRGBa> &I, uint64_t &timestamp, uint32_t &id)
2572 {
2573  dc1394video_frame_t *frame;
2574 
2575  open();
2576  frame = dequeue();
2577  // Timeval data structure providing the unix time
2578  // [microseconds] at which the frame was captured in the ring buffer.
2579  timestamp = frame->timestamp;
2580  id = frame->id;
2581 
2582  this->width = frame->size[0];
2583  this->height = frame->size[1];
2584  unsigned int size = this->width * this->height;
2585 
2586  if ((I.getWidth() != width) || (I.getHeight() != height))
2587  I.resize(height, width);
2588 
2589  switch (frame->color_coding) {
2590  case DC1394_COLOR_CODING_MONO8:
2591  case DC1394_COLOR_CODING_RAW8:
2592  vpImageConvert::GreyToRGBa((unsigned char *)frame->image, (unsigned char *)I.bitmap, size);
2593  break;
2594 
2595  case DC1394_COLOR_CODING_YUV411:
2596  vpImageConvert::YUV411ToRGBa((unsigned char *)frame->image, (unsigned char *)I.bitmap, size);
2597  break;
2598 
2599  case DC1394_COLOR_CODING_YUV422:
2600  vpImageConvert::YUV422ToRGBa((unsigned char *)frame->image, (unsigned char *)I.bitmap, size);
2601  break;
2602 
2603  case DC1394_COLOR_CODING_YUV444:
2604  vpImageConvert::YUV444ToRGBa((unsigned char *)frame->image, (unsigned char *)I.bitmap, size);
2605  break;
2606 
2607  case DC1394_COLOR_CODING_RGB8:
2608  vpImageConvert::RGBToRGBa((unsigned char *)frame->image, (unsigned char *)I.bitmap, size);
2609  break;
2610 
2611  default:
2612  close();
2613  vpERROR_TRACE("Format conversion not implemented. Acquisition failed.");
2614  throw(vpFrameGrabberException(vpFrameGrabberException::otherError, "Format conversion not implemented. "
2615  "Acquisition failed."));
2616  };
2617 
2618  enqueue(frame);
2619 }
2620 
2637 void vp1394TwoGrabber::getWidth(unsigned int &w)
2638 {
2639  if (!num_cameras) {
2640  close();
2641  vpERROR_TRACE("No camera found");
2643  }
2644 
2645  w = this->width;
2646 }
2647 
2666 {
2667  if (!num_cameras) {
2668  close();
2669  vpERROR_TRACE("No camera found");
2671  }
2672 
2673  return this->width;
2674 }
2675 
2693 void vp1394TwoGrabber::getHeight(unsigned int &h)
2694 {
2695  if (!num_cameras) {
2696  close();
2697  vpERROR_TRACE("No camera found");
2699  }
2700 
2701  h = this->height;
2702 }
2721 {
2722  if (!num_cameras) {
2723  close();
2724  vpERROR_TRACE("No camera found");
2726  }
2727 
2728  return this->height;
2729 }
2730 
2737 {
2738  std::cout << "----------------------------------------------------------" << std::endl
2739  << "----- Information for camera " << camera_id << " -----" << std::endl
2740  << "----------------------------------------------------------" << std::endl;
2741 
2742 #ifdef VISP_HAVE_DC1394_CAMERA_ENUMERATE // new API > libdc1394-2.0.0-rc7
2743  dc1394_camera_print_info(camera, stdout);
2744 #elif defined VISP_HAVE_DC1394_FIND_CAMERAS // old API <= libdc1394-2.0.0-rc7
2745  dc1394_print_camera_info(camera);
2746 #endif
2747 
2748  dc1394featureset_t features;
2749 #ifdef VISP_HAVE_DC1394_CAMERA_ENUMERATE // new API > libdc1394-2.0.0-rc7
2750  if (dc1394_feature_get_all(camera, &features) != DC1394_SUCCESS)
2751 #elif defined VISP_HAVE_DC1394_FIND_CAMERAS // old API <= libdc1394-2.0.0-rc7
2752  if (dc1394_get_camera_feature_set(camera, &features) != DC1394_SUCCESS)
2753 #endif
2754  {
2755  close();
2756  vpERROR_TRACE("unable to get feature set for camera %d\n", camera_id);
2757  throw(vpFrameGrabberException(vpFrameGrabberException::initializationError, "Cannot get camera features"));
2758 
2759  } else {
2760 #ifdef VISP_HAVE_DC1394_CAMERA_ENUMERATE // new API > libdc1394-2.0.0-rc7
2761  dc1394_feature_print_all(&features, stdout);
2762 #elif defined VISP_HAVE_DC1394_FIND_CAMERAS // old API <= libdc1394-2.0.0-rc7
2763  dc1394_print_feature_set(&features);
2764 #endif
2765  }
2766  std::cout << "----------------------------------------------------------" << std::endl;
2767 }
2768 
2782 {
2783  std::string _str = "";
2784  dc1394video_mode_t _videomode = (dc1394video_mode_t)videomode;
2785 
2786  if ((_videomode >= DC1394_VIDEO_MODE_MIN) && (_videomode <= DC1394_VIDEO_MODE_MAX)) {
2787  _str = strVideoMode[_videomode - DC1394_VIDEO_MODE_MIN];
2788  } else {
2789  vpCERROR << "The video mode " << (int)videomode << " is not supported by the camera" << std::endl;
2790  }
2791 
2792  return _str;
2793 }
2794 
2808 {
2809  std::string _str = "";
2810  dc1394framerate_t _fps = (dc1394framerate_t)fps;
2811 
2812  if ((_fps >= DC1394_FRAMERATE_MIN) && (_fps <= DC1394_FRAMERATE_MAX)) {
2813  _str = strFramerate[_fps - DC1394_FRAMERATE_MIN];
2814  } else {
2815  vpCERROR << "The framerate " << (int)fps << " is not supported by the camera" << std::endl;
2816  }
2817 
2818  return _str;
2819 }
2820 
2834 {
2835  std::string _str = "";
2836  dc1394color_coding_t _coding = (dc1394color_coding_t)colorcoding;
2837 
2838  if ((_coding >= DC1394_COLOR_CODING_MIN) && (_coding <= DC1394_COLOR_CODING_MAX)) {
2839  _str = strColorCoding[_coding - DC1394_COLOR_CODING_MIN];
2840 
2841  } else {
2842  vpCERROR << "The color coding " << (int)colorcoding << " is not supported by the camera" << std::endl;
2843  }
2844 
2845  return _str;
2846 }
2847 
2866 {
2868 
2869  for (int i = DC1394_VIDEO_MODE_MIN; i <= DC1394_VIDEO_MODE_MAX; i++) {
2870  _id = (vp1394TwoVideoModeType)i;
2871  if (videomode.compare(videoMode2string(_id)) == 0)
2872  return _id;
2873  };
2874 
2875  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "The required videomode is not valid"));
2876 
2877  return (vp1394TwoVideoModeType)0;
2878 }
2879 
2898 {
2900 
2901  for (int i = DC1394_FRAMERATE_MIN; i <= DC1394_FRAMERATE_MAX; i++) {
2902  _id = (vp1394TwoFramerateType)i;
2903  if (framerate.compare(framerate2string(_id)) == 0)
2904  return _id;
2905  };
2906 
2907  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "The required framerate is not valid"));
2908 
2909  return (vp1394TwoFramerateType)0;
2910 }
2911 
2930 {
2932 
2933  for (int i = DC1394_COLOR_CODING_MIN; i <= DC1394_COLOR_CODING_MAX; i++) {
2934  _id = (vp1394TwoColorCodingType)i;
2935  if (colorcoding.compare(colorCoding2string(_id)) == 0)
2936  return _id;
2937  };
2938 
2939  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "The required color coding is not valid"));
2940 
2941  return (vp1394TwoColorCodingType)0;
2942 }
2943 
2976 {
2977  for (unsigned int i = 0; i < num_cameras; i++) {
2978  if (camIsOpen[i]) {
2979  camera = cameras[i];
2980  setTransmission(DC1394_OFF);
2981  setCapture(DC1394_OFF);
2982  }
2983  }
2984 #ifdef VISP_HAVE_DC1394_CAMERA_ENUMERATE // new API > libdc1394-2.0.0-rc7
2985  setCamera(camera_id);
2986  // free the other cameras
2987  for (unsigned int i = 0; i < num_cameras; i++) {
2988  if (i != camera_id)
2989  dc1394_camera_free(cameras[i]);
2990  }
2991 
2992  printf("Resetting bus...\n");
2993  dc1394_reset_bus(camera);
2994 
2995  dc1394_camera_free(camera);
2996  dc1394_free(d);
2997  d = NULL;
2998  // if (cameras != NULL)
2999  delete[] cameras;
3000  cameras = NULL;
3001 #elif defined VISP_HAVE_DC1394_FIND_CAMERAS // old API <= libdc1394-2.0.0-rc7
3002 
3003  setCamera(camera_id);
3004  // free the other cameras
3005  for (unsigned int i = 0; i < num_cameras; i++) {
3006  if (i != camera_id)
3007  dc1394_free_camera(cameras[i]);
3008  }
3009  free(cameras);
3010  cameras = NULL;
3011 
3012  dc1394_reset_bus(camera);
3013  dc1394_free_camera(camera);
3014 
3015 #endif
3016  if (camIsOpen != NULL)
3017  delete[] camIsOpen;
3018  camIsOpen = NULL;
3019 
3020  num_cameras = 0;
3021 
3022  init = false;
3023  vpTime::wait(1000);
3024  initialize(false);
3025 }
3026 
3057 void vp1394TwoGrabber::setPanControl(unsigned int panControlValue)
3058 {
3059  open();
3060  if (!num_cameras) {
3061  close();
3062  vpERROR_TRACE("No camera found");
3064  }
3065  uint64_t offset = 0x884;
3066  uint32_t value = 0x82000000 + (uint32_t)panControlValue;
3067  dc1394error_t err;
3068  err = dc1394_set_control_register(camera, offset, value);
3069  if (err != DC1394_SUCCESS) {
3070  vpERROR_TRACE("Unable to set PAN register");
3071  close();
3072  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Unable to set PAN register"));
3073  }
3074 }
3075 
3093 {
3094  if (!num_cameras) {
3095  close();
3096  vpERROR_TRACE("No camera found");
3098  }
3099 
3100  uint32_t value;
3101  dc1394feature_t feature = DC1394_FEATURE_BRIGHTNESS; // = (dc1394feature_t)param;
3102  switch (param) {
3103  case vpFEATURE_BRIGHTNESS:
3104  feature = DC1394_FEATURE_BRIGHTNESS;
3105  break;
3106  case vpFEATURE_EXPOSURE:
3107  feature = DC1394_FEATURE_EXPOSURE;
3108  break;
3109  case vpFEATURE_SHARPNESS:
3110  feature = DC1394_FEATURE_SHARPNESS;
3111  break;
3112  // vpFEATURE_WHITE_BALANCE = DC1394_FEATURE_WHITE_BALANCE,
3113  case vpFEATURE_HUE:
3114  feature = DC1394_FEATURE_HUE;
3115  break;
3116  case vpFEATURE_SATURATION:
3117  feature = DC1394_FEATURE_SATURATION;
3118  break;
3119  case vpFEATURE_GAMMA:
3120  feature = DC1394_FEATURE_GAMMA;
3121  break;
3122  case vpFEATURE_SHUTTER:
3123  feature = DC1394_FEATURE_SHUTTER;
3124  break;
3125  case vpFEATURE_GAIN:
3126  feature = DC1394_FEATURE_GAIN;
3127  break;
3128  case vpFEATURE_IRIS:
3129  feature = DC1394_FEATURE_IRIS;
3130  break;
3131  // vpFEATURE_FOCUS = DC1394_FEATURE_FOCUS,
3132  // vpFEATURE_TEMPERATURE = DC1394_FEATURE_TEMPERATURE,
3133  // vpFEATURE_TRIGGER = DC1394_FEATURE_TRIGGER,
3134  // vpFEATURE_TRIGGER_DELAY = DC1394_FEATURE_TRIGGER_DELAY,
3135  // vpFEATURE_WHITE_SHADING = DC1394_FEATURE_WHITE_SHADING,
3136  // vpFEATURE_FRAME_RATE = DC1394_FEATURE_FRAME_RATE,
3137  // vpFEATURE_ZOOM = DC1394_FEATURE_ZOOM,
3138  // vpFEATURE_PAN = DC1394_FEATURE_PAN,
3139  // vpFEATURE_TILT = DC1394_FEATURE_TILT,
3140  // vpFEATURE_OPTICAL_FILTER = DC1394_FEATURE_OPTICAL_FILTER,
3141  // vpFEATURE_CAPTURE_SIZE = DC1394_FEATURE_CAPTURE_SIZE,
3142  // vpFEATURE_CAPTURE_QUALITY = DC1394_FEATURE_CAPTURE_QUALITY
3143  }
3144 
3145  dc1394error_t err;
3146  err = dc1394_feature_get_value(camera, feature, &value);
3147  if (err != DC1394_SUCCESS) {
3148  vpERROR_TRACE("Unable to get the information");
3149  close();
3150  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Unable to get the information"));
3151  }
3152  return (unsigned int)value;
3153 }
3154 
3177 {
3178  if (!num_cameras) {
3179  close();
3180  vpERROR_TRACE("No camera found");
3182  }
3183  uint32_t value = (uint32_t)val;
3184  dc1394feature_t feature = DC1394_FEATURE_BRIGHTNESS; // = (dc1394feature_t)param;
3185  switch (param) {
3186  case vpFEATURE_BRIGHTNESS:
3187  feature = DC1394_FEATURE_BRIGHTNESS;
3188  break;
3189  case vpFEATURE_EXPOSURE:
3190  feature = DC1394_FEATURE_EXPOSURE;
3191  break;
3192  case vpFEATURE_SHARPNESS:
3193  feature = DC1394_FEATURE_SHARPNESS;
3194  break;
3195  // vpFEATURE_WHITE_BALANCE = DC1394_FEATURE_WHITE_BALANCE,
3196  case vpFEATURE_HUE:
3197  feature = DC1394_FEATURE_HUE;
3198  break;
3199  case vpFEATURE_SATURATION:
3200  feature = DC1394_FEATURE_SATURATION;
3201  break;
3202  case vpFEATURE_GAMMA:
3203  feature = DC1394_FEATURE_GAMMA;
3204  break;
3205  case vpFEATURE_SHUTTER:
3206  feature = DC1394_FEATURE_SHUTTER;
3207  break;
3208  case vpFEATURE_GAIN:
3209  feature = DC1394_FEATURE_GAIN;
3210  break;
3211  case vpFEATURE_IRIS:
3212  feature = DC1394_FEATURE_IRIS;
3213  break;
3214  // vpFEATURE_FOCUS = DC1394_FEATURE_FOCUS,
3215  // vpFEATURE_TEMPERATURE = DC1394_FEATURE_TEMPERATURE,
3216  // vpFEATURE_TRIGGER = DC1394_FEATURE_TRIGGER,
3217  // vpFEATURE_TRIGGER_DELAY = DC1394_FEATURE_TRIGGER_DELAY,
3218  // vpFEATURE_WHITE_SHADING = DC1394_FEATURE_WHITE_SHADING,
3219  // vpFEATURE_FRAME_RATE = DC1394_FEATURE_FRAME_RATE,
3220  // vpFEATURE_ZOOM = DC1394_FEATURE_ZOOM,
3221  // vpFEATURE_PAN = DC1394_FEATURE_PAN,
3222  // vpFEATURE_TILT = DC1394_FEATURE_TILT,
3223  // vpFEATURE_OPTICAL_FILTER = DC1394_FEATURE_OPTICAL_FILTER,
3224  // vpFEATURE_CAPTURE_SIZE = DC1394_FEATURE_CAPTURE_SIZE,
3225  // vpFEATURE_CAPTURE_QUALITY = DC1394_FEATURE_CAPTURE_QUALITY
3226  }
3227 
3228  dc1394error_t err;
3229  dc1394bool_t hasManualMode = DC1394_FALSE;
3230  dc1394feature_modes_t modesAvailable;
3231 
3232  // test wether we can set the shutter value (manual mode available or not)
3233  err = dc1394_feature_get_modes(camera, feature, &modesAvailable);
3234  if (err != DC1394_SUCCESS) {
3235  vpERROR_TRACE("Unable to detect the manual mode information");
3236  close();
3237  throw(
3238  vpFrameGrabberException(vpFrameGrabberException::settingError, "Unable to detect the manual mode information"));
3239  }
3240 
3241  for (unsigned int i = 0; i < modesAvailable.num; i++) {
3242  if (modesAvailable.modes[i] == DC1394_FEATURE_MODE_MANUAL) {
3243  hasManualMode = DC1394_TRUE;
3244  }
3245  }
3246 
3247  if (hasManualMode == DC1394_TRUE) {
3248 
3249  if (!isDataModified[camera_id]) { // to ensure we save the first mode
3250  // even after several set
3251  /* we update the structure */
3252  updateDataCamToStruct();
3253  err = dc1394_feature_get_mode(camera, feature, &(initialShutterMode[camera_id]));
3254  if (err != DC1394_SUCCESS) {
3255  vpERROR_TRACE("Unable to get the initial mode");
3256  close();
3257  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Unable to get the initial mode"));
3258  }
3259  isDataModified[camera_id] = true;
3260  }
3261 
3262  dc1394feature_mode_t manualMode = DC1394_FEATURE_MODE_MANUAL;
3263  err = dc1394_feature_set_mode(camera, feature, manualMode);
3264  if (err != DC1394_SUCCESS) {
3265  vpERROR_TRACE("Unable to set the muanual mode");
3266  close();
3267  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Unable to set the manual mode"));
3268  }
3269  err = dc1394_feature_set_value(camera, feature, value);
3270  if (err != DC1394_SUCCESS) {
3271  vpERROR_TRACE("Unable to set the shutter information");
3272  close();
3273  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Unable to set the shutter information"));
3274  }
3275  } else {
3276  vpERROR_TRACE("The camera does not have a manual mode.\nCannot change the value");
3277  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "The camera does not have a manual mode"));
3278  }
3279 }
3287 void vp1394TwoGrabber::getGuid(uint64_t &guid)
3288 {
3289  if (!num_cameras) {
3290  close();
3291  vpERROR_TRACE("No camera found");
3293  }
3294 
3295  guid = camera->guid;
3296 }
3297 
3306 {
3307  if (!num_cameras) {
3308  close();
3309  vpERROR_TRACE("No camera found");
3311  }
3312 
3313  return camera->guid;
3314 }
3315 
3320 inline void vp1394TwoGrabber::updateDataCamToStruct()
3321 {
3322  dataCam[camera_id].brightness = getParameterValue(vpFEATURE_BRIGHTNESS);
3323  dataCam[camera_id].exposure = getParameterValue(vpFEATURE_EXPOSURE);
3324  dataCam[camera_id].sharpness = getParameterValue(vpFEATURE_SHARPNESS);
3325  dataCam[camera_id].hue = getParameterValue(vpFEATURE_HUE);
3326  dataCam[camera_id].saturation = getParameterValue(vpFEATURE_SATURATION);
3327  dataCam[camera_id].gamma = getParameterValue(vpFEATURE_GAMMA);
3328  dataCam[camera_id].shutter = getParameterValue(vpFEATURE_SHUTTER);
3329  dataCam[camera_id].gain = getParameterValue(vpFEATURE_GAIN);
3330  dataCam[camera_id].iris = getParameterValue(vpFEATURE_IRIS);
3331 }
3332 
3337 inline void vp1394TwoGrabber::updateDataStructToCam()
3338 {
3339  setParameterValue(vpFEATURE_BRIGHTNESS, dataCam[camera_id].brightness);
3340  setParameterValue(vpFEATURE_EXPOSURE, dataCam[camera_id].exposure);
3341  setParameterValue(vpFEATURE_SHARPNESS, dataCam[camera_id].sharpness);
3342  setParameterValue(vpFEATURE_HUE, dataCam[camera_id].hue);
3343  setParameterValue(vpFEATURE_SATURATION, dataCam[camera_id].saturation);
3344  setParameterValue(vpFEATURE_GAMMA, dataCam[camera_id].gamma);
3345  setParameterValue(vpFEATURE_SHUTTER, dataCam[camera_id].shutter);
3346  setParameterValue(vpFEATURE_GAIN, dataCam[camera_id].gain);
3347  setParameterValue(vpFEATURE_IRIS, dataCam[camera_id].iris);
3348 }
3349 
3367 {
3368  this->acquire(I);
3369  return *this;
3370 }
3371 
3389 {
3390  this->acquire(I);
3391  return *this;
3392 }
3393 
3394 #elif !defined(VISP_BUILD_SHARED_LIBS)
3395 // Work around to avoid warning: libvisp_sensor.a(vp1394TwoGrabber.cpp.o) has
3396 // no symbols
3397 void dummy_vp1394TwoGrabber(){};
3398 #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]
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 emited by the vpFrameGrabber class and its derivates.
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:247
void resize(unsigned int h, unsigned int w)
resize the image : Image initialization
Definition: vpImage.h:800
Type * bitmap
points toward the bitmap
Definition: vpImage.h:144
unsigned int getHeight() const
Definition: vpImage.h:189
#define vpCTRACE
Definition: vpDebug.h:338
#define vpCERROR
Definition: vpDebug.h:365
#define vpTRACE
Definition: vpDebug.h:416
#define vpERROR_TRACE
Definition: vpDebug.h:393
VISP_EXPORT int wait(double t0, double t)