ViSP  2.8.0
vp1394TwoGrabber.cpp
1 /****************************************************************************
2  *
3  * $Id: vp1394TwoGrabber.cpp 4323 2013-07-18 09:24:01Z fspindle $
4  *
5  * This file is part of the ViSP software.
6  * Copyright (C) 2005 - 2013 by INRIA. All rights reserved.
7  *
8  * This software is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU General Public License
10  * ("GPL") version 2 as published by the Free Software Foundation.
11  * See the file LICENSE.txt at the root directory of this source
12  * distribution for additional information about the GNU GPL.
13  *
14  * For using ViSP with software that can not be combined with the GNU
15  * GPL, please contact INRIA about acquiring a ViSP Professional
16  * Edition License.
17  *
18  * See http://www.irisa.fr/lagadic/visp/visp.html for more information.
19  *
20  * This software was developed at:
21  * INRIA Rennes - Bretagne Atlantique
22  * Campus Universitaire de Beaulieu
23  * 35042 Rennes Cedex
24  * France
25  * http://www.irisa.fr/lagadic
26  *
27  * If you have questions regarding the use of this file, please contact
28  * INRIA at visp@inria.fr
29  *
30  * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
31  * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
32  *
33  *
34  * Description:
35  * Firewire cameras video capture.
36  *
37  * Authors:
38  * Fabien Spindler
39  *
40  *****************************************************************************/
41 
42 
48 #include <iostream>
49 
50 #include <visp/vpConfig.h>
51 
52 /*
53  * Interface with libdc1394 2.x
54  */
55 #if defined(VISP_HAVE_DC1394_2)
56 #include <unistd.h>
57 
58 #include <visp/vp1394TwoGrabber.h>
59 #include <visp/vpFrameGrabberException.h>
60 #include <visp/vpImageIo.h>
61 #include <visp/vpImageConvert.h>
62 #include <visp/vpTime.h>
63 
64 const char * vp1394TwoGrabber::strVideoMode[DC1394_VIDEO_MODE_NUM]= {
65  "MODE_160x120_YUV444",
66  "MODE_320x240_YUV422",
67  "MODE_640x480_YUV411",
68  "MODE_640x480_YUV422",
69  "MODE_640x480_RGB8",
70  "MODE_640x480_MONO8",
71  "MODE_640x480_MONO16",
72  "MODE_800x600_YUV422",
73  "MODE_800x600_RGB8",
74  "MODE_800x600_MONO8",
75  "MODE_1024x768_YUV422",
76  "MODE_1024x768_RGB8",
77  "MODE_1024x768_MONO8",
78  "MODE_800x600_MONO16",
79  "MODE_1024x768_MONO16",
80  "MODE_1280x960_YUV422",
81  "MODE_1280x960_RGB8",
82  "MODE_1280x960_MONO8",
83  "MODE_1600x1200_YUV422",
84  "MODE_1600x1200_RGB8",
85  "MODE_1600x1200_MONO8",
86  "MODE_1280x960_MONO16",
87  "MODE_1600x1200_MONO16",
88  "MODE_EXIF",
89  "MODE_FORMAT7_0",
90  "MODE_FORMAT7_1",
91  "MODE_FORMAT7_2",
92  "MODE_FORMAT7_3",
93  "MODE_FORMAT7_4",
94  "MODE_FORMAT7_5",
95  "MODE_FORMAT7_6",
96  "MODE_FORMAT7_7"
97 };
98 
99 const char * vp1394TwoGrabber::strFramerate[DC1394_FRAMERATE_NUM]= {
100  "FRAMERATE_1_875",
101  "FRAMERATE_3_75",
102  "FRAMERATE_7_5",
103  "FRAMERATE_15",
104  "FRAMERATE_30",
105  "FRAMERATE_60",
106  "FRAMERATE_120",
107  "FRAMERATE_240"
108 };
109 
110 const char * vp1394TwoGrabber::strColorCoding[DC1394_COLOR_CODING_NUM]= {
111  "COLOR_CODING_MONO8",
112  "COLOR_CODING_YUV411",
113  "COLOR_CODING_YUV422",
114  "COLOR_CODING_YUV444",
115  "COLOR_CODING_RGB8",
116  "COLOR_CODING_MONO16",
117  "COLOR_CODING_RGB16",
118  "COLOR_CODING_MONO16S",
119  "COLOR_CODING_RGB16S",
120  "COLOR_CODING_RAW8",
121  "COLOR_CODING_RAW16",
122 };
123 
124 
125 
171 {
172  // protected members
173  width = height = 0;
174 
175  // private members
176  num_cameras = 0;
177  cameras = NULL;
178  camera_id = 0;
179  verbose = false;//true;
180  camIsOpen = NULL;
181  init = false;
182  cameras = NULL;
183 #ifdef VISP_HAVE_DC1394_2_CAMERA_ENUMERATE // new API > libdc1394-2.0.0-rc7
184  d = NULL;
185  list = NULL;
186 #endif
187  num_buffers = 4; // ring buffer size
188 
189  isDataModified = NULL;
190  initialShutterMode = NULL;
191  dataCam = NULL;
192 
193  reset = false;
194  initialize(reset);
195 
196  // open();
197 }
198 
209 {
210 /* if(num_cameras >= 1){
211  delete[] isDataModified;
212  delete[] initialShutterMode;
213  delete[] dataCam;
214  }*/
215  close();
216 }
217 
339 void
340 vp1394TwoGrabber::setCamera(uint64_t camera_id)
341 {
342  // Suppose that if camera_id is a camera GUID, this value is greater
343  // than the number of cameras connected to the bus
344  if (camera_id >= num_cameras) {
345  // Check if camera_id is a camera guid
346  bool is_guid = false;
347  // check if the camera_id is a guid
348  for (unsigned int i=0; i< num_cameras; i++) {
349  if (cameras[i]->guid == camera_id) {
350  this->camera_id = i;
351  is_guid = true;
352  break;
353  }
354  }
355  if (is_guid == false) {
356  close();
357  vpERROR_TRACE("The camera with GUID 0x%x or id %u is not present",
358  camera_id, camera_id);
359  vpERROR_TRACE("Only %u camera on the bus.", num_cameras);
361  "The required camera is not present") );
362  }
363  }
364  else {
365  this->camera_id = camera_id;
366  }
367 
368  // create a pointer to the working camera
369  camera = cameras[this->camera_id];
370 }
371 
372 
387 void
388 vp1394TwoGrabber::getCamera(uint64_t &camera_id)
389 {
390  if (num_cameras) {
391  camera_id = this->camera_id;
392  }
393  else {
394  close();
395  vpERROR_TRACE("No cameras found");
397  "No cameras found") );
398  }
399 }
400 
415 uint64_t
417 {
418  if (num_cameras) {
419  return this->camera_id;
420  }
421  else {
422  close();
423  vpERROR_TRACE("No cameras found");
425  "No cameras found") );
426  }
427 }
428 
436 void
437 vp1394TwoGrabber::getNumCameras(unsigned int &ncameras)
438 {
439  if (! num_cameras) {
440  vpCTRACE << "No camera found..."<< std::endl;
441  ncameras = 0;
442  }
443 
444  ncameras = num_cameras;
445 }
446 
454 unsigned int
456 {
457  unsigned int ncameras = 0;
458  if (! num_cameras) {
459  vpCTRACE << "No camera found..."<< std::endl;
460  ncameras = 0;
461  }
462 
463  ncameras = num_cameras;
464  return ncameras;
465 }
466 
512 void
514 {
515  open();
516  if (! num_cameras) {
517  close();
518  vpERROR_TRACE("No camera found");
520  "No camera found") );
521  }
522  if (!isVideoModeSupported(videomode)){
523  vpERROR_TRACE("Video mode not supported by camera %d",camera_id);
525  "Video mode not supported") );
526  return ;
527  }
528  // Stop dma capture if started
529  setTransmission(DC1394_OFF);
530  setCapture(DC1394_OFF);
531 
532  if (dc1394_video_set_mode(camera, (dc1394video_mode_t) videomode) != DC1394_SUCCESS) {
533 
534  close();
535  vpERROR_TRACE("Can't set video mode");
537  "Can't set video mode") );
538  }
539 
540  setCapture(DC1394_ON);
541  setTransmission(DC1394_ON);
542 
543  // Updates image size from new video mode
544  if (dc1394_get_image_size_from_video_mode(camera,
545  (dc1394video_mode_t) videomode,
546  &this->width, &this->height)
547  != DC1394_SUCCESS) {
548 
549  close();
550  vpERROR_TRACE("Can't set video mode");
552  "Can't get image size") );
553  }
554 
555 }
556 
573 void
575 {
576  if (! num_cameras) {
577  close();
578  vpERROR_TRACE("No camera found");
580  "No camera found") );
581  }
582 
583  dc1394video_mode_t _videomode;
584  if (dc1394_video_get_mode(camera, &_videomode) != DC1394_SUCCESS) {
585 
586  close();
587  vpERROR_TRACE("Can't get current video mode");
589  "Can't get current video mode") );
590  }
591  videomode = (vp1394TwoVideoModeType) _videomode;
592 
593 }
594 
595 
596 
614 uint32_t
615 vp1394TwoGrabber::getVideoModeSupported(std::list<vp1394TwoVideoModeType> & videomodes)
616 {
617  // Refresh the list of supported modes
618  videomodes.clear();
619 
620  if (! num_cameras) {
621  close();
622  vpERROR_TRACE("No camera found");
624  "No camera found") );
625  }
626  dc1394video_modes_t _videomodes;
627 
628  // get video modes:
629  if (dc1394_video_get_supported_modes(camera, &_videomodes)!=DC1394_SUCCESS) {
630 
631  close();
632  vpERROR_TRACE("Can't get video modes");
634  "Can't get video modes") );
635  }
636 
637  // parse the video modes to add in the list
638  for (unsigned i=0; i < _videomodes.num; i++) {
639  vp1394TwoVideoModeType _mode = (vp1394TwoVideoModeType) _videomodes.modes[i];
640  videomodes.push_back( _mode );
641  }
642 
643  // return the number of available video modes
644  return _videomodes.num;
645 }
661 bool
663 {
664  if (! num_cameras) {
665  close();
666  vpERROR_TRACE("No camera found");
668  "No camera found") );
669  }
670  dc1394video_modes_t _videomodes;
671 
672  // get video modes:
673  if (dc1394_video_get_supported_modes(camera, &_videomodes)!=DC1394_SUCCESS) {
674 
675  close();
676  vpERROR_TRACE("Can't get video modes");
678  "Can't get video modes") );
679  }
680 
681  // parse the video modes to check with the desired
682  for (unsigned i=0; i < _videomodes.num; i++) {
683  if ((vp1394TwoVideoModeType) _videomodes.modes[i] == videomode)
684  return true;
685  }
686  return false;
687 }
688 
701 bool
703 {
704 
705  if (dc1394_is_video_mode_scalable((dc1394video_mode_t) videomode))
706  return true;
707 
708  return false;
709 }
710 
726 bool
728 {
730  getColorCoding(coding);
731 
732  switch (coding) {
736  case vpCOLOR_CODING_RAW8:
738  return false;
742  case vpCOLOR_CODING_RGB8:
745  return true;
746  }
747  return false;
748 }
749 
774 void
776 {
777  open();
778  if (! num_cameras) {
779  close();
780  vpERROR_TRACE("No camera found");
782  "No camera found") );
783  }
784 
785  vp1394TwoVideoModeType cur_videomode;
786  getVideoMode(cur_videomode);
787  if (isVideoModeFormat7(cur_videomode))
788  return;
789 
790  if (!isFramerateSupported(cur_videomode,fps)){
791  vpERROR_TRACE("Framerate not supported by camera %d",camera_id);
793  "Framerate not supported") );
794  return ;
795  }
796 
797  // Stop dma capture if started
798  setTransmission(DC1394_OFF);
799  setCapture(DC1394_OFF);
800 
801  if (dc1394_video_set_framerate(camera, (dc1394framerate_t) fps) != DC1394_SUCCESS) {
802 
803  close();
804  vpERROR_TRACE("Can't set framerate");
806  "Can't set framerate") );
807  }
808 
809  setCapture(DC1394_ON);
810  setTransmission(DC1394_ON);
811 }
812 
829 void
831 {
832  if (! num_cameras) {
833  close();
834  vpERROR_TRACE("No camera found");
836  "No camera found") );
837  }
838  dc1394framerate_t _fps;
839  if (dc1394_video_get_framerate(camera, &_fps) != DC1394_SUCCESS) {
840 
841  close();
842  vpERROR_TRACE("Can't get current framerate");
844  "Can't get current framerate") );
845  }
846  fps = (vp1394TwoFramerateType) _fps;
847 
848 }
849 
881 uint32_t
883  std::list<vp1394TwoFramerateType> & fps)
884 {
885  if (! num_cameras) {
886  close();
887  vpERROR_TRACE("No camera found");
889  "No camera found") );
890  }
891 
892  // Refresh the list of supported framerates
893  fps.clear();
894 
895  switch (mode) {
896  // Framerate not available for:
897  // - vpVIDEO_MODE_EXIF ie Format_6
898  // - vpVIDEO_MODE_FORMAT7... ie the Format_7
899  case vpVIDEO_MODE_EXIF:
908  return 0;
909  break;
910  default:
911  {
912  dc1394framerates_t _fps;
913  if (dc1394_video_get_supported_framerates(camera,
914  (dc1394video_mode_t)mode,
915  &_fps) != DC1394_SUCCESS) {
916  close();
917  vpERROR_TRACE("Could not query supported frametates for mode %d\n",
918  mode);
920  "Could not query supported framerates") );
921  }
922  if (_fps.num == 0)
923  return 0;
924 
925  for (unsigned int i = 0; i < _fps.num; i ++)
926  fps.push_back((vp1394TwoFramerateType)_fps.framerates[i]);
927 
928  return _fps.num;
929  }
930  break;
931  }
932 }
966 bool
969 {
970  if (! num_cameras) {
971  close();
972  vpERROR_TRACE("No camera found");
974  "No camera found") );
975  }
976 
977  switch (mode) {
978  // Framerate not available for:
979  // - vpVIDEO_MODE_EXIF ie Format_6
980  // - vpVIDEO_MODE_FORMAT7... ie the Format_7
981  case vpVIDEO_MODE_EXIF:
990  return 0;
991  break;
992  default:
993  {
994  dc1394framerates_t _fps;
995  if (dc1394_video_get_supported_framerates(camera,
996  (dc1394video_mode_t)mode,
997  &_fps) != DC1394_SUCCESS) {
998  close();
999  vpERROR_TRACE("Could not query supported frametates for mode %d\n",
1000  mode);
1002  "Could not query supported framerates") );
1003  }
1004  if (_fps.num == 0)
1005  return 0;
1006 
1007  for (unsigned int i = 0; i < _fps.num; i ++){
1008  if (fps==(vp1394TwoFramerateType)_fps.framerates[i]){
1009  return true;
1010  }
1011  }
1012  return false;
1013  }
1014  break;
1015  }
1016 }
1017 
1066 void
1068 {
1069  if (! num_cameras) {
1070  close();
1071  vpERROR_TRACE("No camera found");
1073  "No camera found") );
1074  }
1075 
1076  dc1394video_mode_t _videomode;
1077  if (dc1394_video_get_mode(camera, &_videomode) != DC1394_SUCCESS) {
1078 
1079  close();
1080  vpERROR_TRACE("Can't get current video mode");
1082  "Can't get current video mode") );
1083  }
1084 
1085  if (!isColorCodingSupported((vp1394TwoVideoModeType)_videomode,coding)){
1086  vpERROR_TRACE("Color coding not supported by camera %d",camera_id);
1088  "Color coding not supported") );
1089  return ;
1090  }
1091 
1092  // Format 7 video mode
1093  if (dc1394_is_video_mode_scalable(_videomode)) {
1094  setTransmission(DC1394_OFF);
1095  setCapture(DC1394_OFF);
1096 
1097  if (dc1394_format7_set_color_coding(camera, _videomode,
1098  (dc1394color_coding_t) coding)
1099  != DC1394_SUCCESS) {
1100 
1101  close();
1102  vpERROR_TRACE("Can't set color coding");
1104  "Can't set color coding") );
1105  }
1106 
1107  setCapture(DC1394_ON);
1108  setTransmission(DC1394_ON);
1109  }
1110 }
1111 
1129 void
1131 {
1132  if (! num_cameras) {
1133  close();
1134  vpERROR_TRACE("No camera found");
1136  "No camera found") );
1137  }
1138  dc1394video_mode_t _videomode;
1139  if (dc1394_video_get_mode(camera, &_videomode) != DC1394_SUCCESS) {
1140 
1141  close();
1142  vpERROR_TRACE("Can't get current video mode");
1144  "Can't get current video mode") );
1145  }
1146 
1147  dc1394color_coding_t _coding;
1148  if (dc1394_is_video_mode_scalable(_videomode)) {
1149  // Format 7 video mode
1150  if (dc1394_format7_get_color_coding(camera, _videomode, &_coding)
1151  != DC1394_SUCCESS) {
1152 
1153  close();
1154  vpERROR_TRACE("Can't get current color coding");
1156  "Can't query current color coding") );
1157  }
1158  }
1159  else if (dc1394_is_video_mode_still_image((dc1394video_mode_t)_videomode)) {
1161  "No color coding for format 6 video mode"));
1162  }
1163  else {
1164  // Not Format 7 and not Format 6 video modes
1165  if (dc1394_get_color_coding_from_video_mode(camera,
1166  (dc1394video_mode_t)_videomode,
1167  &_coding) != DC1394_SUCCESS) {
1168  close();
1169  vpERROR_TRACE("Could not query supported color coding for mode %d\n",
1170  _videomode);
1172  "Can't query current color coding"));
1173  }
1174  }
1175  coding = (vp1394TwoColorCodingType) _coding;
1176 }
1177 
1199 uint32_t
1201  std::list<vp1394TwoColorCodingType> & codings)
1202 {
1203  if (! num_cameras) {
1204  close();
1205  vpERROR_TRACE("No camera found");
1207  "No camera found") );
1208  }
1209 
1210  // Refresh the list of supported framerates
1211  codings.clear();
1212 
1213  if (dc1394_is_video_mode_scalable((dc1394video_mode_t)mode)) {
1214  // Format 7 video mode
1215  dc1394color_codings_t _codings;
1216  if (dc1394_format7_get_color_codings(camera,
1217  (dc1394video_mode_t)mode,
1218  &_codings) != DC1394_SUCCESS) {
1219  close();
1220  vpERROR_TRACE("Could not query supported color codings for mode %d\n",
1221  mode);
1223  "Could not query supported color codings") );
1224  }
1225  if (_codings.num == 0)
1226  return 0;
1227 
1228  for (unsigned int i = 0; i < _codings.num; i ++)
1229  codings.push_back((vp1394TwoColorCodingType)_codings.codings[i]);
1230 
1231  return _codings.num;
1232  }
1233  else if (dc1394_is_video_mode_still_image((dc1394video_mode_t)mode)) {
1234  // Format 6 video mode
1235  return 0;
1236  }
1237  else {
1238  // Not Format 7 and not Format 6 video modes
1239  dc1394color_coding_t _coding;
1240  if (dc1394_get_color_coding_from_video_mode(camera,
1241  (dc1394video_mode_t)mode,
1242  &_coding) != DC1394_SUCCESS) {
1243  close();
1244  vpERROR_TRACE("Could not query supported color coding for mode %d\n",
1245  mode);
1247  "Could not query supported color coding") );
1248  }
1249  codings.push_back((vp1394TwoColorCodingType)_coding);
1250  return 1;
1251  }
1252 }
1274 bool
1276  vp1394TwoColorCodingType coding)
1277 {
1278  if (! num_cameras) {
1279  close();
1280  vpERROR_TRACE("No camera found");
1282  "No camera found") );
1283  }
1284 
1285 
1286  if (dc1394_is_video_mode_scalable((dc1394video_mode_t)mode)) {
1287  // Format 7 video mode
1288  dc1394color_codings_t _codings;
1289  if (dc1394_format7_get_color_codings(camera,
1290  (dc1394video_mode_t)mode,
1291  &_codings) != DC1394_SUCCESS) {
1292  close();
1293  vpERROR_TRACE("Could not query supported color codings for mode %d\n",
1294  mode);
1296  "Could not query supported color codings") );
1297  }
1298  if (_codings.num == 0)
1299  return 0;
1300 
1301  for (unsigned int i = 0; i < _codings.num; i ++){
1302  if (coding==(vp1394TwoColorCodingType)_codings.codings[i])
1303  return true;
1304  }
1305  return false;
1306  }
1307  else if (dc1394_is_video_mode_still_image((dc1394video_mode_t)mode)) {
1308  // Format 6 video mode
1309  return false;
1310  }
1311  else {
1312  // Not Format 7 and not Format 6 video modes
1313  dc1394color_coding_t _coding;
1314  if (dc1394_get_color_coding_from_video_mode(camera,
1315  (dc1394video_mode_t)mode,
1316  &_coding) != DC1394_SUCCESS) {
1317  close();
1318  vpERROR_TRACE("Could not query supported color coding for mode %d\n",
1319  mode);
1321  "Could not query supported color coding") );
1322  return false;
1323  }
1324  if (coding==(vp1394TwoColorCodingType)_coding)
1325  return true;
1326 
1327  return false;
1328  }
1329 }
1330 
1331 
1363 void
1364 vp1394TwoGrabber::setFormat7ROI(unsigned int left, unsigned int top,
1365  unsigned int width, unsigned int height)
1366 {
1367  open();
1368  if (! num_cameras) {
1369  close();
1370  vpERROR_TRACE("No camera found");
1372  "No camera found") );
1373  }
1374 
1375  dc1394video_mode_t _videomode;
1376  if (dc1394_video_get_mode(camera, &_videomode) != DC1394_SUCCESS) {
1377 
1378  close();
1379  vpERROR_TRACE("Can't get current video mode");
1381  "Can't get current video mode") );
1382  }
1383  if (dc1394_is_video_mode_scalable(_videomode)) {
1384  // Stop dma capture if started
1385  setTransmission(DC1394_OFF);
1386  setCapture(DC1394_OFF);
1387  // Format 7 video mode
1388  unsigned int max_width, max_height;
1389  if (dc1394_format7_get_max_image_size(camera, _videomode,
1390  &max_width, &max_height)
1391  != DC1394_SUCCESS) {
1392 
1393  close();
1394  vpERROR_TRACE("Can't get format7 max image size");
1396  "Can't get format7 max image size") );
1397  }
1398 #if 0
1399  vpTRACE("left: %d top: %d width: %d height: %d", left, top,
1400  width == 0 ? DC1394_USE_MAX_AVAIL: width,
1401  height == 0 ? DC1394_USE_MAX_AVAIL : height);
1402  vpTRACE("max_width: %d max_height: %d", max_width, max_height);
1403 #endif
1404 
1405  if (left > max_width) {
1406  vpERROR_TRACE("Can't set format7 ROI");
1408  "Can't set format7 ROI") );
1409  }
1410  if (top > max_height) {
1411  vpERROR_TRACE("Can't set format7 ROI");
1413  "Can't set format7 ROI") );
1414  }
1415 
1416  int32_t roi_width;
1417  int32_t roi_height;
1418 
1419  if (width != 0) {
1420  // Check if roi width is acceptable (ie roi is contained in the image)
1421  if (width > (max_width - left))
1422  width = (max_width - left);
1423  roi_width = (int32_t)width;
1424  }
1425  else {
1426  roi_width = DC1394_USE_MAX_AVAIL;
1427  }
1428 
1429  if (height != 0) {
1430  // Check if roi height is acceptable (ie roi is contained in the image)
1431  if (height > (max_height - top))
1432  height = (max_height - top);
1433  roi_height = (int32_t)height;
1434  }
1435  else {
1436  roi_height = DC1394_USE_MAX_AVAIL;
1437  }
1438 
1439 
1440  if (dc1394_format7_set_roi(camera, _videomode,
1441  (dc1394color_coding_t) DC1394_QUERY_FROM_CAMERA, // color_coding
1442  DC1394_USE_MAX_AVAIL/*DC1394_QUERY_FROM_CAMERA*/, // bytes_per_packet
1443  (int32_t)left, // left
1444  (int32_t)top, // top
1445  roi_width,
1446  roi_height)
1447  != DC1394_SUCCESS) {
1448  close();
1449  vpERROR_TRACE("Can't set format7 roi");
1451  "Can't get current video mode") );
1452  }
1453  // Update the image size
1454  if (dc1394_format7_get_image_size(camera, _videomode,
1455  &this->width,
1456  &this->height)
1457  != DC1394_SUCCESS) {
1458  close();
1459  vpERROR_TRACE("Can't get format7 image size");
1461  "Can't get format7 image size") );
1462  }
1463 
1464  setCapture(DC1394_ON);
1465  setTransmission(DC1394_ON);
1466  }
1467 }
1482 void
1483 vp1394TwoGrabber::initialize(bool reset)
1484 {
1485  if (init == false){
1486  // Find cameras
1487 #ifdef VISP_HAVE_DC1394_2_CAMERA_ENUMERATE // new API > libdc1394-2.0.0-rc7
1488  if (d != NULL)
1489  dc1394_free (d);
1490 
1491  d = dc1394_new ();
1492  if (dc1394_camera_enumerate (d, &list) != DC1394_SUCCESS) {
1493  dc1394_camera_free_list (list);
1494  close();
1495  vpERROR_TRACE("Failed to enumerate cameras\n");
1497  "Failed to enumerate cameras") );
1498  }
1499 
1500  if (list->num == 0) {
1501  dc1394_camera_free_list (list);
1502  close();
1503  vpERROR_TRACE("No cameras found");
1505  "No cameras found") );
1506  }
1507 
1508  if (cameras != NULL)
1509  delete [] cameras;
1510 
1511  cameras = new dc1394camera_t * [list->num];
1512 
1513  num_cameras = 0;
1514 
1515  for (unsigned int i=0; i < list->num; i ++) {
1516  cameras[i] = dc1394_camera_new (d, list->ids[i].guid);
1517  if (!cameras[i]) {
1518  vpTRACE ("Failed to initialize camera with guid \"%ld\"\n",
1519  list->ids[i].guid);
1520  continue;
1521  }
1522  // Update the number of working cameras
1523  num_cameras ++;
1524  }
1525 
1526  if (reset) {
1527  // Reset the bus to make firewire working if the program was not properly
1528  // stopped by a CTRL-C. We reset here only the bus attached to the first
1529  // camera
1530  dc1394_reset_bus(cameras[0]);
1531  }
1532 
1533  if (list != NULL)
1534  dc1394_camera_free_list (list);
1535  list = NULL;
1536 
1537 #elif defined VISP_HAVE_DC1394_2_FIND_CAMERAS // old API <= libdc1394-2.0.0-rc7
1538  if (cameras != NULL)
1539  free(cameras);
1540  cameras = NULL;
1541  int err = dc1394_find_cameras(&cameras, &num_cameras);
1542 
1543  if (err!=DC1394_SUCCESS && err != DC1394_NO_CAMERA) {
1544  close();
1545  vpERROR_TRACE("Unable to look for cameras\n\n"
1546  "Please check \n"
1547  " - if the kernel modules `ieee1394',`raw1394' and `ohci1394' are loaded \n"
1548  " - if you have read/write access to /dev/raw1394\n\n");
1550  "Unable to look for cameras") );
1551 
1552  }
1553 #endif
1554 
1555  if (num_cameras == 0) {
1556  close();
1557  vpERROR_TRACE("No cameras found");
1559  "No cameras found") );
1560  }
1561 
1562  // allocation for the parameters
1563  isDataModified = new bool[num_cameras];
1564  for(unsigned int i=0; i<num_cameras; i++)
1565  isDataModified[i] = false;
1566  initialShutterMode = new dc1394feature_mode_t[num_cameras];
1567  dataCam = new vpDc1394TwoCameraParametersData[num_cameras];
1568 
1569  if (camera_id >= num_cameras) {
1570  // Bad camera id
1571  close();
1572  vpERROR_TRACE("Bad camera id: %u", camera_id);
1573  vpERROR_TRACE("Only %u camera on the bus.", num_cameras);
1575  "Bad camera id") );
1576  }
1577 
1578  if (verbose) {
1579  std::cout << "------ Bus information ------" << std::endl;
1580  std::cout << "Number of camera(s) on the bus : " << num_cameras <<std::endl;
1581  std::cout << "-----------------------------" << std::endl;
1582  }
1583 
1584  if (camIsOpen != NULL) delete [] camIsOpen;
1585  camIsOpen = new bool [num_cameras];
1586  for (unsigned int i = 0;i<num_cameras;i++){
1587  camIsOpen[i]=false;
1588  }
1589 
1590  init = true;
1591  }
1592 }
1602 void
1604 {
1605  if (init == false) initialize(false);
1606  if (camIsOpen[camera_id] == false){
1607  dc1394switch_t status = DC1394_OFF;
1608 
1609  //#ifdef VISP_HAVE_DC1394_2_CAMERA_ENUMERATE // new API > libdc1394-2.0.0-rc7
1610  dc1394_video_get_transmission(cameras[camera_id], &status);
1611  if (status != DC1394_OFF){
1612  //#endif
1613  if (dc1394_video_set_transmission(cameras[camera_id],DC1394_OFF)!=DC1394_SUCCESS)
1614  vpTRACE("Could not stop ISO transmission");
1615  else {
1616  vpTime::wait(500);
1617  if (dc1394_video_get_transmission(cameras[camera_id], &status)!=DC1394_SUCCESS)
1618  vpTRACE("Could get ISO status");
1619  else {
1620  if (status==DC1394_ON) {
1621  vpTRACE("ISO transmission refuses to stop");
1622  }
1623 #ifdef VISP_HAVE_DC1394_2_FIND_CAMERAS // old API <= libdc1394-2.0.0-rc7
1624  // No yet in the new API
1625  cameras[camera_id]->is_iso_on=status;
1626 #endif
1627  }
1628  //#ifdef VISP_HAVE_DC1394_2_CAMERA_ENUMERATE // new API > libdc1394-2.0.0-rc7
1629  }
1630  //#endif
1631  }
1632  setCamera(camera_id);
1633  //setIsoSpeed(DC1394_ISO_SPEED_400);
1634  setCapture(DC1394_ON);
1635  setTransmission(DC1394_ON);
1636  camIsOpen[camera_id] = true;
1637  }
1638 }
1647 void
1649 {
1650  if (init){
1651  if (num_cameras) {
1652  for (unsigned int i = 0; i < num_cameras;i++) {
1653  if (camIsOpen[i]) {
1654  camera = cameras[i];
1655  this->camera_id = i;// set camera id for the function updateDataStructToCam
1656  setTransmission(DC1394_OFF);
1657  setCapture(DC1394_OFF);
1658  if(isDataModified[i]){
1659  // reset values
1660  try{
1661  updateDataStructToCam();
1662  }
1663  catch(...){
1664  }
1665  // reset mode (manual, auto, ...)
1666  if (dc1394_feature_set_mode(camera, DC1394_FEATURE_BRIGHTNESS, initialShutterMode[i]) != DC1394_SUCCESS ||
1667  dc1394_feature_set_mode(camera, DC1394_FEATURE_EXPOSURE, initialShutterMode[i]) != DC1394_SUCCESS ||
1668  dc1394_feature_set_mode(camera, DC1394_FEATURE_SHARPNESS, initialShutterMode[i]) != DC1394_SUCCESS ||
1669  dc1394_feature_set_mode(camera, DC1394_FEATURE_HUE, initialShutterMode[i]) != DC1394_SUCCESS ||
1670  dc1394_feature_set_mode(camera, DC1394_FEATURE_SATURATION, initialShutterMode[i]) != DC1394_SUCCESS ||
1671  dc1394_feature_set_mode(camera, DC1394_FEATURE_GAMMA, initialShutterMode[i]) != DC1394_SUCCESS ||
1672  dc1394_feature_set_mode(camera, DC1394_FEATURE_SHUTTER, initialShutterMode[i]) != DC1394_SUCCESS ||
1673  dc1394_feature_set_mode(camera, DC1394_FEATURE_GAIN, initialShutterMode[i]) != DC1394_SUCCESS ||
1674  dc1394_feature_set_mode(camera, DC1394_FEATURE_IRIS, initialShutterMode[i])){
1675 
1676  vpERROR_TRACE("Unable to reset the initial mode");
1678  "Unable to reset the initial mode"));
1679  }
1680  }
1681  if (dc1394_camera_set_power(camera, DC1394_OFF) != DC1394_SUCCESS)
1682  std::cout << "Unable to turn camera off" << std::endl;
1683  }
1684 #ifdef VISP_HAVE_DC1394_2_CAMERA_ENUMERATE // new API > libdc1394-2.0.0-rc7
1685  dc1394_camera_free(cameras[i]);
1686 #elif defined VISP_HAVE_DC1394_2_FIND_CAMERAS // old API <= libdc1394-2.0.0-rc7
1687  dc1394_free_camera(cameras[i]);
1688 #endif
1689  }
1690  }
1691  if (camIsOpen != NULL) {
1692  delete [] camIsOpen;
1693  camIsOpen = NULL;
1694  }
1695 
1696 #ifdef VISP_HAVE_DC1394_2_CAMERA_ENUMERATE // new API > libdc1394-2.0.0-rc7
1697  if (cameras != NULL) {
1698  delete [] cameras;
1699  cameras = NULL;
1700  }
1701  if (d != NULL) {
1702  dc1394_free (d);
1703  d = NULL;
1704  }
1705 
1706 #elif defined VISP_HAVE_DC1394_2_FIND_CAMERAS // old API <= libdc1394-2.0.0-rc7
1707  if (cameras != NULL) {
1708  free(cameras);
1709  cameras = NULL;
1710  }
1711 #endif
1712 
1713  camIsOpen = NULL;
1714  num_cameras = 0;
1715 
1716  // remove data for the parameters
1717  if(isDataModified != NULL){
1718  delete[] isDataModified;
1719  isDataModified = NULL;
1720  }
1721  if(initialShutterMode != NULL){
1722  delete[] initialShutterMode;
1723  initialShutterMode = NULL;
1724  }
1725  if(dataCam != NULL){
1726  delete[] dataCam;
1727  dataCam = NULL;
1728  }
1729 
1730  init = false;
1731  }
1732 }
1733 
1745 void
1747 {
1748  if (size < 1) {
1749  close();
1751  "Could not set ring buffer size") );
1752  }
1753 
1754  if (size != num_buffers) {
1755  // We need to change the ring buffer size
1756  num_buffers = size;
1757  if(camIsOpen[camera_id]){
1758  setCapture(DC1394_OFF);
1759  setCapture(DC1394_ON);
1760  }
1761  }
1762 }
1763 
1773 unsigned int
1775 {
1776  return num_buffers;
1777 }
1778 
1815 void
1817 {
1818  if (! num_cameras) {
1819  close();
1820  vpERROR_TRACE("No camera found");
1822  "No camera found") );
1823  }
1824 
1825  if (dc1394_feature_set_power(camera, DC1394_FEATURE_SHUTTER, DC1394_ON)
1826  != DC1394_SUCCESS) {
1827  // vpERROR_TRACE("Cannot set shutter on. \n");
1828  close();
1830  "Cannot set shutter on") );
1831  }
1832 
1833  if (dc1394_feature_set_mode(camera,
1834  DC1394_FEATURE_SHUTTER,
1835  DC1394_FEATURE_MODE_AUTO)
1836  != DC1394_SUCCESS) {
1837  // vpERROR_TRACE("Cannot set auto shutter. \n");
1838  close();
1840  "Cannot set auto shutter") );
1841  }
1842 }
1883 void
1884 vp1394TwoGrabber::setAutoShutter(unsigned int minvalue, unsigned int maxvalue)
1885 {
1886  setAutoShutter();
1887 
1888  if (dc1394_avt_set_auto_shutter(camera, minvalue, maxvalue)
1889  != DC1394_SUCCESS) {
1890  // vpERROR_TRACE("Cannot set auto shutter min and max values. Is the camera an AVT one?\n");
1891  close();
1893  "Cannot set auto shutter min and max values") );
1894  }
1895 }
1896 
1909 void
1910 vp1394TwoGrabber::getAutoShutter(unsigned int &minvalue, unsigned int &maxvalue)
1911 {
1912  if (! num_cameras) {
1913  close();
1914  vpERROR_TRACE("No camera found");
1916  "No camera found") );
1917  }
1918 
1919  if (dc1394_avt_get_auto_shutter(camera, &minvalue, &maxvalue)
1920  != DC1394_SUCCESS) {
1921  // vpERROR_TRACE("Cannot get auto shutter min and max values. Is the camera an AVT one?\n");
1922  close();
1924  "Cannot get auto shutter min and max values") );
1925  }
1926 }
1927 
1964 void
1966 {
1967  if (! num_cameras) {
1968  close();
1969  vpERROR_TRACE("No camera found");
1971  "No camera found") );
1972  }
1973 
1974  if (dc1394_feature_set_power(camera, DC1394_FEATURE_SHUTTER, DC1394_ON)
1975  != DC1394_SUCCESS) {
1976  // vpERROR_TRACE("Cannot set shutter on. \n");
1977  close();
1979  "Cannot set shutter on") );
1980  }
1981 
1982  if (dc1394_feature_set_mode(camera,
1983  DC1394_FEATURE_GAIN,
1984  DC1394_FEATURE_MODE_AUTO)
1985  != DC1394_SUCCESS) {
1986  // vpERROR_TRACE("Cannot set auto gain. \n");
1987  close();
1989  "Cannot set auto gain") );
1990  }
1991 }
2032 void
2033 vp1394TwoGrabber::setAutoGain(unsigned int minvalue, unsigned int maxvalue)
2034 {
2035  setAutoGain();
2036 
2037  if (dc1394_avt_set_auto_gain(camera, minvalue, maxvalue)
2038  != DC1394_SUCCESS) {
2039  // vpERROR_TRACE("Cannot set auto gain min and max values. Is the camera an AVT one?\n");
2040  close();
2042  "Cannot set auto gain min and max values") );
2043  }
2044 }
2045 
2058 void
2059 vp1394TwoGrabber::getAutoGain(unsigned int &minvalue, unsigned int &maxvalue)
2060 {
2061  if (! num_cameras) {
2062  close();
2063  vpERROR_TRACE("No camera found");
2065  "No camera found") );
2066  }
2067 
2068  if (dc1394_avt_get_auto_gain(camera, &minvalue, &maxvalue)
2069  != DC1394_SUCCESS) {
2070  // vpERROR_TRACE("Cannot get auto gain min and max values. Is the camera an AVT one?\n");
2071  close();
2073  "Cannot get auto gain min and max values") );
2074  }
2075 }
2076 
2077 
2095 void
2096 vp1394TwoGrabber::setCapture(dc1394switch_t _switch)
2097 {
2098  if (! num_cameras) {
2099  close();
2100  vpERROR_TRACE("No camera found");
2102  "No camera found") );
2103  }
2104 
2105  if (_switch == DC1394_ON) {
2106  //if (dc1394_capture_setup(camera, num_buffers) != DC1394_SUCCESS) {
2107  // To be compatible with libdc1394 svn 382 version
2108  if (dc1394_capture_setup(camera, num_buffers,
2109  DC1394_CAPTURE_FLAGS_DEFAULT) != DC1394_SUCCESS) {
2110  vpERROR_TRACE("Unable to setup camera capture-\n"
2111  "make sure that the video mode and framerate are "
2112  "supported by your camera.\n");
2113  close();
2115  "Could not setup dma capture") );
2116  }
2117  }
2118  else { // _switch == DC1394_OFF
2119  dc1394error_t code = dc1394_capture_stop(camera);
2120 
2121  if (code != DC1394_SUCCESS && code != DC1394_CAPTURE_IS_NOT_SET) {
2122  vpERROR_TRACE("Unable to stop camera capture\n");
2123  close();
2125  "Could not setup dma capture") );
2126  }
2127  }
2128 }
2129 
2130 
2145 void
2146 vp1394TwoGrabber::setTransmission(dc1394switch_t _switch)
2147 {
2148  if (! num_cameras) {
2149  close();
2150  vpERROR_TRACE("No camera found");
2152  "No camera found") );
2153  }
2154 
2155  dc1394switch_t status = DC1394_OFF;
2156 
2157  if (dc1394_video_get_transmission(camera, &status)!=DC1394_SUCCESS) {
2158  vpERROR_TRACE("Unable to get transmision status");
2159  close();
2161  "Could not setup dma capture") );
2162  }
2163 
2164  // if (status!=_switch){
2165  // Start dma capture if halted
2166  if (dc1394_video_set_transmission(camera, _switch) != DC1394_SUCCESS) {
2167  vpERROR_TRACE("Unable to setup camera capture-\n"
2168  "make sure that the video mode and framerate are "
2169  "supported by your camera.\n");
2170  close();
2172  "Could not setup dma capture") );
2173  }
2174 
2175  if (_switch == DC1394_ON) {
2176  status = DC1394_OFF;
2177 
2178  int i = 0;
2179  while ( status == DC1394_OFF && i++ < 5 ) {
2180  usleep(50000);
2181  if (dc1394_video_get_transmission(camera, &status)!=DC1394_SUCCESS) {
2182  vpERROR_TRACE("Unable to get transmision status");
2183  close();
2185  "Could not setup dma capture") );
2186  }
2187  }
2188  }
2189  // }
2190 }
2191 
2226 void
2228 {
2229  if (! num_cameras) {
2230  close();
2231  vpERROR_TRACE("No camera found");
2233  "No camera found") );
2234  }
2235 
2236  dc1394operation_mode_t op_mode;
2237  dc1394speed_t speed;
2238 
2239  // Check the speed to configure in B-mode or A-mode
2240  if (isospeed >= vpISO_SPEED_800) {
2241  if (camera->bmode_capable != DC1394_TRUE) {
2242 // vpERROR_TRACE("Camera is not 1394B mode capable. \n"
2243 // "Set the iso speed lower or equal to 400Mbps");
2244  close();
2246  "Camera is not 1394B mode capable") );
2247  }
2248 
2249  if(dc1394_video_set_operation_mode(camera,
2250  DC1394_OPERATION_MODE_1394B)
2251  != DC1394_SUCCESS) {
2252 // vpERROR_TRACE("Cannot set camera to 1394B mode. \n");
2253  close();
2255  "Cannot set camera to 1394B mode") );
2256  }
2257 
2258  if (dc1394_video_get_operation_mode(camera, &op_mode) != DC1394_SUCCESS) {
2259 // vpERROR_TRACE("Failed to set 1394B mode. \n");
2260  close();
2262  "Failed to set 1394B mode") );
2263  }
2264  }
2265  else {
2266  if (dc1394_video_set_operation_mode(camera,
2267  DC1394_OPERATION_MODE_LEGACY)
2268  != DC1394_SUCCESS) {
2269 // vpERROR_TRACE("Cannot set camera to 1394A mode. \n");
2270  close();
2272  "Cannot set camera to 1394A mode") );
2273  }
2274 
2275  if (dc1394_video_get_operation_mode(camera, &op_mode) != DC1394_SUCCESS) {
2276 // vpERROR_TRACE("Failed to set 1394A mode. \n");
2277  close();
2279  "Failed to set 1394A mode") );
2280  }
2281  }
2282 
2283  if (dc1394_video_set_iso_speed(camera, (dc1394speed_t) isospeed)
2284  != DC1394_SUCCESS) {
2285 // vpERROR_TRACE("Cannot set requested iso speed. \n");
2286  close();
2288  "Cannot set requested iso speed") );
2289  }
2290 
2291  if (dc1394_video_get_iso_speed(camera, &speed) != DC1394_SUCCESS) {
2292 // vpERROR_TRACE("Failed to set iso speed. \n");
2293  close();
2295  "Failed to set iso speed") );
2296  }
2297 }
2298 
2309 void
2311 {
2312  open();
2313  acquire(I);
2314 }
2315 
2326 void
2328 {
2329  open();
2330  acquire(I);
2331 }
2332 
2333 
2372 dc1394video_frame_t *
2374 {
2375 
2376  if (! num_cameras) {
2377  close();
2378  vpERROR_TRACE("No camera found");
2380  "No camera found") );
2381  }
2382 
2383  dc1394video_frame_t *frame = NULL;
2384 
2385  if (dc1394_capture_dequeue(camera, DC1394_CAPTURE_POLICY_WAIT, &frame)
2386  !=DC1394_SUCCESS) {
2387  vpERROR_TRACE ("Error: Failed to capture from camera %d\n", camera_id);
2388  }
2389 
2390  return frame;
2391 }
2392 
2434 dc1394video_frame_t *
2436 {
2437  uint64_t timestamp;
2438  uint32_t id;
2439 
2440  dc1394video_frame_t *frame;
2441 
2442  frame = dequeue(I, timestamp, id);
2443 
2444  return frame;
2445 }
2446 
2495 dc1394video_frame_t *
2497  uint64_t &timestamp,
2498  uint32_t &id)
2499 {
2500 
2501  open();
2502 
2503  dc1394video_frame_t *frame;
2504 
2505  frame = dequeue();
2506 
2507  // Timeval data structure providing the unix time
2508  // [microseconds] at which the frame was captured in the ring buffer.
2509  timestamp = frame->timestamp;
2510  id = frame->id;
2511 
2512  this->width = frame->size[0];
2513  this->height = frame->size[1];
2514  unsigned int size = this->width * this->height;
2515 
2516  if ((I.getWidth() != this->width)||(I.getHeight() != this->height))
2517  I.resize(this->height, this->width);
2518 
2519  switch(frame->color_coding) {
2520  case DC1394_COLOR_CODING_MONO8:
2521  case DC1394_COLOR_CODING_RAW8:
2522  memcpy(I.bitmap, (unsigned char *) frame->image,
2523  size*sizeof(unsigned char));
2524  break;
2525  case DC1394_COLOR_CODING_MONO16:
2526  case DC1394_COLOR_CODING_RAW16:
2527  vpImageConvert::MONO16ToGrey( (unsigned char *) frame->image,
2528  I.bitmap, size);
2529  break;
2530 
2531  case DC1394_COLOR_CODING_YUV411:
2532  vpImageConvert::YUV411ToGrey( (unsigned char *) frame->image,
2533  I.bitmap, size);
2534  break;
2535 
2536  case DC1394_COLOR_CODING_YUV422:
2537  vpImageConvert::YUV422ToGrey( (unsigned char *) frame->image,
2538  I.bitmap, size);
2539  break;
2540 
2541  case DC1394_COLOR_CODING_YUV444:
2542  vpImageConvert::YUV444ToGrey( (unsigned char *) frame->image,
2543  I.bitmap, size);
2544  break;
2545 
2546  case DC1394_COLOR_CODING_RGB8:
2547  vpImageConvert::RGBToGrey((unsigned char *) frame->image, I.bitmap, size);
2548  break;
2549 
2550 
2551  default:
2552  close();
2553  vpERROR_TRACE("Format conversion not implemented. Acquisition failed.");
2555  "Format conversion not implemented. "
2556  "Acquisition failed.") );
2557  break;
2558  };
2559 
2560  return frame;
2561 }
2562 
2603 dc1394video_frame_t *
2605 {
2606  uint64_t timestamp;
2607  uint32_t id;
2608 
2609  dc1394video_frame_t *frame;
2610 
2611  frame = dequeue(I, timestamp, id);
2612 
2613  return frame;
2614 }
2615 
2664 dc1394video_frame_t *
2666  uint64_t &timestamp,
2667  uint32_t &id)
2668 {
2669 
2670  open();
2671 
2672  dc1394video_frame_t *frame;
2673 
2674  frame = dequeue();
2675 
2676  // Timeval data structure providing the unix time
2677  // [microseconds] at which the frame was captured in the ring buffer.
2678  timestamp = frame->timestamp;
2679  id = frame->id;
2680 
2681  this->width = frame->size[0];
2682  this->height = frame->size[1];
2683  unsigned int size = this->width * this->height;
2684 
2685  if ((I.getWidth() != width)||(I.getHeight() != height))
2686  I.resize(height, width);
2687 
2688  switch (frame->color_coding) {
2689  case DC1394_COLOR_CODING_MONO8:
2690  case DC1394_COLOR_CODING_RAW8:
2691  vpImageConvert::GreyToRGBa((unsigned char *) frame->image,
2692  (unsigned char *) I.bitmap, size);
2693  break;
2694 
2695  case DC1394_COLOR_CODING_MONO16:
2696  case DC1394_COLOR_CODING_RAW16:
2697  vpImageConvert::MONO16ToRGBa((unsigned char *) frame->image,
2698  (unsigned char *) I.bitmap, size);
2699  break;
2700 
2701  case DC1394_COLOR_CODING_YUV411:
2702  vpImageConvert::YUV411ToRGBa( (unsigned char *) frame->image,
2703  (unsigned char *) I.bitmap, size);
2704  break;
2705 
2706  case DC1394_COLOR_CODING_YUV422:
2707  vpImageConvert::YUV422ToRGBa( (unsigned char *) frame->image,
2708  (unsigned char *) I.bitmap, size);
2709  break;
2710 
2711  case DC1394_COLOR_CODING_YUV444:
2712  vpImageConvert::YUV444ToRGBa( (unsigned char *) frame->image,
2713  (unsigned char *) I.bitmap, size);
2714  break;
2715 
2716  case DC1394_COLOR_CODING_RGB8:
2717  vpImageConvert::RGBToRGBa((unsigned char *) frame->image,
2718  (unsigned char *) I.bitmap, size);
2719  break;
2720 
2721 
2722  default:
2723  close();
2724  vpERROR_TRACE("Format conversion not implemented. Acquisition failed.");
2726  "Format conversion not implemented. "
2727  "Acquisition failed.") );
2728  break;
2729  };
2730 
2731  return frame;
2732 }
2733 
2744 void
2745 vp1394TwoGrabber::enqueue(dc1394video_frame_t *frame)
2746 {
2747 
2748  if (! num_cameras) {
2749  close();
2750  vpERROR_TRACE("No camera found");
2752  "No camera found") );
2753  }
2754 
2755  if (frame)
2756  dc1394_capture_enqueue(camera, frame);
2757 }
2758 
2759 
2773 void
2775 {
2776  uint64_t timestamp;
2777  uint32_t id;
2778 
2779  dc1394video_frame_t *frame;
2780 
2781  frame = dequeue(I, timestamp, id);
2782  enqueue(frame);
2783 }
2784 
2803 void
2805  uint64_t &timestamp,
2806  uint32_t &id)
2807 {
2808  dc1394video_frame_t *frame;
2809 
2810  open();
2811  frame = dequeue(I, timestamp, id);
2812  enqueue(frame);
2813 }
2814 
2815 
2816 
2830 void
2832 {
2833  uint64_t timestamp;
2834  uint32_t id;
2835  dc1394video_frame_t *frame;
2836 
2837  open();
2838  frame = dequeue(I, timestamp, id);
2839  enqueue(frame);
2840 }
2841 
2860 void
2862  uint64_t &timestamp,
2863  uint32_t &id)
2864 {
2865  dc1394video_frame_t *frame;
2866 
2867  open();
2868  frame = dequeue();
2869  // Timeval data structure providing the unix time
2870  // [microseconds] at which the frame was captured in the ring buffer.
2871  timestamp = frame->timestamp;
2872  id = frame->id;
2873 
2874  this->width = frame->size[0];
2875  this->height = frame->size[1];
2876  unsigned int size = this->width * this->height;
2877 
2878  if ((I.getWidth() != width)||(I.getHeight() != height))
2879  I.resize(height, width);
2880 
2881  switch (frame->color_coding) {
2882  case DC1394_COLOR_CODING_MONO8:
2883  case DC1394_COLOR_CODING_RAW8:
2884  vpImageConvert::GreyToRGBa((unsigned char *) frame->image,
2885  (unsigned char *) I.bitmap, size);
2886  break;
2887 
2888  case DC1394_COLOR_CODING_YUV411:
2889  vpImageConvert::YUV411ToRGBa( (unsigned char *) frame->image,
2890  (unsigned char *) I.bitmap, size);
2891  break;
2892 
2893  case DC1394_COLOR_CODING_YUV422:
2894  vpImageConvert::YUV422ToRGBa( (unsigned char *) frame->image,
2895  (unsigned char *) I.bitmap, size);
2896  break;
2897 
2898  case DC1394_COLOR_CODING_YUV444:
2899  vpImageConvert::YUV444ToRGBa( (unsigned char *) frame->image,
2900  (unsigned char *) I.bitmap, size);
2901  break;
2902 
2903  case DC1394_COLOR_CODING_RGB8:
2904  vpImageConvert::RGBToRGBa((unsigned char *) frame->image,
2905  (unsigned char *) I.bitmap, size);
2906  break;
2907 
2908 
2909  default:
2910  close();
2911  vpERROR_TRACE("Format conversion not implemented. Acquisition failed.");
2913  "Format conversion not implemented. "
2914  "Acquisition failed.") );
2915  break;
2916  };
2917 
2918  enqueue(frame);
2919 
2920 }
2921 
2938 void vp1394TwoGrabber::getWidth(unsigned int &width)
2939 {
2940  if (! num_cameras) {
2941  close();
2942  vpERROR_TRACE("No camera found");
2944  "No camera found") );
2945  }
2946 
2947  width = this->width;
2948 }
2949 
2967 {
2968  if (! num_cameras) {
2969  close();
2970  vpERROR_TRACE("No camera found");
2972  "No camera found") );
2973  }
2974 
2975  return this->width;
2976 }
2977 
2995 void vp1394TwoGrabber::getHeight(unsigned int &height)
2996 {
2997  if (! num_cameras) {
2998  close();
2999  vpERROR_TRACE("No camera found");
3001  "No camera found") );
3002  }
3003 
3004  height = this->height;
3005 }
3024 {
3025  if (! num_cameras) {
3026  close();
3027  vpERROR_TRACE("No camera found");
3029  "No camera found") );
3030  }
3031 
3032  return this->height;
3033 }
3034 
3040 void
3042 {
3043  std::cout << "----------------------------------------------------------"
3044  << std::endl
3045  << "----- Information for camera " << camera_id
3046  << " -----" << std::endl
3047  << "----------------------------------------------------------" << std::endl;
3048 
3049 #ifdef VISP_HAVE_DC1394_2_CAMERA_ENUMERATE // new API > libdc1394-2.0.0-rc7
3050  dc1394_camera_print_info( camera, stdout);
3051 #elif defined VISP_HAVE_DC1394_2_FIND_CAMERAS // old API <= libdc1394-2.0.0-rc7
3052  dc1394_print_camera_info( camera);
3053 #endif
3054 
3055  dc1394featureset_t features;
3056 #ifdef VISP_HAVE_DC1394_2_CAMERA_ENUMERATE // new API > libdc1394-2.0.0-rc7
3057  if (dc1394_feature_get_all(camera, &features) != DC1394_SUCCESS)
3058 #elif defined VISP_HAVE_DC1394_2_FIND_CAMERAS // old API <= libdc1394-2.0.0-rc7
3059  if (dc1394_get_camera_feature_set(camera, &features) != DC1394_SUCCESS)
3060 #endif
3061  {
3062  close();
3063  vpERROR_TRACE("unable to get feature set for camera %d\n", camera_id);
3065  "Cannot get camera features") );
3066 
3067  } else {
3068 #ifdef VISP_HAVE_DC1394_2_CAMERA_ENUMERATE // new API > libdc1394-2.0.0-rc7
3069  dc1394_feature_print_all(&features, stdout);
3070 #elif defined VISP_HAVE_DC1394_2_FIND_CAMERAS // old API <= libdc1394-2.0.0-rc7
3071  dc1394_print_feature_set(&features);
3072 #endif
3073  }
3074  std::cout << "----------------------------------------------------------" << std::endl;
3075 }
3076 
3090 {
3091  std::string _str = "";
3092  dc1394video_mode_t _videomode = (dc1394video_mode_t) videomode;
3093 
3094  if ((_videomode >= DC1394_VIDEO_MODE_MIN)
3095  && (_videomode <= DC1394_VIDEO_MODE_MAX)) {
3096  _str = strVideoMode[_videomode - DC1394_VIDEO_MODE_MIN];
3097  }
3098  else {
3099  vpCERROR << "The video mode " << videomode
3100  << " is not supported by the camera" << std::endl;
3101  }
3102 
3103  return _str;
3104 }
3105 
3119 {
3120  std::string _str = "";
3121  dc1394framerate_t _fps = (dc1394framerate_t) fps;
3122 
3123  if ((_fps >= DC1394_FRAMERATE_MIN)
3124  && (_fps <= DC1394_FRAMERATE_MAX)) {
3125  _str = strFramerate[_fps - DC1394_FRAMERATE_MIN];
3126  }
3127  else {
3128  vpCERROR << "The framerate " << fps
3129  << " is not supported by the camera" << std::endl;
3130  }
3131 
3132  return _str;
3133 }
3134 
3148 {
3149  std::string _str = "";
3150  dc1394color_coding_t _coding = (dc1394color_coding_t) colorcoding;
3151 
3152  if ((_coding >= DC1394_COLOR_CODING_MIN)
3153  && (_coding <= DC1394_COLOR_CODING_MAX)) {
3154  _str = strColorCoding[_coding - DC1394_COLOR_CODING_MIN];
3155 
3156  }
3157  else {
3158  vpCERROR << "The color coding " << colorcoding
3159  << " is not supported by the camera" << std::endl;
3160  }
3161 
3162  return _str;
3163 }
3164 
3184 {
3186 
3187  for (int i = DC1394_VIDEO_MODE_MIN; i <= DC1394_VIDEO_MODE_MAX; i ++) {
3188  _id = (vp1394TwoVideoModeType) i;
3189  if (videomode.compare(videoMode2string(_id)) == 0)
3190  return _id;
3191  };
3192 
3194  "The required videomode is not valid") );
3195 
3196  return (vp1394TwoVideoModeType) 0;
3197 }
3198 
3199 
3219 {
3221 
3222  for (int i = DC1394_FRAMERATE_MIN; i <= DC1394_FRAMERATE_MAX; i ++) {
3223  _id = (vp1394TwoFramerateType) i;
3224  if (framerate.compare(framerate2string(_id)) == 0)
3225  return _id;
3226  };
3227 
3229  "The required framerate is not valid") );
3230 
3231  return (vp1394TwoFramerateType) 0;
3232 }
3233 
3253 {
3255 
3256  for (int i = DC1394_COLOR_CODING_MIN; i <= DC1394_COLOR_CODING_MAX; i ++) {
3257  _id = (vp1394TwoColorCodingType) i;
3258  if (colorcoding.compare(colorCoding2string(_id)) == 0)
3259  return _id;
3260  };
3261 
3263  "The required color coding is not valid") );
3264 
3265  return (vp1394TwoColorCodingType) 0;
3266 }
3267 
3301 {
3302  for (unsigned int i = 0; i < num_cameras;i++) {
3303  if (camIsOpen[i]) {
3304  camera = cameras[i];
3305  setTransmission(DC1394_OFF);
3306  setCapture(DC1394_OFF);
3307  }
3308  }
3309 #ifdef VISP_HAVE_DC1394_2_CAMERA_ENUMERATE // new API > libdc1394-2.0.0-rc7
3310  setCamera(camera_id);
3311  // free the other cameras
3312  for (unsigned int i=0;i<num_cameras;i++){
3313  if (i!=camera_id) dc1394_camera_free(cameras[i]);
3314  }
3315 
3316  printf ("Reseting bus...\n");
3317  dc1394_reset_bus (camera);
3318 
3319  dc1394_camera_free (camera);
3320  dc1394_free (d);
3321  d = NULL;
3322  if (cameras != NULL)
3323  delete [] cameras;
3324  cameras = NULL ;
3325 #elif defined VISP_HAVE_DC1394_2_FIND_CAMERAS // old API <= libdc1394-2.0.0-rc7
3326 
3327  setCamera(camera_id);
3328  // free the other cameras
3329  for (unsigned int i=0;i<num_cameras;i++){
3330  if (i!=camera_id) dc1394_free_camera(cameras[i]);
3331  }
3332  free(cameras);
3333  cameras = NULL;
3334 
3335  dc1394_reset_bus(camera);
3336  dc1394_free_camera(camera);
3337 
3338 #endif
3339  if (camIsOpen != NULL)
3340  delete [] camIsOpen;
3341  camIsOpen = NULL ;
3342 
3343  num_cameras = 0;
3344 
3345  init = false;
3346  vpTime::wait(1000);
3347  initialize(false);
3348 }
3349 
3379 void vp1394TwoGrabber::setPanControl(unsigned int panControlValue)
3380 {
3381  open();
3382  if (! num_cameras) {
3383  close();
3384  vpERROR_TRACE("No camera found");
3386  "No camera found") );
3387  }
3388  uint64_t offset = 0x884;
3389  uint32_t value = 0x82000000 + (uint32_t)panControlValue;
3390  dc1394error_t err;
3391  err = dc1394_set_control_register(camera, offset, value);
3392  if (err != DC1394_SUCCESS) {
3393  vpERROR_TRACE("Unable to set PAN register");
3394  close();
3396  "Unable to set PAN register") );
3397  }
3398 }
3399 
3400 
3418 {
3419  if (! num_cameras) {
3420  close();
3421  vpERROR_TRACE("No camera found");
3423  "No camera found") );
3424  }
3425 
3426  uint32_t value;
3427  dc1394feature_t feature = (dc1394feature_t)param;
3428  dc1394error_t err;
3429  err = dc1394_feature_get_value(camera, feature, &value);
3430  if (err != DC1394_SUCCESS) {
3431  vpERROR_TRACE("Unable to get the information");
3432  close();
3434  "Unable to get the information") );
3435  }
3436  return (unsigned int)value;
3437 }
3438 
3439 
3461  unsigned int val)
3462 {
3463  if (! num_cameras) {
3464  close();
3465  vpERROR_TRACE("No camera found");
3467  "No camera found") );
3468  }
3469  uint32_t value = (uint32_t)val;
3470  dc1394feature_t feature = (dc1394feature_t)param;
3471  dc1394error_t err;
3472  dc1394bool_t hasManualMode = DC1394_FALSE;
3473  dc1394feature_modes_t modesAvailable;
3474 
3475  // test wether we can set the shutter value (manual mode available or not)
3476  err = dc1394_feature_get_modes(camera, feature, &modesAvailable);
3477  if (err != DC1394_SUCCESS) {
3478  vpERROR_TRACE("Unable to detect the manual mode information");
3479  close();
3481  "Unable to detect the manual mode information"));
3482  }
3483 
3484  for(unsigned int i=0; i<modesAvailable.num; i++){
3485  if(modesAvailable.modes[i] == DC1394_FEATURE_MODE_MANUAL){
3486  hasManualMode = DC1394_TRUE;
3487  }
3488  }
3489 
3490  if(hasManualMode == DC1394_TRUE){
3491 
3492  if(!isDataModified[camera_id]){// to ensure we save the first mode even after several set
3493  /* we update the structure */
3494  updateDataCamToStruct();
3495  err = dc1394_feature_get_mode(camera, feature, &(initialShutterMode[camera_id]));
3496  if (err != DC1394_SUCCESS) {
3497  vpERROR_TRACE("Unable to get the initial mode");
3498  close();
3500  "Unable to get the initial mode"));
3501  }
3502  isDataModified[camera_id] = true;
3503  }
3504 
3505  dc1394feature_mode_t manualMode = DC1394_FEATURE_MODE_MANUAL;
3506  err = dc1394_feature_set_mode(camera, feature, manualMode);
3507  if (err != DC1394_SUCCESS) {
3508  vpERROR_TRACE("Unable to set the muanual mode");
3509  close();
3511  "Unable to set the manual mode") );
3512  }
3513  err = dc1394_feature_set_value(camera, feature, value);
3514  if (err != DC1394_SUCCESS) {
3515  vpERROR_TRACE("Unable to set the shutter information");
3516  close();
3518  "Unable to set the shutter information") );
3519  }
3520  }
3521  else{
3522  vpERROR_TRACE("The camera does not have a manual mode.\nCannot change the value");
3524  "The camera does not have a manual mode"));
3525  }
3526 }
3534 void
3536 {
3537  if (! num_cameras) {
3538  close();
3539  vpERROR_TRACE("No camera found");
3541  "No camera found") );
3542  }
3543 
3544  guid = camera->guid;
3545 }
3546 
3554 uint64_t
3556 {
3557  if (! num_cameras) {
3558  close();
3559  vpERROR_TRACE("No camera found");
3561  "No camera found") );
3562  }
3563 
3564  return camera->guid;
3565 }
3566 
3567 
3572 inline void
3573 vp1394TwoGrabber::updateDataCamToStruct()
3574 {
3575  dataCam[camera_id].brightness = getParameterValue(vpFEATURE_BRIGHTNESS);
3576  dataCam[camera_id].exposure = getParameterValue(vpFEATURE_EXPOSURE);
3577  dataCam[camera_id].sharpness = getParameterValue(vpFEATURE_SHARPNESS);
3578  dataCam[camera_id].hue = getParameterValue(vpFEATURE_HUE);
3579  dataCam[camera_id].saturation = getParameterValue(vpFEATURE_SATURATION);
3580  dataCam[camera_id].gamma = getParameterValue(vpFEATURE_GAMMA);
3581  dataCam[camera_id].shutter = getParameterValue(vpFEATURE_SHUTTER);
3582  dataCam[camera_id].gain = getParameterValue(vpFEATURE_GAIN);
3583  dataCam[camera_id].iris = getParameterValue(vpFEATURE_IRIS);
3584 }
3585 
3590 inline void
3591 vp1394TwoGrabber::updateDataStructToCam()
3592 {
3593  setParameterValue(vpFEATURE_BRIGHTNESS, dataCam[camera_id].brightness);
3594  setParameterValue(vpFEATURE_EXPOSURE, dataCam[camera_id].exposure);
3595  setParameterValue(vpFEATURE_SHARPNESS, dataCam[camera_id].sharpness);
3596  setParameterValue(vpFEATURE_HUE, dataCam[camera_id].hue);
3597  setParameterValue(vpFEATURE_SATURATION, dataCam[camera_id].saturation);
3598  setParameterValue(vpFEATURE_GAMMA, dataCam[camera_id].gamma);
3599  setParameterValue(vpFEATURE_SHUTTER, dataCam[camera_id].shutter);
3600  setParameterValue(vpFEATURE_GAIN, dataCam[camera_id].gain);
3601  setParameterValue(vpFEATURE_IRIS, dataCam[camera_id].iris);
3602 }
3603 
3604 #ifdef VISP_BUILD_DEPRECATED_FUNCTIONS
3605 
3623 uint32_t
3625 {
3626  // Refresh the list of supported modes
3627  videomodes.kill();
3628 
3629  if (! num_cameras) {
3630  close();
3631  vpERROR_TRACE("No camera found");
3633  "No camera found") );
3634  }
3635  dc1394video_modes_t _videomodes;
3636 
3637  // get video modes:
3638  if (dc1394_video_get_supported_modes(camera, &_videomodes)!=DC1394_SUCCESS) {
3639 
3640  close();
3641  vpERROR_TRACE("Can't get video modes");
3643  "Can't get video modes") );
3644  }
3645 
3646  // parse the video modes to add in the list
3647  for (unsigned i=0; i < _videomodes.num; i++) {
3648  vp1394TwoVideoModeType _mode = (vp1394TwoVideoModeType) _videomodes.modes[i];
3649  videomodes.addRight( _mode );
3650  }
3651 
3652  // return the number of available video modes
3653  return _videomodes.num;
3654 }
3655 
3688 uint32_t
3691 {
3692  if (! num_cameras) {
3693  close();
3694  vpERROR_TRACE("No camera found");
3696  "No camera found") );
3697  }
3698 
3699  // Refresh the list of supported framerates
3700  fps.kill();
3701 
3702  switch (mode) {
3703  // Framerate not available for:
3704  // - vpVIDEO_MODE_EXIF ie Format_6
3705  // - vpVIDEO_MODE_FORMAT7... ie the Format_7
3706  case vpVIDEO_MODE_EXIF:
3715  return 0;
3716  break;
3717  default:
3718  {
3719  dc1394framerates_t _fps;
3720  if (dc1394_video_get_supported_framerates(camera,
3721  (dc1394video_mode_t)mode,
3722  &_fps) != DC1394_SUCCESS) {
3723  close();
3724  vpERROR_TRACE("Could not query supported frametates for mode %d\n",
3725  mode);
3727  "Could not query supported framerates") );
3728  }
3729  if (_fps.num == 0)
3730  return 0;
3731 
3732  for (unsigned int i = 0; i < _fps.num; i ++)
3733  fps.addRight((vp1394TwoFramerateType)_fps.framerates[i]);
3734 
3735  return _fps.num;
3736  }
3737  break;
3738  }
3739 }
3740 
3765 uint32_t
3768 {
3769  if (! num_cameras) {
3770  close();
3771  vpERROR_TRACE("No camera found");
3773  "No camera found") );
3774  }
3775 
3776  // Refresh the list of supported framerates
3777  codings.kill();
3778 
3779  if (dc1394_is_video_mode_scalable((dc1394video_mode_t)mode)) {
3780  // Format 7 video mode
3781  dc1394color_codings_t _codings;
3782  if (dc1394_format7_get_color_codings(camera,
3783  (dc1394video_mode_t)mode,
3784  &_codings) != DC1394_SUCCESS) {
3785  close();
3786  vpERROR_TRACE("Could not query supported color codings for mode %d\n",
3787  mode);
3789  "Could not query supported color codings") );
3790  }
3791  if (_codings.num == 0)
3792  return 0;
3793 
3794  for (unsigned int i = 0; i < _codings.num; i ++)
3795  codings.addRight((vp1394TwoColorCodingType)_codings.codings[i]);
3796 
3797  return _codings.num;
3798  }
3799  else if (dc1394_is_video_mode_still_image((dc1394video_mode_t)mode)) {
3800  // Format 6 video mode
3801  return 0;
3802  }
3803  else {
3804  // Not Format 7 and not Format 6 video modes
3805  dc1394color_coding_t _coding;
3806  if (dc1394_get_color_coding_from_video_mode(camera,
3807  (dc1394video_mode_t)mode,
3808  &_coding) != DC1394_SUCCESS) {
3809  close();
3810  vpERROR_TRACE("Could not query supported color coding for mode %d\n",
3811  mode);
3813  "Could not query supported color coding") );
3814  }
3815  codings.addRight((vp1394TwoColorCodingType)_coding);
3816  return 1;
3817  }
3818 }
3819 #endif
3820 
3821 #endif
3822 
void getColorCoding(vp1394TwoColorCodingType &coding)
static const char * strFramerate[DC1394_FRAMERATE_NUM]
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 setIsoTransmissionSpeed(vp1394TwoIsoSpeedType isospeed)
static std::string framerate2string(vp1394TwoFramerateType fps)
void getAutoGain(unsigned int &minvalue, unsigned int &maxvalue)
unsigned int getWidth() const
Definition: vpImage.h:159
#define vpERROR_TRACE
Definition: vpDebug.h:379
static void RGBToRGBa(unsigned char *rgb, unsigned char *rgba, unsigned int size)
#define vpTRACE
Definition: vpDebug.h:401
Provide simple list management.
Definition: vpList.h:112
Type * bitmap
points toward the bitmap
Definition: vpImage.h:120
static void MONO16ToGrey(unsigned char *grey16, unsigned char *grey, unsigned int size)
#define vpCERROR
Definition: vpDebug.h:354
vp1394TwoGrabber(bool reset=true)
bool isVideoModeFormat7(vp1394TwoVideoModeType videomode)
void resize(const unsigned int height, const unsigned int width)
set the size of the image
Definition: vpImage.h:535
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)
void kill()
Destroy the list.
Definition: vpList.h:694
static int wait(double t0, double t)
Definition: vpTime.cpp:149
unsigned int getParameterValue(vp1394TwoParametersType param)
void acquire(vpImage< unsigned char > &I)
unsigned int getNumCameras()
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)
unsigned int getRingBufferSize()
#define vpCTRACE
Definition: vpDebug.h:327
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)
unsigned int height
Number of rows in the image.
void setCamera(uint64_t camera)
static const char * strVideoMode[DC1394_VIDEO_MODE_NUM]
void addRight(const type &el)
add a new element in the list, at the right of the current one
Definition: vpList.h:480
static void MONO16ToRGBa(unsigned char *grey16, unsigned char *rgba, unsigned int size)
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)
bool isColorCodingSupported(vp1394TwoVideoModeType videomode, vp1394TwoColorCodingType coding)
static void YUV411ToRGBa(unsigned char *yuv, unsigned char *rgba, unsigned int size)
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:150
bool isVideoModeSupported(vp1394TwoVideoModeType videomode)
static void YUV411ToGrey(unsigned char *yuv, unsigned char *grey, unsigned int size)
void getVideoMode(vp1394TwoVideoModeType &videomode)
unsigned int width
Number of columns in the image.
unsigned int getHeight()