Visual Servoing Platform version 3.7.0
Loading...
Searching...
No Matches
vp1394TwoGrabber.cpp
1/*
2 * ViSP, open source Visual Servoing Platform software.
3 * Copyright (C) 2005 - 2025 by Inria. All rights reserved.
4 *
5 * This software is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 * See the file LICENSE.txt at the root directory of this source
10 * distribution for additional information about the GNU GPL.
11 *
12 * For using ViSP with software that can not be combined with the GNU
13 * GPL, please contact Inria about acquiring a ViSP Professional
14 * Edition License.
15 *
16 * See https://visp.inria.fr for more information.
17 *
18 * This software was developed at:
19 * Inria Rennes - Bretagne Atlantique
20 * Campus Universitaire de Beaulieu
21 * 35042 Rennes Cedex
22 * France
23 *
24 * If you have questions regarding the use of this file, please contact
25 * Inria at visp@inria.fr
26 *
27 * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
28 * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
29 *
30 * Description:
31 * Firewire cameras video capture.
32 */
33
38#include <iostream>
39
40#include <visp3/core/vpConfig.h>
41#include <visp3/core/vpDebug.h>
42
43/*
44 * Interface with libdc1394 2.x
45 */
46#if defined(VISP_HAVE_DC1394)
47#include <unistd.h>
48
49#include <visp3/core/vpFrameGrabberException.h>
50#include <visp3/core/vpImageConvert.h>
51#include <visp3/core/vpTime.h>
52#include <visp3/sensor/vp1394TwoGrabber.h>
53
55const char *vp1394TwoGrabber::strVideoMode[DC1394_VIDEO_MODE_NUM] = {
56 "MODE_160x120_YUV444", "MODE_320x240_YUV422", "MODE_640x480_YUV411", "MODE_640x480_YUV422",
57 "MODE_640x480_RGB8", "MODE_640x480_MONO8", "MODE_640x480_MONO16", "MODE_800x600_YUV422",
58 "MODE_800x600_RGB8", "MODE_800x600_MONO8", "MODE_1024x768_YUV422", "MODE_1024x768_RGB8",
59 "MODE_1024x768_MONO8", "MODE_800x600_MONO16", "MODE_1024x768_MONO16", "MODE_1280x960_YUV422",
60 "MODE_1280x960_RGB8", "MODE_1280x960_MONO8", "MODE_1600x1200_YUV422", "MODE_1600x1200_RGB8",
61 "MODE_1600x1200_MONO8", "MODE_1280x960_MONO16", "MODE_1600x1200_MONO16", "MODE_EXIF",
62 "MODE_FORMAT7_0", "MODE_FORMAT7_1", "MODE_FORMAT7_2", "MODE_FORMAT7_3",
63 "MODE_FORMAT7_4", "MODE_FORMAT7_5", "MODE_FORMAT7_6", "MODE_FORMAT7_7" };
64
65const char *vp1394TwoGrabber::strFramerate[DC1394_FRAMERATE_NUM] = {
66 "FRAMERATE_1_875", "FRAMERATE_3_75", "FRAMERATE_7_5", "FRAMERATE_15",
67 "FRAMERATE_30", "FRAMERATE_60", "FRAMERATE_120", "FRAMERATE_240" };
68
69const char *vp1394TwoGrabber::strColorCoding[DC1394_COLOR_CODING_NUM] = {
70 "COLOR_CODING_MONO8", "COLOR_CODING_YUV411", "COLOR_CODING_YUV422", "COLOR_CODING_YUV444",
71 "COLOR_CODING_RGB8", "COLOR_CODING_MONO16", "COLOR_CODING_RGB16", "COLOR_CODING_MONO16S",
72 "COLOR_CODING_RGB16S", "COLOR_CODING_RAW8", "COLOR_CODING_RAW16",
73};
74
124 : camera(nullptr), cameras(nullptr), num_cameras(0), camera_id(0), verbose(false), camIsOpen(nullptr),
125 num_buffers(4), // ring buffer size
126 isDataModified(nullptr), initialShutterMode(nullptr), dataCam(nullptr)
127#ifdef VISP_HAVE_DC1394_CAMERA_ENUMERATE // new API > libdc1394-2.0.0-rc7
128 ,
129 d(nullptr), list(nullptr)
130#endif
131{
132 // protected members
133 width = height = 0;
134
135 // private members
136 init = false;
137
138 reset = false;
139 initialize(reset);
140
141 // open();
142}
143
154{
155 /* if(num_cameras >= 1){
156 delete[] isDataModified;
157 delete[] initialShutterMode;
158 delete[] dataCam;
159 }*/
160 close();
161}
162
293void vp1394TwoGrabber::setCamera(uint64_t cam_id)
294{
295 // Suppose that if camera_id is a camera GUID, this value is greater
296 // than the number of cameras connected to the bus
297 if (cam_id >= num_cameras) {
298 // Check if camera_id is a camera guid
299 bool is_guid = false;
300 // check if the camera_id is a guid
301 for (unsigned int i = 0; i < num_cameras; i++) {
302 if (cameras[i]->guid == cam_id) {
303 this->camera_id = i;
304 is_guid = true;
305 break;
306 }
307 }
308 if (is_guid == false) {
309 std::cout << "Error: The camera with guid 0x" << std::hex << cam_id << " is not present" << std::endl;
310 std::cout << num_cameras << " camera(s) connected" << std::endl;
311 for (unsigned int i = 0; i < num_cameras; i++) {
312 std::cout << " - camera " << i << " with guid 0x" << std::hex << cameras[i]->guid << std::endl;
313 }
314 close();
315 throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "The required camera is not present"));
316 }
317 }
318 else {
319 this->camera_id = static_cast<unsigned int>(cam_id); // The input cam_id is not a
320 // uint64_t guid, but the index of
321 // the camera
322 }
323
324 // create a pointer to the working camera
325 camera = cameras[this->camera_id];
326}
327
342void vp1394TwoGrabber::getCamera(uint64_t &cam_id)
343{
344 if (num_cameras) {
345 cam_id = this->camera_id;
346 }
347 else {
348 close();
349 vpERROR_TRACE("No cameras found");
351 }
352}
353
369{
370 if (num_cameras) {
371 return this->camera_id;
372 }
373 else {
374 close();
375 vpERROR_TRACE("No cameras found");
377 }
378}
379
387void vp1394TwoGrabber::getNumCameras(unsigned int &ncameras) const
388{
389 if (!num_cameras) {
390 vpCTRACE << "No camera found..." << std::endl;
391 ncameras = 0;
392 }
393
394 ncameras = num_cameras;
395}
396
405{
406 unsigned int ncameras = 0;
407 if (!num_cameras) {
408 vpCTRACE << "No camera found..." << std::endl;
409 ncameras = 0;
410 }
411
412 ncameras = num_cameras;
413 return ncameras;
414}
415
465{
466 open();
467 if (!num_cameras) {
468 close();
470 }
471 if (!isVideoModeSupported(videomode)) {
472 throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Video mode not supported by camera %d",
473 camera_id));
474 }
475 // Stop dma capture if started
476 setTransmission(DC1394_OFF);
477 setCapture(DC1394_OFF);
478
479 if (dc1394_video_set_mode(camera, (dc1394video_mode_t)videomode) != DC1394_SUCCESS) {
480 close();
482 }
483
484 setCapture(DC1394_ON);
485 setTransmission(DC1394_ON);
486
487 // Updates image size from new video mode
488 if (dc1394_get_image_size_from_video_mode(camera, (dc1394video_mode_t)videomode, &this->width, &this->height) !=
489 DC1394_SUCCESS) {
490
491 close();
493 }
494}
495
513{
514 if (!num_cameras) {
515 close();
516 vpERROR_TRACE("No camera found");
518 }
519
520 dc1394video_mode_t _videomode;
521 if (dc1394_video_get_mode(camera, &_videomode) != DC1394_SUCCESS) {
522
523 close();
524 vpERROR_TRACE("Can't get current video mode");
525 throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Can't get current video mode"));
526 }
527 videomode = (vp1394TwoVideoModeType)_videomode;
528}
529
546uint32_t vp1394TwoGrabber::getVideoModeSupported(std::list<vp1394TwoVideoModeType> &videomodes)
547{
548 // Refresh the list of supported modes
549 videomodes.clear();
550
551 if (!num_cameras) {
552 close();
553 vpERROR_TRACE("No camera found");
555 }
556 dc1394video_modes_t _videomodes;
557
558 // get video modes:
559 if (dc1394_video_get_supported_modes(camera, &_videomodes) != DC1394_SUCCESS) {
560
561 close();
562 vpERROR_TRACE("Can't get video modes");
563 throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Can't get video modes"));
564 }
565
566 // parse the video modes to add in the list
567 for (unsigned i = 0; i < _videomodes.num; i++) {
568 vp1394TwoVideoModeType _mode = (vp1394TwoVideoModeType)_videomodes.modes[i];
569 videomodes.push_back(_mode);
570 }
571
572 // return the number of available video modes
573 return _videomodes.num;
574}
575
591{
592 if (!num_cameras) {
593 close();
594 vpERROR_TRACE("No camera found");
596 }
597 dc1394video_modes_t _videomodes;
598
599 // get video modes:
600 if (dc1394_video_get_supported_modes(camera, &_videomodes) != DC1394_SUCCESS) {
601
602 close();
603 vpERROR_TRACE("Can't get video modes");
604 throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Can't get video modes"));
605 }
606
607 // parse the video modes to check with the desired
608 for (unsigned i = 0; i < _videomodes.num; i++) {
609 if ((vp1394TwoVideoModeType)_videomodes.modes[i] == videomode) {
610 return true;
611 }
612 }
613 return false;
614}
615
629{
630
631 if (dc1394_is_video_mode_scalable((dc1394video_mode_t)videomode))
632 return true;
633
634 return false;
635}
636
653{
655 getColorCoding(coding);
656
657 switch (coding) {
663 return false;
670 return true;
671 }
672 return false;
673}
674
700{
701 open();
702 if (!num_cameras) {
703 close();
705 }
706
707 vp1394TwoVideoModeType cur_videomode;
708 getVideoMode(cur_videomode);
709 if (isVideoModeFormat7(cur_videomode))
710 return;
711
712 if (!isFramerateSupported(cur_videomode, fps)) {
713 throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Framerate not supported by camera %d",
714 camera_id));
715 }
716
717 // Stop dma capture if started
718 setTransmission(DC1394_OFF);
719 setCapture(DC1394_OFF);
720
721 if (dc1394_video_set_framerate(camera, (dc1394framerate_t)fps) != DC1394_SUCCESS) {
722
723 close();
725 }
726
727 setCapture(DC1394_ON);
728 setTransmission(DC1394_ON);
729}
730
748{
749 if (!num_cameras) {
750 close();
751 vpERROR_TRACE("No camera found");
753 }
754 dc1394framerate_t _fps;
755 if (dc1394_video_get_framerate(camera, &_fps) != DC1394_SUCCESS) {
756
757 close();
758 vpERROR_TRACE("Can't get current framerate");
759 throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Can't get current framerate"));
760 }
761 fps = (vp1394TwoFramerateType)_fps;
762}
763
795uint32_t vp1394TwoGrabber::getFramerateSupported(vp1394TwoVideoModeType mode, std::list<vp1394TwoFramerateType> &fps)
796{
797 if (!num_cameras) {
798 close();
799 vpERROR_TRACE("No camera found");
801 }
802
803 // Refresh the list of supported framerates
804 fps.clear();
805
806 switch (mode) {
807 // Framerate not available for:
808 // - vpVIDEO_MODE_EXIF ie Format_6
809 // - vpVIDEO_MODE_FORMAT7... ie the Format_7
819 return 0;
820 break;
821 default: {
822 dc1394framerates_t _fps;
823 if (dc1394_video_get_supported_framerates(camera, (dc1394video_mode_t)mode, &_fps) != DC1394_SUCCESS) {
824 close();
825 vpERROR_TRACE("Could not query supported frametates for mode %d\n", mode);
826 throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Could not query supported framerates"));
827 }
828 if (_fps.num == 0)
829 return 0;
830
831 for (unsigned int i = 0; i < _fps.num; i++)
832 fps.push_back((vp1394TwoFramerateType)_fps.framerates[i]);
833
834 return _fps.num;
835 } break;
836 }
837}
838
872{
873 if (!num_cameras) {
874 close();
875 vpERROR_TRACE("No camera found");
877 }
878
879 switch (mode) {
880 // Framerate not available for:
881 // - vpVIDEO_MODE_EXIF ie Format_6
882 // - vpVIDEO_MODE_FORMAT7... ie the Format_7
892 return 0;
893 break;
894 default: {
895 dc1394framerates_t _fps;
896 if (dc1394_video_get_supported_framerates(camera, (dc1394video_mode_t)mode, &_fps) != DC1394_SUCCESS) {
897 close();
898 vpERROR_TRACE("Could not query supported frametates for mode %d\n", mode);
899 throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Could not query supported framerates"));
900 }
901 if (_fps.num == 0)
902 return 0;
903
904 for (unsigned int i = 0; i < _fps.num; i++) {
905 if (fps == (vp1394TwoFramerateType)_fps.framerates[i]) {
906 return true;
907 }
908 }
909 return false;
910 } break;
911 }
912}
913
966{
967 if (!num_cameras) {
968 close();
970 }
971
972 dc1394video_mode_t _videomode;
973 if (dc1394_video_get_mode(camera, &_videomode) != DC1394_SUCCESS) {
974
975 close();
976 throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Can't get current video mode"));
977 }
978
979 if (!isColorCodingSupported((vp1394TwoVideoModeType)_videomode, coding)) {
980 throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Color coding not supported by camera %d",
981 camera_id));
982 }
983
984 // Format 7 video mode
985 if (dc1394_is_video_mode_scalable(_videomode)) {
986 setTransmission(DC1394_OFF);
987 setCapture(DC1394_OFF);
988
989 if (dc1394_format7_set_color_coding(camera, _videomode, (dc1394color_coding_t)coding) != DC1394_SUCCESS) {
990
991 close();
992 throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Can't set color coding"));
993 }
994
995 setCapture(DC1394_ON);
996 setTransmission(DC1394_ON);
997 }
998}
999
1018{
1019 if (!num_cameras) {
1020 close();
1021 vpERROR_TRACE("No camera found");
1023 }
1024 dc1394video_mode_t _videomode;
1025 if (dc1394_video_get_mode(camera, &_videomode) != DC1394_SUCCESS) {
1026
1027 close();
1028 vpERROR_TRACE("Can't get current video mode");
1029 throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Can't get current video mode"));
1030 }
1031
1032 dc1394color_coding_t _coding;
1033 if (dc1394_is_video_mode_scalable(_videomode)) {
1034 // Format 7 video mode
1035 if (dc1394_format7_get_color_coding(camera, _videomode, &_coding) != DC1394_SUCCESS) {
1036
1037 close();
1038 vpERROR_TRACE("Can't get current color coding");
1039 throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Can't query current color coding"));
1040 }
1041 }
1042 else if (dc1394_is_video_mode_still_image((dc1394video_mode_t)_videomode)) {
1043 throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "No color coding for format 6 video mode"));
1044 }
1045 else {
1046 // Not Format 7 and not Format 6 video modes
1047 if (dc1394_get_color_coding_from_video_mode(camera, (dc1394video_mode_t)_videomode, &_coding) != DC1394_SUCCESS) {
1048 close();
1049 vpERROR_TRACE("Could not query supported color coding for mode %d\n", _videomode);
1050 throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Can't query current color coding"));
1051 }
1052 }
1053 coding = (vp1394TwoColorCodingType)_coding;
1054}
1055
1078 std::list<vp1394TwoColorCodingType> &codings)
1079{
1080 if (!num_cameras) {
1081 close();
1082 vpERROR_TRACE("No camera found");
1084 }
1085
1086 // Refresh the list of supported framerates
1087 codings.clear();
1088
1089 if (dc1394_is_video_mode_scalable((dc1394video_mode_t)mode)) {
1090 // Format 7 video mode
1091 dc1394color_codings_t _codings;
1092 if (dc1394_format7_get_color_codings(camera, (dc1394video_mode_t)mode, &_codings) != DC1394_SUCCESS) {
1093 close();
1094 vpERROR_TRACE("Could not query supported color codings for mode %d\n", mode);
1095 throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Could not query supported color codings"));
1096 }
1097 if (_codings.num == 0)
1098 return 0;
1099
1100 for (unsigned int i = 0; i < _codings.num; i++)
1101 codings.push_back((vp1394TwoColorCodingType)_codings.codings[i]);
1102
1103 return _codings.num;
1104 }
1105 else if (dc1394_is_video_mode_still_image((dc1394video_mode_t)mode)) {
1106 // Format 6 video mode
1107 return 0;
1108 }
1109 else {
1110 // Not Format 7 and not Format 6 video modes
1111 dc1394color_coding_t _coding;
1112 if (dc1394_get_color_coding_from_video_mode(camera, (dc1394video_mode_t)mode, &_coding) != DC1394_SUCCESS) {
1113 close();
1114 vpERROR_TRACE("Could not query supported color coding for mode %d\n", mode);
1115 throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Could not query supported color coding"));
1116 }
1117 codings.push_back((vp1394TwoColorCodingType)_coding);
1118 return 1;
1119 }
1120}
1121
1143{
1144 if (!num_cameras) {
1145 close();
1146 vpERROR_TRACE("No camera found");
1148 }
1149
1150 if (dc1394_is_video_mode_scalable((dc1394video_mode_t)mode)) {
1151 // Format 7 video mode
1152 dc1394color_codings_t _codings;
1153 if (dc1394_format7_get_color_codings(camera, (dc1394video_mode_t)mode, &_codings) != DC1394_SUCCESS) {
1154 close();
1155 vpERROR_TRACE("Could not query supported color codings for mode %d\n", mode);
1156 throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Could not query supported color codings"));
1157 }
1158 if (_codings.num == 0)
1159 return 0;
1160
1161 for (unsigned int i = 0; i < _codings.num; i++) {
1162 if (coding == (vp1394TwoColorCodingType)_codings.codings[i])
1163 return true;
1164 }
1165 return false;
1166 }
1167 else if (dc1394_is_video_mode_still_image((dc1394video_mode_t)mode)) {
1168 // Format 6 video mode
1169 return false;
1170 }
1171 else {
1172 // Not Format 7 and not Format 6 video modes
1173 dc1394color_coding_t _coding;
1174 if (dc1394_get_color_coding_from_video_mode(camera, (dc1394video_mode_t)mode, &_coding) != DC1394_SUCCESS) {
1175 close();
1176 vpERROR_TRACE("Could not query supported color coding for mode %d\n", mode);
1177 throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Could not query supported color coding"));
1178 return false;
1179 }
1180 if (coding == (vp1394TwoColorCodingType)_coding)
1181 return true;
1182
1183 return false;
1184 }
1185}
1186
1218void vp1394TwoGrabber::setFormat7ROI(unsigned int left, unsigned int top, unsigned int w, unsigned int h)
1219{
1220 open();
1221 if (!num_cameras) {
1222 close();
1223 vpERROR_TRACE("No camera found");
1225 }
1226
1227 dc1394video_mode_t _videomode;
1228 if (dc1394_video_get_mode(camera, &_videomode) != DC1394_SUCCESS) {
1229
1230 close();
1231 vpERROR_TRACE("Can't get current video mode");
1232 throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Can't get current video mode"));
1233 }
1234 if (dc1394_is_video_mode_scalable(_videomode)) {
1235 // Stop dma capture if started
1236 setTransmission(DC1394_OFF);
1237 setCapture(DC1394_OFF);
1238 // Format 7 video mode
1239 unsigned int max_width, max_height;
1240 if (dc1394_format7_get_max_image_size(camera, _videomode, &max_width, &max_height) != DC1394_SUCCESS) {
1241
1242 close();
1243 vpERROR_TRACE("Can't get format7 max image size");
1244 throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Can't get format7 max image size"));
1245 }
1246#if 0
1247 vpTRACE("left: %d top: %d width: %d height: %d", left, top,
1248 width == 0 ? DC1394_USE_MAX_AVAIL : w,
1249 height == 0 ? DC1394_USE_MAX_AVAIL : h);
1250 vpTRACE("max_width: %d max_height: %d", max_width, max_height);
1251#endif
1252
1253 if (left > max_width) {
1254 vpERROR_TRACE("Can't set format7 ROI");
1255 throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Can't set format7 ROI"));
1256 }
1257 if (top > max_height) {
1258 vpERROR_TRACE("Can't set format7 ROI");
1259 throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Can't set format7 ROI"));
1260 }
1261
1262 int32_t roi_width;
1263 int32_t roi_height;
1264
1265 if (w != 0) {
1266 // Check if roi width is acceptable (ie roi is contained in the image)
1267 if (w > (max_width - left))
1268 w = (max_width - left);
1269 roi_width = (int32_t)w;
1270 }
1271 else {
1272 roi_width = DC1394_USE_MAX_AVAIL;
1273 }
1274
1275 if (h != 0) {
1276 // Check if roi height is acceptable (ie roi is contained in the image)
1277 if (h > (max_height - top))
1278 h = (max_height - top);
1279 roi_height = (int32_t)h;
1280 }
1281 else {
1282 roi_height = DC1394_USE_MAX_AVAIL;
1283 }
1284
1285 if (dc1394_format7_set_roi(camera, _videomode,
1286 (dc1394color_coding_t)DC1394_QUERY_FROM_CAMERA, // color_coding
1287 DC1394_USE_MAX_AVAIL /*DC1394_QUERY_FROM_CAMERA*/
1288 , // bytes_per_packet
1289 (int32_t)left, // left
1290 (int32_t)top, // top
1291 roi_width, roi_height) != DC1394_SUCCESS) {
1292 close();
1293 vpERROR_TRACE("Can't set format7 roi");
1294 throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Can't get current video mode"));
1295 }
1296 // Update the image size
1297 if (dc1394_format7_get_image_size(camera, _videomode, &this->width, &this->height) != DC1394_SUCCESS) {
1298 close();
1299 vpERROR_TRACE("Can't get format7 image size");
1300 throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Can't get format7 image size"));
1301 }
1302
1303 setCapture(DC1394_ON);
1304 setTransmission(DC1394_ON);
1305 }
1306}
1307
1321void vp1394TwoGrabber::initialize(bool reset)
1322{
1323 if (init == false) {
1324// Find cameras
1325#ifdef VISP_HAVE_DC1394_CAMERA_ENUMERATE // new API > libdc1394-2.0.0-rc7
1326 if (d != nullptr)
1327 dc1394_free(d);
1328
1329 d = dc1394_new();
1330 if (dc1394_camera_enumerate(d, &list) != DC1394_SUCCESS) {
1331 dc1394_camera_free_list(list);
1332 close();
1333 vpERROR_TRACE("Failed to enumerate cameras\n");
1334 throw(vpFrameGrabberException(vpFrameGrabberException::initializationError, "Failed to enumerate cameras"));
1335 }
1336
1337 if (list->num == 0) {
1338 dc1394_camera_free_list(list);
1339 close();
1340 vpERROR_TRACE("No cameras found");
1341 throw(vpFrameGrabberException(vpFrameGrabberException::initializationError, "No cameras found"));
1342 }
1343
1344 if (cameras != nullptr)
1345 delete[] cameras;
1346
1347 cameras = new dc1394camera_t *[list->num];
1348
1349 num_cameras = 0;
1350
1351 for (unsigned int i = 0; i < list->num; i++) {
1352 cameras[i] = dc1394_camera_new(d, list->ids[i].guid);
1353 if (!cameras[i]) {
1354 vpTRACE("Failed to initialize camera with guid \"%ld\"\n", list->ids[i].guid);
1355 continue;
1356 }
1357 // Update the number of working cameras
1358 num_cameras++;
1359 }
1360
1361 if (reset) {
1362 // Reset the bus to make firewire working if the program was not
1363 // properly stopped by a CTRL-C. We reset here only the bus attached to
1364 // the first camera
1365 dc1394_reset_bus(cameras[0]);
1366 }
1367
1368 // if (list != nullptr)
1369 dc1394_camera_free_list(list);
1370 list = nullptr;
1371
1372#elif defined VISP_HAVE_DC1394_FIND_CAMERAS // old API <= libdc1394-2.0.0-rc7
1373 if (cameras != nullptr)
1374 free(cameras);
1375 cameras = nullptr;
1376 int err = dc1394_find_cameras(&cameras, &num_cameras);
1377
1378 if (err != DC1394_SUCCESS && err != DC1394_NO_CAMERA) {
1379 close();
1380 vpERROR_TRACE("Unable to look for cameras\n\n"
1381 "Please check \n"
1382 " - if the kernel modules `ieee1394',`raw1394' and "
1383 "`ohci1394' are loaded \n"
1384 " - if you have read/write access to /dev/raw1394\n\n");
1385 throw(vpFrameGrabberException(vpFrameGrabberException::initializationError, "Unable to look for cameras"));
1386 }
1387#endif
1388
1389 if (num_cameras == 0) {
1390 close();
1391 vpERROR_TRACE("No cameras found");
1392 throw(vpFrameGrabberException(vpFrameGrabberException::initializationError, "No cameras found"));
1393 }
1394
1395 // allocation for the parameters
1396 isDataModified = new bool[num_cameras];
1397 for (unsigned int i = 0; i < num_cameras; i++)
1398 isDataModified[i] = false;
1399 initialShutterMode = new dc1394feature_mode_t[num_cameras];
1400 dataCam = new vpDc1394TwoCameraParametersData[num_cameras];
1401
1402 if (camera_id >= num_cameras) {
1403 // Bad camera id
1404 close();
1405 vpERROR_TRACE("Bad camera id: %u", camera_id);
1406 vpERROR_TRACE("Only %u camera on the bus.", num_cameras);
1407 throw(vpFrameGrabberException(vpFrameGrabberException::initializationError, "Bad camera id"));
1408 }
1409
1410 if (verbose) {
1411 std::cout << "------ Bus information ------" << std::endl;
1412 std::cout << "Number of camera(s) on the bus : " << num_cameras << std::endl;
1413 std::cout << "-----------------------------" << std::endl;
1414 }
1415
1416 if (camIsOpen != nullptr)
1417 delete[] camIsOpen;
1418 camIsOpen = new bool[num_cameras];
1419 for (unsigned int i = 0; i < num_cameras; i++) {
1420 camIsOpen[i] = false;
1421 }
1422
1423 init = true;
1424 }
1425}
1436{
1437 if (init == false)
1438 initialize(false);
1439 if (camIsOpen[camera_id] == false) {
1440 dc1394switch_t status = DC1394_OFF;
1441
1442 //#ifdef VISP_HAVE_DC1394_CAMERA_ENUMERATE // new API >
1443 // libdc1394-2.0.0-rc7
1444 dc1394_video_get_transmission(cameras[camera_id], &status);
1445 if (status != DC1394_OFF) {
1446 //#endif
1447 if (dc1394_video_set_transmission(cameras[camera_id], DC1394_OFF) != DC1394_SUCCESS)
1448 vpTRACE("Could not stop ISO transmission");
1449 else {
1450 vpTime::wait(500);
1451 if (dc1394_video_get_transmission(cameras[camera_id], &status) != DC1394_SUCCESS)
1452 vpTRACE("Could get ISO status");
1453 else {
1454 if (status == DC1394_ON) {
1455 vpTRACE("ISO transmission refuses to stop");
1456 }
1457#ifdef VISP_HAVE_DC1394_FIND_CAMERAS // old API <= libdc1394-2.0.0-rc7
1458 // No yet in the new API
1459 cameras[camera_id]->is_iso_on = status;
1460#endif
1461 }
1462 //#ifdef VISP_HAVE_DC1394_CAMERA_ENUMERATE // new API >
1463 // libdc1394-2.0.0-rc7
1464 }
1465 //#endif
1466 }
1467 setCamera(camera_id);
1468 // setIsoSpeed(DC1394_ISO_SPEED_400);
1469 setCapture(DC1394_ON);
1470 setTransmission(DC1394_ON);
1471 camIsOpen[camera_id] = true;
1472 }
1473}
1483{
1484 if (init) {
1485 if (num_cameras) {
1486 for (unsigned int i = 0; i < num_cameras; i++) {
1487 if (camIsOpen[i]) {
1488 camera = cameras[i];
1489 this->camera_id = i; // set camera id for the function updateDataStructToCam
1490 setTransmission(DC1394_OFF);
1491 setCapture(DC1394_OFF);
1492 if (isDataModified[i]) {
1493 // reset values
1494 try {
1495 updateDataStructToCam();
1496 }
1497 catch (...) {
1498 }
1499 // reset mode (manual, auto, ...)
1500 if (dc1394_feature_set_mode(camera, DC1394_FEATURE_BRIGHTNESS, initialShutterMode[i]) != DC1394_SUCCESS ||
1501 dc1394_feature_set_mode(camera, DC1394_FEATURE_EXPOSURE, initialShutterMode[i]) != DC1394_SUCCESS ||
1502 dc1394_feature_set_mode(camera, DC1394_FEATURE_SHARPNESS, initialShutterMode[i]) != DC1394_SUCCESS ||
1503 dc1394_feature_set_mode(camera, DC1394_FEATURE_HUE, initialShutterMode[i]) != DC1394_SUCCESS ||
1504 dc1394_feature_set_mode(camera, DC1394_FEATURE_SATURATION, initialShutterMode[i]) != DC1394_SUCCESS ||
1505 dc1394_feature_set_mode(camera, DC1394_FEATURE_GAMMA, initialShutterMode[i]) != DC1394_SUCCESS ||
1506 dc1394_feature_set_mode(camera, DC1394_FEATURE_SHUTTER, initialShutterMode[i]) != DC1394_SUCCESS ||
1507 dc1394_feature_set_mode(camera, DC1394_FEATURE_GAIN, initialShutterMode[i]) != DC1394_SUCCESS ||
1508 dc1394_feature_set_mode(camera, DC1394_FEATURE_IRIS, initialShutterMode[i])) {
1509
1510 vpERROR_TRACE("Unable to reset the initial mode");
1511 throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Unable to reset the initial mode"));
1512 }
1513 }
1514 if (dc1394_camera_set_power(camera, DC1394_OFF) != DC1394_SUCCESS)
1515 std::cout << "Unable to turn camera off" << std::endl;
1516 }
1517#ifdef VISP_HAVE_DC1394_CAMERA_ENUMERATE // new API > libdc1394-2.0.0-rc7
1518 dc1394_camera_free(cameras[i]);
1519#elif defined VISP_HAVE_DC1394_FIND_CAMERAS // old API <= libdc1394-2.0.0-rc7
1520 dc1394_free_camera(cameras[i]);
1521#endif
1522 }
1523 }
1524 if (camIsOpen != nullptr) {
1525 delete[] camIsOpen;
1526 camIsOpen = nullptr;
1527 }
1528
1529#ifdef VISP_HAVE_DC1394_CAMERA_ENUMERATE // new API > libdc1394-2.0.0-rc7
1530 if (cameras != nullptr) {
1531 delete[] cameras;
1532 cameras = nullptr;
1533 }
1534 if (d != nullptr) {
1535 dc1394_free(d);
1536 d = nullptr;
1537 }
1538
1539#elif defined VISP_HAVE_DC1394_FIND_CAMERAS // old API <= libdc1394-2.0.0-rc7
1540 if (cameras != nullptr) {
1541 free(cameras);
1542 cameras = nullptr;
1543 }
1544#endif
1545
1546 camIsOpen = nullptr;
1547 num_cameras = 0;
1548
1549 // remove data for the parameters
1550 if (isDataModified != nullptr) {
1551 delete[] isDataModified;
1552 isDataModified = nullptr;
1553 }
1554 if (initialShutterMode != nullptr) {
1555 delete[] initialShutterMode;
1556 initialShutterMode = nullptr;
1557 }
1558 if (dataCam != nullptr) {
1559 delete[] dataCam;
1560 dataCam = nullptr;
1561 }
1562
1563 init = false;
1564 }
1565}
1566
1580{
1581 if (size < 1) {
1582 close();
1583 throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Could not set ring buffer size"));
1584 }
1585
1586 if (size != num_buffers) {
1587 // We need to change the ring buffer size
1588 num_buffers = size;
1589 if (camIsOpen[camera_id]) {
1590 setCapture(DC1394_OFF);
1591 setCapture(DC1394_ON);
1592 }
1593 }
1594}
1595
1605unsigned int vp1394TwoGrabber::getRingBufferSize() const { return num_buffers; }
1606
1650{
1651 if (!num_cameras) {
1652 close();
1653 vpERROR_TRACE("No camera found");
1655 }
1656
1657 dc1394feature_mode_t mode;
1658 if (enable) {
1659 mode = DC1394_FEATURE_MODE_AUTO;
1660 }
1661 else {
1662 mode = DC1394_FEATURE_MODE_MANUAL;
1663 }
1664
1665 if (dc1394_feature_set_power(camera, DC1394_FEATURE_SHUTTER, DC1394_ON) != DC1394_SUCCESS) {
1666 // vpERROR_TRACE("Cannot set shutter on. \n");
1667 close();
1668 throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Cannot set shutter on"));
1669 }
1670
1671 if (dc1394_feature_set_mode(camera, DC1394_FEATURE_SHUTTER, mode) != DC1394_SUCCESS) {
1672 // vpERROR_TRACE("Cannot set auto shutter. \n");
1673 close();
1674 throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Cannot set auto shutter"));
1675 }
1676}
1677
1720void vp1394TwoGrabber::setAutoShutter(unsigned int minvalue, unsigned int maxvalue)
1721{
1723
1724 if (dc1394_avt_set_auto_shutter(camera, minvalue, maxvalue) != DC1394_SUCCESS) {
1725 // vpERROR_TRACE("Cannot set auto shutter min and max values. Is the
1726 // camera an AVT one?\n");
1727 close();
1728 throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Cannot set auto shutter min and max values"));
1729 }
1730}
1731
1744void vp1394TwoGrabber::getAutoShutter(unsigned int &minvalue, unsigned int &maxvalue)
1745{
1746 if (!num_cameras) {
1747 close();
1748 vpERROR_TRACE("No camera found");
1750 }
1751
1752 if (dc1394_avt_get_auto_shutter(camera, &minvalue, &maxvalue) != DC1394_SUCCESS) {
1753 // vpERROR_TRACE("Cannot get auto shutter min and max values. Is the
1754 // camera an AVT one?\n");
1755 close();
1756 throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Cannot get auto shutter min and max values"));
1757 }
1758}
1759
1803{
1804 if (!num_cameras) {
1805 close();
1806 vpERROR_TRACE("No camera found");
1808 }
1809
1810 dc1394feature_mode_t mode;
1811 if (enable) {
1812 mode = DC1394_FEATURE_MODE_AUTO;
1813 }
1814 else {
1815 mode = DC1394_FEATURE_MODE_MANUAL;
1816 }
1817
1818 if (dc1394_feature_set_power(camera, DC1394_FEATURE_GAIN, DC1394_ON) != DC1394_SUCCESS) {
1819 // vpERROR_TRACE("Cannot set shutter on. \n");
1820 close();
1821 throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Cannot set shutter on"));
1822 }
1823
1824 if (dc1394_feature_set_mode(camera, DC1394_FEATURE_GAIN, mode) != DC1394_SUCCESS) {
1825 // vpERROR_TRACE("Cannot set auto gain. \n");
1826 close();
1827 throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Cannot set auto gain"));
1828 }
1829}
1830
1873void vp1394TwoGrabber::setAutoGain(unsigned int minvalue, unsigned int maxvalue)
1874{
1875 setAutoGain();
1876
1877 if (dc1394_avt_set_auto_gain(camera, minvalue, maxvalue) != DC1394_SUCCESS) {
1878 // vpERROR_TRACE("Cannot set auto gain min and max values. Is the
1879 // camera an AVT one?\n");
1880 close();
1881 throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Cannot set auto gain min and max values"));
1882 }
1883}
1884
1897void vp1394TwoGrabber::getAutoGain(unsigned int &minvalue, unsigned int &maxvalue)
1898{
1899 if (!num_cameras) {
1900 close();
1901 vpERROR_TRACE("No camera found");
1903 }
1904
1905 if (dc1394_avt_get_auto_gain(camera, &minvalue, &maxvalue) != DC1394_SUCCESS) {
1906 // vpERROR_TRACE("Cannot get auto gain min and max values. Is the
1907 // camera an AVT one?\n");
1908 close();
1909 throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Cannot get auto gain min and max values"));
1910 }
1911}
1912
1930void vp1394TwoGrabber::setCapture(dc1394switch_t _switch)
1931{
1932 if (!num_cameras) {
1933 close();
1934 vpERROR_TRACE("No camera found");
1936 }
1937
1938 if (_switch == DC1394_ON) {
1939 // if (dc1394_capture_setup(camera, num_buffers) != DC1394_SUCCESS) {
1940 // To be compatible with libdc1394 svn 382 version
1941 if (dc1394_capture_setup(camera, num_buffers, DC1394_CAPTURE_FLAGS_DEFAULT) != DC1394_SUCCESS) {
1942 vpERROR_TRACE("Unable to setup camera capture-\n"
1943 "make sure that the video mode and framerate are "
1944 "supported by your camera.\n");
1945 close();
1946 throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Could not setup dma capture"));
1947 }
1948 }
1949 else { // _switch == DC1394_OFF
1950 dc1394error_t code = dc1394_capture_stop(camera);
1951
1952 if (code != DC1394_SUCCESS && code != DC1394_CAPTURE_IS_NOT_SET) {
1953 vpERROR_TRACE("Unable to stop camera capture\n");
1954 close();
1955 throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Could not setup dma capture"));
1956 }
1957 }
1958}
1959
1974void vp1394TwoGrabber::setTransmission(dc1394switch_t _switch)
1975{
1976 if (!num_cameras) {
1977 close();
1978 vpERROR_TRACE("No camera found");
1979 throw(vpFrameGrabberException(vpFrameGrabberException::initializationError, "No camera found"));
1980 }
1981
1982 dc1394switch_t status = DC1394_OFF;
1983
1984 if (dc1394_video_get_transmission(camera, &status) != DC1394_SUCCESS) {
1985 vpERROR_TRACE("Unable to get transmision status");
1986 close();
1987 throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Could not setup dma capture"));
1988 }
1989
1990 // if (status!=_switch){
1991 // Start dma capture if halted
1992 if (dc1394_video_set_transmission(camera, _switch) != DC1394_SUCCESS) {
1993 vpERROR_TRACE("Unable to setup camera capture-\n"
1994 "make sure that the video mode and framerate are "
1995 "supported by your camera.\n");
1996 close();
1997 throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Could not setup dma capture"));
1998 }
1999
2000 if (_switch == DC1394_ON) {
2001 status = DC1394_OFF;
2002
2003 int i = 0;
2004 while (status == DC1394_OFF && i++ < 5) {
2005 usleep(50000);
2006 if (dc1394_video_get_transmission(camera, &status) != DC1394_SUCCESS) {
2007 vpERROR_TRACE("Unable to get transmision status");
2008 close();
2009 throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Could not setup dma capture"));
2010 }
2011 }
2012 }
2013 // }
2014}
2015
2054{
2055 if (!num_cameras) {
2056 close();
2057 vpERROR_TRACE("No camera found");
2059 }
2060
2061 dc1394operation_mode_t op_mode;
2062 dc1394speed_t speed;
2063
2064 // Check the speed to configure in B-mode or A-mode
2065 if (isospeed >= vpISO_SPEED_800) {
2066 if (camera->bmode_capable != DC1394_TRUE) {
2067 close();
2068 throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Camera is not 1394B mode capable"));
2069 }
2070
2071 if (dc1394_video_set_operation_mode(camera, DC1394_OPERATION_MODE_1394B) != DC1394_SUCCESS) {
2072 close();
2073 throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Cannot set camera to 1394B mode"));
2074 }
2075
2076 if (dc1394_video_get_operation_mode(camera, &op_mode) != DC1394_SUCCESS) {
2077 close();
2078 throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Failed to set 1394B mode"));
2079 }
2080 }
2081 else {
2082 if (dc1394_video_set_operation_mode(camera, DC1394_OPERATION_MODE_LEGACY) != DC1394_SUCCESS) {
2083 close();
2084 throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Cannot set camera to 1394A mode"));
2085 }
2086
2087 if (dc1394_video_get_operation_mode(camera, &op_mode) != DC1394_SUCCESS) {
2088 close();
2089 throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Failed to set 1394A mode"));
2090 }
2091 }
2092
2093 if (dc1394_video_set_iso_speed(camera, (dc1394speed_t)isospeed) != DC1394_SUCCESS) {
2094 close();
2095 throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Cannot set requested iso speed"));
2096 }
2097
2098 if (dc1394_video_get_iso_speed(camera, &speed) != DC1394_SUCCESS) {
2099 close();
2100 throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Failed to set iso speed"));
2101 }
2102}
2103
2115{
2116 open();
2117 acquire(I);
2118}
2119
2131{
2132 open();
2133 acquire(I);
2134}
2135
2177dc1394video_frame_t *vp1394TwoGrabber::dequeue()
2178{
2179
2180 if (!num_cameras) {
2181 close();
2182 vpERROR_TRACE("No camera found");
2184 }
2185
2186 dc1394video_frame_t *frame = nullptr;
2187
2188 if (dc1394_capture_dequeue(camera, DC1394_CAPTURE_POLICY_WAIT, &frame) != DC1394_SUCCESS) {
2189 vpERROR_TRACE("Error: Failed to capture from camera %d\n", camera_id);
2190 }
2191
2192 return frame;
2193}
2194
2240{
2241 uint64_t timestamp;
2242 uint32_t id;
2243
2244 dc1394video_frame_t *frame;
2245
2246 frame = dequeue(I, timestamp, id);
2247
2248 return frame;
2249}
2250
2302dc1394video_frame_t *vp1394TwoGrabber::dequeue(vpImage<unsigned char> &I, uint64_t &timestamp, uint32_t &id)
2303{
2304
2305 open();
2306
2307 dc1394video_frame_t *frame;
2308
2309 frame = dequeue();
2310
2311 // Timeval data structure providing the unix time
2312 // [microseconds] at which the frame was captured in the ring buffer.
2313 timestamp = frame->timestamp;
2314 id = frame->id;
2315
2316 this->width = frame->size[0];
2317 this->height = frame->size[1];
2318 unsigned int size = this->width * this->height;
2319
2320 if ((I.getWidth() != this->width) || (I.getHeight() != this->height))
2321 I.resize(this->height, this->width);
2322
2323 switch (frame->color_coding) {
2324 case DC1394_COLOR_CODING_MONO8:
2325 case DC1394_COLOR_CODING_RAW8:
2326 memcpy(I.bitmap, (unsigned char *)frame->image, size * sizeof(unsigned char));
2327 break;
2328 case DC1394_COLOR_CODING_MONO16:
2329 case DC1394_COLOR_CODING_RAW16:
2330 vpImageConvert::MONO16ToGrey((unsigned char *)frame->image, I.bitmap, size);
2331 break;
2332
2333 case DC1394_COLOR_CODING_YUV411:
2334 vpImageConvert::YUV411ToGrey((unsigned char *)frame->image, I.bitmap, size);
2335 break;
2336
2337 case DC1394_COLOR_CODING_YUV422:
2338 vpImageConvert::YUV422ToGrey((unsigned char *)frame->image, I.bitmap, size);
2339 break;
2340
2341 case DC1394_COLOR_CODING_YUV444:
2342 vpImageConvert::YUV444ToGrey((unsigned char *)frame->image, I.bitmap, size);
2343 break;
2344
2345 case DC1394_COLOR_CODING_RGB8:
2346 vpImageConvert::RGBToGrey((unsigned char *)frame->image, I.bitmap, size);
2347 break;
2348
2349 default:
2350 close();
2351 vpERROR_TRACE("Format conversion not implemented. Acquisition failed.");
2352 throw(vpFrameGrabberException(vpFrameGrabberException::otherError, "Format conversion not implemented. "
2353 "Acquisition failed."));
2354 };
2355
2356 return frame;
2357}
2358
2403{
2404 uint64_t timestamp;
2405 uint32_t id;
2406
2407 dc1394video_frame_t *frame;
2408
2409 frame = dequeue(I, timestamp, id);
2410
2411 return frame;
2412}
2413
2465dc1394video_frame_t *vp1394TwoGrabber::dequeue(vpImage<vpRGBa> &I, uint64_t &timestamp, uint32_t &id)
2466{
2467
2468 open();
2469
2470 dc1394video_frame_t *frame;
2471
2472 frame = dequeue();
2473
2474 // Timeval data structure providing the unix time
2475 // [microseconds] at which the frame was captured in the ring buffer.
2476 timestamp = frame->timestamp;
2477 id = frame->id;
2478
2479 this->width = frame->size[0];
2480 this->height = frame->size[1];
2481 unsigned int size = this->width * this->height;
2482
2483 if ((I.getWidth() != width) || (I.getHeight() != height))
2484 I.resize(height, width);
2485
2486 switch (frame->color_coding) {
2487 case DC1394_COLOR_CODING_MONO8:
2488 case DC1394_COLOR_CODING_RAW8:
2489 vpImageConvert::GreyToRGBa((unsigned char *)frame->image, (unsigned char *)I.bitmap, size);
2490 break;
2491
2492 case DC1394_COLOR_CODING_MONO16:
2493 case DC1394_COLOR_CODING_RAW16:
2494 vpImageConvert::MONO16ToRGBa((unsigned char *)frame->image, (unsigned char *)I.bitmap, size);
2495 break;
2496
2497 case DC1394_COLOR_CODING_YUV411:
2498 vpImageConvert::YUV411ToRGBa((unsigned char *)frame->image, (unsigned char *)I.bitmap, size);
2499 break;
2500
2501 case DC1394_COLOR_CODING_YUV422:
2502 vpImageConvert::YUV422ToRGBa((unsigned char *)frame->image, (unsigned char *)I.bitmap, size);
2503 break;
2504
2505 case DC1394_COLOR_CODING_YUV444:
2506 vpImageConvert::YUV444ToRGBa((unsigned char *)frame->image, (unsigned char *)I.bitmap, size);
2507 break;
2508
2509 case DC1394_COLOR_CODING_RGB8:
2510 vpImageConvert::RGBToRGBa((unsigned char *)frame->image, (unsigned char *)I.bitmap, size);
2511 break;
2512
2513 default:
2514 close();
2515 vpERROR_TRACE("Format conversion not implemented. Acquisition failed.");
2516 throw(vpFrameGrabberException(vpFrameGrabberException::otherError, "Format conversion not implemented. "
2517 "Acquisition failed."));
2518 };
2519
2520 return frame;
2521}
2522
2533void vp1394TwoGrabber::enqueue(dc1394video_frame_t *frame)
2534{
2535
2536 if (!num_cameras) {
2537 close();
2538 vpERROR_TRACE("No camera found");
2540 }
2541
2542 if (frame)
2543 dc1394_capture_enqueue(camera, frame);
2544}
2545
2560{
2561 uint64_t timestamp;
2562 uint32_t id;
2563
2564 dc1394video_frame_t *frame;
2565
2566 frame = dequeue(I, timestamp, id);
2567 enqueue(frame);
2568}
2569
2588void vp1394TwoGrabber::acquire(vpImage<unsigned char> &I, uint64_t &timestamp, uint32_t &id)
2589{
2590 dc1394video_frame_t *frame;
2591
2592 open();
2593 frame = dequeue(I, timestamp, id);
2594 enqueue(frame);
2595}
2596
2611{
2612 uint64_t timestamp;
2613 uint32_t id;
2614 dc1394video_frame_t *frame;
2615
2616 open();
2617 frame = dequeue(I, timestamp, id);
2618 enqueue(frame);
2619}
2620
2639void vp1394TwoGrabber::acquire(vpImage<vpRGBa> &I, uint64_t &timestamp, uint32_t &id)
2640{
2641 dc1394video_frame_t *frame;
2642
2643 open();
2644 frame = dequeue();
2645 // Timeval data structure providing the unix time
2646 // [microseconds] at which the frame was captured in the ring buffer.
2647 timestamp = frame->timestamp;
2648 id = frame->id;
2649
2650 this->width = frame->size[0];
2651 this->height = frame->size[1];
2652 unsigned int size = this->width * this->height;
2653
2654 if ((I.getWidth() != width) || (I.getHeight() != height))
2655 I.resize(height, width);
2656
2657 switch (frame->color_coding) {
2658 case DC1394_COLOR_CODING_MONO8:
2659 case DC1394_COLOR_CODING_RAW8:
2660 vpImageConvert::GreyToRGBa((unsigned char *)frame->image, (unsigned char *)I.bitmap, size);
2661 break;
2662
2663 case DC1394_COLOR_CODING_YUV411:
2664 vpImageConvert::YUV411ToRGBa((unsigned char *)frame->image, (unsigned char *)I.bitmap, size);
2665 break;
2666
2667 case DC1394_COLOR_CODING_YUV422:
2668 vpImageConvert::YUV422ToRGBa((unsigned char *)frame->image, (unsigned char *)I.bitmap, size);
2669 break;
2670
2671 case DC1394_COLOR_CODING_YUV444:
2672 vpImageConvert::YUV444ToRGBa((unsigned char *)frame->image, (unsigned char *)I.bitmap, size);
2673 break;
2674
2675 case DC1394_COLOR_CODING_RGB8:
2676 vpImageConvert::RGBToRGBa((unsigned char *)frame->image, (unsigned char *)I.bitmap, size);
2677 break;
2678
2679 default:
2680 close();
2681 vpERROR_TRACE("Format conversion not implemented. Acquisition failed.");
2682 throw(vpFrameGrabberException(vpFrameGrabberException::otherError, "Format conversion not implemented. "
2683 "Acquisition failed."));
2684 };
2685
2686 enqueue(frame);
2687}
2688
2705void vp1394TwoGrabber::getWidth(unsigned int &w)
2706{
2707 if (!num_cameras) {
2708 close();
2709 vpERROR_TRACE("No camera found");
2711 }
2712
2713 w = this->width;
2714}
2715
2734{
2735 if (!num_cameras) {
2736 close();
2737 vpERROR_TRACE("No camera found");
2739 }
2740
2741 return this->width;
2742}
2743
2761void vp1394TwoGrabber::getHeight(unsigned int &h)
2762{
2763 if (!num_cameras) {
2764 close();
2765 vpERROR_TRACE("No camera found");
2767 }
2768
2769 h = this->height;
2770}
2771
2789{
2790 if (!num_cameras) {
2791 close();
2792 vpERROR_TRACE("No camera found");
2794 }
2795
2796 return this->height;
2797}
2798
2805{
2806 std::cout << "----------------------------------------------------------" << std::endl
2807 << "----- Information for camera " << camera_id << " -----" << std::endl
2808 << "----------------------------------------------------------" << std::endl;
2809
2810#ifdef VISP_HAVE_DC1394_CAMERA_ENUMERATE // new API > libdc1394-2.0.0-rc7
2811 dc1394_camera_print_info(camera, stdout);
2812#elif defined VISP_HAVE_DC1394_FIND_CAMERAS // old API <= libdc1394-2.0.0-rc7
2813 dc1394_print_camera_info(camera);
2814#endif
2815
2816 dc1394featureset_t features;
2817#ifdef VISP_HAVE_DC1394_CAMERA_ENUMERATE // new API > libdc1394-2.0.0-rc7
2818 if (dc1394_feature_get_all(camera, &features) != DC1394_SUCCESS)
2819#elif defined VISP_HAVE_DC1394_FIND_CAMERAS // old API <= libdc1394-2.0.0-rc7
2820 if (dc1394_get_camera_feature_set(camera, &features) != DC1394_SUCCESS)
2821#endif
2822 {
2823 close();
2824 vpERROR_TRACE("unable to get feature set for camera %d\n", camera_id);
2825 throw(vpFrameGrabberException(vpFrameGrabberException::initializationError, "Cannot get camera features"));
2826
2827 }
2828 else {
2829#ifdef VISP_HAVE_DC1394_CAMERA_ENUMERATE // new API > libdc1394-2.0.0-rc7
2830 dc1394_feature_print_all(&features, stdout);
2831#elif defined VISP_HAVE_DC1394_FIND_CAMERAS // old API <= libdc1394-2.0.0-rc7
2832 dc1394_print_feature_set(&features);
2833#endif
2834 }
2835 std::cout << "----------------------------------------------------------" << std::endl;
2836}
2837
2851{
2852 std::string _str = "";
2853 dc1394video_mode_t _videomode = (dc1394video_mode_t)videomode;
2854
2855 if ((_videomode >= DC1394_VIDEO_MODE_MIN) && (_videomode <= DC1394_VIDEO_MODE_MAX)) {
2856 _str = strVideoMode[_videomode - DC1394_VIDEO_MODE_MIN];
2857 }
2858 else {
2859 vpCERROR << "The video mode " << static_cast<int>(videomode) << " is not supported by the camera" << std::endl;
2860 }
2861
2862 return _str;
2863}
2864
2878{
2879 std::string _str = "";
2880 dc1394framerate_t _fps = (dc1394framerate_t)fps;
2881
2882 if ((_fps >= DC1394_FRAMERATE_MIN) && (_fps <= DC1394_FRAMERATE_MAX)) {
2883 _str = strFramerate[_fps - DC1394_FRAMERATE_MIN];
2884 }
2885 else {
2886 vpCERROR << "The framerate " << static_cast<int>(fps) << " is not supported by the camera" << std::endl;
2887 }
2888
2889 return _str;
2890}
2891
2905{
2906 std::string _str = "";
2907 dc1394color_coding_t _coding = (dc1394color_coding_t)colorcoding;
2908
2909 if ((_coding >= DC1394_COLOR_CODING_MIN) && (_coding <= DC1394_COLOR_CODING_MAX)) {
2910 _str = strColorCoding[_coding - DC1394_COLOR_CODING_MIN];
2911
2912 }
2913 else {
2914 vpCERROR << "The color coding " << static_cast<int>(colorcoding) << " is not supported by the camera" << std::endl;
2915 }
2916
2917 return _str;
2918}
2919
2938{
2940
2941 for (int i = DC1394_VIDEO_MODE_MIN; i <= DC1394_VIDEO_MODE_MAX; i++) {
2942 _id = (vp1394TwoVideoModeType)i;
2943 if (videomode.compare(videoMode2string(_id)) == 0)
2944 return _id;
2945 };
2946
2947 throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "The required videomode is not valid"));
2948
2949 return (vp1394TwoVideoModeType)0;
2950}
2951
2970{
2972
2973 for (int i = DC1394_FRAMERATE_MIN; i <= DC1394_FRAMERATE_MAX; i++) {
2974 _id = (vp1394TwoFramerateType)i;
2975 if (framerate.compare(framerate2string(_id)) == 0)
2976 return _id;
2977 };
2978
2979 throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "The required framerate is not valid"));
2980
2981 return (vp1394TwoFramerateType)0;
2982}
2983
3002{
3004
3005 for (int i = DC1394_COLOR_CODING_MIN; i <= DC1394_COLOR_CODING_MAX; i++) {
3006 _id = (vp1394TwoColorCodingType)i;
3007 if (colorcoding.compare(colorCoding2string(_id)) == 0)
3008 return _id;
3009 };
3010
3011 throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "The required color coding is not valid"));
3012
3013 return (vp1394TwoColorCodingType)0;
3014}
3015
3052{
3053 for (unsigned int i = 0; i < num_cameras; i++) {
3054 if (camIsOpen[i]) {
3055 camera = cameras[i];
3056 setTransmission(DC1394_OFF);
3057 setCapture(DC1394_OFF);
3058 }
3059 }
3060#ifdef VISP_HAVE_DC1394_CAMERA_ENUMERATE // new API > libdc1394-2.0.0-rc7
3061 setCamera(camera_id);
3062 // free the other cameras
3063 for (unsigned int i = 0; i < num_cameras; i++) {
3064 if (i != camera_id)
3065 dc1394_camera_free(cameras[i]);
3066 }
3067
3068 printf("Resetting bus...\n");
3069 dc1394_reset_bus(camera);
3070
3071 dc1394_camera_free(camera);
3072 dc1394_free(d);
3073 d = nullptr;
3074 // if (cameras != nullptr)
3075 delete[] cameras;
3076 cameras = nullptr;
3077#elif defined VISP_HAVE_DC1394_FIND_CAMERAS // old API <= libdc1394-2.0.0-rc7
3078
3079 setCamera(camera_id);
3080 // free the other cameras
3081 for (unsigned int i = 0; i < num_cameras; i++) {
3082 if (i != camera_id)
3083 dc1394_free_camera(cameras[i]);
3084 }
3085 free(cameras);
3086 cameras = nullptr;
3087
3088 dc1394_reset_bus(camera);
3089 dc1394_free_camera(camera);
3090
3091#endif
3092 if (camIsOpen != nullptr)
3093 delete[] camIsOpen;
3094 camIsOpen = nullptr;
3095
3096 num_cameras = 0;
3097
3098 init = false;
3099 vpTime::wait(1000);
3100 initialize(false);
3101}
3102
3133void vp1394TwoGrabber::setPanControl(unsigned int panControlValue)
3134{
3135 open();
3136 if (!num_cameras) {
3137 close();
3138 vpERROR_TRACE("No camera found");
3140 }
3141 uint64_t offset = 0x884;
3142 uint32_t value = 0x82000000 + static_cast<uint32_t>(panControlValue);
3143 dc1394error_t err;
3144 err = dc1394_set_control_register(camera, offset, value);
3145 if (err != DC1394_SUCCESS) {
3146 vpERROR_TRACE("Unable to set PAN register");
3147 close();
3148 throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Unable to set PAN register"));
3149 }
3150}
3151
3169{
3170 if (!num_cameras) {
3171 close();
3172 vpERROR_TRACE("No camera found");
3174 }
3175
3176 uint32_t value;
3177 dc1394feature_t feature = DC1394_FEATURE_BRIGHTNESS; // = (dc1394feature_t)param;
3178 switch (param) {
3180 feature = DC1394_FEATURE_BRIGHTNESS;
3181 break;
3182 case vpFEATURE_EXPOSURE:
3183 feature = DC1394_FEATURE_EXPOSURE;
3184 break;
3186 feature = DC1394_FEATURE_SHARPNESS;
3187 break;
3188 // vpFEATURE_WHITE_BALANCE = DC1394_FEATURE_WHITE_BALANCE,
3189 case vpFEATURE_HUE:
3190 feature = DC1394_FEATURE_HUE;
3191 break;
3193 feature = DC1394_FEATURE_SATURATION;
3194 break;
3195 case vpFEATURE_GAMMA:
3196 feature = DC1394_FEATURE_GAMMA;
3197 break;
3198 case vpFEATURE_SHUTTER:
3199 feature = DC1394_FEATURE_SHUTTER;
3200 break;
3201 case vpFEATURE_GAIN:
3202 feature = DC1394_FEATURE_GAIN;
3203 break;
3204 case vpFEATURE_IRIS:
3205 feature = DC1394_FEATURE_IRIS;
3206 break;
3207 // vpFEATURE_FOCUS = DC1394_FEATURE_FOCUS,
3208 // vpFEATURE_TEMPERATURE = DC1394_FEATURE_TEMPERATURE,
3209 // vpFEATURE_TRIGGER = DC1394_FEATURE_TRIGGER,
3210 // vpFEATURE_TRIGGER_DELAY = DC1394_FEATURE_TRIGGER_DELAY,
3211 // vpFEATURE_WHITE_SHADING = DC1394_FEATURE_WHITE_SHADING,
3212 // vpFEATURE_FRAME_RATE = DC1394_FEATURE_FRAME_RATE,
3213 // vpFEATURE_ZOOM = DC1394_FEATURE_ZOOM,
3214 // vpFEATURE_PAN = DC1394_FEATURE_PAN,
3215 // vpFEATURE_TILT = DC1394_FEATURE_TILT,
3216 // vpFEATURE_OPTICAL_FILTER = DC1394_FEATURE_OPTICAL_FILTER,
3217 // vpFEATURE_CAPTURE_SIZE = DC1394_FEATURE_CAPTURE_SIZE,
3218 // vpFEATURE_CAPTURE_QUALITY = DC1394_FEATURE_CAPTURE_QUALITY
3219 }
3220
3221 dc1394error_t err;
3222 err = dc1394_feature_get_value(camera, feature, &value);
3223 if (err != DC1394_SUCCESS) {
3224 vpERROR_TRACE("Unable to get the information");
3225 close();
3226 throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Unable to get the information"));
3227 }
3228 return (static_cast<unsigned int>(value));
3229}
3230
3253{
3254 if (!num_cameras) {
3255 close();
3256 vpERROR_TRACE("No camera found");
3258 }
3259 uint32_t value = static_cast<uint32_t>(val);
3260 dc1394feature_t feature = DC1394_FEATURE_BRIGHTNESS; // = (dc1394feature_t)param;
3261 switch (param) {
3263 feature = DC1394_FEATURE_BRIGHTNESS;
3264 break;
3265 case vpFEATURE_EXPOSURE:
3266 feature = DC1394_FEATURE_EXPOSURE;
3267 break;
3269 feature = DC1394_FEATURE_SHARPNESS;
3270 break;
3271 // vpFEATURE_WHITE_BALANCE = DC1394_FEATURE_WHITE_BALANCE,
3272 case vpFEATURE_HUE:
3273 feature = DC1394_FEATURE_HUE;
3274 break;
3276 feature = DC1394_FEATURE_SATURATION;
3277 break;
3278 case vpFEATURE_GAMMA:
3279 feature = DC1394_FEATURE_GAMMA;
3280 break;
3281 case vpFEATURE_SHUTTER:
3282 feature = DC1394_FEATURE_SHUTTER;
3283 break;
3284 case vpFEATURE_GAIN:
3285 feature = DC1394_FEATURE_GAIN;
3286 break;
3287 case vpFEATURE_IRIS:
3288 feature = DC1394_FEATURE_IRIS;
3289 break;
3290 // vpFEATURE_FOCUS = DC1394_FEATURE_FOCUS,
3291 // vpFEATURE_TEMPERATURE = DC1394_FEATURE_TEMPERATURE,
3292 // vpFEATURE_TRIGGER = DC1394_FEATURE_TRIGGER,
3293 // vpFEATURE_TRIGGER_DELAY = DC1394_FEATURE_TRIGGER_DELAY,
3294 // vpFEATURE_WHITE_SHADING = DC1394_FEATURE_WHITE_SHADING,
3295 // vpFEATURE_FRAME_RATE = DC1394_FEATURE_FRAME_RATE,
3296 // vpFEATURE_ZOOM = DC1394_FEATURE_ZOOM,
3297 // vpFEATURE_PAN = DC1394_FEATURE_PAN,
3298 // vpFEATURE_TILT = DC1394_FEATURE_TILT,
3299 // vpFEATURE_OPTICAL_FILTER = DC1394_FEATURE_OPTICAL_FILTER,
3300 // vpFEATURE_CAPTURE_SIZE = DC1394_FEATURE_CAPTURE_SIZE,
3301 // vpFEATURE_CAPTURE_QUALITY = DC1394_FEATURE_CAPTURE_QUALITY
3302 }
3303
3304 dc1394error_t err;
3305 dc1394bool_t hasManualMode = DC1394_FALSE;
3306 dc1394feature_modes_t modesAvailable;
3307
3308 // test wether we can set the shutter value (manual mode available or not)
3309 err = dc1394_feature_get_modes(camera, feature, &modesAvailable);
3310 if (err != DC1394_SUCCESS) {
3311 vpERROR_TRACE("Unable to detect the manual mode information");
3312 close();
3313 throw(
3314 vpFrameGrabberException(vpFrameGrabberException::settingError, "Unable to detect the manual mode information"));
3315 }
3316
3317 for (unsigned int i = 0; i < modesAvailable.num; i++) {
3318 if (modesAvailable.modes[i] == DC1394_FEATURE_MODE_MANUAL) {
3319 hasManualMode = DC1394_TRUE;
3320 }
3321 }
3322
3323 if (hasManualMode == DC1394_TRUE) {
3324
3325 if (!isDataModified[camera_id]) { // to ensure we save the first mode
3326 // even after several set
3327 /* we update the structure */
3328 updateDataCamToStruct();
3329 err = dc1394_feature_get_mode(camera, feature, &(initialShutterMode[camera_id]));
3330 if (err != DC1394_SUCCESS) {
3331 vpERROR_TRACE("Unable to get the initial mode");
3332 close();
3333 throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Unable to get the initial mode"));
3334 }
3335 isDataModified[camera_id] = true;
3336 }
3337
3338 dc1394feature_mode_t manualMode = DC1394_FEATURE_MODE_MANUAL;
3339 err = dc1394_feature_set_mode(camera, feature, manualMode);
3340 if (err != DC1394_SUCCESS) {
3341 vpERROR_TRACE("Unable to set the muanual mode");
3342 close();
3343 throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Unable to set the manual mode"));
3344 }
3345 err = dc1394_feature_set_value(camera, feature, value);
3346 if (err != DC1394_SUCCESS) {
3347 vpERROR_TRACE("Unable to set the shutter information");
3348 close();
3349 throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "Unable to set the shutter information"));
3350 }
3351 }
3352 else {
3353 vpERROR_TRACE("The camera does not have a manual mode.\nCannot change the value");
3354 throw(vpFrameGrabberException(vpFrameGrabberException::settingError, "The camera does not have a manual mode"));
3355 }
3356}
3357
3364void vp1394TwoGrabber::getGuid(uint64_t &guid)
3365{
3366 if (!num_cameras) {
3367 close();
3368 vpERROR_TRACE("No camera found");
3370 }
3371
3372 guid = camera->guid;
3373}
3374
3383{
3384 if (!num_cameras) {
3385 close();
3386 vpERROR_TRACE("No camera found");
3388 }
3389
3390 return camera->guid;
3391}
3392
3397inline void vp1394TwoGrabber::updateDataCamToStruct()
3398{
3399 dataCam[camera_id].brightness = getParameterValue(vpFEATURE_BRIGHTNESS);
3400 dataCam[camera_id].exposure = getParameterValue(vpFEATURE_EXPOSURE);
3401 dataCam[camera_id].sharpness = getParameterValue(vpFEATURE_SHARPNESS);
3402 dataCam[camera_id].hue = getParameterValue(vpFEATURE_HUE);
3403 dataCam[camera_id].saturation = getParameterValue(vpFEATURE_SATURATION);
3404 dataCam[camera_id].gamma = getParameterValue(vpFEATURE_GAMMA);
3405 dataCam[camera_id].shutter = getParameterValue(vpFEATURE_SHUTTER);
3406 dataCam[camera_id].gain = getParameterValue(vpFEATURE_GAIN);
3407 dataCam[camera_id].iris = getParameterValue(vpFEATURE_IRIS);
3408}
3409
3414inline void vp1394TwoGrabber::updateDataStructToCam()
3415{
3416 setParameterValue(vpFEATURE_BRIGHTNESS, dataCam[camera_id].brightness);
3417 setParameterValue(vpFEATURE_EXPOSURE, dataCam[camera_id].exposure);
3418 setParameterValue(vpFEATURE_SHARPNESS, dataCam[camera_id].sharpness);
3419 setParameterValue(vpFEATURE_HUE, dataCam[camera_id].hue);
3420 setParameterValue(vpFEATURE_SATURATION, dataCam[camera_id].saturation);
3421 setParameterValue(vpFEATURE_GAMMA, dataCam[camera_id].gamma);
3422 setParameterValue(vpFEATURE_SHUTTER, dataCam[camera_id].shutter);
3423 setParameterValue(vpFEATURE_GAIN, dataCam[camera_id].gain);
3424 setParameterValue(vpFEATURE_IRIS, dataCam[camera_id].iris);
3425}
3426
3448{
3449 this->acquire(I);
3450 return *this;
3451}
3452
3473{
3474 this->acquire(I);
3475 return *this;
3476}
3477END_VISP_NAMESPACE
3478#elif !defined(VISP_BUILD_SHARED_LIBS)
3479// Work around to avoid warning: libvisp_sensor.a(vp1394TwoGrabber.cpp.o) has
3480// no symbols
3481void dummy_vp1394TwoGrabber() { }
3482#endif
void setAutoShutter(bool enable=true)
static const char * strColorCoding[DC1394_COLOR_CODING_NUM]
void getVideoMode(vp1394TwoVideoModeType &videomode)
void setAutoGain(bool enable=true)
void setParameterValue(vp1394TwoParametersType param, unsigned int val)
static std::string colorCoding2string(vp1394TwoColorCodingType colorcoding)
void setRingBufferSize(unsigned int size)
void getFramerate(vp1394TwoFramerateType &fps)
uint32_t getFramerateSupported(vp1394TwoVideoModeType videomode, std::list< vp1394TwoFramerateType > &fps)
void acquire(vpImage< unsigned char > &I)
void setPanControl(unsigned int panControlValue)
static vp1394TwoColorCodingType string2colorCoding(std::string colorcoding)
static vp1394TwoVideoModeType string2videoMode(std::string videomode)
void setColorCoding(vp1394TwoColorCodingType coding)
bool isVideoModeFormat7(vp1394TwoVideoModeType videomode)
void setVideoMode(vp1394TwoVideoModeType videomode)
unsigned int getRingBufferSize() const
void setFormat7ROI(unsigned int left=0, unsigned int top=0, unsigned int width=0, unsigned int height=0)
void getAutoShutter(unsigned int &minvalue, unsigned int &maxvalue)
unsigned int getNumCameras() const
void setCamera(uint64_t camera)
unsigned int getWidth()
static vp1394TwoFramerateType string2framerate(std::string fps)
void enqueue(dc1394video_frame_t *frame)
vp1394TwoGrabber & operator>>(vpImage< unsigned char > &I)
unsigned int getParameterValue(vp1394TwoParametersType param)
void getAutoGain(unsigned int &minvalue, unsigned int &maxvalue)
void getColorCoding(vp1394TwoColorCodingType &coding)
void setIsoTransmissionSpeed(vp1394TwoIsoSpeedType isospeed)
uint32_t getColorCodingSupported(vp1394TwoVideoModeType videomode, std::list< vp1394TwoColorCodingType > &codings)
void setFramerate(vp1394TwoFramerateType fps)
static std::string framerate2string(vp1394TwoFramerateType fps)
unsigned int getHeight()
bool isColorCodingSupported(vp1394TwoVideoModeType videomode, vp1394TwoColorCodingType coding)
bool isFramerateSupported(vp1394TwoVideoModeType videomode, vp1394TwoFramerateType fps)
dc1394video_frame_t * dequeue()
static std::string videoMode2string(vp1394TwoVideoModeType videomode)
static const char * strVideoMode[DC1394_VIDEO_MODE_NUM]
VP_EXPLICIT vp1394TwoGrabber(bool reset=true)
bool isVideoModeSupported(vp1394TwoVideoModeType videomode)
uint32_t getVideoModeSupported(std::list< vp1394TwoVideoModeType > &videomodes)
void open(vpImage< unsigned char > &I)
static const char * strFramerate[DC1394_FRAMERATE_NUM]
Error that can be emitted by the vpFrameGrabber class and its derivates.
@ settingError
Grabber settings error.
@ initializationError
Grabber initialization error.
@ otherError
Grabber returned an other error.
unsigned int height
Number of rows in the image.
bool init
Set to true if the frame grabber has been initialized.
unsigned int width
Number of columns in the image.
static void YUV411ToGrey(unsigned char *yuv, unsigned char *grey, unsigned int size)
static void MONO16ToGrey(unsigned char *grey16, unsigned char *grey, unsigned int size)
static void YUV422ToGrey(unsigned char *yuv, unsigned char *grey, unsigned int size)
static void YUV411ToRGBa(unsigned char *yuv, unsigned char *rgba, unsigned int size)
static void GreyToRGBa(unsigned char *grey, unsigned char *rgba, unsigned int width, unsigned int height)
static void MONO16ToRGBa(unsigned char *grey16, unsigned char *rgba, unsigned int size)
static void RGBToGrey(unsigned char *rgb, unsigned char *grey, unsigned int width, unsigned int height, bool flip=false)
static void RGBToRGBa(unsigned char *rgb, unsigned char *rgba, unsigned int size)
static void YUV422ToRGBa(unsigned char *yuv, unsigned char *rgba, unsigned int size)
static void YUV444ToRGBa(unsigned char *yuv, unsigned char *rgba, unsigned int size)
static void YUV444ToGrey(unsigned char *yuv, unsigned char *grey, unsigned int size)
Definition of the vpImage class member functions.
Definition vpImage.h:131
#define vpCTRACE
Definition vpDebug.h:362
#define vpCERROR
Definition vpDebug.h:393
#define vpTRACE
Definition vpDebug.h:450
#define vpERROR_TRACE
Definition vpDebug.h:423
VISP_EXPORT int wait(double t0, double t)