Visual Servoing Platform  version 3.6.0 under development (2023-09-27)
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 
41 #include <iostream>
42 
43 #include <visp3/core/vpConfig.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 const char *vp1394TwoGrabber::strVideoMode[DC1394_VIDEO_MODE_NUM] = {
57  "MODE_160x120_YUV444", "MODE_320x240_YUV422", "MODE_640x480_YUV411", "MODE_640x480_YUV422",
58  "MODE_640x480_RGB8", "MODE_640x480_MONO8", "MODE_640x480_MONO16", "MODE_800x600_YUV422",
59  "MODE_800x600_RGB8", "MODE_800x600_MONO8", "MODE_1024x768_YUV422", "MODE_1024x768_RGB8",
60  "MODE_1024x768_MONO8", "MODE_800x600_MONO16", "MODE_1024x768_MONO16", "MODE_1280x960_YUV422",
61  "MODE_1280x960_RGB8", "MODE_1280x960_MONO8", "MODE_1600x1200_YUV422", "MODE_1600x1200_RGB8",
62  "MODE_1600x1200_MONO8", "MODE_1280x960_MONO16", "MODE_1600x1200_MONO16", "MODE_EXIF",
63  "MODE_FORMAT7_0", "MODE_FORMAT7_1", "MODE_FORMAT7_2", "MODE_FORMAT7_3",
64  "MODE_FORMAT7_4", "MODE_FORMAT7_5", "MODE_FORMAT7_6", "MODE_FORMAT7_7"};
65 
66 const char *vp1394TwoGrabber::strFramerate[DC1394_FRAMERATE_NUM] = {
67  "FRAMERATE_1_875", "FRAMERATE_3_75", "FRAMERATE_7_5", "FRAMERATE_15",
68  "FRAMERATE_30", "FRAMERATE_60", "FRAMERATE_120", "FRAMERATE_240"};
69 
70 const char *vp1394TwoGrabber::strColorCoding[DC1394_COLOR_CODING_NUM] = {
71  "COLOR_CODING_MONO8", "COLOR_CODING_YUV411", "COLOR_CODING_YUV422", "COLOR_CODING_YUV444",
72  "COLOR_CODING_RGB8", "COLOR_CODING_MONO16", "COLOR_CODING_RGB16", "COLOR_CODING_MONO16S",
73  "COLOR_CODING_RGB16S", "COLOR_CODING_RAW8", "COLOR_CODING_RAW16",
74 };
75 
121  : camera(NULL), cameras(NULL), num_cameras(0), camera_id(0), verbose(false), camIsOpen(NULL),
122  num_buffers(4), // ring buffer size
123  isDataModified(NULL), initialShutterMode(NULL), dataCam(NULL)
124 #ifdef VISP_HAVE_DC1394_CAMERA_ENUMERATE // new API > libdc1394-2.0.0-rc7
125  ,
126  d(NULL), list(NULL)
127 #endif
128 {
129  // protected members
130  width = height = 0;
131 
132  // private members
133  init = false;
134 
135  reset = false;
136  initialize(reset);
137 
138  // open();
139 }
140 
151 {
152  /* if(num_cameras >= 1){
153  delete[] isDataModified;
154  delete[] initialShutterMode;
155  delete[] dataCam;
156  }*/
157  close();
158 }
159 
278 void vp1394TwoGrabber::setCamera(uint64_t cam_id)
279 {
280  // Suppose that if camera_id is a camera GUID, this value is greater
281  // than the number of cameras connected to the bus
282  if (cam_id >= num_cameras) {
283  // Check if camera_id is a camera guid
284  bool is_guid = false;
285  // check if the camera_id is a guid
286  for (unsigned int i = 0; i < num_cameras; i++) {
287  if (cameras[i]->guid == cam_id) {
288  this->camera_id = i;
289  is_guid = true;
290  break;
291  }
292  }
293  if (is_guid == false) {
294  std::cout << "Error: The camera with guid 0x" << std::hex << cam_id << " is not present" << std::endl;
295  std::cout << num_cameras << " camera(s) connected" << std::endl;
296  for (unsigned int i = 0; i < num_cameras; i++) {
297  std::cout << " - camera " << i << " with guid 0x" << std::hex << cameras[i]->guid << std::endl;
298  }
299  close();
300  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "The required camera is not present"));
301  }
302  } else {
303  this->camera_id = (unsigned int)cam_id; // The input cam_id is not a
304  // uint64_t guid, but the index of
305  // the camera
306  }
307 
308  // create a pointer to the working camera
309  camera = cameras[this->camera_id];
310 }
311 
326 void vp1394TwoGrabber::getCamera(uint64_t &cam_id)
327 {
328  if (num_cameras) {
329  cam_id = this->camera_id;
330  } else {
331  close();
332  vpERROR_TRACE("No cameras found");
334  }
335 }
336 
352 {
353  if (num_cameras) {
354  return this->camera_id;
355  } else {
356  close();
357  vpERROR_TRACE("No cameras found");
359  }
360 }
361 
369 void vp1394TwoGrabber::getNumCameras(unsigned int &ncameras) const
370 {
371  if (!num_cameras) {
372  vpCTRACE << "No camera found..." << std::endl;
373  ncameras = 0;
374  }
375 
376  ncameras = num_cameras;
377 }
378 
387 {
388  unsigned int ncameras = 0;
389  if (!num_cameras) {
390  vpCTRACE << "No camera found..." << std::endl;
391  ncameras = 0;
392  }
393 
394  ncameras = num_cameras;
395  return ncameras;
396 }
397 
443 {
444  open();
445  if (!num_cameras) {
446  close();
448  }
449  if (!isVideoModeSupported(videomode)) {
450  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Video mode not supported by camera %d",
451  camera_id));
452  }
453  // Stop dma capture if started
454  setTransmission(DC1394_OFF);
455  setCapture(DC1394_OFF);
456 
457  if (dc1394_video_set_mode(camera, (dc1394video_mode_t)videomode) != DC1394_SUCCESS) {
458  close();
459  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Can't set video mode"));
460  }
461 
462  setCapture(DC1394_ON);
463  setTransmission(DC1394_ON);
464 
465  // Updates image size from new video mode
466  if (dc1394_get_image_size_from_video_mode(camera, (dc1394video_mode_t)videomode, &this->width, &this->height) !=
467  DC1394_SUCCESS) {
468 
469  close();
470  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Can't get image size"));
471  }
472 }
473 
491 {
492  if (!num_cameras) {
493  close();
494  vpERROR_TRACE("No camera found");
496  }
497 
498  dc1394video_mode_t _videomode;
499  if (dc1394_video_get_mode(camera, &_videomode) != DC1394_SUCCESS) {
500 
501  close();
502  vpERROR_TRACE("Can't get current video mode");
503  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Can't get current video mode"));
504  }
505  videomode = (vp1394TwoVideoModeType)_videomode;
506 }
507 
525 uint32_t vp1394TwoGrabber::getVideoModeSupported(std::list<vp1394TwoVideoModeType> &videomodes)
526 {
527  // Refresh the list of supported modes
528  videomodes.clear();
529 
530  if (!num_cameras) {
531  close();
532  vpERROR_TRACE("No camera found");
534  }
535  dc1394video_modes_t _videomodes;
536 
537  // get video modes:
538  if (dc1394_video_get_supported_modes(camera, &_videomodes) != DC1394_SUCCESS) {
539 
540  close();
541  vpERROR_TRACE("Can't get video modes");
542  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Can't get video modes"));
543  }
544 
545  // parse the video modes to add in the list
546  for (unsigned i = 0; i < _videomodes.num; i++) {
547  vp1394TwoVideoModeType _mode = (vp1394TwoVideoModeType)_videomodes.modes[i];
548  videomodes.push_back(_mode);
549  }
550 
551  // return the number of available video modes
552  return _videomodes.num;
553 }
570 {
571  if (!num_cameras) {
572  close();
573  vpERROR_TRACE("No camera found");
575  }
576  dc1394video_modes_t _videomodes;
577 
578  // get video modes:
579  if (dc1394_video_get_supported_modes(camera, &_videomodes) != DC1394_SUCCESS) {
580 
581  close();
582  vpERROR_TRACE("Can't get video modes");
583  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Can't get video modes"));
584  }
585 
586  // parse the video modes to check with the desired
587  for (unsigned i = 0; i < _videomodes.num; i++) {
588  if ((vp1394TwoVideoModeType)_videomodes.modes[i] == videomode)
589  return true;
590  }
591  return false;
592 }
593 
607 {
608 
609  if (dc1394_is_video_mode_scalable((dc1394video_mode_t)videomode))
610  return true;
611 
612  return false;
613 }
614 
631 {
633  getColorCoding(coding);
634 
635  switch (coding) {
639  case vpCOLOR_CODING_RAW8:
641  return false;
645  case vpCOLOR_CODING_RGB8:
648  return true;
649  }
650  return false;
651 }
652 
678 {
679  open();
680  if (!num_cameras) {
681  close();
683  }
684 
685  vp1394TwoVideoModeType cur_videomode;
686  getVideoMode(cur_videomode);
687  if (isVideoModeFormat7(cur_videomode))
688  return;
689 
690  if (!isFramerateSupported(cur_videomode, fps)) {
691  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Framerate not supported by camera %d",
692  camera_id));
693  }
694 
695  // Stop dma capture if started
696  setTransmission(DC1394_OFF);
697  setCapture(DC1394_OFF);
698 
699  if (dc1394_video_set_framerate(camera, (dc1394framerate_t)fps) != DC1394_SUCCESS) {
700 
701  close();
702  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Can't set framerate"));
703  }
704 
705  setCapture(DC1394_ON);
706  setTransmission(DC1394_ON);
707 }
708 
726 {
727  if (!num_cameras) {
728  close();
729  vpERROR_TRACE("No camera found");
731  }
732  dc1394framerate_t _fps;
733  if (dc1394_video_get_framerate(camera, &_fps) != DC1394_SUCCESS) {
734 
735  close();
736  vpERROR_TRACE("Can't get current framerate");
737  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Can't get current framerate"));
738  }
739  fps = (vp1394TwoFramerateType)_fps;
740 }
741 
773 uint32_t vp1394TwoGrabber::getFramerateSupported(vp1394TwoVideoModeType mode, std::list<vp1394TwoFramerateType> &fps)
774 {
775  if (!num_cameras) {
776  close();
777  vpERROR_TRACE("No camera found");
779  }
780 
781  // Refresh the list of supported framerates
782  fps.clear();
783 
784  switch (mode) {
785  // Framerate not available for:
786  // - vpVIDEO_MODE_EXIF ie Format_6
787  // - vpVIDEO_MODE_FORMAT7... ie the Format_7
788  case vpVIDEO_MODE_EXIF:
797  return 0;
798  break;
799  default: {
800  dc1394framerates_t _fps;
801  if (dc1394_video_get_supported_framerates(camera, (dc1394video_mode_t)mode, &_fps) != DC1394_SUCCESS) {
802  close();
803  vpERROR_TRACE("Could not query supported frametates for mode %d\n", mode);
804  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Could not query supported framerates"));
805  }
806  if (_fps.num == 0)
807  return 0;
808 
809  for (unsigned int i = 0; i < _fps.num; i++)
810  fps.push_back((vp1394TwoFramerateType)_fps.framerates[i]);
811 
812  return _fps.num;
813  } break;
814  }
815 }
850 {
851  if (!num_cameras) {
852  close();
853  vpERROR_TRACE("No camera found");
855  }
856 
857  switch (mode) {
858  // Framerate not available for:
859  // - vpVIDEO_MODE_EXIF ie Format_6
860  // - vpVIDEO_MODE_FORMAT7... ie the Format_7
861  case vpVIDEO_MODE_EXIF:
870  return 0;
871  break;
872  default: {
873  dc1394framerates_t _fps;
874  if (dc1394_video_get_supported_framerates(camera, (dc1394video_mode_t)mode, &_fps) != DC1394_SUCCESS) {
875  close();
876  vpERROR_TRACE("Could not query supported frametates for mode %d\n", mode);
877  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Could not query supported framerates"));
878  }
879  if (_fps.num == 0)
880  return 0;
881 
882  for (unsigned int i = 0; i < _fps.num; i++) {
883  if (fps == (vp1394TwoFramerateType)_fps.framerates[i]) {
884  return true;
885  }
886  }
887  return false;
888  } break;
889  }
890 }
891 
940 {
941  if (!num_cameras) {
942  close();
944  }
945 
946  dc1394video_mode_t _videomode;
947  if (dc1394_video_get_mode(camera, &_videomode) != DC1394_SUCCESS) {
948 
949  close();
950  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Can't get current video mode"));
951  }
952 
953  if (!isColorCodingSupported((vp1394TwoVideoModeType)_videomode, coding)) {
954  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Color coding not supported by camera %d",
955  camera_id));
956  }
957 
958  // Format 7 video mode
959  if (dc1394_is_video_mode_scalable(_videomode)) {
960  setTransmission(DC1394_OFF);
961  setCapture(DC1394_OFF);
962 
963  if (dc1394_format7_set_color_coding(camera, _videomode, (dc1394color_coding_t)coding) != DC1394_SUCCESS) {
964 
965  close();
966  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Can't set color coding"));
967  }
968 
969  setCapture(DC1394_ON);
970  setTransmission(DC1394_ON);
971  }
972 }
973 
992 {
993  if (!num_cameras) {
994  close();
995  vpERROR_TRACE("No camera found");
997  }
998  dc1394video_mode_t _videomode;
999  if (dc1394_video_get_mode(camera, &_videomode) != DC1394_SUCCESS) {
1000 
1001  close();
1002  vpERROR_TRACE("Can't get current video mode");
1003  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Can't get current video mode"));
1004  }
1005 
1006  dc1394color_coding_t _coding;
1007  if (dc1394_is_video_mode_scalable(_videomode)) {
1008  // Format 7 video mode
1009  if (dc1394_format7_get_color_coding(camera, _videomode, &_coding) != DC1394_SUCCESS) {
1010 
1011  close();
1012  vpERROR_TRACE("Can't get current color coding");
1013  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Can't query current color coding"));
1014  }
1015  } else if (dc1394_is_video_mode_still_image((dc1394video_mode_t)_videomode)) {
1016  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "No color coding for format 6 video mode"));
1017  } else {
1018  // Not Format 7 and not Format 6 video modes
1019  if (dc1394_get_color_coding_from_video_mode(camera, (dc1394video_mode_t)_videomode, &_coding) != DC1394_SUCCESS) {
1020  close();
1021  vpERROR_TRACE("Could not query supported color coding for mode %d\n", _videomode);
1022  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Can't query current color coding"));
1023  }
1024  }
1025  coding = (vp1394TwoColorCodingType)_coding;
1026 }
1027 
1050  std::list<vp1394TwoColorCodingType> &codings)
1051 {
1052  if (!num_cameras) {
1053  close();
1054  vpERROR_TRACE("No camera found");
1056  }
1057 
1058  // Refresh the list of supported framerates
1059  codings.clear();
1060 
1061  if (dc1394_is_video_mode_scalable((dc1394video_mode_t)mode)) {
1062  // Format 7 video mode
1063  dc1394color_codings_t _codings;
1064  if (dc1394_format7_get_color_codings(camera, (dc1394video_mode_t)mode, &_codings) != DC1394_SUCCESS) {
1065  close();
1066  vpERROR_TRACE("Could not query supported color codings for mode %d\n", mode);
1067  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Could not query supported color codings"));
1068  }
1069  if (_codings.num == 0)
1070  return 0;
1071 
1072  for (unsigned int i = 0; i < _codings.num; i++)
1073  codings.push_back((vp1394TwoColorCodingType)_codings.codings[i]);
1074 
1075  return _codings.num;
1076  } else if (dc1394_is_video_mode_still_image((dc1394video_mode_t)mode)) {
1077  // Format 6 video mode
1078  return 0;
1079  } else {
1080  // Not Format 7 and not Format 6 video modes
1081  dc1394color_coding_t _coding;
1082  if (dc1394_get_color_coding_from_video_mode(camera, (dc1394video_mode_t)mode, &_coding) != DC1394_SUCCESS) {
1083  close();
1084  vpERROR_TRACE("Could not query supported color coding for mode %d\n", mode);
1085  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Could not query supported color coding"));
1086  }
1087  codings.push_back((vp1394TwoColorCodingType)_coding);
1088  return 1;
1089  }
1090 }
1113 {
1114  if (!num_cameras) {
1115  close();
1116  vpERROR_TRACE("No camera found");
1118  }
1119 
1120  if (dc1394_is_video_mode_scalable((dc1394video_mode_t)mode)) {
1121  // Format 7 video mode
1122  dc1394color_codings_t _codings;
1123  if (dc1394_format7_get_color_codings(camera, (dc1394video_mode_t)mode, &_codings) != DC1394_SUCCESS) {
1124  close();
1125  vpERROR_TRACE("Could not query supported color codings for mode %d\n", mode);
1126  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Could not query supported color codings"));
1127  }
1128  if (_codings.num == 0)
1129  return 0;
1130 
1131  for (unsigned int i = 0; i < _codings.num; i++) {
1132  if (coding == (vp1394TwoColorCodingType)_codings.codings[i])
1133  return true;
1134  }
1135  return false;
1136  } else if (dc1394_is_video_mode_still_image((dc1394video_mode_t)mode)) {
1137  // Format 6 video mode
1138  return false;
1139  } else {
1140  // Not Format 7 and not Format 6 video modes
1141  dc1394color_coding_t _coding;
1142  if (dc1394_get_color_coding_from_video_mode(camera, (dc1394video_mode_t)mode, &_coding) != DC1394_SUCCESS) {
1143  close();
1144  vpERROR_TRACE("Could not query supported color coding for mode %d\n", mode);
1145  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Could not query supported color coding"));
1146  return false;
1147  }
1148  if (coding == (vp1394TwoColorCodingType)_coding)
1149  return true;
1150 
1151  return false;
1152  }
1153 }
1154 
1186 void vp1394TwoGrabber::setFormat7ROI(unsigned int left, unsigned int top, unsigned int w, unsigned int h)
1187 {
1188  open();
1189  if (!num_cameras) {
1190  close();
1191  vpERROR_TRACE("No camera found");
1193  }
1194 
1195  dc1394video_mode_t _videomode;
1196  if (dc1394_video_get_mode(camera, &_videomode) != DC1394_SUCCESS) {
1197 
1198  close();
1199  vpERROR_TRACE("Can't get current video mode");
1200  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Can't get current video mode"));
1201  }
1202  if (dc1394_is_video_mode_scalable(_videomode)) {
1203  // Stop dma capture if started
1204  setTransmission(DC1394_OFF);
1205  setCapture(DC1394_OFF);
1206  // Format 7 video mode
1207  unsigned int max_width, max_height;
1208  if (dc1394_format7_get_max_image_size(camera, _videomode, &max_width, &max_height) != DC1394_SUCCESS) {
1209 
1210  close();
1211  vpERROR_TRACE("Can't get format7 max image size");
1212  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Can't get format7 max image size"));
1213  }
1214 #if 0
1215  vpTRACE("left: %d top: %d width: %d height: %d", left, top,
1216  width == 0 ? DC1394_USE_MAX_AVAIL: w,
1217  height == 0 ? DC1394_USE_MAX_AVAIL : h);
1218  vpTRACE("max_width: %d max_height: %d", max_width, max_height);
1219 #endif
1220 
1221  if (left > max_width) {
1222  vpERROR_TRACE("Can't set format7 ROI");
1223  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Can't set format7 ROI"));
1224  }
1225  if (top > max_height) {
1226  vpERROR_TRACE("Can't set format7 ROI");
1227  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Can't set format7 ROI"));
1228  }
1229 
1230  int32_t roi_width;
1231  int32_t roi_height;
1232 
1233  if (w != 0) {
1234  // Check if roi width is acceptable (ie roi is contained in the image)
1235  if (w > (max_width - left))
1236  w = (max_width - left);
1237  roi_width = (int32_t)w;
1238  } else {
1239  roi_width = DC1394_USE_MAX_AVAIL;
1240  }
1241 
1242  if (h != 0) {
1243  // Check if roi height is acceptable (ie roi is contained in the image)
1244  if (h > (max_height - top))
1245  h = (max_height - top);
1246  roi_height = (int32_t)h;
1247  } else {
1248  roi_height = DC1394_USE_MAX_AVAIL;
1249  }
1250 
1251  if (dc1394_format7_set_roi(camera, _videomode,
1252  (dc1394color_coding_t)DC1394_QUERY_FROM_CAMERA, // color_coding
1253  DC1394_USE_MAX_AVAIL /*DC1394_QUERY_FROM_CAMERA*/
1254  , // bytes_per_packet
1255  (int32_t)left, // left
1256  (int32_t)top, // top
1257  roi_width, roi_height) != DC1394_SUCCESS) {
1258  close();
1259  vpERROR_TRACE("Can't set format7 roi");
1260  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Can't get current video mode"));
1261  }
1262  // Update the image size
1263  if (dc1394_format7_get_image_size(camera, _videomode, &this->width, &this->height) != DC1394_SUCCESS) {
1264  close();
1265  vpERROR_TRACE("Can't get format7 image size");
1266  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Can't get format7 image size"));
1267  }
1268 
1269  setCapture(DC1394_ON);
1270  setTransmission(DC1394_ON);
1271  }
1272 }
1287 void vp1394TwoGrabber::initialize(bool reset)
1288 {
1289  if (init == false) {
1290 // Find cameras
1291 #ifdef VISP_HAVE_DC1394_CAMERA_ENUMERATE // new API > libdc1394-2.0.0-rc7
1292  if (d != NULL)
1293  dc1394_free(d);
1294 
1295  d = dc1394_new();
1296  if (dc1394_camera_enumerate(d, &list) != DC1394_SUCCESS) {
1297  dc1394_camera_free_list(list);
1298  close();
1299  vpERROR_TRACE("Failed to enumerate cameras\n");
1300  throw(vpFrameGrabberException(vpFrameGrabberException::initializationError, "Failed to enumerate cameras"));
1301  }
1302 
1303  if (list->num == 0) {
1304  dc1394_camera_free_list(list);
1305  close();
1306  vpERROR_TRACE("No cameras found");
1308  }
1309 
1310  if (cameras != NULL)
1311  delete[] cameras;
1312 
1313  cameras = new dc1394camera_t *[list->num];
1314 
1315  num_cameras = 0;
1316 
1317  for (unsigned int i = 0; i < list->num; i++) {
1318  cameras[i] = dc1394_camera_new(d, list->ids[i].guid);
1319  if (!cameras[i]) {
1320  vpTRACE("Failed to initialize camera with guid \"%ld\"\n", list->ids[i].guid);
1321  continue;
1322  }
1323  // Update the number of working cameras
1324  num_cameras++;
1325  }
1326 
1327  if (reset) {
1328  // Reset the bus to make firewire working if the program was not
1329  // properly stopped by a CTRL-C. We reset here only the bus attached to
1330  // the first camera
1331  dc1394_reset_bus(cameras[0]);
1332  }
1333 
1334  // if (list != NULL)
1335  dc1394_camera_free_list(list);
1336  list = NULL;
1337 
1338 #elif defined VISP_HAVE_DC1394_FIND_CAMERAS // old API <= libdc1394-2.0.0-rc7
1339  if (cameras != NULL)
1340  free(cameras);
1341  cameras = NULL;
1342  int err = dc1394_find_cameras(&cameras, &num_cameras);
1343 
1344  if (err != DC1394_SUCCESS && err != DC1394_NO_CAMERA) {
1345  close();
1346  vpERROR_TRACE("Unable to look for cameras\n\n"
1347  "Please check \n"
1348  " - if the kernel modules `ieee1394',`raw1394' and "
1349  "`ohci1394' are loaded \n"
1350  " - if you have read/write access to /dev/raw1394\n\n");
1351  throw(vpFrameGrabberException(vpFrameGrabberException::initializationError, "Unable to look for cameras"));
1352  }
1353 #endif
1354 
1355  if (num_cameras == 0) {
1356  close();
1357  vpERROR_TRACE("No cameras found");
1359  }
1360 
1361  // allocation for the parameters
1362  isDataModified = new bool[num_cameras];
1363  for (unsigned int i = 0; i < num_cameras; i++)
1364  isDataModified[i] = false;
1365  initialShutterMode = new dc1394feature_mode_t[num_cameras];
1366  dataCam = new vpDc1394TwoCameraParametersData[num_cameras];
1367 
1368  if (camera_id >= num_cameras) {
1369  // Bad camera id
1370  close();
1371  vpERROR_TRACE("Bad camera id: %u", camera_id);
1372  vpERROR_TRACE("Only %u camera on the bus.", num_cameras);
1374  }
1375 
1376  if (verbose) {
1377  std::cout << "------ Bus information ------" << std::endl;
1378  std::cout << "Number of camera(s) on the bus : " << num_cameras << std::endl;
1379  std::cout << "-----------------------------" << std::endl;
1380  }
1381 
1382  if (camIsOpen != NULL)
1383  delete[] camIsOpen;
1384  camIsOpen = new bool[num_cameras];
1385  for (unsigned int i = 0; i < num_cameras; i++) {
1386  camIsOpen[i] = false;
1387  }
1388 
1389  init = true;
1390  }
1391 }
1402 {
1403  if (init == false)
1404  initialize(false);
1405  if (camIsOpen[camera_id] == false) {
1406  dc1394switch_t status = DC1394_OFF;
1407 
1408  //#ifdef VISP_HAVE_DC1394_CAMERA_ENUMERATE // new API >
1409  // libdc1394-2.0.0-rc7
1410  dc1394_video_get_transmission(cameras[camera_id], &status);
1411  if (status != DC1394_OFF) {
1412  //#endif
1413  if (dc1394_video_set_transmission(cameras[camera_id], DC1394_OFF) != DC1394_SUCCESS)
1414  vpTRACE("Could not stop ISO transmission");
1415  else {
1416  vpTime::wait(500);
1417  if (dc1394_video_get_transmission(cameras[camera_id], &status) != DC1394_SUCCESS)
1418  vpTRACE("Could get ISO status");
1419  else {
1420  if (status == DC1394_ON) {
1421  vpTRACE("ISO transmission refuses to stop");
1422  }
1423 #ifdef VISP_HAVE_DC1394_FIND_CAMERAS // old API <= libdc1394-2.0.0-rc7
1424  // No yet in the new API
1425  cameras[camera_id]->is_iso_on = status;
1426 #endif
1427  }
1428  //#ifdef VISP_HAVE_DC1394_CAMERA_ENUMERATE // new API >
1429  // libdc1394-2.0.0-rc7
1430  }
1431  //#endif
1432  }
1433  setCamera(camera_id);
1434  // setIsoSpeed(DC1394_ISO_SPEED_400);
1435  setCapture(DC1394_ON);
1436  setTransmission(DC1394_ON);
1437  camIsOpen[camera_id] = true;
1438  }
1439 }
1449 {
1450  if (init) {
1451  if (num_cameras) {
1452  for (unsigned int i = 0; i < num_cameras; i++) {
1453  if (camIsOpen[i]) {
1454  camera = cameras[i];
1455  this->camera_id = i; // set camera id for the function updateDataStructToCam
1456  setTransmission(DC1394_OFF);
1457  setCapture(DC1394_OFF);
1458  if (isDataModified[i]) {
1459  // reset values
1460  try {
1461  updateDataStructToCam();
1462  } catch (...) {
1463  }
1464  // reset mode (manual, auto, ...)
1465  if (dc1394_feature_set_mode(camera, DC1394_FEATURE_BRIGHTNESS, initialShutterMode[i]) != DC1394_SUCCESS ||
1466  dc1394_feature_set_mode(camera, DC1394_FEATURE_EXPOSURE, initialShutterMode[i]) != DC1394_SUCCESS ||
1467  dc1394_feature_set_mode(camera, DC1394_FEATURE_SHARPNESS, initialShutterMode[i]) != DC1394_SUCCESS ||
1468  dc1394_feature_set_mode(camera, DC1394_FEATURE_HUE, initialShutterMode[i]) != DC1394_SUCCESS ||
1469  dc1394_feature_set_mode(camera, DC1394_FEATURE_SATURATION, initialShutterMode[i]) != DC1394_SUCCESS ||
1470  dc1394_feature_set_mode(camera, DC1394_FEATURE_GAMMA, initialShutterMode[i]) != DC1394_SUCCESS ||
1471  dc1394_feature_set_mode(camera, DC1394_FEATURE_SHUTTER, initialShutterMode[i]) != DC1394_SUCCESS ||
1472  dc1394_feature_set_mode(camera, DC1394_FEATURE_GAIN, initialShutterMode[i]) != DC1394_SUCCESS ||
1473  dc1394_feature_set_mode(camera, DC1394_FEATURE_IRIS, initialShutterMode[i])) {
1474 
1475  vpERROR_TRACE("Unable to reset the initial mode");
1476  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Unable to reset the initial mode"));
1477  }
1478  }
1479  if (dc1394_camera_set_power(camera, DC1394_OFF) != DC1394_SUCCESS)
1480  std::cout << "Unable to turn camera off" << std::endl;
1481  }
1482 #ifdef VISP_HAVE_DC1394_CAMERA_ENUMERATE // new API > libdc1394-2.0.0-rc7
1483  dc1394_camera_free(cameras[i]);
1484 #elif defined VISP_HAVE_DC1394_FIND_CAMERAS // old API <= libdc1394-2.0.0-rc7
1485  dc1394_free_camera(cameras[i]);
1486 #endif
1487  }
1488  }
1489  if (camIsOpen != NULL) {
1490  delete[] camIsOpen;
1491  camIsOpen = NULL;
1492  }
1493 
1494 #ifdef VISP_HAVE_DC1394_CAMERA_ENUMERATE // new API > libdc1394-2.0.0-rc7
1495  if (cameras != NULL) {
1496  delete[] cameras;
1497  cameras = NULL;
1498  }
1499  if (d != NULL) {
1500  dc1394_free(d);
1501  d = NULL;
1502  }
1503 
1504 #elif defined VISP_HAVE_DC1394_FIND_CAMERAS // old API <= libdc1394-2.0.0-rc7
1505  if (cameras != NULL) {
1506  free(cameras);
1507  cameras = NULL;
1508  }
1509 #endif
1510 
1511  camIsOpen = NULL;
1512  num_cameras = 0;
1513 
1514  // remove data for the parameters
1515  if (isDataModified != NULL) {
1516  delete[] isDataModified;
1517  isDataModified = NULL;
1518  }
1519  if (initialShutterMode != NULL) {
1520  delete[] initialShutterMode;
1521  initialShutterMode = NULL;
1522  }
1523  if (dataCam != NULL) {
1524  delete[] dataCam;
1525  dataCam = NULL;
1526  }
1527 
1528  init = false;
1529  }
1530 }
1531 
1545 {
1546  if (size < 1) {
1547  close();
1548  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Could not set ring buffer size"));
1549  }
1550 
1551  if (size != num_buffers) {
1552  // We need to change the ring buffer size
1553  num_buffers = size;
1554  if (camIsOpen[camera_id]) {
1555  setCapture(DC1394_OFF);
1556  setCapture(DC1394_ON);
1557  }
1558  }
1559 }
1560 
1570 unsigned int vp1394TwoGrabber::getRingBufferSize() const { return num_buffers; }
1571 
1611 {
1612  if (!num_cameras) {
1613  close();
1614  vpERROR_TRACE("No camera found");
1616  }
1617 
1618  dc1394feature_mode_t mode;
1619  if (enable) {
1620  mode = DC1394_FEATURE_MODE_AUTO;
1621  } else {
1622  mode = DC1394_FEATURE_MODE_MANUAL;
1623  }
1624 
1625  if (dc1394_feature_set_power(camera, DC1394_FEATURE_SHUTTER, DC1394_ON) != DC1394_SUCCESS) {
1626  // vpERROR_TRACE("Cannot set shutter on. \n");
1627  close();
1628  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Cannot set shutter on"));
1629  }
1630 
1631  if (dc1394_feature_set_mode(camera, DC1394_FEATURE_SHUTTER, mode) != DC1394_SUCCESS) {
1632  // vpERROR_TRACE("Cannot set auto shutter. \n");
1633  close();
1634  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Cannot set auto shutter"));
1635  }
1636 }
1676 void vp1394TwoGrabber::setAutoShutter(unsigned int minvalue, unsigned int maxvalue)
1677 {
1678  setAutoShutter();
1679 
1680  if (dc1394_avt_set_auto_shutter(camera, minvalue, maxvalue) != DC1394_SUCCESS) {
1681  // vpERROR_TRACE("Cannot set auto shutter min and max values. Is the
1682  // camera an AVT one?\n");
1683  close();
1684  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Cannot set auto shutter min and max values"));
1685  }
1686 }
1687 
1700 void vp1394TwoGrabber::getAutoShutter(unsigned int &minvalue, unsigned int &maxvalue)
1701 {
1702  if (!num_cameras) {
1703  close();
1704  vpERROR_TRACE("No camera found");
1706  }
1707 
1708  if (dc1394_avt_get_auto_shutter(camera, &minvalue, &maxvalue) != DC1394_SUCCESS) {
1709  // vpERROR_TRACE("Cannot get auto shutter min and max values. Is the
1710  // camera an AVT one?\n");
1711  close();
1712  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Cannot get auto shutter min and max values"));
1713  }
1714 }
1715 
1755 {
1756  if (!num_cameras) {
1757  close();
1758  vpERROR_TRACE("No camera found");
1760  }
1761 
1762  dc1394feature_mode_t mode;
1763  if (enable) {
1764  mode = DC1394_FEATURE_MODE_AUTO;
1765  } else {
1766  mode = DC1394_FEATURE_MODE_MANUAL;
1767  }
1768 
1769  if (dc1394_feature_set_power(camera, DC1394_FEATURE_GAIN, DC1394_ON) != DC1394_SUCCESS) {
1770  // vpERROR_TRACE("Cannot set shutter on. \n");
1771  close();
1772  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Cannot set shutter on"));
1773  }
1774 
1775  if (dc1394_feature_set_mode(camera, DC1394_FEATURE_GAIN, mode) != DC1394_SUCCESS) {
1776  // vpERROR_TRACE("Cannot set auto gain. \n");
1777  close();
1778  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Cannot set auto gain"));
1779  }
1780 }
1820 void vp1394TwoGrabber::setAutoGain(unsigned int minvalue, unsigned int maxvalue)
1821 {
1822  setAutoGain();
1823 
1824  if (dc1394_avt_set_auto_gain(camera, minvalue, maxvalue) != DC1394_SUCCESS) {
1825  // vpERROR_TRACE("Cannot set auto gain min and max values. Is the
1826  // camera an AVT one?\n");
1827  close();
1828  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Cannot set auto gain min and max values"));
1829  }
1830 }
1831 
1844 void vp1394TwoGrabber::getAutoGain(unsigned int &minvalue, unsigned int &maxvalue)
1845 {
1846  if (!num_cameras) {
1847  close();
1848  vpERROR_TRACE("No camera found");
1850  }
1851 
1852  if (dc1394_avt_get_auto_gain(camera, &minvalue, &maxvalue) != DC1394_SUCCESS) {
1853  // vpERROR_TRACE("Cannot get auto gain min and max values. Is the
1854  // camera an AVT one?\n");
1855  close();
1856  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Cannot get auto gain min and max values"));
1857  }
1858 }
1859 
1877 void vp1394TwoGrabber::setCapture(dc1394switch_t _switch)
1878 {
1879  if (!num_cameras) {
1880  close();
1881  vpERROR_TRACE("No camera found");
1883  }
1884 
1885  if (_switch == DC1394_ON) {
1886  // if (dc1394_capture_setup(camera, num_buffers) != DC1394_SUCCESS) {
1887  // To be compatible with libdc1394 svn 382 version
1888  if (dc1394_capture_setup(camera, num_buffers, DC1394_CAPTURE_FLAGS_DEFAULT) != DC1394_SUCCESS) {
1889  vpERROR_TRACE("Unable to setup camera capture-\n"
1890  "make sure that the video mode and framerate are "
1891  "supported by your camera.\n");
1892  close();
1893  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Could not setup dma capture"));
1894  }
1895  } else { // _switch == DC1394_OFF
1896  dc1394error_t code = dc1394_capture_stop(camera);
1897 
1898  if (code != DC1394_SUCCESS && code != DC1394_CAPTURE_IS_NOT_SET) {
1899  vpERROR_TRACE("Unable to stop camera capture\n");
1900  close();
1901  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Could not setup dma capture"));
1902  }
1903  }
1904 }
1905 
1920 void vp1394TwoGrabber::setTransmission(dc1394switch_t _switch)
1921 {
1922  if (!num_cameras) {
1923  close();
1924  vpERROR_TRACE("No camera found");
1926  }
1927 
1928  dc1394switch_t status = DC1394_OFF;
1929 
1930  if (dc1394_video_get_transmission(camera, &status) != DC1394_SUCCESS) {
1931  vpERROR_TRACE("Unable to get transmision status");
1932  close();
1933  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Could not setup dma capture"));
1934  }
1935 
1936  // if (status!=_switch){
1937  // Start dma capture if halted
1938  if (dc1394_video_set_transmission(camera, _switch) != DC1394_SUCCESS) {
1939  vpERROR_TRACE("Unable to setup camera capture-\n"
1940  "make sure that the video mode and framerate are "
1941  "supported by your camera.\n");
1942  close();
1943  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Could not setup dma capture"));
1944  }
1945 
1946  if (_switch == DC1394_ON) {
1947  status = DC1394_OFF;
1948 
1949  int i = 0;
1950  while (status == DC1394_OFF && i++ < 5) {
1951  usleep(50000);
1952  if (dc1394_video_get_transmission(camera, &status) != DC1394_SUCCESS) {
1953  vpERROR_TRACE("Unable to get transmision status");
1954  close();
1955  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Could not setup dma capture"));
1956  }
1957  }
1958  }
1959  // }
1960 }
1961 
1996 {
1997  if (!num_cameras) {
1998  close();
1999  vpERROR_TRACE("No camera found");
2001  }
2002 
2003  dc1394operation_mode_t op_mode;
2004  dc1394speed_t speed;
2005 
2006  // Check the speed to configure in B-mode or A-mode
2007  if (isospeed >= vpISO_SPEED_800) {
2008  if (camera->bmode_capable != DC1394_TRUE) {
2009  close();
2010  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Camera is not 1394B mode capable"));
2011  }
2012 
2013  if (dc1394_video_set_operation_mode(camera, DC1394_OPERATION_MODE_1394B) != DC1394_SUCCESS) {
2014  close();
2015  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Cannot set camera to 1394B mode"));
2016  }
2017 
2018  if (dc1394_video_get_operation_mode(camera, &op_mode) != DC1394_SUCCESS) {
2019  close();
2020  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Failed to set 1394B mode"));
2021  }
2022  } else {
2023  if (dc1394_video_set_operation_mode(camera, DC1394_OPERATION_MODE_LEGACY) != DC1394_SUCCESS) {
2024  close();
2025  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Cannot set camera to 1394A mode"));
2026  }
2027 
2028  if (dc1394_video_get_operation_mode(camera, &op_mode) != DC1394_SUCCESS) {
2029  close();
2030  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Failed to set 1394A mode"));
2031  }
2032  }
2033 
2034  if (dc1394_video_set_iso_speed(camera, (dc1394speed_t)isospeed) != DC1394_SUCCESS) {
2035  close();
2036  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Cannot set requested iso speed"));
2037  }
2038 
2039  if (dc1394_video_get_iso_speed(camera, &speed) != DC1394_SUCCESS) {
2040  close();
2041  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Failed to set iso speed"));
2042  }
2043 }
2044 
2056 {
2057  open();
2058  acquire(I);
2059 }
2060 
2072 {
2073  open();
2074  acquire(I);
2075 }
2076 
2114 dc1394video_frame_t *vp1394TwoGrabber::dequeue()
2115 {
2116 
2117  if (!num_cameras) {
2118  close();
2119  vpERROR_TRACE("No camera found");
2121  }
2122 
2123  dc1394video_frame_t *frame = NULL;
2124 
2125  if (dc1394_capture_dequeue(camera, DC1394_CAPTURE_POLICY_WAIT, &frame) != DC1394_SUCCESS) {
2126  vpERROR_TRACE("Error: Failed to capture from camera %d\n", camera_id);
2127  }
2128 
2129  return frame;
2130 }
2131 
2173 {
2174  uint64_t timestamp;
2175  uint32_t id;
2176 
2177  dc1394video_frame_t *frame;
2178 
2179  frame = dequeue(I, timestamp, id);
2180 
2181  return frame;
2182 }
2183 
2231 dc1394video_frame_t *vp1394TwoGrabber::dequeue(vpImage<unsigned char> &I, uint64_t &timestamp, uint32_t &id)
2232 {
2233 
2234  open();
2235 
2236  dc1394video_frame_t *frame;
2237 
2238  frame = dequeue();
2239 
2240  // Timeval data structure providing the unix time
2241  // [microseconds] at which the frame was captured in the ring buffer.
2242  timestamp = frame->timestamp;
2243  id = frame->id;
2244 
2245  this->width = frame->size[0];
2246  this->height = frame->size[1];
2247  unsigned int size = this->width * this->height;
2248 
2249  if ((I.getWidth() != this->width) || (I.getHeight() != this->height))
2250  I.resize(this->height, this->width);
2251 
2252  switch (frame->color_coding) {
2253  case DC1394_COLOR_CODING_MONO8:
2254  case DC1394_COLOR_CODING_RAW8:
2255  memcpy(I.bitmap, (unsigned char *)frame->image, size * sizeof(unsigned char));
2256  break;
2257  case DC1394_COLOR_CODING_MONO16:
2258  case DC1394_COLOR_CODING_RAW16:
2259  vpImageConvert::MONO16ToGrey((unsigned char *)frame->image, I.bitmap, size);
2260  break;
2261 
2262  case DC1394_COLOR_CODING_YUV411:
2263  vpImageConvert::YUV411ToGrey((unsigned char *)frame->image, I.bitmap, size);
2264  break;
2265 
2266  case DC1394_COLOR_CODING_YUV422:
2267  vpImageConvert::YUV422ToGrey((unsigned char *)frame->image, I.bitmap, size);
2268  break;
2269 
2270  case DC1394_COLOR_CODING_YUV444:
2271  vpImageConvert::YUV444ToGrey((unsigned char *)frame->image, I.bitmap, size);
2272  break;
2273 
2274  case DC1394_COLOR_CODING_RGB8:
2275  vpImageConvert::RGBToGrey((unsigned char *)frame->image, I.bitmap, size);
2276  break;
2277 
2278  default:
2279  close();
2280  vpERROR_TRACE("Format conversion not implemented. Acquisition failed.");
2281  throw(vpFrameGrabberException(vpFrameGrabberException::otherError, "Format conversion not implemented. "
2282  "Acquisition failed."));
2283  };
2284 
2285  return frame;
2286 }
2287 
2328 {
2329  uint64_t timestamp;
2330  uint32_t id;
2331 
2332  dc1394video_frame_t *frame;
2333 
2334  frame = dequeue(I, timestamp, id);
2335 
2336  return frame;
2337 }
2338 
2386 dc1394video_frame_t *vp1394TwoGrabber::dequeue(vpImage<vpRGBa> &I, uint64_t &timestamp, uint32_t &id)
2387 {
2388 
2389  open();
2390 
2391  dc1394video_frame_t *frame;
2392 
2393  frame = dequeue();
2394 
2395  // Timeval data structure providing the unix time
2396  // [microseconds] at which the frame was captured in the ring buffer.
2397  timestamp = frame->timestamp;
2398  id = frame->id;
2399 
2400  this->width = frame->size[0];
2401  this->height = frame->size[1];
2402  unsigned int size = this->width * this->height;
2403 
2404  if ((I.getWidth() != width) || (I.getHeight() != height))
2405  I.resize(height, width);
2406 
2407  switch (frame->color_coding) {
2408  case DC1394_COLOR_CODING_MONO8:
2409  case DC1394_COLOR_CODING_RAW8:
2410  vpImageConvert::GreyToRGBa((unsigned char *)frame->image, (unsigned char *)I.bitmap, size);
2411  break;
2412 
2413  case DC1394_COLOR_CODING_MONO16:
2414  case DC1394_COLOR_CODING_RAW16:
2415  vpImageConvert::MONO16ToRGBa((unsigned char *)frame->image, (unsigned char *)I.bitmap, size);
2416  break;
2417 
2418  case DC1394_COLOR_CODING_YUV411:
2419  vpImageConvert::YUV411ToRGBa((unsigned char *)frame->image, (unsigned char *)I.bitmap, size);
2420  break;
2421 
2422  case DC1394_COLOR_CODING_YUV422:
2423  vpImageConvert::YUV422ToRGBa((unsigned char *)frame->image, (unsigned char *)I.bitmap, size);
2424  break;
2425 
2426  case DC1394_COLOR_CODING_YUV444:
2427  vpImageConvert::YUV444ToRGBa((unsigned char *)frame->image, (unsigned char *)I.bitmap, size);
2428  break;
2429 
2430  case DC1394_COLOR_CODING_RGB8:
2431  vpImageConvert::RGBToRGBa((unsigned char *)frame->image, (unsigned char *)I.bitmap, size);
2432  break;
2433 
2434  default:
2435  close();
2436  vpERROR_TRACE("Format conversion not implemented. Acquisition failed.");
2437  throw(vpFrameGrabberException(vpFrameGrabberException::otherError, "Format conversion not implemented. "
2438  "Acquisition failed."));
2439  };
2440 
2441  return frame;
2442 }
2443 
2454 void vp1394TwoGrabber::enqueue(dc1394video_frame_t *frame)
2455 {
2456 
2457  if (!num_cameras) {
2458  close();
2459  vpERROR_TRACE("No camera found");
2461  }
2462 
2463  if (frame)
2464  dc1394_capture_enqueue(camera, frame);
2465 }
2466 
2481 {
2482  uint64_t timestamp;
2483  uint32_t id;
2484 
2485  dc1394video_frame_t *frame;
2486 
2487  frame = dequeue(I, timestamp, id);
2488  enqueue(frame);
2489 }
2490 
2509 void vp1394TwoGrabber::acquire(vpImage<unsigned char> &I, uint64_t &timestamp, uint32_t &id)
2510 {
2511  dc1394video_frame_t *frame;
2512 
2513  open();
2514  frame = dequeue(I, timestamp, id);
2515  enqueue(frame);
2516 }
2517 
2532 {
2533  uint64_t timestamp;
2534  uint32_t id;
2535  dc1394video_frame_t *frame;
2536 
2537  open();
2538  frame = dequeue(I, timestamp, id);
2539  enqueue(frame);
2540 }
2541 
2560 void vp1394TwoGrabber::acquire(vpImage<vpRGBa> &I, uint64_t &timestamp, uint32_t &id)
2561 {
2562  dc1394video_frame_t *frame;
2563 
2564  open();
2565  frame = dequeue();
2566  // Timeval data structure providing the unix time
2567  // [microseconds] at which the frame was captured in the ring buffer.
2568  timestamp = frame->timestamp;
2569  id = frame->id;
2570 
2571  this->width = frame->size[0];
2572  this->height = frame->size[1];
2573  unsigned int size = this->width * this->height;
2574 
2575  if ((I.getWidth() != width) || (I.getHeight() != height))
2576  I.resize(height, width);
2577 
2578  switch (frame->color_coding) {
2579  case DC1394_COLOR_CODING_MONO8:
2580  case DC1394_COLOR_CODING_RAW8:
2581  vpImageConvert::GreyToRGBa((unsigned char *)frame->image, (unsigned char *)I.bitmap, size);
2582  break;
2583 
2584  case DC1394_COLOR_CODING_YUV411:
2585  vpImageConvert::YUV411ToRGBa((unsigned char *)frame->image, (unsigned char *)I.bitmap, size);
2586  break;
2587 
2588  case DC1394_COLOR_CODING_YUV422:
2589  vpImageConvert::YUV422ToRGBa((unsigned char *)frame->image, (unsigned char *)I.bitmap, size);
2590  break;
2591 
2592  case DC1394_COLOR_CODING_YUV444:
2593  vpImageConvert::YUV444ToRGBa((unsigned char *)frame->image, (unsigned char *)I.bitmap, size);
2594  break;
2595 
2596  case DC1394_COLOR_CODING_RGB8:
2597  vpImageConvert::RGBToRGBa((unsigned char *)frame->image, (unsigned char *)I.bitmap, size);
2598  break;
2599 
2600  default:
2601  close();
2602  vpERROR_TRACE("Format conversion not implemented. Acquisition failed.");
2603  throw(vpFrameGrabberException(vpFrameGrabberException::otherError, "Format conversion not implemented. "
2604  "Acquisition failed."));
2605  };
2606 
2607  enqueue(frame);
2608 }
2609 
2626 void vp1394TwoGrabber::getWidth(unsigned int &w)
2627 {
2628  if (!num_cameras) {
2629  close();
2630  vpERROR_TRACE("No camera found");
2632  }
2633 
2634  w = this->width;
2635 }
2636 
2655 {
2656  if (!num_cameras) {
2657  close();
2658  vpERROR_TRACE("No camera found");
2660  }
2661 
2662  return this->width;
2663 }
2664 
2682 void vp1394TwoGrabber::getHeight(unsigned int &h)
2683 {
2684  if (!num_cameras) {
2685  close();
2686  vpERROR_TRACE("No camera found");
2688  }
2689 
2690  h = this->height;
2691 }
2710 {
2711  if (!num_cameras) {
2712  close();
2713  vpERROR_TRACE("No camera found");
2715  }
2716 
2717  return this->height;
2718 }
2719 
2726 {
2727  std::cout << "----------------------------------------------------------" << std::endl
2728  << "----- Information for camera " << camera_id << " -----" << std::endl
2729  << "----------------------------------------------------------" << std::endl;
2730 
2731 #ifdef VISP_HAVE_DC1394_CAMERA_ENUMERATE // new API > libdc1394-2.0.0-rc7
2732  dc1394_camera_print_info(camera, stdout);
2733 #elif defined VISP_HAVE_DC1394_FIND_CAMERAS // old API <= libdc1394-2.0.0-rc7
2734  dc1394_print_camera_info(camera);
2735 #endif
2736 
2737  dc1394featureset_t features;
2738 #ifdef VISP_HAVE_DC1394_CAMERA_ENUMERATE // new API > libdc1394-2.0.0-rc7
2739  if (dc1394_feature_get_all(camera, &features) != DC1394_SUCCESS)
2740 #elif defined VISP_HAVE_DC1394_FIND_CAMERAS // old API <= libdc1394-2.0.0-rc7
2741  if (dc1394_get_camera_feature_set(camera, &features) != DC1394_SUCCESS)
2742 #endif
2743  {
2744  close();
2745  vpERROR_TRACE("unable to get feature set for camera %d\n", camera_id);
2746  throw(vpFrameGrabberException(vpFrameGrabberException::initializationError, "Cannot get camera features"));
2747 
2748  } else {
2749 #ifdef VISP_HAVE_DC1394_CAMERA_ENUMERATE // new API > libdc1394-2.0.0-rc7
2750  dc1394_feature_print_all(&features, stdout);
2751 #elif defined VISP_HAVE_DC1394_FIND_CAMERAS // old API <= libdc1394-2.0.0-rc7
2752  dc1394_print_feature_set(&features);
2753 #endif
2754  }
2755  std::cout << "----------------------------------------------------------" << std::endl;
2756 }
2757 
2771 {
2772  std::string _str = "";
2773  dc1394video_mode_t _videomode = (dc1394video_mode_t)videomode;
2774 
2775  if ((_videomode >= DC1394_VIDEO_MODE_MIN) && (_videomode <= DC1394_VIDEO_MODE_MAX)) {
2776  _str = strVideoMode[_videomode - DC1394_VIDEO_MODE_MIN];
2777  } else {
2778  vpCERROR << "The video mode " << (int)videomode << " is not supported by the camera" << std::endl;
2779  }
2780 
2781  return _str;
2782 }
2783 
2797 {
2798  std::string _str = "";
2799  dc1394framerate_t _fps = (dc1394framerate_t)fps;
2800 
2801  if ((_fps >= DC1394_FRAMERATE_MIN) && (_fps <= DC1394_FRAMERATE_MAX)) {
2802  _str = strFramerate[_fps - DC1394_FRAMERATE_MIN];
2803  } else {
2804  vpCERROR << "The framerate " << (int)fps << " is not supported by the camera" << std::endl;
2805  }
2806 
2807  return _str;
2808 }
2809 
2823 {
2824  std::string _str = "";
2825  dc1394color_coding_t _coding = (dc1394color_coding_t)colorcoding;
2826 
2827  if ((_coding >= DC1394_COLOR_CODING_MIN) && (_coding <= DC1394_COLOR_CODING_MAX)) {
2828  _str = strColorCoding[_coding - DC1394_COLOR_CODING_MIN];
2829 
2830  } else {
2831  vpCERROR << "The color coding " << (int)colorcoding << " is not supported by the camera" << std::endl;
2832  }
2833 
2834  return _str;
2835 }
2836 
2855 {
2857 
2858  for (int i = DC1394_VIDEO_MODE_MIN; i <= DC1394_VIDEO_MODE_MAX; i++) {
2859  _id = (vp1394TwoVideoModeType)i;
2860  if (videomode.compare(videoMode2string(_id)) == 0)
2861  return _id;
2862  };
2863 
2864  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "The required videomode is not valid"));
2865 
2866  return (vp1394TwoVideoModeType)0;
2867 }
2868 
2887 {
2889 
2890  for (int i = DC1394_FRAMERATE_MIN; i <= DC1394_FRAMERATE_MAX; i++) {
2891  _id = (vp1394TwoFramerateType)i;
2892  if (framerate.compare(framerate2string(_id)) == 0)
2893  return _id;
2894  };
2895 
2896  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "The required framerate is not valid"));
2897 
2898  return (vp1394TwoFramerateType)0;
2899 }
2900 
2919 {
2921 
2922  for (int i = DC1394_COLOR_CODING_MIN; i <= DC1394_COLOR_CODING_MAX; i++) {
2923  _id = (vp1394TwoColorCodingType)i;
2924  if (colorcoding.compare(colorCoding2string(_id)) == 0)
2925  return _id;
2926  };
2927 
2928  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "The required color coding is not valid"));
2929 
2930  return (vp1394TwoColorCodingType)0;
2931 }
2932 
2965 {
2966  for (unsigned int i = 0; i < num_cameras; i++) {
2967  if (camIsOpen[i]) {
2968  camera = cameras[i];
2969  setTransmission(DC1394_OFF);
2970  setCapture(DC1394_OFF);
2971  }
2972  }
2973 #ifdef VISP_HAVE_DC1394_CAMERA_ENUMERATE // new API > libdc1394-2.0.0-rc7
2974  setCamera(camera_id);
2975  // free the other cameras
2976  for (unsigned int i = 0; i < num_cameras; i++) {
2977  if (i != camera_id)
2978  dc1394_camera_free(cameras[i]);
2979  }
2980 
2981  printf("Resetting bus...\n");
2982  dc1394_reset_bus(camera);
2983 
2984  dc1394_camera_free(camera);
2985  dc1394_free(d);
2986  d = NULL;
2987  // if (cameras != NULL)
2988  delete[] cameras;
2989  cameras = NULL;
2990 #elif defined VISP_HAVE_DC1394_FIND_CAMERAS // old API <= libdc1394-2.0.0-rc7
2991 
2992  setCamera(camera_id);
2993  // free the other cameras
2994  for (unsigned int i = 0; i < num_cameras; i++) {
2995  if (i != camera_id)
2996  dc1394_free_camera(cameras[i]);
2997  }
2998  free(cameras);
2999  cameras = NULL;
3000 
3001  dc1394_reset_bus(camera);
3002  dc1394_free_camera(camera);
3003 
3004 #endif
3005  if (camIsOpen != NULL)
3006  delete[] camIsOpen;
3007  camIsOpen = NULL;
3008 
3009  num_cameras = 0;
3010 
3011  init = false;
3012  vpTime::wait(1000);
3013  initialize(false);
3014 }
3015 
3046 void vp1394TwoGrabber::setPanControl(unsigned int panControlValue)
3047 {
3048  open();
3049  if (!num_cameras) {
3050  close();
3051  vpERROR_TRACE("No camera found");
3053  }
3054  uint64_t offset = 0x884;
3055  uint32_t value = 0x82000000 + (uint32_t)panControlValue;
3056  dc1394error_t err;
3057  err = dc1394_set_control_register(camera, offset, value);
3058  if (err != DC1394_SUCCESS) {
3059  vpERROR_TRACE("Unable to set PAN register");
3060  close();
3061  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Unable to set PAN register"));
3062  }
3063 }
3064 
3082 {
3083  if (!num_cameras) {
3084  close();
3085  vpERROR_TRACE("No camera found");
3087  }
3088 
3089  uint32_t value;
3090  dc1394feature_t feature = DC1394_FEATURE_BRIGHTNESS; // = (dc1394feature_t)param;
3091  switch (param) {
3092  case vpFEATURE_BRIGHTNESS:
3093  feature = DC1394_FEATURE_BRIGHTNESS;
3094  break;
3095  case vpFEATURE_EXPOSURE:
3096  feature = DC1394_FEATURE_EXPOSURE;
3097  break;
3098  case vpFEATURE_SHARPNESS:
3099  feature = DC1394_FEATURE_SHARPNESS;
3100  break;
3101  // vpFEATURE_WHITE_BALANCE = DC1394_FEATURE_WHITE_BALANCE,
3102  case vpFEATURE_HUE:
3103  feature = DC1394_FEATURE_HUE;
3104  break;
3105  case vpFEATURE_SATURATION:
3106  feature = DC1394_FEATURE_SATURATION;
3107  break;
3108  case vpFEATURE_GAMMA:
3109  feature = DC1394_FEATURE_GAMMA;
3110  break;
3111  case vpFEATURE_SHUTTER:
3112  feature = DC1394_FEATURE_SHUTTER;
3113  break;
3114  case vpFEATURE_GAIN:
3115  feature = DC1394_FEATURE_GAIN;
3116  break;
3117  case vpFEATURE_IRIS:
3118  feature = DC1394_FEATURE_IRIS;
3119  break;
3120  // vpFEATURE_FOCUS = DC1394_FEATURE_FOCUS,
3121  // vpFEATURE_TEMPERATURE = DC1394_FEATURE_TEMPERATURE,
3122  // vpFEATURE_TRIGGER = DC1394_FEATURE_TRIGGER,
3123  // vpFEATURE_TRIGGER_DELAY = DC1394_FEATURE_TRIGGER_DELAY,
3124  // vpFEATURE_WHITE_SHADING = DC1394_FEATURE_WHITE_SHADING,
3125  // vpFEATURE_FRAME_RATE = DC1394_FEATURE_FRAME_RATE,
3126  // vpFEATURE_ZOOM = DC1394_FEATURE_ZOOM,
3127  // vpFEATURE_PAN = DC1394_FEATURE_PAN,
3128  // vpFEATURE_TILT = DC1394_FEATURE_TILT,
3129  // vpFEATURE_OPTICAL_FILTER = DC1394_FEATURE_OPTICAL_FILTER,
3130  // vpFEATURE_CAPTURE_SIZE = DC1394_FEATURE_CAPTURE_SIZE,
3131  // vpFEATURE_CAPTURE_QUALITY = DC1394_FEATURE_CAPTURE_QUALITY
3132  }
3133 
3134  dc1394error_t err;
3135  err = dc1394_feature_get_value(camera, feature, &value);
3136  if (err != DC1394_SUCCESS) {
3137  vpERROR_TRACE("Unable to get the information");
3138  close();
3139  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Unable to get the information"));
3140  }
3141  return (unsigned int)value;
3142 }
3143 
3166 {
3167  if (!num_cameras) {
3168  close();
3169  vpERROR_TRACE("No camera found");
3171  }
3172  uint32_t value = (uint32_t)val;
3173  dc1394feature_t feature = DC1394_FEATURE_BRIGHTNESS; // = (dc1394feature_t)param;
3174  switch (param) {
3175  case vpFEATURE_BRIGHTNESS:
3176  feature = DC1394_FEATURE_BRIGHTNESS;
3177  break;
3178  case vpFEATURE_EXPOSURE:
3179  feature = DC1394_FEATURE_EXPOSURE;
3180  break;
3181  case vpFEATURE_SHARPNESS:
3182  feature = DC1394_FEATURE_SHARPNESS;
3183  break;
3184  // vpFEATURE_WHITE_BALANCE = DC1394_FEATURE_WHITE_BALANCE,
3185  case vpFEATURE_HUE:
3186  feature = DC1394_FEATURE_HUE;
3187  break;
3188  case vpFEATURE_SATURATION:
3189  feature = DC1394_FEATURE_SATURATION;
3190  break;
3191  case vpFEATURE_GAMMA:
3192  feature = DC1394_FEATURE_GAMMA;
3193  break;
3194  case vpFEATURE_SHUTTER:
3195  feature = DC1394_FEATURE_SHUTTER;
3196  break;
3197  case vpFEATURE_GAIN:
3198  feature = DC1394_FEATURE_GAIN;
3199  break;
3200  case vpFEATURE_IRIS:
3201  feature = DC1394_FEATURE_IRIS;
3202  break;
3203  // vpFEATURE_FOCUS = DC1394_FEATURE_FOCUS,
3204  // vpFEATURE_TEMPERATURE = DC1394_FEATURE_TEMPERATURE,
3205  // vpFEATURE_TRIGGER = DC1394_FEATURE_TRIGGER,
3206  // vpFEATURE_TRIGGER_DELAY = DC1394_FEATURE_TRIGGER_DELAY,
3207  // vpFEATURE_WHITE_SHADING = DC1394_FEATURE_WHITE_SHADING,
3208  // vpFEATURE_FRAME_RATE = DC1394_FEATURE_FRAME_RATE,
3209  // vpFEATURE_ZOOM = DC1394_FEATURE_ZOOM,
3210  // vpFEATURE_PAN = DC1394_FEATURE_PAN,
3211  // vpFEATURE_TILT = DC1394_FEATURE_TILT,
3212  // vpFEATURE_OPTICAL_FILTER = DC1394_FEATURE_OPTICAL_FILTER,
3213  // vpFEATURE_CAPTURE_SIZE = DC1394_FEATURE_CAPTURE_SIZE,
3214  // vpFEATURE_CAPTURE_QUALITY = DC1394_FEATURE_CAPTURE_QUALITY
3215  }
3216 
3217  dc1394error_t err;
3218  dc1394bool_t hasManualMode = DC1394_FALSE;
3219  dc1394feature_modes_t modesAvailable;
3220 
3221  // test wether we can set the shutter value (manual mode available or not)
3222  err = dc1394_feature_get_modes(camera, feature, &modesAvailable);
3223  if (err != DC1394_SUCCESS) {
3224  vpERROR_TRACE("Unable to detect the manual mode information");
3225  close();
3226  throw(
3227  vpFrameGrabberException(vpFrameGrabberException::settingError, "Unable to detect the manual mode information"));
3228  }
3229 
3230  for (unsigned int i = 0; i < modesAvailable.num; i++) {
3231  if (modesAvailable.modes[i] == DC1394_FEATURE_MODE_MANUAL) {
3232  hasManualMode = DC1394_TRUE;
3233  }
3234  }
3235 
3236  if (hasManualMode == DC1394_TRUE) {
3237 
3238  if (!isDataModified[camera_id]) { // to ensure we save the first mode
3239  // even after several set
3240  /* we update the structure */
3241  updateDataCamToStruct();
3242  err = dc1394_feature_get_mode(camera, feature, &(initialShutterMode[camera_id]));
3243  if (err != DC1394_SUCCESS) {
3244  vpERROR_TRACE("Unable to get the initial mode");
3245  close();
3246  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Unable to get the initial mode"));
3247  }
3248  isDataModified[camera_id] = true;
3249  }
3250 
3251  dc1394feature_mode_t manualMode = DC1394_FEATURE_MODE_MANUAL;
3252  err = dc1394_feature_set_mode(camera, feature, manualMode);
3253  if (err != DC1394_SUCCESS) {
3254  vpERROR_TRACE("Unable to set the muanual mode");
3255  close();
3256  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Unable to set the manual mode"));
3257  }
3258  err = dc1394_feature_set_value(camera, feature, value);
3259  if (err != DC1394_SUCCESS) {
3260  vpERROR_TRACE("Unable to set the shutter information");
3261  close();
3262  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Unable to set the shutter information"));
3263  }
3264  } else {
3265  vpERROR_TRACE("The camera does not have a manual mode.\nCannot change the value");
3266  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "The camera does not have a manual mode"));
3267  }
3268 }
3276 void vp1394TwoGrabber::getGuid(uint64_t &guid)
3277 {
3278  if (!num_cameras) {
3279  close();
3280  vpERROR_TRACE("No camera found");
3282  }
3283 
3284  guid = camera->guid;
3285 }
3286 
3295 {
3296  if (!num_cameras) {
3297  close();
3298  vpERROR_TRACE("No camera found");
3300  }
3301 
3302  return camera->guid;
3303 }
3304 
3309 inline void vp1394TwoGrabber::updateDataCamToStruct()
3310 {
3311  dataCam[camera_id].brightness = getParameterValue(vpFEATURE_BRIGHTNESS);
3312  dataCam[camera_id].exposure = getParameterValue(vpFEATURE_EXPOSURE);
3313  dataCam[camera_id].sharpness = getParameterValue(vpFEATURE_SHARPNESS);
3314  dataCam[camera_id].hue = getParameterValue(vpFEATURE_HUE);
3315  dataCam[camera_id].saturation = getParameterValue(vpFEATURE_SATURATION);
3316  dataCam[camera_id].gamma = getParameterValue(vpFEATURE_GAMMA);
3317  dataCam[camera_id].shutter = getParameterValue(vpFEATURE_SHUTTER);
3318  dataCam[camera_id].gain = getParameterValue(vpFEATURE_GAIN);
3319  dataCam[camera_id].iris = getParameterValue(vpFEATURE_IRIS);
3320 }
3321 
3326 inline void vp1394TwoGrabber::updateDataStructToCam()
3327 {
3328  setParameterValue(vpFEATURE_BRIGHTNESS, dataCam[camera_id].brightness);
3329  setParameterValue(vpFEATURE_EXPOSURE, dataCam[camera_id].exposure);
3330  setParameterValue(vpFEATURE_SHARPNESS, dataCam[camera_id].sharpness);
3331  setParameterValue(vpFEATURE_HUE, dataCam[camera_id].hue);
3332  setParameterValue(vpFEATURE_SATURATION, dataCam[camera_id].saturation);
3333  setParameterValue(vpFEATURE_GAMMA, dataCam[camera_id].gamma);
3334  setParameterValue(vpFEATURE_SHUTTER, dataCam[camera_id].shutter);
3335  setParameterValue(vpFEATURE_GAIN, dataCam[camera_id].gain);
3336  setParameterValue(vpFEATURE_IRIS, dataCam[camera_id].iris);
3337 }
3338 
3356 {
3357  this->acquire(I);
3358  return *this;
3359 }
3360 
3378 {
3379  this->acquire(I);
3380  return *this;
3381 }
3382 
3383 #elif !defined(VISP_BUILD_SHARED_LIBS)
3384 // Work around to avoid warning: libvisp_sensor.a(vp1394TwoGrabber.cpp.o) has
3385 // no symbols
3386 void dummy_vp1394TwoGrabber(){};
3387 #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 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:795
Type * bitmap
points toward the bitmap
Definition: vpImage.h:139
unsigned int getHeight() const
Definition: vpImage.h:184
#define vpCTRACE
Definition: vpDebug.h:333
#define vpCERROR
Definition: vpDebug.h:360
#define vpTRACE
Definition: vpDebug.h:411
#define vpERROR_TRACE
Definition: vpDebug.h:388
VISP_EXPORT int wait(double t0, double t)