Visual Servoing Platform  version 3.6.1 under development (2024-04-24)
vp1394TwoGrabber.cpp
1 /****************************************************************************
2  *
3  * ViSP, open source Visual Servoing Platform software.
4  * Copyright (C) 2005 - 2023 by Inria. All rights reserved.
5  *
6  * This software is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  * See the file LICENSE.txt at the root directory of this source
11  * distribution for additional information about the GNU GPL.
12  *
13  * For using ViSP with software that can not be combined with the GNU
14  * GPL, please contact Inria about acquiring a ViSP Professional
15  * Edition License.
16  *
17  * See https://visp.inria.fr for more information.
18  *
19  * This software was developed at:
20  * Inria Rennes - Bretagne Atlantique
21  * Campus Universitaire de Beaulieu
22  * 35042 Rennes Cedex
23  * France
24  *
25  * If you have questions regarding the use of this file, please contact
26  * Inria at visp@inria.fr
27  *
28  * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
29  * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
30  *
31  * Description:
32  * Firewire cameras video capture.
33  *
34 *****************************************************************************/
35 
40 #include <iostream>
41 
42 #include <visp3/core/vpConfig.h>
43 
44 /*
45  * Interface with libdc1394 2.x
46  */
47 #if defined(VISP_HAVE_DC1394)
48 #include <unistd.h>
49 
50 #include <visp3/core/vpFrameGrabberException.h>
51 #include <visp3/core/vpImageConvert.h>
52 #include <visp3/core/vpTime.h>
53 #include <visp3/sensor/vp1394TwoGrabber.h>
54 
55 const char *vp1394TwoGrabber::strVideoMode[DC1394_VIDEO_MODE_NUM] = {
56  "MODE_160x120_YUV444", "MODE_320x240_YUV422", "MODE_640x480_YUV411", "MODE_640x480_YUV422",
57  "MODE_640x480_RGB8", "MODE_640x480_MONO8", "MODE_640x480_MONO16", "MODE_800x600_YUV422",
58  "MODE_800x600_RGB8", "MODE_800x600_MONO8", "MODE_1024x768_YUV422", "MODE_1024x768_RGB8",
59  "MODE_1024x768_MONO8", "MODE_800x600_MONO16", "MODE_1024x768_MONO16", "MODE_1280x960_YUV422",
60  "MODE_1280x960_RGB8", "MODE_1280x960_MONO8", "MODE_1600x1200_YUV422", "MODE_1600x1200_RGB8",
61  "MODE_1600x1200_MONO8", "MODE_1280x960_MONO16", "MODE_1600x1200_MONO16", "MODE_EXIF",
62  "MODE_FORMAT7_0", "MODE_FORMAT7_1", "MODE_FORMAT7_2", "MODE_FORMAT7_3",
63  "MODE_FORMAT7_4", "MODE_FORMAT7_5", "MODE_FORMAT7_6", "MODE_FORMAT7_7" };
64 
65 const char *vp1394TwoGrabber::strFramerate[DC1394_FRAMERATE_NUM] = {
66  "FRAMERATE_1_875", "FRAMERATE_3_75", "FRAMERATE_7_5", "FRAMERATE_15",
67  "FRAMERATE_30", "FRAMERATE_60", "FRAMERATE_120", "FRAMERATE_240" };
68 
69 const char *vp1394TwoGrabber::strColorCoding[DC1394_COLOR_CODING_NUM] = {
70  "COLOR_CODING_MONO8", "COLOR_CODING_YUV411", "COLOR_CODING_YUV422", "COLOR_CODING_YUV444",
71  "COLOR_CODING_RGB8", "COLOR_CODING_MONO16", "COLOR_CODING_RGB16", "COLOR_CODING_MONO16S",
72  "COLOR_CODING_RGB16S", "COLOR_CODING_RAW8", "COLOR_CODING_RAW16",
73 };
74 
120  : camera(nullptr), cameras(nullptr), num_cameras(0), camera_id(0), verbose(false), camIsOpen(nullptr),
121  num_buffers(4), // ring buffer size
122  isDataModified(nullptr), initialShutterMode(nullptr), dataCam(nullptr)
123 #ifdef VISP_HAVE_DC1394_CAMERA_ENUMERATE // new API > libdc1394-2.0.0-rc7
124  ,
125  d(nullptr), list(nullptr)
126 #endif
127 {
128  // protected members
129  width = height = 0;
130 
131  // private members
132  init = false;
133 
134  reset = false;
135  initialize(reset);
136 
137  // open();
138 }
139 
150 {
151  /* if(num_cameras >= 1){
152  delete[] isDataModified;
153  delete[] initialShutterMode;
154  delete[] dataCam;
155  }*/
156  close();
157 }
158 
277 void vp1394TwoGrabber::setCamera(uint64_t cam_id)
278 {
279  // Suppose that if camera_id is a camera GUID, this value is greater
280  // than the number of cameras connected to the bus
281  if (cam_id >= num_cameras) {
282  // Check if camera_id is a camera guid
283  bool is_guid = false;
284  // check if the camera_id is a guid
285  for (unsigned int i = 0; i < num_cameras; i++) {
286  if (cameras[i]->guid == cam_id) {
287  this->camera_id = i;
288  is_guid = true;
289  break;
290  }
291  }
292  if (is_guid == false) {
293  std::cout << "Error: The camera with guid 0x" << std::hex << cam_id << " is not present" << std::endl;
294  std::cout << num_cameras << " camera(s) connected" << std::endl;
295  for (unsigned int i = 0; i < num_cameras; i++) {
296  std::cout << " - camera " << i << " with guid 0x" << std::hex << cameras[i]->guid << std::endl;
297  }
298  close();
299  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "The required camera is not present"));
300  }
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  }
331  else {
332  close();
333  vpERROR_TRACE("No cameras found");
335  }
336 }
337 
353 {
354  if (num_cameras) {
355  return this->camera_id;
356  }
357  else {
358  close();
359  vpERROR_TRACE("No cameras found");
361  }
362 }
363 
371 void vp1394TwoGrabber::getNumCameras(unsigned int &ncameras) const
372 {
373  if (!num_cameras) {
374  vpCTRACE << "No camera found..." << std::endl;
375  ncameras = 0;
376  }
377 
378  ncameras = num_cameras;
379 }
380 
389 {
390  unsigned int ncameras = 0;
391  if (!num_cameras) {
392  vpCTRACE << "No camera found..." << std::endl;
393  ncameras = 0;
394  }
395 
396  ncameras = num_cameras;
397  return ncameras;
398 }
399 
445 {
446  open();
447  if (!num_cameras) {
448  close();
450  }
451  if (!isVideoModeSupported(videomode)) {
452  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Video mode not supported by camera %d",
453  camera_id));
454  }
455  // Stop dma capture if started
456  setTransmission(DC1394_OFF);
457  setCapture(DC1394_OFF);
458 
459  if (dc1394_video_set_mode(camera, (dc1394video_mode_t)videomode) != DC1394_SUCCESS) {
460  close();
461  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Can't set video mode"));
462  }
463 
464  setCapture(DC1394_ON);
465  setTransmission(DC1394_ON);
466 
467  // Updates image size from new video mode
468  if (dc1394_get_image_size_from_video_mode(camera, (dc1394video_mode_t)videomode, &this->width, &this->height) !=
469  DC1394_SUCCESS) {
470 
471  close();
472  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Can't get image size"));
473  }
474 }
475 
493 {
494  if (!num_cameras) {
495  close();
496  vpERROR_TRACE("No camera found");
498  }
499 
500  dc1394video_mode_t _videomode;
501  if (dc1394_video_get_mode(camera, &_videomode) != DC1394_SUCCESS) {
502 
503  close();
504  vpERROR_TRACE("Can't get current video mode");
505  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Can't get current video mode"));
506  }
507  videomode = (vp1394TwoVideoModeType)_videomode;
508 }
509 
526 uint32_t vp1394TwoGrabber::getVideoModeSupported(std::list<vp1394TwoVideoModeType> &videomodes)
527 {
528  // Refresh the list of supported modes
529  videomodes.clear();
530 
531  if (!num_cameras) {
532  close();
533  vpERROR_TRACE("No camera found");
535  }
536  dc1394video_modes_t _videomodes;
537 
538  // get video modes:
539  if (dc1394_video_get_supported_modes(camera, &_videomodes) != DC1394_SUCCESS) {
540 
541  close();
542  vpERROR_TRACE("Can't get video modes");
543  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Can't get video modes"));
544  }
545 
546  // parse the video modes to add in the list
547  for (unsigned i = 0; i < _videomodes.num; i++) {
548  vp1394TwoVideoModeType _mode = (vp1394TwoVideoModeType)_videomodes.modes[i];
549  videomodes.push_back(_mode);
550  }
551 
552  // return the number of available video modes
553  return _videomodes.num;
554 }
571 {
572  if (!num_cameras) {
573  close();
574  vpERROR_TRACE("No camera found");
576  }
577  dc1394video_modes_t _videomodes;
578 
579  // get video modes:
580  if (dc1394_video_get_supported_modes(camera, &_videomodes) != DC1394_SUCCESS) {
581 
582  close();
583  vpERROR_TRACE("Can't get video modes");
584  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Can't get video modes"));
585  }
586 
587  // parse the video modes to check with the desired
588  for (unsigned i = 0; i < _videomodes.num; i++) {
589  if ((vp1394TwoVideoModeType)_videomodes.modes[i] == videomode) {
590  return true;
591  }
592  }
593  return false;
594 }
595 
609 {
610 
611  if (dc1394_is_video_mode_scalable((dc1394video_mode_t)videomode))
612  return true;
613 
614  return false;
615 }
616 
633 {
635  getColorCoding(coding);
636 
637  switch (coding) {
641  case vpCOLOR_CODING_RAW8:
643  return false;
647  case vpCOLOR_CODING_RGB8:
650  return true;
651  }
652  return false;
653 }
654 
680 {
681  open();
682  if (!num_cameras) {
683  close();
685  }
686 
687  vp1394TwoVideoModeType cur_videomode;
688  getVideoMode(cur_videomode);
689  if (isVideoModeFormat7(cur_videomode))
690  return;
691 
692  if (!isFramerateSupported(cur_videomode, fps)) {
693  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Framerate not supported by camera %d",
694  camera_id));
695  }
696 
697  // Stop dma capture if started
698  setTransmission(DC1394_OFF);
699  setCapture(DC1394_OFF);
700 
701  if (dc1394_video_set_framerate(camera, (dc1394framerate_t)fps) != DC1394_SUCCESS) {
702 
703  close();
704  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Can't set framerate"));
705  }
706 
707  setCapture(DC1394_ON);
708  setTransmission(DC1394_ON);
709 }
710 
728 {
729  if (!num_cameras) {
730  close();
731  vpERROR_TRACE("No camera found");
733  }
734  dc1394framerate_t _fps;
735  if (dc1394_video_get_framerate(camera, &_fps) != DC1394_SUCCESS) {
736 
737  close();
738  vpERROR_TRACE("Can't get current framerate");
739  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Can't get current framerate"));
740  }
741  fps = (vp1394TwoFramerateType)_fps;
742 }
743 
775 uint32_t vp1394TwoGrabber::getFramerateSupported(vp1394TwoVideoModeType mode, std::list<vp1394TwoFramerateType> &fps)
776 {
777  if (!num_cameras) {
778  close();
779  vpERROR_TRACE("No camera found");
781  }
782 
783  // Refresh the list of supported framerates
784  fps.clear();
785 
786  switch (mode) {
787  // Framerate not available for:
788  // - vpVIDEO_MODE_EXIF ie Format_6
789  // - vpVIDEO_MODE_FORMAT7... ie the Format_7
790  case vpVIDEO_MODE_EXIF:
799  return 0;
800  break;
801  default: {
802  dc1394framerates_t _fps;
803  if (dc1394_video_get_supported_framerates(camera, (dc1394video_mode_t)mode, &_fps) != DC1394_SUCCESS) {
804  close();
805  vpERROR_TRACE("Could not query supported frametates for mode %d\n", mode);
806  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Could not query supported framerates"));
807  }
808  if (_fps.num == 0)
809  return 0;
810 
811  for (unsigned int i = 0; i < _fps.num; i++)
812  fps.push_back((vp1394TwoFramerateType)_fps.framerates[i]);
813 
814  return _fps.num;
815  } break;
816  }
817 }
852 {
853  if (!num_cameras) {
854  close();
855  vpERROR_TRACE("No camera found");
857  }
858 
859  switch (mode) {
860  // Framerate not available for:
861  // - vpVIDEO_MODE_EXIF ie Format_6
862  // - vpVIDEO_MODE_FORMAT7... ie the Format_7
863  case vpVIDEO_MODE_EXIF:
872  return 0;
873  break;
874  default: {
875  dc1394framerates_t _fps;
876  if (dc1394_video_get_supported_framerates(camera, (dc1394video_mode_t)mode, &_fps) != DC1394_SUCCESS) {
877  close();
878  vpERROR_TRACE("Could not query supported frametates for mode %d\n", mode);
879  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Could not query supported framerates"));
880  }
881  if (_fps.num == 0)
882  return 0;
883 
884  for (unsigned int i = 0; i < _fps.num; i++) {
885  if (fps == (vp1394TwoFramerateType)_fps.framerates[i]) {
886  return true;
887  }
888  }
889  return false;
890  } break;
891  }
892 }
893 
942 {
943  if (!num_cameras) {
944  close();
946  }
947 
948  dc1394video_mode_t _videomode;
949  if (dc1394_video_get_mode(camera, &_videomode) != DC1394_SUCCESS) {
950 
951  close();
952  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Can't get current video mode"));
953  }
954 
955  if (!isColorCodingSupported((vp1394TwoVideoModeType)_videomode, coding)) {
956  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Color coding not supported by camera %d",
957  camera_id));
958  }
959 
960  // Format 7 video mode
961  if (dc1394_is_video_mode_scalable(_videomode)) {
962  setTransmission(DC1394_OFF);
963  setCapture(DC1394_OFF);
964 
965  if (dc1394_format7_set_color_coding(camera, _videomode, (dc1394color_coding_t)coding) != DC1394_SUCCESS) {
966 
967  close();
968  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Can't set color coding"));
969  }
970 
971  setCapture(DC1394_ON);
972  setTransmission(DC1394_ON);
973  }
974 }
975 
994 {
995  if (!num_cameras) {
996  close();
997  vpERROR_TRACE("No camera found");
999  }
1000  dc1394video_mode_t _videomode;
1001  if (dc1394_video_get_mode(camera, &_videomode) != DC1394_SUCCESS) {
1002 
1003  close();
1004  vpERROR_TRACE("Can't get current video mode");
1005  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Can't get current video mode"));
1006  }
1007 
1008  dc1394color_coding_t _coding;
1009  if (dc1394_is_video_mode_scalable(_videomode)) {
1010  // Format 7 video mode
1011  if (dc1394_format7_get_color_coding(camera, _videomode, &_coding) != DC1394_SUCCESS) {
1012 
1013  close();
1014  vpERROR_TRACE("Can't get current color coding");
1015  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Can't query current color coding"));
1016  }
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  }
1021  else {
1022  // Not Format 7 and not Format 6 video modes
1023  if (dc1394_get_color_coding_from_video_mode(camera, (dc1394video_mode_t)_videomode, &_coding) != DC1394_SUCCESS) {
1024  close();
1025  vpERROR_TRACE("Could not query supported color coding for mode %d\n", _videomode);
1026  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Can't query current color coding"));
1027  }
1028  }
1029  coding = (vp1394TwoColorCodingType)_coding;
1030 }
1031 
1054  std::list<vp1394TwoColorCodingType> &codings)
1055 {
1056  if (!num_cameras) {
1057  close();
1058  vpERROR_TRACE("No camera found");
1060  }
1061 
1062  // Refresh the list of supported framerates
1063  codings.clear();
1064 
1065  if (dc1394_is_video_mode_scalable((dc1394video_mode_t)mode)) {
1066  // Format 7 video mode
1067  dc1394color_codings_t _codings;
1068  if (dc1394_format7_get_color_codings(camera, (dc1394video_mode_t)mode, &_codings) != DC1394_SUCCESS) {
1069  close();
1070  vpERROR_TRACE("Could not query supported color codings for mode %d\n", mode);
1071  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Could not query supported color codings"));
1072  }
1073  if (_codings.num == 0)
1074  return 0;
1075 
1076  for (unsigned int i = 0; i < _codings.num; i++)
1077  codings.push_back((vp1394TwoColorCodingType)_codings.codings[i]);
1078 
1079  return _codings.num;
1080  }
1081  else if (dc1394_is_video_mode_still_image((dc1394video_mode_t)mode)) {
1082  // Format 6 video mode
1083  return 0;
1084  }
1085  else {
1086  // Not Format 7 and not Format 6 video modes
1087  dc1394color_coding_t _coding;
1088  if (dc1394_get_color_coding_from_video_mode(camera, (dc1394video_mode_t)mode, &_coding) != DC1394_SUCCESS) {
1089  close();
1090  vpERROR_TRACE("Could not query supported color coding for mode %d\n", mode);
1091  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Could not query supported color coding"));
1092  }
1093  codings.push_back((vp1394TwoColorCodingType)_coding);
1094  return 1;
1095  }
1096 }
1119 {
1120  if (!num_cameras) {
1121  close();
1122  vpERROR_TRACE("No camera found");
1124  }
1125 
1126  if (dc1394_is_video_mode_scalable((dc1394video_mode_t)mode)) {
1127  // Format 7 video mode
1128  dc1394color_codings_t _codings;
1129  if (dc1394_format7_get_color_codings(camera, (dc1394video_mode_t)mode, &_codings) != DC1394_SUCCESS) {
1130  close();
1131  vpERROR_TRACE("Could not query supported color codings for mode %d\n", mode);
1132  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Could not query supported color codings"));
1133  }
1134  if (_codings.num == 0)
1135  return 0;
1136 
1137  for (unsigned int i = 0; i < _codings.num; i++) {
1138  if (coding == (vp1394TwoColorCodingType)_codings.codings[i])
1139  return true;
1140  }
1141  return false;
1142  }
1143  else if (dc1394_is_video_mode_still_image((dc1394video_mode_t)mode)) {
1144  // Format 6 video mode
1145  return false;
1146  }
1147  else {
1148  // Not Format 7 and not Format 6 video modes
1149  dc1394color_coding_t _coding;
1150  if (dc1394_get_color_coding_from_video_mode(camera, (dc1394video_mode_t)mode, &_coding) != DC1394_SUCCESS) {
1151  close();
1152  vpERROR_TRACE("Could not query supported color coding for mode %d\n", mode);
1153  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Could not query supported color coding"));
1154  return false;
1155  }
1156  if (coding == (vp1394TwoColorCodingType)_coding)
1157  return true;
1158 
1159  return false;
1160  }
1161 }
1162 
1194 void vp1394TwoGrabber::setFormat7ROI(unsigned int left, unsigned int top, unsigned int w, unsigned int h)
1195 {
1196  open();
1197  if (!num_cameras) {
1198  close();
1199  vpERROR_TRACE("No camera found");
1201  }
1202 
1203  dc1394video_mode_t _videomode;
1204  if (dc1394_video_get_mode(camera, &_videomode) != DC1394_SUCCESS) {
1205 
1206  close();
1207  vpERROR_TRACE("Can't get current video mode");
1208  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Can't get current video mode"));
1209  }
1210  if (dc1394_is_video_mode_scalable(_videomode)) {
1211  // Stop dma capture if started
1212  setTransmission(DC1394_OFF);
1213  setCapture(DC1394_OFF);
1214  // Format 7 video mode
1215  unsigned int max_width, max_height;
1216  if (dc1394_format7_get_max_image_size(camera, _videomode, &max_width, &max_height) != DC1394_SUCCESS) {
1217 
1218  close();
1219  vpERROR_TRACE("Can't get format7 max image size");
1220  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Can't get format7 max image size"));
1221  }
1222 #if 0
1223  vpTRACE("left: %d top: %d width: %d height: %d", left, top,
1224  width == 0 ? DC1394_USE_MAX_AVAIL : w,
1225  height == 0 ? DC1394_USE_MAX_AVAIL : h);
1226  vpTRACE("max_width: %d max_height: %d", max_width, max_height);
1227 #endif
1228 
1229  if (left > max_width) {
1230  vpERROR_TRACE("Can't set format7 ROI");
1231  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Can't set format7 ROI"));
1232  }
1233  if (top > max_height) {
1234  vpERROR_TRACE("Can't set format7 ROI");
1235  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Can't set format7 ROI"));
1236  }
1237 
1238  int32_t roi_width;
1239  int32_t roi_height;
1240 
1241  if (w != 0) {
1242  // Check if roi width is acceptable (ie roi is contained in the image)
1243  if (w > (max_width - left))
1244  w = (max_width - left);
1245  roi_width = (int32_t)w;
1246  }
1247  else {
1248  roi_width = DC1394_USE_MAX_AVAIL;
1249  }
1250 
1251  if (h != 0) {
1252  // Check if roi height is acceptable (ie roi is contained in the image)
1253  if (h > (max_height - top))
1254  h = (max_height - top);
1255  roi_height = (int32_t)h;
1256  }
1257  else {
1258  roi_height = DC1394_USE_MAX_AVAIL;
1259  }
1260 
1261  if (dc1394_format7_set_roi(camera, _videomode,
1262  (dc1394color_coding_t)DC1394_QUERY_FROM_CAMERA, // color_coding
1263  DC1394_USE_MAX_AVAIL /*DC1394_QUERY_FROM_CAMERA*/
1264  , // bytes_per_packet
1265  (int32_t)left, // left
1266  (int32_t)top, // top
1267  roi_width, roi_height) != DC1394_SUCCESS) {
1268  close();
1269  vpERROR_TRACE("Can't set format7 roi");
1270  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Can't get current video mode"));
1271  }
1272  // Update the image size
1273  if (dc1394_format7_get_image_size(camera, _videomode, &this->width, &this->height) != DC1394_SUCCESS) {
1274  close();
1275  vpERROR_TRACE("Can't get format7 image size");
1276  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Can't get format7 image size"));
1277  }
1278 
1279  setCapture(DC1394_ON);
1280  setTransmission(DC1394_ON);
1281  }
1282 }
1297 void vp1394TwoGrabber::initialize(bool reset)
1298 {
1299  if (init == false) {
1300 // Find cameras
1301 #ifdef VISP_HAVE_DC1394_CAMERA_ENUMERATE // new API > libdc1394-2.0.0-rc7
1302  if (d != nullptr)
1303  dc1394_free(d);
1304 
1305  d = dc1394_new();
1306  if (dc1394_camera_enumerate(d, &list) != DC1394_SUCCESS) {
1307  dc1394_camera_free_list(list);
1308  close();
1309  vpERROR_TRACE("Failed to enumerate cameras\n");
1310  throw(vpFrameGrabberException(vpFrameGrabberException::initializationError, "Failed to enumerate cameras"));
1311  }
1312 
1313  if (list->num == 0) {
1314  dc1394_camera_free_list(list);
1315  close();
1316  vpERROR_TRACE("No cameras found");
1318  }
1319 
1320  if (cameras != nullptr)
1321  delete[] cameras;
1322 
1323  cameras = new dc1394camera_t *[list->num];
1324 
1325  num_cameras = 0;
1326 
1327  for (unsigned int i = 0; i < list->num; i++) {
1328  cameras[i] = dc1394_camera_new(d, list->ids[i].guid);
1329  if (!cameras[i]) {
1330  vpTRACE("Failed to initialize camera with guid \"%ld\"\n", list->ids[i].guid);
1331  continue;
1332  }
1333  // Update the number of working cameras
1334  num_cameras++;
1335  }
1336 
1337  if (reset) {
1338  // Reset the bus to make firewire working if the program was not
1339  // properly stopped by a CTRL-C. We reset here only the bus attached to
1340  // the first camera
1341  dc1394_reset_bus(cameras[0]);
1342  }
1343 
1344  // if (list != nullptr)
1345  dc1394_camera_free_list(list);
1346  list = nullptr;
1347 
1348 #elif defined VISP_HAVE_DC1394_FIND_CAMERAS // old API <= libdc1394-2.0.0-rc7
1349  if (cameras != nullptr)
1350  free(cameras);
1351  cameras = nullptr;
1352  int err = dc1394_find_cameras(&cameras, &num_cameras);
1353 
1354  if (err != DC1394_SUCCESS && err != DC1394_NO_CAMERA) {
1355  close();
1356  vpERROR_TRACE("Unable to look for cameras\n\n"
1357  "Please check \n"
1358  " - if the kernel modules `ieee1394',`raw1394' and "
1359  "`ohci1394' are loaded \n"
1360  " - if you have read/write access to /dev/raw1394\n\n");
1361  throw(vpFrameGrabberException(vpFrameGrabberException::initializationError, "Unable to look for cameras"));
1362  }
1363 #endif
1364 
1365  if (num_cameras == 0) {
1366  close();
1367  vpERROR_TRACE("No cameras found");
1369  }
1370 
1371  // allocation for the parameters
1372  isDataModified = new bool[num_cameras];
1373  for (unsigned int i = 0; i < num_cameras; i++)
1374  isDataModified[i] = false;
1375  initialShutterMode = new dc1394feature_mode_t[num_cameras];
1376  dataCam = new vpDc1394TwoCameraParametersData[num_cameras];
1377 
1378  if (camera_id >= num_cameras) {
1379  // Bad camera id
1380  close();
1381  vpERROR_TRACE("Bad camera id: %u", camera_id);
1382  vpERROR_TRACE("Only %u camera on the bus.", num_cameras);
1384  }
1385 
1386  if (verbose) {
1387  std::cout << "------ Bus information ------" << std::endl;
1388  std::cout << "Number of camera(s) on the bus : " << num_cameras << std::endl;
1389  std::cout << "-----------------------------" << std::endl;
1390  }
1391 
1392  if (camIsOpen != nullptr)
1393  delete[] camIsOpen;
1394  camIsOpen = new bool[num_cameras];
1395  for (unsigned int i = 0; i < num_cameras; i++) {
1396  camIsOpen[i] = false;
1397  }
1398 
1399  init = true;
1400  }
1401 }
1412 {
1413  if (init == false)
1414  initialize(false);
1415  if (camIsOpen[camera_id] == false) {
1416  dc1394switch_t status = DC1394_OFF;
1417 
1418  //#ifdef VISP_HAVE_DC1394_CAMERA_ENUMERATE // new API >
1419  // libdc1394-2.0.0-rc7
1420  dc1394_video_get_transmission(cameras[camera_id], &status);
1421  if (status != DC1394_OFF) {
1422  //#endif
1423  if (dc1394_video_set_transmission(cameras[camera_id], DC1394_OFF) != DC1394_SUCCESS)
1424  vpTRACE("Could not stop ISO transmission");
1425  else {
1426  vpTime::wait(500);
1427  if (dc1394_video_get_transmission(cameras[camera_id], &status) != DC1394_SUCCESS)
1428  vpTRACE("Could get ISO status");
1429  else {
1430  if (status == DC1394_ON) {
1431  vpTRACE("ISO transmission refuses to stop");
1432  }
1433 #ifdef VISP_HAVE_DC1394_FIND_CAMERAS // old API <= libdc1394-2.0.0-rc7
1434  // No yet in the new API
1435  cameras[camera_id]->is_iso_on = status;
1436 #endif
1437  }
1438  //#ifdef VISP_HAVE_DC1394_CAMERA_ENUMERATE // new API >
1439  // libdc1394-2.0.0-rc7
1440  }
1441  //#endif
1442  }
1443  setCamera(camera_id);
1444  // setIsoSpeed(DC1394_ISO_SPEED_400);
1445  setCapture(DC1394_ON);
1446  setTransmission(DC1394_ON);
1447  camIsOpen[camera_id] = true;
1448  }
1449 }
1459 {
1460  if (init) {
1461  if (num_cameras) {
1462  for (unsigned int i = 0; i < num_cameras; i++) {
1463  if (camIsOpen[i]) {
1464  camera = cameras[i];
1465  this->camera_id = i; // set camera id for the function updateDataStructToCam
1466  setTransmission(DC1394_OFF);
1467  setCapture(DC1394_OFF);
1468  if (isDataModified[i]) {
1469  // reset values
1470  try {
1471  updateDataStructToCam();
1472  }
1473  catch (...) {
1474  }
1475  // reset mode (manual, auto, ...)
1476  if (dc1394_feature_set_mode(camera, DC1394_FEATURE_BRIGHTNESS, initialShutterMode[i]) != DC1394_SUCCESS ||
1477  dc1394_feature_set_mode(camera, DC1394_FEATURE_EXPOSURE, initialShutterMode[i]) != DC1394_SUCCESS ||
1478  dc1394_feature_set_mode(camera, DC1394_FEATURE_SHARPNESS, initialShutterMode[i]) != DC1394_SUCCESS ||
1479  dc1394_feature_set_mode(camera, DC1394_FEATURE_HUE, initialShutterMode[i]) != DC1394_SUCCESS ||
1480  dc1394_feature_set_mode(camera, DC1394_FEATURE_SATURATION, initialShutterMode[i]) != DC1394_SUCCESS ||
1481  dc1394_feature_set_mode(camera, DC1394_FEATURE_GAMMA, initialShutterMode[i]) != DC1394_SUCCESS ||
1482  dc1394_feature_set_mode(camera, DC1394_FEATURE_SHUTTER, initialShutterMode[i]) != DC1394_SUCCESS ||
1483  dc1394_feature_set_mode(camera, DC1394_FEATURE_GAIN, initialShutterMode[i]) != DC1394_SUCCESS ||
1484  dc1394_feature_set_mode(camera, DC1394_FEATURE_IRIS, initialShutterMode[i])) {
1485 
1486  vpERROR_TRACE("Unable to reset the initial mode");
1487  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Unable to reset the initial mode"));
1488  }
1489  }
1490  if (dc1394_camera_set_power(camera, DC1394_OFF) != DC1394_SUCCESS)
1491  std::cout << "Unable to turn camera off" << std::endl;
1492  }
1493 #ifdef VISP_HAVE_DC1394_CAMERA_ENUMERATE // new API > libdc1394-2.0.0-rc7
1494  dc1394_camera_free(cameras[i]);
1495 #elif defined VISP_HAVE_DC1394_FIND_CAMERAS // old API <= libdc1394-2.0.0-rc7
1496  dc1394_free_camera(cameras[i]);
1497 #endif
1498  }
1499  }
1500  if (camIsOpen != nullptr) {
1501  delete[] camIsOpen;
1502  camIsOpen = nullptr;
1503  }
1504 
1505 #ifdef VISP_HAVE_DC1394_CAMERA_ENUMERATE // new API > libdc1394-2.0.0-rc7
1506  if (cameras != nullptr) {
1507  delete[] cameras;
1508  cameras = nullptr;
1509  }
1510  if (d != nullptr) {
1511  dc1394_free(d);
1512  d = nullptr;
1513  }
1514 
1515 #elif defined VISP_HAVE_DC1394_FIND_CAMERAS // old API <= libdc1394-2.0.0-rc7
1516  if (cameras != nullptr) {
1517  free(cameras);
1518  cameras = nullptr;
1519  }
1520 #endif
1521 
1522  camIsOpen = nullptr;
1523  num_cameras = 0;
1524 
1525  // remove data for the parameters
1526  if (isDataModified != nullptr) {
1527  delete[] isDataModified;
1528  isDataModified = nullptr;
1529  }
1530  if (initialShutterMode != nullptr) {
1531  delete[] initialShutterMode;
1532  initialShutterMode = nullptr;
1533  }
1534  if (dataCam != nullptr) {
1535  delete[] dataCam;
1536  dataCam = nullptr;
1537  }
1538 
1539  init = false;
1540  }
1541 }
1542 
1556 {
1557  if (size < 1) {
1558  close();
1559  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Could not set ring buffer size"));
1560  }
1561 
1562  if (size != num_buffers) {
1563  // We need to change the ring buffer size
1564  num_buffers = size;
1565  if (camIsOpen[camera_id]) {
1566  setCapture(DC1394_OFF);
1567  setCapture(DC1394_ON);
1568  }
1569  }
1570 }
1571 
1581 unsigned int vp1394TwoGrabber::getRingBufferSize() const { return num_buffers; }
1582 
1622 {
1623  if (!num_cameras) {
1624  close();
1625  vpERROR_TRACE("No camera found");
1627  }
1628 
1629  dc1394feature_mode_t mode;
1630  if (enable) {
1631  mode = DC1394_FEATURE_MODE_AUTO;
1632  }
1633  else {
1634  mode = DC1394_FEATURE_MODE_MANUAL;
1635  }
1636 
1637  if (dc1394_feature_set_power(camera, DC1394_FEATURE_SHUTTER, DC1394_ON) != DC1394_SUCCESS) {
1638  // vpERROR_TRACE("Cannot set shutter on. \n");
1639  close();
1640  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Cannot set shutter on"));
1641  }
1642 
1643  if (dc1394_feature_set_mode(camera, DC1394_FEATURE_SHUTTER, mode) != DC1394_SUCCESS) {
1644  // vpERROR_TRACE("Cannot set auto shutter. \n");
1645  close();
1646  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Cannot set auto shutter"));
1647  }
1648 }
1688 void vp1394TwoGrabber::setAutoShutter(unsigned int minvalue, unsigned int maxvalue)
1689 {
1690  setAutoShutter();
1691 
1692  if (dc1394_avt_set_auto_shutter(camera, minvalue, maxvalue) != DC1394_SUCCESS) {
1693  // vpERROR_TRACE("Cannot set auto shutter min and max values. Is the
1694  // camera an AVT one?\n");
1695  close();
1696  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Cannot set auto shutter min and max values"));
1697  }
1698 }
1699 
1712 void vp1394TwoGrabber::getAutoShutter(unsigned int &minvalue, unsigned int &maxvalue)
1713 {
1714  if (!num_cameras) {
1715  close();
1716  vpERROR_TRACE("No camera found");
1718  }
1719 
1720  if (dc1394_avt_get_auto_shutter(camera, &minvalue, &maxvalue) != DC1394_SUCCESS) {
1721  // vpERROR_TRACE("Cannot get auto shutter min and max values. Is the
1722  // camera an AVT one?\n");
1723  close();
1724  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Cannot get auto shutter min and max values"));
1725  }
1726 }
1727 
1767 {
1768  if (!num_cameras) {
1769  close();
1770  vpERROR_TRACE("No camera found");
1772  }
1773 
1774  dc1394feature_mode_t mode;
1775  if (enable) {
1776  mode = DC1394_FEATURE_MODE_AUTO;
1777  }
1778  else {
1779  mode = DC1394_FEATURE_MODE_MANUAL;
1780  }
1781 
1782  if (dc1394_feature_set_power(camera, DC1394_FEATURE_GAIN, DC1394_ON) != DC1394_SUCCESS) {
1783  // vpERROR_TRACE("Cannot set shutter on. \n");
1784  close();
1785  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Cannot set shutter on"));
1786  }
1787 
1788  if (dc1394_feature_set_mode(camera, DC1394_FEATURE_GAIN, mode) != DC1394_SUCCESS) {
1789  // vpERROR_TRACE("Cannot set auto gain. \n");
1790  close();
1791  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Cannot set auto gain"));
1792  }
1793 }
1833 void vp1394TwoGrabber::setAutoGain(unsigned int minvalue, unsigned int maxvalue)
1834 {
1835  setAutoGain();
1836 
1837  if (dc1394_avt_set_auto_gain(camera, minvalue, maxvalue) != DC1394_SUCCESS) {
1838  // vpERROR_TRACE("Cannot set auto gain min and max values. Is the
1839  // camera an AVT one?\n");
1840  close();
1841  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Cannot set auto gain min and max values"));
1842  }
1843 }
1844 
1857 void vp1394TwoGrabber::getAutoGain(unsigned int &minvalue, unsigned int &maxvalue)
1858 {
1859  if (!num_cameras) {
1860  close();
1861  vpERROR_TRACE("No camera found");
1863  }
1864 
1865  if (dc1394_avt_get_auto_gain(camera, &minvalue, &maxvalue) != DC1394_SUCCESS) {
1866  // vpERROR_TRACE("Cannot get auto gain min and max values. Is the
1867  // camera an AVT one?\n");
1868  close();
1869  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Cannot get auto gain min and max values"));
1870  }
1871 }
1872 
1890 void vp1394TwoGrabber::setCapture(dc1394switch_t _switch)
1891 {
1892  if (!num_cameras) {
1893  close();
1894  vpERROR_TRACE("No camera found");
1896  }
1897 
1898  if (_switch == DC1394_ON) {
1899  // if (dc1394_capture_setup(camera, num_buffers) != DC1394_SUCCESS) {
1900  // To be compatible with libdc1394 svn 382 version
1901  if (dc1394_capture_setup(camera, num_buffers, DC1394_CAPTURE_FLAGS_DEFAULT) != DC1394_SUCCESS) {
1902  vpERROR_TRACE("Unable to setup camera capture-\n"
1903  "make sure that the video mode and framerate are "
1904  "supported by your camera.\n");
1905  close();
1906  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Could not setup dma capture"));
1907  }
1908  }
1909  else { // _switch == DC1394_OFF
1910  dc1394error_t code = dc1394_capture_stop(camera);
1911 
1912  if (code != DC1394_SUCCESS && code != DC1394_CAPTURE_IS_NOT_SET) {
1913  vpERROR_TRACE("Unable to stop camera capture\n");
1914  close();
1915  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Could not setup dma capture"));
1916  }
1917  }
1918 }
1919 
1934 void vp1394TwoGrabber::setTransmission(dc1394switch_t _switch)
1935 {
1936  if (!num_cameras) {
1937  close();
1938  vpERROR_TRACE("No camera found");
1940  }
1941 
1942  dc1394switch_t status = DC1394_OFF;
1943 
1944  if (dc1394_video_get_transmission(camera, &status) != DC1394_SUCCESS) {
1945  vpERROR_TRACE("Unable to get transmision status");
1946  close();
1947  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Could not setup dma capture"));
1948  }
1949 
1950  // if (status!=_switch){
1951  // Start dma capture if halted
1952  if (dc1394_video_set_transmission(camera, _switch) != DC1394_SUCCESS) {
1953  vpERROR_TRACE("Unable to setup camera capture-\n"
1954  "make sure that the video mode and framerate are "
1955  "supported by your camera.\n");
1956  close();
1957  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Could not setup dma capture"));
1958  }
1959 
1960  if (_switch == DC1394_ON) {
1961  status = DC1394_OFF;
1962 
1963  int i = 0;
1964  while (status == DC1394_OFF && i++ < 5) {
1965  usleep(50000);
1966  if (dc1394_video_get_transmission(camera, &status) != DC1394_SUCCESS) {
1967  vpERROR_TRACE("Unable to get transmision status");
1968  close();
1969  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Could not setup dma capture"));
1970  }
1971  }
1972  }
1973  // }
1974 }
1975 
2010 {
2011  if (!num_cameras) {
2012  close();
2013  vpERROR_TRACE("No camera found");
2015  }
2016 
2017  dc1394operation_mode_t op_mode;
2018  dc1394speed_t speed;
2019 
2020  // Check the speed to configure in B-mode or A-mode
2021  if (isospeed >= vpISO_SPEED_800) {
2022  if (camera->bmode_capable != DC1394_TRUE) {
2023  close();
2024  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Camera is not 1394B mode capable"));
2025  }
2026 
2027  if (dc1394_video_set_operation_mode(camera, DC1394_OPERATION_MODE_1394B) != DC1394_SUCCESS) {
2028  close();
2029  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Cannot set camera to 1394B mode"));
2030  }
2031 
2032  if (dc1394_video_get_operation_mode(camera, &op_mode) != DC1394_SUCCESS) {
2033  close();
2034  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Failed to set 1394B mode"));
2035  }
2036  }
2037  else {
2038  if (dc1394_video_set_operation_mode(camera, DC1394_OPERATION_MODE_LEGACY) != DC1394_SUCCESS) {
2039  close();
2040  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Cannot set camera to 1394A mode"));
2041  }
2042 
2043  if (dc1394_video_get_operation_mode(camera, &op_mode) != DC1394_SUCCESS) {
2044  close();
2045  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Failed to set 1394A mode"));
2046  }
2047  }
2048 
2049  if (dc1394_video_set_iso_speed(camera, (dc1394speed_t)isospeed) != DC1394_SUCCESS) {
2050  close();
2051  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Cannot set requested iso speed"));
2052  }
2053 
2054  if (dc1394_video_get_iso_speed(camera, &speed) != DC1394_SUCCESS) {
2055  close();
2056  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Failed to set iso speed"));
2057  }
2058 }
2059 
2071 {
2072  open();
2073  acquire(I);
2074 }
2075 
2087 {
2088  open();
2089  acquire(I);
2090 }
2091 
2129 dc1394video_frame_t *vp1394TwoGrabber::dequeue()
2130 {
2131 
2132  if (!num_cameras) {
2133  close();
2134  vpERROR_TRACE("No camera found");
2136  }
2137 
2138  dc1394video_frame_t *frame = nullptr;
2139 
2140  if (dc1394_capture_dequeue(camera, DC1394_CAPTURE_POLICY_WAIT, &frame) != DC1394_SUCCESS) {
2141  vpERROR_TRACE("Error: Failed to capture from camera %d\n", camera_id);
2142  }
2143 
2144  return frame;
2145 }
2146 
2188 {
2189  uint64_t timestamp;
2190  uint32_t id;
2191 
2192  dc1394video_frame_t *frame;
2193 
2194  frame = dequeue(I, timestamp, id);
2195 
2196  return frame;
2197 }
2198 
2246 dc1394video_frame_t *vp1394TwoGrabber::dequeue(vpImage<unsigned char> &I, uint64_t &timestamp, uint32_t &id)
2247 {
2248 
2249  open();
2250 
2251  dc1394video_frame_t *frame;
2252 
2253  frame = dequeue();
2254 
2255  // Timeval data structure providing the unix time
2256  // [microseconds] at which the frame was captured in the ring buffer.
2257  timestamp = frame->timestamp;
2258  id = frame->id;
2259 
2260  this->width = frame->size[0];
2261  this->height = frame->size[1];
2262  unsigned int size = this->width * this->height;
2263 
2264  if ((I.getWidth() != this->width) || (I.getHeight() != this->height))
2265  I.resize(this->height, this->width);
2266 
2267  switch (frame->color_coding) {
2268  case DC1394_COLOR_CODING_MONO8:
2269  case DC1394_COLOR_CODING_RAW8:
2270  memcpy(I.bitmap, (unsigned char *)frame->image, size * sizeof(unsigned char));
2271  break;
2272  case DC1394_COLOR_CODING_MONO16:
2273  case DC1394_COLOR_CODING_RAW16:
2274  vpImageConvert::MONO16ToGrey((unsigned char *)frame->image, I.bitmap, size);
2275  break;
2276 
2277  case DC1394_COLOR_CODING_YUV411:
2278  vpImageConvert::YUV411ToGrey((unsigned char *)frame->image, I.bitmap, size);
2279  break;
2280 
2281  case DC1394_COLOR_CODING_YUV422:
2282  vpImageConvert::YUV422ToGrey((unsigned char *)frame->image, I.bitmap, size);
2283  break;
2284 
2285  case DC1394_COLOR_CODING_YUV444:
2286  vpImageConvert::YUV444ToGrey((unsigned char *)frame->image, I.bitmap, size);
2287  break;
2288 
2289  case DC1394_COLOR_CODING_RGB8:
2290  vpImageConvert::RGBToGrey((unsigned char *)frame->image, I.bitmap, size);
2291  break;
2292 
2293  default:
2294  close();
2295  vpERROR_TRACE("Format conversion not implemented. Acquisition failed.");
2296  throw(vpFrameGrabberException(vpFrameGrabberException::otherError, "Format conversion not implemented. "
2297  "Acquisition failed."));
2298  };
2299 
2300  return frame;
2301 }
2302 
2343 {
2344  uint64_t timestamp;
2345  uint32_t id;
2346 
2347  dc1394video_frame_t *frame;
2348 
2349  frame = dequeue(I, timestamp, id);
2350 
2351  return frame;
2352 }
2353 
2401 dc1394video_frame_t *vp1394TwoGrabber::dequeue(vpImage<vpRGBa> &I, uint64_t &timestamp, uint32_t &id)
2402 {
2403 
2404  open();
2405 
2406  dc1394video_frame_t *frame;
2407 
2408  frame = dequeue();
2409 
2410  // Timeval data structure providing the unix time
2411  // [microseconds] at which the frame was captured in the ring buffer.
2412  timestamp = frame->timestamp;
2413  id = frame->id;
2414 
2415  this->width = frame->size[0];
2416  this->height = frame->size[1];
2417  unsigned int size = this->width * this->height;
2418 
2419  if ((I.getWidth() != width) || (I.getHeight() != height))
2420  I.resize(height, width);
2421 
2422  switch (frame->color_coding) {
2423  case DC1394_COLOR_CODING_MONO8:
2424  case DC1394_COLOR_CODING_RAW8:
2425  vpImageConvert::GreyToRGBa((unsigned char *)frame->image, (unsigned char *)I.bitmap, size);
2426  break;
2427 
2428  case DC1394_COLOR_CODING_MONO16:
2429  case DC1394_COLOR_CODING_RAW16:
2430  vpImageConvert::MONO16ToRGBa((unsigned char *)frame->image, (unsigned char *)I.bitmap, size);
2431  break;
2432 
2433  case DC1394_COLOR_CODING_YUV411:
2434  vpImageConvert::YUV411ToRGBa((unsigned char *)frame->image, (unsigned char *)I.bitmap, size);
2435  break;
2436 
2437  case DC1394_COLOR_CODING_YUV422:
2438  vpImageConvert::YUV422ToRGBa((unsigned char *)frame->image, (unsigned char *)I.bitmap, size);
2439  break;
2440 
2441  case DC1394_COLOR_CODING_YUV444:
2442  vpImageConvert::YUV444ToRGBa((unsigned char *)frame->image, (unsigned char *)I.bitmap, size);
2443  break;
2444 
2445  case DC1394_COLOR_CODING_RGB8:
2446  vpImageConvert::RGBToRGBa((unsigned char *)frame->image, (unsigned char *)I.bitmap, size);
2447  break;
2448 
2449  default:
2450  close();
2451  vpERROR_TRACE("Format conversion not implemented. Acquisition failed.");
2452  throw(vpFrameGrabberException(vpFrameGrabberException::otherError, "Format conversion not implemented. "
2453  "Acquisition failed."));
2454  };
2455 
2456  return frame;
2457 }
2458 
2469 void vp1394TwoGrabber::enqueue(dc1394video_frame_t *frame)
2470 {
2471 
2472  if (!num_cameras) {
2473  close();
2474  vpERROR_TRACE("No camera found");
2476  }
2477 
2478  if (frame)
2479  dc1394_capture_enqueue(camera, frame);
2480 }
2481 
2496 {
2497  uint64_t timestamp;
2498  uint32_t id;
2499 
2500  dc1394video_frame_t *frame;
2501 
2502  frame = dequeue(I, timestamp, id);
2503  enqueue(frame);
2504 }
2505 
2524 void vp1394TwoGrabber::acquire(vpImage<unsigned char> &I, uint64_t &timestamp, uint32_t &id)
2525 {
2526  dc1394video_frame_t *frame;
2527 
2528  open();
2529  frame = dequeue(I, timestamp, id);
2530  enqueue(frame);
2531 }
2532 
2547 {
2548  uint64_t timestamp;
2549  uint32_t id;
2550  dc1394video_frame_t *frame;
2551 
2552  open();
2553  frame = dequeue(I, timestamp, id);
2554  enqueue(frame);
2555 }
2556 
2575 void vp1394TwoGrabber::acquire(vpImage<vpRGBa> &I, uint64_t &timestamp, uint32_t &id)
2576 {
2577  dc1394video_frame_t *frame;
2578 
2579  open();
2580  frame = dequeue();
2581  // Timeval data structure providing the unix time
2582  // [microseconds] at which the frame was captured in the ring buffer.
2583  timestamp = frame->timestamp;
2584  id = frame->id;
2585 
2586  this->width = frame->size[0];
2587  this->height = frame->size[1];
2588  unsigned int size = this->width * this->height;
2589 
2590  if ((I.getWidth() != width) || (I.getHeight() != height))
2591  I.resize(height, width);
2592 
2593  switch (frame->color_coding) {
2594  case DC1394_COLOR_CODING_MONO8:
2595  case DC1394_COLOR_CODING_RAW8:
2596  vpImageConvert::GreyToRGBa((unsigned char *)frame->image, (unsigned char *)I.bitmap, size);
2597  break;
2598 
2599  case DC1394_COLOR_CODING_YUV411:
2600  vpImageConvert::YUV411ToRGBa((unsigned char *)frame->image, (unsigned char *)I.bitmap, size);
2601  break;
2602 
2603  case DC1394_COLOR_CODING_YUV422:
2604  vpImageConvert::YUV422ToRGBa((unsigned char *)frame->image, (unsigned char *)I.bitmap, size);
2605  break;
2606 
2607  case DC1394_COLOR_CODING_YUV444:
2608  vpImageConvert::YUV444ToRGBa((unsigned char *)frame->image, (unsigned char *)I.bitmap, size);
2609  break;
2610 
2611  case DC1394_COLOR_CODING_RGB8:
2612  vpImageConvert::RGBToRGBa((unsigned char *)frame->image, (unsigned char *)I.bitmap, size);
2613  break;
2614 
2615  default:
2616  close();
2617  vpERROR_TRACE("Format conversion not implemented. Acquisition failed.");
2618  throw(vpFrameGrabberException(vpFrameGrabberException::otherError, "Format conversion not implemented. "
2619  "Acquisition failed."));
2620  };
2621 
2622  enqueue(frame);
2623 }
2624 
2641 void vp1394TwoGrabber::getWidth(unsigned int &w)
2642 {
2643  if (!num_cameras) {
2644  close();
2645  vpERROR_TRACE("No camera found");
2647  }
2648 
2649  w = this->width;
2650 }
2651 
2670 {
2671  if (!num_cameras) {
2672  close();
2673  vpERROR_TRACE("No camera found");
2675  }
2676 
2677  return this->width;
2678 }
2679 
2697 void vp1394TwoGrabber::getHeight(unsigned int &h)
2698 {
2699  if (!num_cameras) {
2700  close();
2701  vpERROR_TRACE("No camera found");
2703  }
2704 
2705  h = this->height;
2706 }
2725 {
2726  if (!num_cameras) {
2727  close();
2728  vpERROR_TRACE("No camera found");
2730  }
2731 
2732  return this->height;
2733 }
2734 
2741 {
2742  std::cout << "----------------------------------------------------------" << std::endl
2743  << "----- Information for camera " << camera_id << " -----" << std::endl
2744  << "----------------------------------------------------------" << std::endl;
2745 
2746 #ifdef VISP_HAVE_DC1394_CAMERA_ENUMERATE // new API > libdc1394-2.0.0-rc7
2747  dc1394_camera_print_info(camera, stdout);
2748 #elif defined VISP_HAVE_DC1394_FIND_CAMERAS // old API <= libdc1394-2.0.0-rc7
2749  dc1394_print_camera_info(camera);
2750 #endif
2751 
2752  dc1394featureset_t features;
2753 #ifdef VISP_HAVE_DC1394_CAMERA_ENUMERATE // new API > libdc1394-2.0.0-rc7
2754  if (dc1394_feature_get_all(camera, &features) != DC1394_SUCCESS)
2755 #elif defined VISP_HAVE_DC1394_FIND_CAMERAS // old API <= libdc1394-2.0.0-rc7
2756  if (dc1394_get_camera_feature_set(camera, &features) != DC1394_SUCCESS)
2757 #endif
2758  {
2759  close();
2760  vpERROR_TRACE("unable to get feature set for camera %d\n", camera_id);
2761  throw(vpFrameGrabberException(vpFrameGrabberException::initializationError, "Cannot get camera features"));
2762 
2763  }
2764  else {
2765 #ifdef VISP_HAVE_DC1394_CAMERA_ENUMERATE // new API > libdc1394-2.0.0-rc7
2766  dc1394_feature_print_all(&features, stdout);
2767 #elif defined VISP_HAVE_DC1394_FIND_CAMERAS // old API <= libdc1394-2.0.0-rc7
2768  dc1394_print_feature_set(&features);
2769 #endif
2770  }
2771  std::cout << "----------------------------------------------------------" << std::endl;
2772 }
2773 
2787 {
2788  std::string _str = "";
2789  dc1394video_mode_t _videomode = (dc1394video_mode_t)videomode;
2790 
2791  if ((_videomode >= DC1394_VIDEO_MODE_MIN) && (_videomode <= DC1394_VIDEO_MODE_MAX)) {
2792  _str = strVideoMode[_videomode - DC1394_VIDEO_MODE_MIN];
2793  }
2794  else {
2795  vpCERROR << "The video mode " << (int)videomode << " is not supported by the camera" << std::endl;
2796  }
2797 
2798  return _str;
2799 }
2800 
2814 {
2815  std::string _str = "";
2816  dc1394framerate_t _fps = (dc1394framerate_t)fps;
2817 
2818  if ((_fps >= DC1394_FRAMERATE_MIN) && (_fps <= DC1394_FRAMERATE_MAX)) {
2819  _str = strFramerate[_fps - DC1394_FRAMERATE_MIN];
2820  }
2821  else {
2822  vpCERROR << "The framerate " << (int)fps << " is not supported by the camera" << std::endl;
2823  }
2824 
2825  return _str;
2826 }
2827 
2841 {
2842  std::string _str = "";
2843  dc1394color_coding_t _coding = (dc1394color_coding_t)colorcoding;
2844 
2845  if ((_coding >= DC1394_COLOR_CODING_MIN) && (_coding <= DC1394_COLOR_CODING_MAX)) {
2846  _str = strColorCoding[_coding - DC1394_COLOR_CODING_MIN];
2847 
2848  }
2849  else {
2850  vpCERROR << "The color coding " << (int)colorcoding << " is not supported by the camera" << std::endl;
2851  }
2852 
2853  return _str;
2854 }
2855 
2874 {
2876 
2877  for (int i = DC1394_VIDEO_MODE_MIN; i <= DC1394_VIDEO_MODE_MAX; i++) {
2878  _id = (vp1394TwoVideoModeType)i;
2879  if (videomode.compare(videoMode2string(_id)) == 0)
2880  return _id;
2881  };
2882 
2883  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "The required videomode is not valid"));
2884 
2885  return (vp1394TwoVideoModeType)0;
2886 }
2887 
2906 {
2908 
2909  for (int i = DC1394_FRAMERATE_MIN; i <= DC1394_FRAMERATE_MAX; i++) {
2910  _id = (vp1394TwoFramerateType)i;
2911  if (framerate.compare(framerate2string(_id)) == 0)
2912  return _id;
2913  };
2914 
2915  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "The required framerate is not valid"));
2916 
2917  return (vp1394TwoFramerateType)0;
2918 }
2919 
2938 {
2940 
2941  for (int i = DC1394_COLOR_CODING_MIN; i <= DC1394_COLOR_CODING_MAX; i++) {
2942  _id = (vp1394TwoColorCodingType)i;
2943  if (colorcoding.compare(colorCoding2string(_id)) == 0)
2944  return _id;
2945  };
2946 
2947  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "The required color coding is not valid"));
2948 
2949  return (vp1394TwoColorCodingType)0;
2950 }
2951 
2984 {
2985  for (unsigned int i = 0; i < num_cameras; i++) {
2986  if (camIsOpen[i]) {
2987  camera = cameras[i];
2988  setTransmission(DC1394_OFF);
2989  setCapture(DC1394_OFF);
2990  }
2991  }
2992 #ifdef VISP_HAVE_DC1394_CAMERA_ENUMERATE // new API > libdc1394-2.0.0-rc7
2993  setCamera(camera_id);
2994  // free the other cameras
2995  for (unsigned int i = 0; i < num_cameras; i++) {
2996  if (i != camera_id)
2997  dc1394_camera_free(cameras[i]);
2998  }
2999 
3000  printf("Resetting bus...\n");
3001  dc1394_reset_bus(camera);
3002 
3003  dc1394_camera_free(camera);
3004  dc1394_free(d);
3005  d = nullptr;
3006  // if (cameras != nullptr)
3007  delete[] cameras;
3008  cameras = nullptr;
3009 #elif defined VISP_HAVE_DC1394_FIND_CAMERAS // old API <= libdc1394-2.0.0-rc7
3010 
3011  setCamera(camera_id);
3012  // free the other cameras
3013  for (unsigned int i = 0; i < num_cameras; i++) {
3014  if (i != camera_id)
3015  dc1394_free_camera(cameras[i]);
3016  }
3017  free(cameras);
3018  cameras = nullptr;
3019 
3020  dc1394_reset_bus(camera);
3021  dc1394_free_camera(camera);
3022 
3023 #endif
3024  if (camIsOpen != nullptr)
3025  delete[] camIsOpen;
3026  camIsOpen = nullptr;
3027 
3028  num_cameras = 0;
3029 
3030  init = false;
3031  vpTime::wait(1000);
3032  initialize(false);
3033 }
3034 
3065 void vp1394TwoGrabber::setPanControl(unsigned int panControlValue)
3066 {
3067  open();
3068  if (!num_cameras) {
3069  close();
3070  vpERROR_TRACE("No camera found");
3072  }
3073  uint64_t offset = 0x884;
3074  uint32_t value = 0x82000000 + (uint32_t)panControlValue;
3075  dc1394error_t err;
3076  err = dc1394_set_control_register(camera, offset, value);
3077  if (err != DC1394_SUCCESS) {
3078  vpERROR_TRACE("Unable to set PAN register");
3079  close();
3080  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Unable to set PAN register"));
3081  }
3082 }
3083 
3101 {
3102  if (!num_cameras) {
3103  close();
3104  vpERROR_TRACE("No camera found");
3106  }
3107 
3108  uint32_t value;
3109  dc1394feature_t feature = DC1394_FEATURE_BRIGHTNESS; // = (dc1394feature_t)param;
3110  switch (param) {
3111  case vpFEATURE_BRIGHTNESS:
3112  feature = DC1394_FEATURE_BRIGHTNESS;
3113  break;
3114  case vpFEATURE_EXPOSURE:
3115  feature = DC1394_FEATURE_EXPOSURE;
3116  break;
3117  case vpFEATURE_SHARPNESS:
3118  feature = DC1394_FEATURE_SHARPNESS;
3119  break;
3120  // vpFEATURE_WHITE_BALANCE = DC1394_FEATURE_WHITE_BALANCE,
3121  case vpFEATURE_HUE:
3122  feature = DC1394_FEATURE_HUE;
3123  break;
3124  case vpFEATURE_SATURATION:
3125  feature = DC1394_FEATURE_SATURATION;
3126  break;
3127  case vpFEATURE_GAMMA:
3128  feature = DC1394_FEATURE_GAMMA;
3129  break;
3130  case vpFEATURE_SHUTTER:
3131  feature = DC1394_FEATURE_SHUTTER;
3132  break;
3133  case vpFEATURE_GAIN:
3134  feature = DC1394_FEATURE_GAIN;
3135  break;
3136  case vpFEATURE_IRIS:
3137  feature = DC1394_FEATURE_IRIS;
3138  break;
3139  // vpFEATURE_FOCUS = DC1394_FEATURE_FOCUS,
3140  // vpFEATURE_TEMPERATURE = DC1394_FEATURE_TEMPERATURE,
3141  // vpFEATURE_TRIGGER = DC1394_FEATURE_TRIGGER,
3142  // vpFEATURE_TRIGGER_DELAY = DC1394_FEATURE_TRIGGER_DELAY,
3143  // vpFEATURE_WHITE_SHADING = DC1394_FEATURE_WHITE_SHADING,
3144  // vpFEATURE_FRAME_RATE = DC1394_FEATURE_FRAME_RATE,
3145  // vpFEATURE_ZOOM = DC1394_FEATURE_ZOOM,
3146  // vpFEATURE_PAN = DC1394_FEATURE_PAN,
3147  // vpFEATURE_TILT = DC1394_FEATURE_TILT,
3148  // vpFEATURE_OPTICAL_FILTER = DC1394_FEATURE_OPTICAL_FILTER,
3149  // vpFEATURE_CAPTURE_SIZE = DC1394_FEATURE_CAPTURE_SIZE,
3150  // vpFEATURE_CAPTURE_QUALITY = DC1394_FEATURE_CAPTURE_QUALITY
3151  }
3152 
3153  dc1394error_t err;
3154  err = dc1394_feature_get_value(camera, feature, &value);
3155  if (err != DC1394_SUCCESS) {
3156  vpERROR_TRACE("Unable to get the information");
3157  close();
3158  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Unable to get the information"));
3159  }
3160  return (unsigned int)value;
3161 }
3162 
3185 {
3186  if (!num_cameras) {
3187  close();
3188  vpERROR_TRACE("No camera found");
3190  }
3191  uint32_t value = (uint32_t)val;
3192  dc1394feature_t feature = DC1394_FEATURE_BRIGHTNESS; // = (dc1394feature_t)param;
3193  switch (param) {
3194  case vpFEATURE_BRIGHTNESS:
3195  feature = DC1394_FEATURE_BRIGHTNESS;
3196  break;
3197  case vpFEATURE_EXPOSURE:
3198  feature = DC1394_FEATURE_EXPOSURE;
3199  break;
3200  case vpFEATURE_SHARPNESS:
3201  feature = DC1394_FEATURE_SHARPNESS;
3202  break;
3203  // vpFEATURE_WHITE_BALANCE = DC1394_FEATURE_WHITE_BALANCE,
3204  case vpFEATURE_HUE:
3205  feature = DC1394_FEATURE_HUE;
3206  break;
3207  case vpFEATURE_SATURATION:
3208  feature = DC1394_FEATURE_SATURATION;
3209  break;
3210  case vpFEATURE_GAMMA:
3211  feature = DC1394_FEATURE_GAMMA;
3212  break;
3213  case vpFEATURE_SHUTTER:
3214  feature = DC1394_FEATURE_SHUTTER;
3215  break;
3216  case vpFEATURE_GAIN:
3217  feature = DC1394_FEATURE_GAIN;
3218  break;
3219  case vpFEATURE_IRIS:
3220  feature = DC1394_FEATURE_IRIS;
3221  break;
3222  // vpFEATURE_FOCUS = DC1394_FEATURE_FOCUS,
3223  // vpFEATURE_TEMPERATURE = DC1394_FEATURE_TEMPERATURE,
3224  // vpFEATURE_TRIGGER = DC1394_FEATURE_TRIGGER,
3225  // vpFEATURE_TRIGGER_DELAY = DC1394_FEATURE_TRIGGER_DELAY,
3226  // vpFEATURE_WHITE_SHADING = DC1394_FEATURE_WHITE_SHADING,
3227  // vpFEATURE_FRAME_RATE = DC1394_FEATURE_FRAME_RATE,
3228  // vpFEATURE_ZOOM = DC1394_FEATURE_ZOOM,
3229  // vpFEATURE_PAN = DC1394_FEATURE_PAN,
3230  // vpFEATURE_TILT = DC1394_FEATURE_TILT,
3231  // vpFEATURE_OPTICAL_FILTER = DC1394_FEATURE_OPTICAL_FILTER,
3232  // vpFEATURE_CAPTURE_SIZE = DC1394_FEATURE_CAPTURE_SIZE,
3233  // vpFEATURE_CAPTURE_QUALITY = DC1394_FEATURE_CAPTURE_QUALITY
3234  }
3235 
3236  dc1394error_t err;
3237  dc1394bool_t hasManualMode = DC1394_FALSE;
3238  dc1394feature_modes_t modesAvailable;
3239 
3240  // test wether we can set the shutter value (manual mode available or not)
3241  err = dc1394_feature_get_modes(camera, feature, &modesAvailable);
3242  if (err != DC1394_SUCCESS) {
3243  vpERROR_TRACE("Unable to detect the manual mode information");
3244  close();
3245  throw(
3246  vpFrameGrabberException(vpFrameGrabberException::settingError, "Unable to detect the manual mode information"));
3247  }
3248 
3249  for (unsigned int i = 0; i < modesAvailable.num; i++) {
3250  if (modesAvailable.modes[i] == DC1394_FEATURE_MODE_MANUAL) {
3251  hasManualMode = DC1394_TRUE;
3252  }
3253  }
3254 
3255  if (hasManualMode == DC1394_TRUE) {
3256 
3257  if (!isDataModified[camera_id]) { // to ensure we save the first mode
3258  // even after several set
3259  /* we update the structure */
3260  updateDataCamToStruct();
3261  err = dc1394_feature_get_mode(camera, feature, &(initialShutterMode[camera_id]));
3262  if (err != DC1394_SUCCESS) {
3263  vpERROR_TRACE("Unable to get the initial mode");
3264  close();
3265  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Unable to get the initial mode"));
3266  }
3267  isDataModified[camera_id] = true;
3268  }
3269 
3270  dc1394feature_mode_t manualMode = DC1394_FEATURE_MODE_MANUAL;
3271  err = dc1394_feature_set_mode(camera, feature, manualMode);
3272  if (err != DC1394_SUCCESS) {
3273  vpERROR_TRACE("Unable to set the muanual mode");
3274  close();
3275  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Unable to set the manual mode"));
3276  }
3277  err = dc1394_feature_set_value(camera, feature, value);
3278  if (err != DC1394_SUCCESS) {
3279  vpERROR_TRACE("Unable to set the shutter information");
3280  close();
3281  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Unable to set the shutter information"));
3282  }
3283  }
3284  else {
3285  vpERROR_TRACE("The camera does not have a manual mode.\nCannot change the value");
3286  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "The camera does not have a manual mode"));
3287  }
3288 }
3296 void vp1394TwoGrabber::getGuid(uint64_t &guid)
3297 {
3298  if (!num_cameras) {
3299  close();
3300  vpERROR_TRACE("No camera found");
3302  }
3303 
3304  guid = camera->guid;
3305 }
3306 
3315 {
3316  if (!num_cameras) {
3317  close();
3318  vpERROR_TRACE("No camera found");
3320  }
3321 
3322  return camera->guid;
3323 }
3324 
3329 inline void vp1394TwoGrabber::updateDataCamToStruct()
3330 {
3331  dataCam[camera_id].brightness = getParameterValue(vpFEATURE_BRIGHTNESS);
3332  dataCam[camera_id].exposure = getParameterValue(vpFEATURE_EXPOSURE);
3333  dataCam[camera_id].sharpness = getParameterValue(vpFEATURE_SHARPNESS);
3334  dataCam[camera_id].hue = getParameterValue(vpFEATURE_HUE);
3335  dataCam[camera_id].saturation = getParameterValue(vpFEATURE_SATURATION);
3336  dataCam[camera_id].gamma = getParameterValue(vpFEATURE_GAMMA);
3337  dataCam[camera_id].shutter = getParameterValue(vpFEATURE_SHUTTER);
3338  dataCam[camera_id].gain = getParameterValue(vpFEATURE_GAIN);
3339  dataCam[camera_id].iris = getParameterValue(vpFEATURE_IRIS);
3340 }
3341 
3346 inline void vp1394TwoGrabber::updateDataStructToCam()
3347 {
3348  setParameterValue(vpFEATURE_BRIGHTNESS, dataCam[camera_id].brightness);
3349  setParameterValue(vpFEATURE_EXPOSURE, dataCam[camera_id].exposure);
3350  setParameterValue(vpFEATURE_SHARPNESS, dataCam[camera_id].sharpness);
3351  setParameterValue(vpFEATURE_HUE, dataCam[camera_id].hue);
3352  setParameterValue(vpFEATURE_SATURATION, dataCam[camera_id].saturation);
3353  setParameterValue(vpFEATURE_GAMMA, dataCam[camera_id].gamma);
3354  setParameterValue(vpFEATURE_SHUTTER, dataCam[camera_id].shutter);
3355  setParameterValue(vpFEATURE_GAIN, dataCam[camera_id].gain);
3356  setParameterValue(vpFEATURE_IRIS, dataCam[camera_id].iris);
3357 }
3358 
3376 {
3377  this->acquire(I);
3378  return *this;
3379 }
3380 
3398 {
3399  this->acquire(I);
3400  return *this;
3401 }
3402 
3403 #elif !defined(VISP_BUILD_SHARED_LIBS)
3404 // Work around to avoid warning: libvisp_sensor.a(vp1394TwoGrabber.cpp.o) has
3405 // no symbols
3406 void dummy_vp1394TwoGrabber() { };
3407 #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:245
void resize(unsigned int h, unsigned int w)
resize the image : Image initialization
Definition: vpImage.h:783
Type * bitmap
points toward the bitmap
Definition: vpImage.h:139
unsigned int getHeight() const
Definition: vpImage.h:184
#define vpCTRACE
Definition: vpDebug.h:329
#define vpCERROR
Definition: vpDebug.h:356
#define vpTRACE
Definition: vpDebug.h:405
#define vpERROR_TRACE
Definition: vpDebug.h:382
VISP_EXPORT int wait(double t0, double t)