Visual Servoing Platform  version 3.2.1 under development (2019-07-18)
vp1394TwoGrabber.cpp
1 /****************************************************************************
2  *
3  * ViSP, open source Visual Servoing Platform software.
4  * Copyright (C) 2005 - 2019 by Inria. All rights reserved.
5  *
6  * This software is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  * See the file LICENSE.txt at the root directory of this source
11  * distribution for additional information about the GNU GPL.
12  *
13  * For using ViSP with software that can not be combined with the GNU
14  * GPL, please contact Inria about acquiring a ViSP Professional
15  * Edition License.
16  *
17  * See http://visp.inria.fr for more information.
18  *
19  * This software was developed at:
20  * Inria Rennes - Bretagne Atlantique
21  * Campus Universitaire de Beaulieu
22  * 35042 Rennes Cedex
23  * France
24  *
25  * If you have questions regarding the use of this file, please contact
26  * Inria at visp@inria.fr
27  *
28  * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
29  * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
30  *
31  * Description:
32  * Firewire cameras video capture.
33  *
34  * Authors:
35  * Fabien Spindler
36  *
37  *****************************************************************************/
38 
44 #include <iostream>
45 
46 #include <visp3/core/vpConfig.h>
47 
48 /*
49  * Interface with libdc1394 2.x
50  */
51 #if defined(VISP_HAVE_DC1394)
52 #include <unistd.h>
53 
54 #include <visp3/core/vpFrameGrabberException.h>
55 #include <visp3/core/vpImageConvert.h>
56 #include <visp3/core/vpTime.h>
57 #include <visp3/sensor/vp1394TwoGrabber.h>
58 
59 const char *vp1394TwoGrabber::strVideoMode[DC1394_VIDEO_MODE_NUM] = {
60  "MODE_160x120_YUV444", "MODE_320x240_YUV422", "MODE_640x480_YUV411", "MODE_640x480_YUV422",
61  "MODE_640x480_RGB8", "MODE_640x480_MONO8", "MODE_640x480_MONO16", "MODE_800x600_YUV422",
62  "MODE_800x600_RGB8", "MODE_800x600_MONO8", "MODE_1024x768_YUV422", "MODE_1024x768_RGB8",
63  "MODE_1024x768_MONO8", "MODE_800x600_MONO16", "MODE_1024x768_MONO16", "MODE_1280x960_YUV422",
64  "MODE_1280x960_RGB8", "MODE_1280x960_MONO8", "MODE_1600x1200_YUV422", "MODE_1600x1200_RGB8",
65  "MODE_1600x1200_MONO8", "MODE_1280x960_MONO16", "MODE_1600x1200_MONO16", "MODE_EXIF",
66  "MODE_FORMAT7_0", "MODE_FORMAT7_1", "MODE_FORMAT7_2", "MODE_FORMAT7_3",
67  "MODE_FORMAT7_4", "MODE_FORMAT7_5", "MODE_FORMAT7_6", "MODE_FORMAT7_7"};
68 
69 const char *vp1394TwoGrabber::strFramerate[DC1394_FRAMERATE_NUM] = {
70  "FRAMERATE_1_875", "FRAMERATE_3_75", "FRAMERATE_7_5", "FRAMERATE_15",
71  "FRAMERATE_30", "FRAMERATE_60", "FRAMERATE_120", "FRAMERATE_240"};
72 
73 const char *vp1394TwoGrabber::strColorCoding[DC1394_COLOR_CODING_NUM] = {
74  "COLOR_CODING_MONO8", "COLOR_CODING_YUV411", "COLOR_CODING_YUV422", "COLOR_CODING_YUV444",
75  "COLOR_CODING_RGB8", "COLOR_CODING_MONO16", "COLOR_CODING_RGB16", "COLOR_CODING_MONO16S",
76  "COLOR_CODING_RGB16S", "COLOR_CODING_RAW8", "COLOR_CODING_RAW16",
77 };
78 
125  : camera(NULL), cameras(NULL), num_cameras(0), camera_id(0), verbose(false), camIsOpen(NULL),
126  num_buffers(4), // ring buffer size
127  isDataModified(NULL), initialShutterMode(NULL), dataCam(NULL)
128 #ifdef VISP_HAVE_DC1394_CAMERA_ENUMERATE // new API > libdc1394-2.0.0-rc7
129  ,
130  d(NULL), list(NULL)
131 #endif
132 {
133  // protected members
134  width = height = 0;
135 
136  // private members
137  init = false;
138 
139  reset = false;
140  initialize(reset);
141 
142  // open();
143 }
144 
155 {
156  /* if(num_cameras >= 1){
157  delete[] isDataModified;
158  delete[] initialShutterMode;
159  delete[] dataCam;
160  }*/
161  close();
162 }
163 
285 void vp1394TwoGrabber::setCamera(uint64_t cam_id)
286 {
287  // Suppose that if camera_id is a camera GUID, this value is greater
288  // than the number of cameras connected to the bus
289  if (cam_id >= num_cameras) {
290  // Check if camera_id is a camera guid
291  bool is_guid = false;
292  // check if the camera_id is a guid
293  for (unsigned int i = 0; i < num_cameras; i++) {
294  if (cameras[i]->guid == cam_id) {
295  this->camera_id = i;
296  is_guid = true;
297  break;
298  }
299  }
300  if (is_guid == false) {
301  std::cout << "Error: The camera with guid 0x" << std::hex << cam_id << " is not present" << std::endl;
302  std::cout << num_cameras << " camera(s) connected" << std::endl;
303  for (unsigned int i = 0; i < num_cameras; i++) {
304  std::cout << " - camera " << i << " with guid 0x" << std::hex << cameras[i]->guid << std::endl;
305  }
306  close();
307  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "The required camera is not present"));
308  }
309  } else {
310  this->camera_id = (unsigned int)cam_id; // The input cam_id is not a
311  // uint64_t guid, but the index of
312  // the camera
313  }
314 
315  // create a pointer to the working camera
316  camera = cameras[this->camera_id];
317 }
318 
333 void vp1394TwoGrabber::getCamera(uint64_t &cam_id)
334 {
335  if (num_cameras) {
336  cam_id = this->camera_id;
337  } else {
338  close();
339  vpERROR_TRACE("No cameras found");
341  }
342 }
343 
359 {
360  if (num_cameras) {
361  return this->camera_id;
362  } else {
363  close();
364  vpERROR_TRACE("No cameras found");
366  }
367 }
368 
376 void vp1394TwoGrabber::getNumCameras(unsigned int &ncameras) const
377 {
378  if (!num_cameras) {
379  vpCTRACE << "No camera found..." << std::endl;
380  ncameras = 0;
381  }
382 
383  ncameras = num_cameras;
384 }
385 
394 {
395  unsigned int ncameras = 0;
396  if (!num_cameras) {
397  vpCTRACE << "No camera found..." << std::endl;
398  ncameras = 0;
399  }
400 
401  ncameras = num_cameras;
402  return ncameras;
403 }
404 
451 {
452  open();
453  if (!num_cameras) {
454  close();
456  }
457  if (!isVideoModeSupported(videomode)) {
458  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Video mode not supported by camera %d",
459  camera_id));
460  }
461  // Stop dma capture if started
462  setTransmission(DC1394_OFF);
463  setCapture(DC1394_OFF);
464 
465  if (dc1394_video_set_mode(camera, (dc1394video_mode_t)videomode) != DC1394_SUCCESS) {
466  close();
467  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Can't set video mode"));
468  }
469 
470  setCapture(DC1394_ON);
471  setTransmission(DC1394_ON);
472 
473  // Updates image size from new video mode
474  if (dc1394_get_image_size_from_video_mode(camera, (dc1394video_mode_t)videomode, &this->width, &this->height) !=
475  DC1394_SUCCESS) {
476 
477  close();
478  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Can't get image size"));
479  }
480 }
481 
499 {
500  if (!num_cameras) {
501  close();
502  vpERROR_TRACE("No camera found");
504  }
505 
506  dc1394video_mode_t _videomode;
507  if (dc1394_video_get_mode(camera, &_videomode) != DC1394_SUCCESS) {
508 
509  close();
510  vpERROR_TRACE("Can't get current video mode");
511  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Can't get current video mode"));
512  }
513  videomode = (vp1394TwoVideoModeType)_videomode;
514 }
515 
533 uint32_t vp1394TwoGrabber::getVideoModeSupported(std::list<vp1394TwoVideoModeType> &videomodes)
534 {
535  // Refresh the list of supported modes
536  videomodes.clear();
537 
538  if (!num_cameras) {
539  close();
540  vpERROR_TRACE("No camera found");
542  }
543  dc1394video_modes_t _videomodes;
544 
545  // get video modes:
546  if (dc1394_video_get_supported_modes(camera, &_videomodes) != DC1394_SUCCESS) {
547 
548  close();
549  vpERROR_TRACE("Can't get video modes");
550  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Can't get video modes"));
551  }
552 
553  // parse the video modes to add in the list
554  for (unsigned i = 0; i < _videomodes.num; i++) {
555  vp1394TwoVideoModeType _mode = (vp1394TwoVideoModeType)_videomodes.modes[i];
556  videomodes.push_back(_mode);
557  }
558 
559  // return the number of available video modes
560  return _videomodes.num;
561 }
578 {
579  if (!num_cameras) {
580  close();
581  vpERROR_TRACE("No camera found");
583  }
584  dc1394video_modes_t _videomodes;
585 
586  // get video modes:
587  if (dc1394_video_get_supported_modes(camera, &_videomodes) != DC1394_SUCCESS) {
588 
589  close();
590  vpERROR_TRACE("Can't get video modes");
591  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Can't get video modes"));
592  }
593 
594  // parse the video modes to check with the desired
595  for (unsigned i = 0; i < _videomodes.num; i++) {
596  if ((vp1394TwoVideoModeType)_videomodes.modes[i] == videomode)
597  return true;
598  }
599  return false;
600 }
601 
615 {
616 
617  if (dc1394_is_video_mode_scalable((dc1394video_mode_t)videomode))
618  return true;
619 
620  return false;
621 }
622 
639 {
641  getColorCoding(coding);
642 
643  switch (coding) {
647  case vpCOLOR_CODING_RAW8:
649  return false;
653  case vpCOLOR_CODING_RGB8:
656  return true;
657  }
658  return false;
659 }
660 
686 {
687  open();
688  if (!num_cameras) {
689  close();
691  }
692 
693  vp1394TwoVideoModeType cur_videomode;
694  getVideoMode(cur_videomode);
695  if (isVideoModeFormat7(cur_videomode))
696  return;
697 
698  if (!isFramerateSupported(cur_videomode, fps)) {
699  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Framerate not supported by camera %d",
700  camera_id));
701  }
702 
703  // Stop dma capture if started
704  setTransmission(DC1394_OFF);
705  setCapture(DC1394_OFF);
706 
707  if (dc1394_video_set_framerate(camera, (dc1394framerate_t)fps) != DC1394_SUCCESS) {
708 
709  close();
710  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Can't set framerate"));
711  }
712 
713  setCapture(DC1394_ON);
714  setTransmission(DC1394_ON);
715 }
716 
734 {
735  if (!num_cameras) {
736  close();
737  vpERROR_TRACE("No camera found");
739  }
740  dc1394framerate_t _fps;
741  if (dc1394_video_get_framerate(camera, &_fps) != DC1394_SUCCESS) {
742 
743  close();
744  vpERROR_TRACE("Can't get current framerate");
745  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Can't get current framerate"));
746  }
747  fps = (vp1394TwoFramerateType)_fps;
748 }
749 
781 uint32_t vp1394TwoGrabber::getFramerateSupported(vp1394TwoVideoModeType mode, std::list<vp1394TwoFramerateType> &fps)
782 {
783  if (!num_cameras) {
784  close();
785  vpERROR_TRACE("No camera found");
787  }
788 
789  // Refresh the list of supported framerates
790  fps.clear();
791 
792  switch (mode) {
793  // Framerate not available for:
794  // - vpVIDEO_MODE_EXIF ie Format_6
795  // - vpVIDEO_MODE_FORMAT7... ie the Format_7
796  case vpVIDEO_MODE_EXIF:
805  return 0;
806  break;
807  default: {
808  dc1394framerates_t _fps;
809  if (dc1394_video_get_supported_framerates(camera, (dc1394video_mode_t)mode, &_fps) != DC1394_SUCCESS) {
810  close();
811  vpERROR_TRACE("Could not query supported frametates for mode %d\n", mode);
812  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Could not query supported framerates"));
813  }
814  if (_fps.num == 0)
815  return 0;
816 
817  for (unsigned int i = 0; i < _fps.num; i++)
818  fps.push_back((vp1394TwoFramerateType)_fps.framerates[i]);
819 
820  return _fps.num;
821  } break;
822  }
823 }
858 {
859  if (!num_cameras) {
860  close();
861  vpERROR_TRACE("No camera found");
863  }
864 
865  switch (mode) {
866  // Framerate not available for:
867  // - vpVIDEO_MODE_EXIF ie Format_6
868  // - vpVIDEO_MODE_FORMAT7... ie the Format_7
869  case vpVIDEO_MODE_EXIF:
878  return 0;
879  break;
880  default: {
881  dc1394framerates_t _fps;
882  if (dc1394_video_get_supported_framerates(camera, (dc1394video_mode_t)mode, &_fps) != DC1394_SUCCESS) {
883  close();
884  vpERROR_TRACE("Could not query supported frametates for mode %d\n", mode);
885  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Could not query supported framerates"));
886  }
887  if (_fps.num == 0)
888  return 0;
889 
890  for (unsigned int i = 0; i < _fps.num; i++) {
891  if (fps == (vp1394TwoFramerateType)_fps.framerates[i]) {
892  return true;
893  }
894  }
895  return false;
896  } break;
897  }
898 }
899 
949 {
950  if (!num_cameras) {
951  close();
953  }
954 
955  dc1394video_mode_t _videomode;
956  if (dc1394_video_get_mode(camera, &_videomode) != DC1394_SUCCESS) {
957 
958  close();
959  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Can't get current video mode"));
960  }
961 
962  if (!isColorCodingSupported((vp1394TwoVideoModeType)_videomode, coding)) {
963  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Color coding not supported by camera %d",
964  camera_id));
965  }
966 
967  // Format 7 video mode
968  if (dc1394_is_video_mode_scalable(_videomode)) {
969  setTransmission(DC1394_OFF);
970  setCapture(DC1394_OFF);
971 
972  if (dc1394_format7_set_color_coding(camera, _videomode, (dc1394color_coding_t)coding) != DC1394_SUCCESS) {
973 
974  close();
975  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Can't set color coding"));
976  }
977 
978  setCapture(DC1394_ON);
979  setTransmission(DC1394_ON);
980  }
981 }
982 
1001 {
1002  if (!num_cameras) {
1003  close();
1004  vpERROR_TRACE("No camera found");
1006  }
1007  dc1394video_mode_t _videomode;
1008  if (dc1394_video_get_mode(camera, &_videomode) != DC1394_SUCCESS) {
1009 
1010  close();
1011  vpERROR_TRACE("Can't get current video mode");
1012  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Can't get current video mode"));
1013  }
1014 
1015  dc1394color_coding_t _coding;
1016  if (dc1394_is_video_mode_scalable(_videomode)) {
1017  // Format 7 video mode
1018  if (dc1394_format7_get_color_coding(camera, _videomode, &_coding) != DC1394_SUCCESS) {
1019 
1020  close();
1021  vpERROR_TRACE("Can't get current color coding");
1022  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Can't query current color coding"));
1023  }
1024  } else if (dc1394_is_video_mode_still_image((dc1394video_mode_t)_videomode)) {
1025  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "No color coding for format 6 video mode"));
1026  } else {
1027  // Not Format 7 and not Format 6 video modes
1028  if (dc1394_get_color_coding_from_video_mode(camera, (dc1394video_mode_t)_videomode, &_coding) != DC1394_SUCCESS) {
1029  close();
1030  vpERROR_TRACE("Could not query supported color coding for mode %d\n", _videomode);
1031  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Can't query current color coding"));
1032  }
1033  }
1034  coding = (vp1394TwoColorCodingType)_coding;
1035 }
1036 
1059  std::list<vp1394TwoColorCodingType> &codings)
1060 {
1061  if (!num_cameras) {
1062  close();
1063  vpERROR_TRACE("No camera found");
1065  }
1066 
1067  // Refresh the list of supported framerates
1068  codings.clear();
1069 
1070  if (dc1394_is_video_mode_scalable((dc1394video_mode_t)mode)) {
1071  // Format 7 video mode
1072  dc1394color_codings_t _codings;
1073  if (dc1394_format7_get_color_codings(camera, (dc1394video_mode_t)mode, &_codings) != DC1394_SUCCESS) {
1074  close();
1075  vpERROR_TRACE("Could not query supported color codings for mode %d\n", mode);
1076  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Could not query supported color codings"));
1077  }
1078  if (_codings.num == 0)
1079  return 0;
1080 
1081  for (unsigned int i = 0; i < _codings.num; i++)
1082  codings.push_back((vp1394TwoColorCodingType)_codings.codings[i]);
1083 
1084  return _codings.num;
1085  } else if (dc1394_is_video_mode_still_image((dc1394video_mode_t)mode)) {
1086  // Format 6 video mode
1087  return 0;
1088  } else {
1089  // Not Format 7 and not Format 6 video modes
1090  dc1394color_coding_t _coding;
1091  if (dc1394_get_color_coding_from_video_mode(camera, (dc1394video_mode_t)mode, &_coding) != DC1394_SUCCESS) {
1092  close();
1093  vpERROR_TRACE("Could not query supported color coding for mode %d\n", mode);
1094  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Could not query supported color coding"));
1095  }
1096  codings.push_back((vp1394TwoColorCodingType)_coding);
1097  return 1;
1098  }
1099 }
1122 {
1123  if (!num_cameras) {
1124  close();
1125  vpERROR_TRACE("No camera found");
1127  }
1128 
1129  if (dc1394_is_video_mode_scalable((dc1394video_mode_t)mode)) {
1130  // Format 7 video mode
1131  dc1394color_codings_t _codings;
1132  if (dc1394_format7_get_color_codings(camera, (dc1394video_mode_t)mode, &_codings) != DC1394_SUCCESS) {
1133  close();
1134  vpERROR_TRACE("Could not query supported color codings for mode %d\n", mode);
1135  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Could not query supported color codings"));
1136  }
1137  if (_codings.num == 0)
1138  return 0;
1139 
1140  for (unsigned int i = 0; i < _codings.num; i++) {
1141  if (coding == (vp1394TwoColorCodingType)_codings.codings[i])
1142  return true;
1143  }
1144  return false;
1145  } else if (dc1394_is_video_mode_still_image((dc1394video_mode_t)mode)) {
1146  // Format 6 video mode
1147  return false;
1148  } else {
1149  // Not Format 7 and not Format 6 video modes
1150  dc1394color_coding_t _coding;
1151  if (dc1394_get_color_coding_from_video_mode(camera, (dc1394video_mode_t)mode, &_coding) != DC1394_SUCCESS) {
1152  close();
1153  vpERROR_TRACE("Could not query supported color coding for mode %d\n", mode);
1154  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Could not query supported color coding"));
1155  return false;
1156  }
1157  if (coding == (vp1394TwoColorCodingType)_coding)
1158  return true;
1159 
1160  return false;
1161  }
1162 }
1163 
1195 void vp1394TwoGrabber::setFormat7ROI(unsigned int left, unsigned int top, unsigned int w, unsigned int h)
1196 {
1197  open();
1198  if (!num_cameras) {
1199  close();
1200  vpERROR_TRACE("No camera found");
1202  }
1203 
1204  dc1394video_mode_t _videomode;
1205  if (dc1394_video_get_mode(camera, &_videomode) != DC1394_SUCCESS) {
1206 
1207  close();
1208  vpERROR_TRACE("Can't get current video mode");
1209  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Can't get current video mode"));
1210  }
1211  if (dc1394_is_video_mode_scalable(_videomode)) {
1212  // Stop dma capture if started
1213  setTransmission(DC1394_OFF);
1214  setCapture(DC1394_OFF);
1215  // Format 7 video mode
1216  unsigned int max_width, max_height;
1217  if (dc1394_format7_get_max_image_size(camera, _videomode, &max_width, &max_height) != DC1394_SUCCESS) {
1218 
1219  close();
1220  vpERROR_TRACE("Can't get format7 max image size");
1221  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Can't get format7 max image size"));
1222  }
1223 #if 0
1224  vpTRACE("left: %d top: %d width: %d height: %d", left, top,
1225  width == 0 ? DC1394_USE_MAX_AVAIL: w,
1226  height == 0 ? DC1394_USE_MAX_AVAIL : h);
1227  vpTRACE("max_width: %d max_height: %d", max_width, max_height);
1228 #endif
1229 
1230  if (left > max_width) {
1231  vpERROR_TRACE("Can't set format7 ROI");
1232  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Can't set format7 ROI"));
1233  }
1234  if (top > max_height) {
1235  vpERROR_TRACE("Can't set format7 ROI");
1236  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Can't set format7 ROI"));
1237  }
1238 
1239  int32_t roi_width;
1240  int32_t roi_height;
1241 
1242  if (w != 0) {
1243  // Check if roi width is acceptable (ie roi is contained in the image)
1244  if (w > (max_width - left))
1245  w = (max_width - left);
1246  roi_width = (int32_t)w;
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  } else {
1257  roi_height = DC1394_USE_MAX_AVAIL;
1258  }
1259 
1260  if (dc1394_format7_set_roi(camera, _videomode,
1261  (dc1394color_coding_t)DC1394_QUERY_FROM_CAMERA, // color_coding
1262  DC1394_USE_MAX_AVAIL /*DC1394_QUERY_FROM_CAMERA*/
1263  , // bytes_per_packet
1264  (int32_t)left, // left
1265  (int32_t)top, // top
1266  roi_width, roi_height) != DC1394_SUCCESS) {
1267  close();
1268  vpERROR_TRACE("Can't set format7 roi");
1269  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Can't get current video mode"));
1270  }
1271  // Update the image size
1272  if (dc1394_format7_get_image_size(camera, _videomode, &this->width, &this->height) != DC1394_SUCCESS) {
1273  close();
1274  vpERROR_TRACE("Can't get format7 image size");
1275  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Can't get format7 image size"));
1276  }
1277 
1278  setCapture(DC1394_ON);
1279  setTransmission(DC1394_ON);
1280  }
1281 }
1296 void vp1394TwoGrabber::initialize(bool reset)
1297 {
1298  if (init == false) {
1299 // Find cameras
1300 #ifdef VISP_HAVE_DC1394_CAMERA_ENUMERATE // new API > libdc1394-2.0.0-rc7
1301  if (d != NULL)
1302  dc1394_free(d);
1303 
1304  d = dc1394_new();
1305  if (dc1394_camera_enumerate(d, &list) != DC1394_SUCCESS) {
1306  dc1394_camera_free_list(list);
1307  close();
1308  vpERROR_TRACE("Failed to enumerate cameras\n");
1309  throw(vpFrameGrabberException(vpFrameGrabberException::initializationError, "Failed to enumerate cameras"));
1310  }
1311 
1312  if (list->num == 0) {
1313  dc1394_camera_free_list(list);
1314  close();
1315  vpERROR_TRACE("No cameras found");
1317  }
1318 
1319  if (cameras != NULL)
1320  delete[] cameras;
1321 
1322  cameras = new dc1394camera_t *[list->num];
1323 
1324  num_cameras = 0;
1325 
1326  for (unsigned int i = 0; i < list->num; i++) {
1327  cameras[i] = dc1394_camera_new(d, list->ids[i].guid);
1328  if (!cameras[i]) {
1329  vpTRACE("Failed to initialize camera with guid \"%ld\"\n", list->ids[i].guid);
1330  continue;
1331  }
1332  // Update the number of working cameras
1333  num_cameras++;
1334  }
1335 
1336  if (reset) {
1337  // Reset the bus to make firewire working if the program was not
1338  // properly stopped by a CTRL-C. We reset here only the bus attached to
1339  // the first camera
1340  dc1394_reset_bus(cameras[0]);
1341  }
1342 
1343  // if (list != NULL)
1344  dc1394_camera_free_list(list);
1345  list = NULL;
1346 
1347 #elif defined VISP_HAVE_DC1394_FIND_CAMERAS // old API <= libdc1394-2.0.0-rc7
1348  if (cameras != NULL)
1349  free(cameras);
1350  cameras = NULL;
1351  int err = dc1394_find_cameras(&cameras, &num_cameras);
1352 
1353  if (err != DC1394_SUCCESS && err != DC1394_NO_CAMERA) {
1354  close();
1355  vpERROR_TRACE("Unable to look for cameras\n\n"
1356  "Please check \n"
1357  " - if the kernel modules `ieee1394',`raw1394' and "
1358  "`ohci1394' are loaded \n"
1359  " - if you have read/write access to /dev/raw1394\n\n");
1360  throw(vpFrameGrabberException(vpFrameGrabberException::initializationError, "Unable to look for cameras"));
1361  }
1362 #endif
1363 
1364  if (num_cameras == 0) {
1365  close();
1366  vpERROR_TRACE("No cameras found");
1368  }
1369 
1370  // allocation for the parameters
1371  isDataModified = new bool[num_cameras];
1372  for (unsigned int i = 0; i < num_cameras; i++)
1373  isDataModified[i] = false;
1374  initialShutterMode = new dc1394feature_mode_t[num_cameras];
1375  dataCam = new vpDc1394TwoCameraParametersData[num_cameras];
1376 
1377  if (camera_id >= num_cameras) {
1378  // Bad camera id
1379  close();
1380  vpERROR_TRACE("Bad camera id: %u", camera_id);
1381  vpERROR_TRACE("Only %u camera on the bus.", num_cameras);
1383  }
1384 
1385  if (verbose) {
1386  std::cout << "------ Bus information ------" << std::endl;
1387  std::cout << "Number of camera(s) on the bus : " << num_cameras << std::endl;
1388  std::cout << "-----------------------------" << std::endl;
1389  }
1390 
1391  if (camIsOpen != NULL)
1392  delete[] camIsOpen;
1393  camIsOpen = new bool[num_cameras];
1394  for (unsigned int i = 0; i < num_cameras; i++) {
1395  camIsOpen[i] = false;
1396  }
1397 
1398  init = true;
1399  }
1400 }
1411 {
1412  if (init == false)
1413  initialize(false);
1414  if (camIsOpen[camera_id] == false) {
1415  dc1394switch_t status = DC1394_OFF;
1416 
1417  //#ifdef VISP_HAVE_DC1394_CAMERA_ENUMERATE // new API >
1418  // libdc1394-2.0.0-rc7
1419  dc1394_video_get_transmission(cameras[camera_id], &status);
1420  if (status != DC1394_OFF) {
1421  //#endif
1422  if (dc1394_video_set_transmission(cameras[camera_id], DC1394_OFF) != DC1394_SUCCESS)
1423  vpTRACE("Could not stop ISO transmission");
1424  else {
1425  vpTime::wait(500);
1426  if (dc1394_video_get_transmission(cameras[camera_id], &status) != DC1394_SUCCESS)
1427  vpTRACE("Could get ISO status");
1428  else {
1429  if (status == DC1394_ON) {
1430  vpTRACE("ISO transmission refuses to stop");
1431  }
1432 #ifdef VISP_HAVE_DC1394_FIND_CAMERAS // old API <= libdc1394-2.0.0-rc7
1433  // No yet in the new API
1434  cameras[camera_id]->is_iso_on = status;
1435 #endif
1436  }
1437  //#ifdef VISP_HAVE_DC1394_CAMERA_ENUMERATE // new API >
1438  // libdc1394-2.0.0-rc7
1439  }
1440  //#endif
1441  }
1442  setCamera(camera_id);
1443  // setIsoSpeed(DC1394_ISO_SPEED_400);
1444  setCapture(DC1394_ON);
1445  setTransmission(DC1394_ON);
1446  camIsOpen[camera_id] = true;
1447  }
1448 }
1458 {
1459  if (init) {
1460  if (num_cameras) {
1461  for (unsigned int i = 0; i < num_cameras; i++) {
1462  if (camIsOpen[i]) {
1463  camera = cameras[i];
1464  this->camera_id = i; // set camera id for the function updateDataStructToCam
1465  setTransmission(DC1394_OFF);
1466  setCapture(DC1394_OFF);
1467  if (isDataModified[i]) {
1468  // reset values
1469  try {
1470  updateDataStructToCam();
1471  } catch (...) {
1472  }
1473  // reset mode (manual, auto, ...)
1474  if (dc1394_feature_set_mode(camera, DC1394_FEATURE_BRIGHTNESS, initialShutterMode[i]) != DC1394_SUCCESS ||
1475  dc1394_feature_set_mode(camera, DC1394_FEATURE_EXPOSURE, initialShutterMode[i]) != DC1394_SUCCESS ||
1476  dc1394_feature_set_mode(camera, DC1394_FEATURE_SHARPNESS, initialShutterMode[i]) != DC1394_SUCCESS ||
1477  dc1394_feature_set_mode(camera, DC1394_FEATURE_HUE, initialShutterMode[i]) != DC1394_SUCCESS ||
1478  dc1394_feature_set_mode(camera, DC1394_FEATURE_SATURATION, initialShutterMode[i]) != DC1394_SUCCESS ||
1479  dc1394_feature_set_mode(camera, DC1394_FEATURE_GAMMA, initialShutterMode[i]) != DC1394_SUCCESS ||
1480  dc1394_feature_set_mode(camera, DC1394_FEATURE_SHUTTER, initialShutterMode[i]) != DC1394_SUCCESS ||
1481  dc1394_feature_set_mode(camera, DC1394_FEATURE_GAIN, initialShutterMode[i]) != DC1394_SUCCESS ||
1482  dc1394_feature_set_mode(camera, DC1394_FEATURE_IRIS, initialShutterMode[i])) {
1483 
1484  vpERROR_TRACE("Unable to reset the initial mode");
1485  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Unable to reset the initial mode"));
1486  }
1487  }
1488  if (dc1394_camera_set_power(camera, DC1394_OFF) != DC1394_SUCCESS)
1489  std::cout << "Unable to turn camera off" << std::endl;
1490  }
1491 #ifdef VISP_HAVE_DC1394_CAMERA_ENUMERATE // new API > libdc1394-2.0.0-rc7
1492  dc1394_camera_free(cameras[i]);
1493 #elif defined VISP_HAVE_DC1394_FIND_CAMERAS // old API <= libdc1394-2.0.0-rc7
1494  dc1394_free_camera(cameras[i]);
1495 #endif
1496  }
1497  }
1498  if (camIsOpen != NULL) {
1499  delete[] camIsOpen;
1500  camIsOpen = NULL;
1501  }
1502 
1503 #ifdef VISP_HAVE_DC1394_CAMERA_ENUMERATE // new API > libdc1394-2.0.0-rc7
1504  if (cameras != NULL) {
1505  delete[] cameras;
1506  cameras = NULL;
1507  }
1508  if (d != NULL) {
1509  dc1394_free(d);
1510  d = NULL;
1511  }
1512 
1513 #elif defined VISP_HAVE_DC1394_FIND_CAMERAS // old API <= libdc1394-2.0.0-rc7
1514  if (cameras != NULL) {
1515  free(cameras);
1516  cameras = NULL;
1517  }
1518 #endif
1519 
1520  camIsOpen = NULL;
1521  num_cameras = 0;
1522 
1523  // remove data for the parameters
1524  if (isDataModified != NULL) {
1525  delete[] isDataModified;
1526  isDataModified = NULL;
1527  }
1528  if (initialShutterMode != NULL) {
1529  delete[] initialShutterMode;
1530  initialShutterMode = NULL;
1531  }
1532  if (dataCam != NULL) {
1533  delete[] dataCam;
1534  dataCam = NULL;
1535  }
1536 
1537  init = false;
1538  }
1539 }
1540 
1554 {
1555  if (size < 1) {
1556  close();
1557  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Could not set ring buffer size"));
1558  }
1559 
1560  if (size != num_buffers) {
1561  // We need to change the ring buffer size
1562  num_buffers = size;
1563  if (camIsOpen[camera_id]) {
1564  setCapture(DC1394_OFF);
1565  setCapture(DC1394_ON);
1566  }
1567  }
1568 }
1569 
1579 unsigned int vp1394TwoGrabber::getRingBufferSize() const { return num_buffers; }
1580 
1621 {
1622  if (!num_cameras) {
1623  close();
1624  vpERROR_TRACE("No camera found");
1626  }
1627 
1628  dc1394feature_mode_t mode;
1629  if (enable) {
1630  mode = DC1394_FEATURE_MODE_AUTO;
1631  } else {
1632  mode = DC1394_FEATURE_MODE_MANUAL;
1633  }
1634 
1635  if (dc1394_feature_set_power(camera, DC1394_FEATURE_SHUTTER, DC1394_ON) != DC1394_SUCCESS) {
1636  // vpERROR_TRACE("Cannot set shutter on. \n");
1637  close();
1638  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Cannot set shutter on"));
1639  }
1640 
1641  if (dc1394_feature_set_mode(camera, DC1394_FEATURE_SHUTTER, mode) != DC1394_SUCCESS) {
1642  // vpERROR_TRACE("Cannot set auto shutter. \n");
1643  close();
1644  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Cannot set auto shutter"));
1645  }
1646 }
1687 void vp1394TwoGrabber::setAutoShutter(unsigned int minvalue, unsigned int maxvalue)
1688 {
1689  setAutoShutter();
1690 
1691  if (dc1394_avt_set_auto_shutter(camera, minvalue, maxvalue) != DC1394_SUCCESS) {
1692  // vpERROR_TRACE("Cannot set auto shutter min and max values. Is the
1693  // camera an AVT one?\n");
1694  close();
1695  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Cannot set auto shutter min and max values"));
1696  }
1697 }
1698 
1711 void vp1394TwoGrabber::getAutoShutter(unsigned int &minvalue, unsigned int &maxvalue)
1712 {
1713  if (!num_cameras) {
1714  close();
1715  vpERROR_TRACE("No camera found");
1717  }
1718 
1719  if (dc1394_avt_get_auto_shutter(camera, &minvalue, &maxvalue) != DC1394_SUCCESS) {
1720  // vpERROR_TRACE("Cannot get auto shutter min and max values. Is the
1721  // camera an AVT one?\n");
1722  close();
1723  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Cannot get auto shutter min and max values"));
1724  }
1725 }
1726 
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  } else {
1778  mode = DC1394_FEATURE_MODE_MANUAL;
1779  }
1780 
1781  if (dc1394_feature_set_power(camera, DC1394_FEATURE_GAIN, DC1394_ON) != DC1394_SUCCESS) {
1782  // vpERROR_TRACE("Cannot set shutter on. \n");
1783  close();
1784  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Cannot set shutter on"));
1785  }
1786 
1787  if (dc1394_feature_set_mode(camera, DC1394_FEATURE_GAIN, mode) != DC1394_SUCCESS) {
1788  // vpERROR_TRACE("Cannot set auto gain. \n");
1789  close();
1790  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Cannot set auto gain"));
1791  }
1792 }
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  } else { // _switch == DC1394_OFF
1909  dc1394error_t code = dc1394_capture_stop(camera);
1910 
1911  if (code != DC1394_SUCCESS && code != DC1394_CAPTURE_IS_NOT_SET) {
1912  vpERROR_TRACE("Unable to stop camera capture\n");
1913  close();
1914  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Could not setup dma capture"));
1915  }
1916  }
1917 }
1918 
1933 void vp1394TwoGrabber::setTransmission(dc1394switch_t _switch)
1934 {
1935  if (!num_cameras) {
1936  close();
1937  vpERROR_TRACE("No camera found");
1939  }
1940 
1941  dc1394switch_t status = DC1394_OFF;
1942 
1943  if (dc1394_video_get_transmission(camera, &status) != DC1394_SUCCESS) {
1944  vpERROR_TRACE("Unable to get transmision status");
1945  close();
1946  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Could not setup dma capture"));
1947  }
1948 
1949  // if (status!=_switch){
1950  // Start dma capture if halted
1951  if (dc1394_video_set_transmission(camera, _switch) != DC1394_SUCCESS) {
1952  vpERROR_TRACE("Unable to setup camera capture-\n"
1953  "make sure that the video mode and framerate are "
1954  "supported by your camera.\n");
1955  close();
1956  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Could not setup dma capture"));
1957  }
1958 
1959  if (_switch == DC1394_ON) {
1960  status = DC1394_OFF;
1961 
1962  int i = 0;
1963  while (status == DC1394_OFF && i++ < 5) {
1964  usleep(50000);
1965  if (dc1394_video_get_transmission(camera, &status) != DC1394_SUCCESS) {
1966  vpERROR_TRACE("Unable to get transmision status");
1967  close();
1968  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Could not setup dma capture"));
1969  }
1970  }
1971  }
1972  // }
1973 }
1974 
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  // vpERROR_TRACE("Camera is not 1394B mode capable. \n"
2024  // "Set the iso speed lower or equal to 400Mbps");
2025  close();
2026  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Camera is not 1394B mode capable"));
2027  }
2028 
2029  if (dc1394_video_set_operation_mode(camera, DC1394_OPERATION_MODE_1394B) != DC1394_SUCCESS) {
2030  // vpERROR_TRACE("Cannot set camera to 1394B mode. \n");
2031  close();
2032  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Cannot set camera to 1394B mode"));
2033  }
2034 
2035  if (dc1394_video_get_operation_mode(camera, &op_mode) != DC1394_SUCCESS) {
2036  // vpERROR_TRACE("Failed to set 1394B mode. \n");
2037  close();
2038  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Failed to set 1394B mode"));
2039  }
2040  } else {
2041  if (dc1394_video_set_operation_mode(camera, DC1394_OPERATION_MODE_LEGACY) != DC1394_SUCCESS) {
2042  // vpERROR_TRACE("Cannot set camera to 1394A mode. \n");
2043  close();
2044  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Cannot set camera to 1394A mode"));
2045  }
2046 
2047  if (dc1394_video_get_operation_mode(camera, &op_mode) != DC1394_SUCCESS) {
2048  // vpERROR_TRACE("Failed to set 1394A mode. \n");
2049  close();
2050  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Failed to set 1394A mode"));
2051  }
2052  }
2053 
2054  if (dc1394_video_set_iso_speed(camera, (dc1394speed_t)isospeed) != DC1394_SUCCESS) {
2055  // vpERROR_TRACE("Cannot set requested iso speed. \n");
2056  close();
2057  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Cannot set requested iso speed"));
2058  }
2059 
2060  if (dc1394_video_get_iso_speed(camera, &speed) != DC1394_SUCCESS) {
2061  // vpERROR_TRACE("Failed to set iso speed. \n");
2062  close();
2063  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Failed to set iso speed"));
2064  }
2065 }
2066 
2078 {
2079  open();
2080  acquire(I);
2081 }
2082 
2094 {
2095  open();
2096  acquire(I);
2097 }
2098 
2137 dc1394video_frame_t *vp1394TwoGrabber::dequeue()
2138 {
2139 
2140  if (!num_cameras) {
2141  close();
2142  vpERROR_TRACE("No camera found");
2144  }
2145 
2146  dc1394video_frame_t *frame = NULL;
2147 
2148  if (dc1394_capture_dequeue(camera, DC1394_CAPTURE_POLICY_WAIT, &frame) != DC1394_SUCCESS) {
2149  vpERROR_TRACE("Error: Failed to capture from camera %d\n", camera_id);
2150  }
2151 
2152  return frame;
2153 }
2154 
2197 {
2198  uint64_t timestamp;
2199  uint32_t id;
2200 
2201  dc1394video_frame_t *frame;
2202 
2203  frame = dequeue(I, timestamp, id);
2204 
2205  return frame;
2206 }
2207 
2256 dc1394video_frame_t *vp1394TwoGrabber::dequeue(vpImage<unsigned char> &I, uint64_t &timestamp, uint32_t &id)
2257 {
2258 
2259  open();
2260 
2261  dc1394video_frame_t *frame;
2262 
2263  frame = dequeue();
2264 
2265  // Timeval data structure providing the unix time
2266  // [microseconds] at which the frame was captured in the ring buffer.
2267  timestamp = frame->timestamp;
2268  id = frame->id;
2269 
2270  this->width = frame->size[0];
2271  this->height = frame->size[1];
2272  unsigned int size = this->width * this->height;
2273 
2274  if ((I.getWidth() != this->width) || (I.getHeight() != this->height))
2275  I.resize(this->height, this->width);
2276 
2277  switch (frame->color_coding) {
2278  case DC1394_COLOR_CODING_MONO8:
2279  case DC1394_COLOR_CODING_RAW8:
2280  memcpy(I.bitmap, (unsigned char *)frame->image, size * sizeof(unsigned char));
2281  break;
2282  case DC1394_COLOR_CODING_MONO16:
2283  case DC1394_COLOR_CODING_RAW16:
2284  vpImageConvert::MONO16ToGrey((unsigned char *)frame->image, I.bitmap, size);
2285  break;
2286 
2287  case DC1394_COLOR_CODING_YUV411:
2288  vpImageConvert::YUV411ToGrey((unsigned char *)frame->image, I.bitmap, size);
2289  break;
2290 
2291  case DC1394_COLOR_CODING_YUV422:
2292  vpImageConvert::YUV422ToGrey((unsigned char *)frame->image, I.bitmap, size);
2293  break;
2294 
2295  case DC1394_COLOR_CODING_YUV444:
2296  vpImageConvert::YUV444ToGrey((unsigned char *)frame->image, I.bitmap, size);
2297  break;
2298 
2299  case DC1394_COLOR_CODING_RGB8:
2300  vpImageConvert::RGBToGrey((unsigned char *)frame->image, I.bitmap, size);
2301  break;
2302 
2303  default:
2304  close();
2305  vpERROR_TRACE("Format conversion not implemented. Acquisition failed.");
2306  throw(vpFrameGrabberException(vpFrameGrabberException::otherError, "Format conversion not implemented. "
2307  "Acquisition failed."));
2308  };
2309 
2310  return frame;
2311 }
2312 
2354 {
2355  uint64_t timestamp;
2356  uint32_t id;
2357 
2358  dc1394video_frame_t *frame;
2359 
2360  frame = dequeue(I, timestamp, id);
2361 
2362  return frame;
2363 }
2364 
2413 dc1394video_frame_t *vp1394TwoGrabber::dequeue(vpImage<vpRGBa> &I, uint64_t &timestamp, uint32_t &id)
2414 {
2415 
2416  open();
2417 
2418  dc1394video_frame_t *frame;
2419 
2420  frame = dequeue();
2421 
2422  // Timeval data structure providing the unix time
2423  // [microseconds] at which the frame was captured in the ring buffer.
2424  timestamp = frame->timestamp;
2425  id = frame->id;
2426 
2427  this->width = frame->size[0];
2428  this->height = frame->size[1];
2429  unsigned int size = this->width * this->height;
2430 
2431  if ((I.getWidth() != width) || (I.getHeight() != height))
2432  I.resize(height, width);
2433 
2434  switch (frame->color_coding) {
2435  case DC1394_COLOR_CODING_MONO8:
2436  case DC1394_COLOR_CODING_RAW8:
2437  vpImageConvert::GreyToRGBa((unsigned char *)frame->image, (unsigned char *)I.bitmap, size);
2438  break;
2439 
2440  case DC1394_COLOR_CODING_MONO16:
2441  case DC1394_COLOR_CODING_RAW16:
2442  vpImageConvert::MONO16ToRGBa((unsigned char *)frame->image, (unsigned char *)I.bitmap, size);
2443  break;
2444 
2445  case DC1394_COLOR_CODING_YUV411:
2446  vpImageConvert::YUV411ToRGBa((unsigned char *)frame->image, (unsigned char *)I.bitmap, size);
2447  break;
2448 
2449  case DC1394_COLOR_CODING_YUV422:
2450  vpImageConvert::YUV422ToRGBa((unsigned char *)frame->image, (unsigned char *)I.bitmap, size);
2451  break;
2452 
2453  case DC1394_COLOR_CODING_YUV444:
2454  vpImageConvert::YUV444ToRGBa((unsigned char *)frame->image, (unsigned char *)I.bitmap, size);
2455  break;
2456 
2457  case DC1394_COLOR_CODING_RGB8:
2458  vpImageConvert::RGBToRGBa((unsigned char *)frame->image, (unsigned char *)I.bitmap, size);
2459  break;
2460 
2461  default:
2462  close();
2463  vpERROR_TRACE("Format conversion not implemented. Acquisition failed.");
2464  throw(vpFrameGrabberException(vpFrameGrabberException::otherError, "Format conversion not implemented. "
2465  "Acquisition failed."));
2466  };
2467 
2468  return frame;
2469 }
2470 
2481 void vp1394TwoGrabber::enqueue(dc1394video_frame_t *frame)
2482 {
2483 
2484  if (!num_cameras) {
2485  close();
2486  vpERROR_TRACE("No camera found");
2488  }
2489 
2490  if (frame)
2491  dc1394_capture_enqueue(camera, frame);
2492 }
2493 
2508 {
2509  uint64_t timestamp;
2510  uint32_t id;
2511 
2512  dc1394video_frame_t *frame;
2513 
2514  frame = dequeue(I, timestamp, id);
2515  enqueue(frame);
2516 }
2517 
2536 void vp1394TwoGrabber::acquire(vpImage<unsigned char> &I, uint64_t &timestamp, uint32_t &id)
2537 {
2538  dc1394video_frame_t *frame;
2539 
2540  open();
2541  frame = dequeue(I, timestamp, id);
2542  enqueue(frame);
2543 }
2544 
2559 {
2560  uint64_t timestamp;
2561  uint32_t id;
2562  dc1394video_frame_t *frame;
2563 
2564  open();
2565  frame = dequeue(I, timestamp, id);
2566  enqueue(frame);
2567 }
2568 
2587 void vp1394TwoGrabber::acquire(vpImage<vpRGBa> &I, uint64_t &timestamp, uint32_t &id)
2588 {
2589  dc1394video_frame_t *frame;
2590 
2591  open();
2592  frame = dequeue();
2593  // Timeval data structure providing the unix time
2594  // [microseconds] at which the frame was captured in the ring buffer.
2595  timestamp = frame->timestamp;
2596  id = frame->id;
2597 
2598  this->width = frame->size[0];
2599  this->height = frame->size[1];
2600  unsigned int size = this->width * this->height;
2601 
2602  if ((I.getWidth() != width) || (I.getHeight() != height))
2603  I.resize(height, width);
2604 
2605  switch (frame->color_coding) {
2606  case DC1394_COLOR_CODING_MONO8:
2607  case DC1394_COLOR_CODING_RAW8:
2608  vpImageConvert::GreyToRGBa((unsigned char *)frame->image, (unsigned char *)I.bitmap, size);
2609  break;
2610 
2611  case DC1394_COLOR_CODING_YUV411:
2612  vpImageConvert::YUV411ToRGBa((unsigned char *)frame->image, (unsigned char *)I.bitmap, size);
2613  break;
2614 
2615  case DC1394_COLOR_CODING_YUV422:
2616  vpImageConvert::YUV422ToRGBa((unsigned char *)frame->image, (unsigned char *)I.bitmap, size);
2617  break;
2618 
2619  case DC1394_COLOR_CODING_YUV444:
2620  vpImageConvert::YUV444ToRGBa((unsigned char *)frame->image, (unsigned char *)I.bitmap, size);
2621  break;
2622 
2623  case DC1394_COLOR_CODING_RGB8:
2624  vpImageConvert::RGBToRGBa((unsigned char *)frame->image, (unsigned char *)I.bitmap, size);
2625  break;
2626 
2627  default:
2628  close();
2629  vpERROR_TRACE("Format conversion not implemented. Acquisition failed.");
2630  throw(vpFrameGrabberException(vpFrameGrabberException::otherError, "Format conversion not implemented. "
2631  "Acquisition failed."));
2632  };
2633 
2634  enqueue(frame);
2635 }
2636 
2653 void vp1394TwoGrabber::getWidth(unsigned int &w)
2654 {
2655  if (!num_cameras) {
2656  close();
2657  vpERROR_TRACE("No camera found");
2659  }
2660 
2661  w = this->width;
2662 }
2663 
2682 {
2683  if (!num_cameras) {
2684  close();
2685  vpERROR_TRACE("No camera found");
2687  }
2688 
2689  return this->width;
2690 }
2691 
2709 void vp1394TwoGrabber::getHeight(unsigned int &h)
2710 {
2711  if (!num_cameras) {
2712  close();
2713  vpERROR_TRACE("No camera found");
2715  }
2716 
2717  h = this->height;
2718 }
2737 {
2738  if (!num_cameras) {
2739  close();
2740  vpERROR_TRACE("No camera found");
2742  }
2743 
2744  return this->height;
2745 }
2746 
2753 {
2754  std::cout << "----------------------------------------------------------" << std::endl
2755  << "----- Information for camera " << camera_id << " -----" << std::endl
2756  << "----------------------------------------------------------" << std::endl;
2757 
2758 #ifdef VISP_HAVE_DC1394_CAMERA_ENUMERATE // new API > libdc1394-2.0.0-rc7
2759  dc1394_camera_print_info(camera, stdout);
2760 #elif defined VISP_HAVE_DC1394_FIND_CAMERAS // old API <= libdc1394-2.0.0-rc7
2761  dc1394_print_camera_info(camera);
2762 #endif
2763 
2764  dc1394featureset_t features;
2765 #ifdef VISP_HAVE_DC1394_CAMERA_ENUMERATE // new API > libdc1394-2.0.0-rc7
2766  if (dc1394_feature_get_all(camera, &features) != DC1394_SUCCESS)
2767 #elif defined VISP_HAVE_DC1394_FIND_CAMERAS // old API <= libdc1394-2.0.0-rc7
2768  if (dc1394_get_camera_feature_set(camera, &features) != DC1394_SUCCESS)
2769 #endif
2770  {
2771  close();
2772  vpERROR_TRACE("unable to get feature set for camera %d\n", camera_id);
2773  throw(vpFrameGrabberException(vpFrameGrabberException::initializationError, "Cannot get camera features"));
2774 
2775  } else {
2776 #ifdef VISP_HAVE_DC1394_CAMERA_ENUMERATE // new API > libdc1394-2.0.0-rc7
2777  dc1394_feature_print_all(&features, stdout);
2778 #elif defined VISP_HAVE_DC1394_FIND_CAMERAS // old API <= libdc1394-2.0.0-rc7
2779  dc1394_print_feature_set(&features);
2780 #endif
2781  }
2782  std::cout << "----------------------------------------------------------" << std::endl;
2783 }
2784 
2798 {
2799  std::string _str = "";
2800  dc1394video_mode_t _videomode = (dc1394video_mode_t)videomode;
2801 
2802  if ((_videomode >= DC1394_VIDEO_MODE_MIN) && (_videomode <= DC1394_VIDEO_MODE_MAX)) {
2803  _str = strVideoMode[_videomode - DC1394_VIDEO_MODE_MIN];
2804  } else {
2805  vpCERROR << "The video mode " << (int)videomode << " is not supported by the camera" << std::endl;
2806  }
2807 
2808  return _str;
2809 }
2810 
2824 {
2825  std::string _str = "";
2826  dc1394framerate_t _fps = (dc1394framerate_t)fps;
2827 
2828  if ((_fps >= DC1394_FRAMERATE_MIN) && (_fps <= DC1394_FRAMERATE_MAX)) {
2829  _str = strFramerate[_fps - DC1394_FRAMERATE_MIN];
2830  } else {
2831  vpCERROR << "The framerate " << (int)fps << " is not supported by the camera" << std::endl;
2832  }
2833 
2834  return _str;
2835 }
2836 
2850 {
2851  std::string _str = "";
2852  dc1394color_coding_t _coding = (dc1394color_coding_t)colorcoding;
2853 
2854  if ((_coding >= DC1394_COLOR_CODING_MIN) && (_coding <= DC1394_COLOR_CODING_MAX)) {
2855  _str = strColorCoding[_coding - DC1394_COLOR_CODING_MIN];
2856 
2857  } else {
2858  vpCERROR << "The color coding " << (int)colorcoding << " is not supported by the camera" << std::endl;
2859  }
2860 
2861  return _str;
2862 }
2863 
2882 {
2884 
2885  for (int i = DC1394_VIDEO_MODE_MIN; i <= DC1394_VIDEO_MODE_MAX; i++) {
2886  _id = (vp1394TwoVideoModeType)i;
2887  if (videomode.compare(videoMode2string(_id)) == 0)
2888  return _id;
2889  };
2890 
2891  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "The required videomode is not valid"));
2892 
2893  return (vp1394TwoVideoModeType)0;
2894 }
2895 
2914 {
2916 
2917  for (int i = DC1394_FRAMERATE_MIN; i <= DC1394_FRAMERATE_MAX; i++) {
2918  _id = (vp1394TwoFramerateType)i;
2919  if (framerate.compare(framerate2string(_id)) == 0)
2920  return _id;
2921  };
2922 
2923  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "The required framerate is not valid"));
2924 
2925  return (vp1394TwoFramerateType)0;
2926 }
2927 
2946 {
2948 
2949  for (int i = DC1394_COLOR_CODING_MIN; i <= DC1394_COLOR_CODING_MAX; i++) {
2950  _id = (vp1394TwoColorCodingType)i;
2951  if (colorcoding.compare(colorCoding2string(_id)) == 0)
2952  return _id;
2953  };
2954 
2955  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "The required color coding is not valid"));
2956 
2957  return (vp1394TwoColorCodingType)0;
2958 }
2959 
2993 {
2994  for (unsigned int i = 0; i < num_cameras; i++) {
2995  if (camIsOpen[i]) {
2996  camera = cameras[i];
2997  setTransmission(DC1394_OFF);
2998  setCapture(DC1394_OFF);
2999  }
3000  }
3001 #ifdef VISP_HAVE_DC1394_CAMERA_ENUMERATE // new API > libdc1394-2.0.0-rc7
3002  setCamera(camera_id);
3003  // free the other cameras
3004  for (unsigned int i = 0; i < num_cameras; i++) {
3005  if (i != camera_id)
3006  dc1394_camera_free(cameras[i]);
3007  }
3008 
3009  printf("Reseting bus...\n");
3010  dc1394_reset_bus(camera);
3011 
3012  dc1394_camera_free(camera);
3013  dc1394_free(d);
3014  d = NULL;
3015  // if (cameras != NULL)
3016  delete[] cameras;
3017  cameras = NULL;
3018 #elif defined VISP_HAVE_DC1394_FIND_CAMERAS // old API <= libdc1394-2.0.0-rc7
3019 
3020  setCamera(camera_id);
3021  // free the other cameras
3022  for (unsigned int i = 0; i < num_cameras; i++) {
3023  if (i != camera_id)
3024  dc1394_free_camera(cameras[i]);
3025  }
3026  free(cameras);
3027  cameras = NULL;
3028 
3029  dc1394_reset_bus(camera);
3030  dc1394_free_camera(camera);
3031 
3032 #endif
3033  if (camIsOpen != NULL)
3034  delete[] camIsOpen;
3035  camIsOpen = NULL;
3036 
3037  num_cameras = 0;
3038 
3039  init = false;
3040  vpTime::wait(1000);
3041  initialize(false);
3042 }
3043 
3074 void vp1394TwoGrabber::setPanControl(unsigned int panControlValue)
3075 {
3076  open();
3077  if (!num_cameras) {
3078  close();
3079  vpERROR_TRACE("No camera found");
3081  }
3082  uint64_t offset = 0x884;
3083  uint32_t value = 0x82000000 + (uint32_t)panControlValue;
3084  dc1394error_t err;
3085  err = dc1394_set_control_register(camera, offset, value);
3086  if (err != DC1394_SUCCESS) {
3087  vpERROR_TRACE("Unable to set PAN register");
3088  close();
3089  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Unable to set PAN register"));
3090  }
3091 }
3092 
3110 {
3111  if (!num_cameras) {
3112  close();
3113  vpERROR_TRACE("No camera found");
3115  }
3116 
3117  uint32_t value;
3118  dc1394feature_t feature = DC1394_FEATURE_BRIGHTNESS; // = (dc1394feature_t)param;
3119  switch (param) {
3120  case vpFEATURE_BRIGHTNESS:
3121  feature = DC1394_FEATURE_BRIGHTNESS;
3122  break;
3123  case vpFEATURE_EXPOSURE:
3124  feature = DC1394_FEATURE_EXPOSURE;
3125  break;
3126  case vpFEATURE_SHARPNESS:
3127  feature = DC1394_FEATURE_SHARPNESS;
3128  break;
3129  // vpFEATURE_WHITE_BALANCE = DC1394_FEATURE_WHITE_BALANCE,
3130  case vpFEATURE_HUE:
3131  feature = DC1394_FEATURE_HUE;
3132  break;
3133  case vpFEATURE_SATURATION:
3134  feature = DC1394_FEATURE_SATURATION;
3135  break;
3136  case vpFEATURE_GAMMA:
3137  feature = DC1394_FEATURE_GAMMA;
3138  break;
3139  case vpFEATURE_SHUTTER:
3140  feature = DC1394_FEATURE_SHUTTER;
3141  break;
3142  case vpFEATURE_GAIN:
3143  feature = DC1394_FEATURE_GAIN;
3144  break;
3145  case vpFEATURE_IRIS:
3146  feature = DC1394_FEATURE_IRIS;
3147  break;
3148  // vpFEATURE_FOCUS = DC1394_FEATURE_FOCUS,
3149  // vpFEATURE_TEMPERATURE = DC1394_FEATURE_TEMPERATURE,
3150  // vpFEATURE_TRIGGER = DC1394_FEATURE_TRIGGER,
3151  // vpFEATURE_TRIGGER_DELAY = DC1394_FEATURE_TRIGGER_DELAY,
3152  // vpFEATURE_WHITE_SHADING = DC1394_FEATURE_WHITE_SHADING,
3153  // vpFEATURE_FRAME_RATE = DC1394_FEATURE_FRAME_RATE,
3154  // vpFEATURE_ZOOM = DC1394_FEATURE_ZOOM,
3155  // vpFEATURE_PAN = DC1394_FEATURE_PAN,
3156  // vpFEATURE_TILT = DC1394_FEATURE_TILT,
3157  // vpFEATURE_OPTICAL_FILTER = DC1394_FEATURE_OPTICAL_FILTER,
3158  // vpFEATURE_CAPTURE_SIZE = DC1394_FEATURE_CAPTURE_SIZE,
3159  // vpFEATURE_CAPTURE_QUALITY = DC1394_FEATURE_CAPTURE_QUALITY
3160  }
3161 
3162  dc1394error_t err;
3163  err = dc1394_feature_get_value(camera, feature, &value);
3164  if (err != DC1394_SUCCESS) {
3165  vpERROR_TRACE("Unable to get the information");
3166  close();
3167  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Unable to get the information"));
3168  }
3169  return (unsigned int)value;
3170 }
3171 
3194 {
3195  if (!num_cameras) {
3196  close();
3197  vpERROR_TRACE("No camera found");
3199  }
3200  uint32_t value = (uint32_t)val;
3201  dc1394feature_t feature = DC1394_FEATURE_BRIGHTNESS; // = (dc1394feature_t)param;
3202  switch (param) {
3203  case vpFEATURE_BRIGHTNESS:
3204  feature = DC1394_FEATURE_BRIGHTNESS;
3205  break;
3206  case vpFEATURE_EXPOSURE:
3207  feature = DC1394_FEATURE_EXPOSURE;
3208  break;
3209  case vpFEATURE_SHARPNESS:
3210  feature = DC1394_FEATURE_SHARPNESS;
3211  break;
3212  // vpFEATURE_WHITE_BALANCE = DC1394_FEATURE_WHITE_BALANCE,
3213  case vpFEATURE_HUE:
3214  feature = DC1394_FEATURE_HUE;
3215  break;
3216  case vpFEATURE_SATURATION:
3217  feature = DC1394_FEATURE_SATURATION;
3218  break;
3219  case vpFEATURE_GAMMA:
3220  feature = DC1394_FEATURE_GAMMA;
3221  break;
3222  case vpFEATURE_SHUTTER:
3223  feature = DC1394_FEATURE_SHUTTER;
3224  break;
3225  case vpFEATURE_GAIN:
3226  feature = DC1394_FEATURE_GAIN;
3227  break;
3228  case vpFEATURE_IRIS:
3229  feature = DC1394_FEATURE_IRIS;
3230  break;
3231  // vpFEATURE_FOCUS = DC1394_FEATURE_FOCUS,
3232  // vpFEATURE_TEMPERATURE = DC1394_FEATURE_TEMPERATURE,
3233  // vpFEATURE_TRIGGER = DC1394_FEATURE_TRIGGER,
3234  // vpFEATURE_TRIGGER_DELAY = DC1394_FEATURE_TRIGGER_DELAY,
3235  // vpFEATURE_WHITE_SHADING = DC1394_FEATURE_WHITE_SHADING,
3236  // vpFEATURE_FRAME_RATE = DC1394_FEATURE_FRAME_RATE,
3237  // vpFEATURE_ZOOM = DC1394_FEATURE_ZOOM,
3238  // vpFEATURE_PAN = DC1394_FEATURE_PAN,
3239  // vpFEATURE_TILT = DC1394_FEATURE_TILT,
3240  // vpFEATURE_OPTICAL_FILTER = DC1394_FEATURE_OPTICAL_FILTER,
3241  // vpFEATURE_CAPTURE_SIZE = DC1394_FEATURE_CAPTURE_SIZE,
3242  // vpFEATURE_CAPTURE_QUALITY = DC1394_FEATURE_CAPTURE_QUALITY
3243  }
3244 
3245  dc1394error_t err;
3246  dc1394bool_t hasManualMode = DC1394_FALSE;
3247  dc1394feature_modes_t modesAvailable;
3248 
3249  // test wether we can set the shutter value (manual mode available or not)
3250  err = dc1394_feature_get_modes(camera, feature, &modesAvailable);
3251  if (err != DC1394_SUCCESS) {
3252  vpERROR_TRACE("Unable to detect the manual mode information");
3253  close();
3254  throw(
3255  vpFrameGrabberException(vpFrameGrabberException::settingError, "Unable to detect the manual mode information"));
3256  }
3257 
3258  for (unsigned int i = 0; i < modesAvailable.num; i++) {
3259  if (modesAvailable.modes[i] == DC1394_FEATURE_MODE_MANUAL) {
3260  hasManualMode = DC1394_TRUE;
3261  }
3262  }
3263 
3264  if (hasManualMode == DC1394_TRUE) {
3265 
3266  if (!isDataModified[camera_id]) { // to ensure we save the first mode
3267  // even after several set
3268  /* we update the structure */
3269  updateDataCamToStruct();
3270  err = dc1394_feature_get_mode(camera, feature, &(initialShutterMode[camera_id]));
3271  if (err != DC1394_SUCCESS) {
3272  vpERROR_TRACE("Unable to get the initial mode");
3273  close();
3274  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Unable to get the initial mode"));
3275  }
3276  isDataModified[camera_id] = true;
3277  }
3278 
3279  dc1394feature_mode_t manualMode = DC1394_FEATURE_MODE_MANUAL;
3280  err = dc1394_feature_set_mode(camera, feature, manualMode);
3281  if (err != DC1394_SUCCESS) {
3282  vpERROR_TRACE("Unable to set the muanual mode");
3283  close();
3284  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Unable to set the manual mode"));
3285  }
3286  err = dc1394_feature_set_value(camera, feature, value);
3287  if (err != DC1394_SUCCESS) {
3288  vpERROR_TRACE("Unable to set the shutter information");
3289  close();
3290  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Unable to set the shutter information"));
3291  }
3292  } else {
3293  vpERROR_TRACE("The camera does not have a manual mode.\nCannot change the value");
3294  throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "The camera does not have a manual mode"));
3295  }
3296 }
3304 void vp1394TwoGrabber::getGuid(uint64_t &guid)
3305 {
3306  if (!num_cameras) {
3307  close();
3308  vpERROR_TRACE("No camera found");
3310  }
3311 
3312  guid = camera->guid;
3313 }
3314 
3323 {
3324  if (!num_cameras) {
3325  close();
3326  vpERROR_TRACE("No camera found");
3328  }
3329 
3330  return camera->guid;
3331 }
3332 
3337 inline void vp1394TwoGrabber::updateDataCamToStruct()
3338 {
3339  dataCam[camera_id].brightness = getParameterValue(vpFEATURE_BRIGHTNESS);
3340  dataCam[camera_id].exposure = getParameterValue(vpFEATURE_EXPOSURE);
3341  dataCam[camera_id].sharpness = getParameterValue(vpFEATURE_SHARPNESS);
3342  dataCam[camera_id].hue = getParameterValue(vpFEATURE_HUE);
3343  dataCam[camera_id].saturation = getParameterValue(vpFEATURE_SATURATION);
3344  dataCam[camera_id].gamma = getParameterValue(vpFEATURE_GAMMA);
3345  dataCam[camera_id].shutter = getParameterValue(vpFEATURE_SHUTTER);
3346  dataCam[camera_id].gain = getParameterValue(vpFEATURE_GAIN);
3347  dataCam[camera_id].iris = getParameterValue(vpFEATURE_IRIS);
3348 }
3349 
3354 inline void vp1394TwoGrabber::updateDataStructToCam()
3355 {
3356  setParameterValue(vpFEATURE_BRIGHTNESS, dataCam[camera_id].brightness);
3357  setParameterValue(vpFEATURE_EXPOSURE, dataCam[camera_id].exposure);
3358  setParameterValue(vpFEATURE_SHARPNESS, dataCam[camera_id].sharpness);
3359  setParameterValue(vpFEATURE_HUE, dataCam[camera_id].hue);
3360  setParameterValue(vpFEATURE_SATURATION, dataCam[camera_id].saturation);
3361  setParameterValue(vpFEATURE_GAMMA, dataCam[camera_id].gamma);
3362  setParameterValue(vpFEATURE_SHUTTER, dataCam[camera_id].shutter);
3363  setParameterValue(vpFEATURE_GAIN, dataCam[camera_id].gain);
3364  setParameterValue(vpFEATURE_IRIS, dataCam[camera_id].iris);
3365 }
3366 
3384 {
3385  this->acquire(I);
3386  return *this;
3387 }
3388 
3406 {
3407  this->acquire(I);
3408  return *this;
3409 }
3410 
3411 #elif !defined(VISP_BUILD_SHARED_LIBS)
3412 // Work arround to avoid warning: libvisp_sensor.a(vp1394TwoGrabber.cpp.o) has
3413 // no symbols
3414 void dummy_vp1394TwoGrabber(){};
3415 #endif
void getColorCoding(vp1394TwoColorCodingType &coding)
static const char * strFramerate[DC1394_FRAMERATE_NUM]
VISP_EXPORT int wait(double t0, double t)
Definition: vpTime.cpp:150
uint32_t getColorCodingSupported(vp1394TwoVideoModeType videomode, std::list< vp1394TwoColorCodingType > &codings)
static std::string colorCoding2string(vp1394TwoColorCodingType colorcoding)
static void RGBToGrey(unsigned char *rgb, unsigned char *grey, unsigned int size)
void setAutoGain(bool enable=true)
void setIsoTransmissionSpeed(vp1394TwoIsoSpeedType isospeed)
static std::string framerate2string(vp1394TwoFramerateType fps)
void getAutoGain(unsigned int &minvalue, unsigned int &maxvalue)
unsigned int getWidth() const
Definition: vpImage.h:244
#define vpCERROR
Definition: vpDebug.h:365
static void RGBToRGBa(unsigned char *rgb, unsigned char *rgba, unsigned int size)
Type * bitmap
points toward the bitmap
Definition: vpImage.h:141
static void MONO16ToGrey(unsigned char *grey16, unsigned char *grey, unsigned int size)
#define vpERROR_TRACE
Definition: vpDebug.h:393
vp1394TwoGrabber(bool reset=true)
bool isVideoModeFormat7(vp1394TwoVideoModeType videomode)
static const char * strColorCoding[DC1394_COLOR_CODING_NUM]
static void GreyToRGBa(unsigned char *grey, unsigned char *rgba, unsigned int size)
static void YUV422ToRGBa(unsigned char *yuv, unsigned char *rgba, unsigned int size)
vp1394TwoGrabber & operator>>(vpImage< unsigned char > &I)
unsigned int getParameterValue(vp1394TwoParametersType param)
void acquire(vpImage< unsigned char > &I)
static vp1394TwoColorCodingType string2colorCoding(std::string colorcoding)
Error that can be emited by the vpFrameGrabber class and its derivates.
uint32_t getVideoModeSupported(std::list< vp1394TwoVideoModeType > &videomodes)
static void YUV444ToRGBa(unsigned char *yuv, unsigned char *rgba, unsigned int size)
bool isFramerateSupported(vp1394TwoVideoModeType videomode, vp1394TwoFramerateType fps)
void setColorCoding(vp1394TwoColorCodingType coding)
void open(vpImage< unsigned char > &I)
static void YUV422ToGrey(unsigned char *yuv, unsigned char *grey, unsigned int size)
void setRingBufferSize(unsigned int size)
static vp1394TwoVideoModeType string2videoMode(std::string videomode)
void setFormat7ROI(unsigned int left=0, unsigned int top=0, unsigned int width=0, unsigned int height=0)
#define vpTRACE
Definition: vpDebug.h:416
unsigned int height
Number of rows in the image.
void setCamera(uint64_t camera)
static const char * strVideoMode[DC1394_VIDEO_MODE_NUM]
static void MONO16ToRGBa(unsigned char *grey16, unsigned char *rgba, unsigned int size)
void resize(const unsigned int h, const unsigned int w)
resize the image : Image initialization
Definition: vpImage.h:879
void enqueue(dc1394video_frame_t *frame)
static vp1394TwoFramerateType string2framerate(std::string fps)
unsigned int getWidth()
void getFramerate(vp1394TwoFramerateType &fps)
static std::string videoMode2string(vp1394TwoVideoModeType videomode)
bool init
Set to true if the frame grabber has been initialized.
void setParameterValue(vp1394TwoParametersType param, unsigned int val)
static void YUV444ToGrey(unsigned char *yuv, unsigned char *grey, unsigned int size)
#define vpCTRACE
Definition: vpDebug.h:338
bool isColorCodingSupported(vp1394TwoVideoModeType videomode, vp1394TwoColorCodingType coding)
static void YUV411ToRGBa(unsigned char *yuv, unsigned char *rgba, unsigned int size)
unsigned int getRingBufferSize() const
void setFramerate(vp1394TwoFramerateType fps)
dc1394video_frame_t * dequeue()
void getAutoShutter(unsigned int &minvalue, unsigned int &maxvalue)
void setVideoMode(vp1394TwoVideoModeType videomode)
void setPanControl(unsigned int panControlValue)
uint32_t getFramerateSupported(vp1394TwoVideoModeType videomode, std::list< vp1394TwoFramerateType > &fps)
unsigned int getHeight() const
Definition: vpImage.h:186
bool isVideoModeSupported(vp1394TwoVideoModeType videomode)
Class for firewire ieee1394 video devices using libdc1394-2.x api.
static void YUV411ToGrey(unsigned char *yuv, unsigned char *grey, unsigned int size)
unsigned int getNumCameras() const
void getVideoMode(vp1394TwoVideoModeType &videomode)
unsigned int width
Number of columns in the image.
unsigned int getHeight()
void setAutoShutter(bool enable=true)