tools/Calibration/main.cpp
Go to the documentation of this file.
1 /*
2 Copyright (c) 2010-2016, Mathieu Labbe - IntRoLab - Universite de Sherbrooke
3 All rights reserved.
4 
5 Redistribution and use in source and binary forms, with or without
6 modification, are permitted provided that the following conditions are met:
7  * Redistributions of source code must retain the above copyright
8  notice, this list of conditions and the following disclaimer.
9  * Redistributions in binary form must reproduce the above copyright
10  notice, this list of conditions and the following disclaimer in the
11  documentation and/or other materials provided with the distribution.
12  * Neither the name of the Universite de Sherbrooke nor the
13  names of its contributors may be used to endorse or promote products
14  derived from this software without specific prior written permission.
15 
16 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
17 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
20 DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27 
29 #include "rtabmap/core/CameraRGB.h"
35 #include <QApplication>
36 
37 void showUsage()
38 {
39  printf("\nUsage:\n"
40  "rtabmap-calibration [options]\n"
41  "Options:\n"
42  " --driver # Driver number to use:-1=USB camera\n"
43  " 0=OpenNI-PCL (Kinect)\n"
44  " 1=OpenNI2 (Kinect and Xtion PRO Live)\n"
45  " 2=Freenect (Kinect)\n"
46  " 3=OpenNI-CV (Kinect)\n"
47  " 4=OpenNI-CV-ASUS (Xtion PRO Live)\n"
48  " 5=Freenect2 (Kinect v2)\n"
49  " 6=DC1394 (Bumblebee2)\n"
50  " 7=FlyCapture2 (Bumblebee2)\n"
51  " 11=RealSense2 (T265)\n"
52  " --device # Device id\n"
53  " --debug Debug log\n"
54  " --stereo Stereo: assuming device provides \n"
55  " side-by-side stereo images, otherwise \n"
56  " add also \"--device_r #\" for the right device.\n\n");
57  exit(1);
58 }
59 
60 int main(int argc, char * argv[])
61 {
64  ULogger::setPrintTime(false);
66 
67  int driver = -1;
68  int device = 0;
69  int deviceRight = -1;
70  bool stereo = false;
71  for(int i=1; i<argc; ++i)
72  {
73  if(strcmp(argv[i], "--driver") == 0)
74  {
75  ++i;
76  if(i < argc)
77  {
78  driver = std::atoi(argv[i]);
79  if(driver < -1)
80  {
81  showUsage();
82  }
83  }
84  else
85  {
86  showUsage();
87  }
88  continue;
89  }
90  if(strcmp(argv[i], "--device") == 0)
91  {
92  ++i;
93  if(i < argc)
94  {
95  device = std::atoi(argv[i]);
96  if(device < 0)
97  {
98  showUsage();
99  }
100  }
101  else
102  {
103  showUsage();
104  }
105  continue;
106  }
107  if(strcmp(argv[i], "--device_r") == 0)
108  {
109  ++i;
110  if(i < argc)
111  {
112  deviceRight = std::atoi(argv[i]);
113  if(deviceRight < 0)
114  {
115  showUsage();
116  }
117  }
118  else
119  {
120  showUsage();
121  }
122  continue;
123  }
124  if(strcmp(argv[i], "--debug") == 0)
125  {
127  ULogger::setPrintTime(true);
129  continue;
130  }
131  if(strcmp(argv[i], "--stereo") == 0)
132  {
133  stereo=true;
134  continue;
135  }
136  if(strcmp(argv[i], "--help") == 0)
137  {
138  showUsage();
139  }
140  printf("Unrecognized option : %s\n", argv[i]);
141  showUsage();
142  }
143  if(driver < -1 || driver > 15)
144  {
145  UERROR("driver should be between -1 and 15.");
146  showUsage();
147  }
148  if(driver == 11)
149  {
150  stereo = true;
151  }
152 
153  UINFO("Using driver %d", driver);
154  UINFO("Using device %d", device);
155  UINFO("Stereo: %s", stereo?"true":"false");
156  if(stereo && deviceRight >= 0)
157  {
158  UINFO("Using right device %d", deviceRight);
159  }
160 
161  QApplication app(argc, argv);
162  rtabmap::CalibrationDialog dialog(stereo, ".");
163 
164  rtabmap::Camera * camera = 0;
165  if(driver == -1)
166  {
167  if(stereo)
168  {
169  if(deviceRight>=0)
170  {
171  // left and right videos
172  camera = new rtabmap::CameraStereoVideo(device, deviceRight);
173  }
174  else
175  {
176  // side-by-side video
178  }
179  }
180  else
181  {
183  }
184  dialog.setStereoMode(stereo);
185  }
186  else if(driver == 0)
187  {
189  }
190  else if(driver == 1)
191  {
193  {
194  UERROR("Not built with OpenNI2 support...");
195  exit(-1);
196  }
198  }
199  else if(driver == 2)
200  {
202  {
203  UERROR("Not built with Freenect support...");
204  exit(-1);
205  }
207  }
208  else if(driver == 3)
209  {
211  {
212  UERROR("Not built with OpenNI from OpenCV support...");
213  exit(-1);
214  }
215  camera = new rtabmap::CameraOpenNICV(false);
216  }
217  else if(driver == 4)
218  {
220  {
221  UERROR("Not built with OpenNI from OpenCV support...");
222  exit(-1);
223  }
224  camera = new rtabmap::CameraOpenNICV(true);
225  }
226  else if(driver == 5)
227  {
229  {
230  UERROR("Not built with Freenect2 support...");
231  exit(-1);
232  }
234  dialog.setSwitchedImages(true);
235  dialog.setStereoMode(stereo, "rgb", "depth");
236  }
237  else if(driver == 6)
238  {
240  {
241  UERROR("Not built with DC1394 support...");
242  exit(-1);
243  }
245  dialog.setStereoMode(stereo);
246  }
247  else if(driver == 7)
248  {
250  {
251  UERROR("Not built with FlyCapture2/Triclops support...");
252  exit(-1);
253  }
255  dialog.setStereoMode(stereo);
256  }
257  else if(driver == 11)
258  {
260  {
261  UERROR("Not built with RealSense2 support...");
262  exit(-1);
263  }
265  ((rtabmap::CameraRealSense2*)camera)->setImagesRectified(false);
266  dialog.setStereoMode(true);
267  dialog.setFisheyeModel();
268  }
269  else
270  {
271  UFATAL("Calibration for driver %d not available.", driver);
272  }
273 
274  rtabmap::SensorCaptureThread * cameraThread = 0;
275 
276  if(camera)
277  {
278  if(!camera->init(""))
279  {
280  printf("Camera init failed!\n");
281  delete camera;
282  exit(1);
283  }
284  cameraThread = new rtabmap::SensorCaptureThread(camera);
285  }
286 
287  dialog.registerToEventsManager();
288 
289  dialog.show();
290  cameraThread->start();
291  app.exec();
292  cameraThread->join(true);
293  delete cameraThread;
294 }
rtabmap::SensorCaptureThread
Definition: SensorCaptureThread.h:58
rtabmap::CalibrationDialog::setSwitchedImages
void setSwitchedImages(bool switched)
Definition: CalibrationDialog.cpp:333
UINFO
#define UINFO(...)
rtabmap::CameraStereoVideo
Definition: CameraStereoVideo.h:36
SensorCaptureThread.h
rtabmap::CameraStereoFlyCapture2::available
static bool available()
Definition: CameraStereoFlyCapture2.cpp:68
rtabmap::CameraFreenect::available
static bool available()
Definition: CameraFreenect.cpp:284
UEventsHandler::registerToEventsManager
void registerToEventsManager()
Definition: UEventsHandler.cpp:29
rtabmap::CameraStereoDC1394::available
static bool available()
Definition: CameraStereoDC1394.cpp:317
ULogger::kTypeConsole
@ kTypeConsole
Definition: ULogger.h:244
rtabmap::CameraFreenect2::kTypeColorIR
@ kTypeColorIR
Definition: CameraFreenect2.h:58
ULogger::setLevel
static void setLevel(ULogger::Level level)
Definition: ULogger.h:339
UThread::join
void join(bool killFirst=false)
Definition: UThread.cpp:85
ULogger::kDebug
@ kDebug
Definition: ULogger.h:252
CameraRGBD.h
CameraStereo.h
rtabmap::CameraFreenect2::available
static bool available()
Definition: CameraFreenect2.cpp:45
main
int main(int argc, char *argv[])
Definition: tools/Calibration/main.cpp:60
rtabmap::CameraFreenect
Definition: CameraFreenect.h:44
UFATAL
#define UFATAL(...)
ULogger::setPrintTime
static void setPrintTime(bool printTime)
Definition: ULogger.h:273
app
QApplication * app
Definition: tools/DataRecorder/main.cpp:59
rtabmap::CameraFreenect2
Definition: CameraFreenect2.h:46
rtabmap::CameraOpenNI2
Definition: CameraOpenNI2.h:42
UConversion.h
Some conversion functions.
rtabmap::CameraRealSense2
Definition: CameraRealSense2.h:54
CalibrationDialog.h
rtabmap_superglue.device
string device
Definition: rtabmap_superglue.py:21
rtabmap::CalibrationDialog::setFisheyeModel
void setFisheyeModel()
Definition: CalibrationDialog.cpp:338
ULogger::kInfo
@ kInfo
Definition: ULogger.h:252
rtabmap_netvlad.argv
argv
Definition: rtabmap_netvlad.py:15
rtabmap::CalibrationDialog::setStereoMode
void setStereoMode(bool stereo, const QString &leftSuffix="left", const QString &rightSuffix="right")
Definition: CalibrationDialog.cpp:353
UThread::start
void start()
Definition: UThread.cpp:122
ULogger::setType
static void setType(Type type, const std::string &fileName=kDefaultLogFileName, bool append=true)
Definition: ULogger.cpp:176
CameraRGB.h
rtabmap::Camera
Definition: Camera.h:43
rtabmap::CameraOpenNICV
Definition: CameraOpenNICV.h:36
rtabmap::CameraStereoDC1394
Definition: CameraStereoDC1394.h:39
ULogger::setPrintWhere
static void setPrintWhere(bool printWhere)
Definition: ULogger.h:302
ULogger.h
ULogger class and convenient macros.
rtabmap::CameraOpenNICV::available
static bool available()
Definition: CameraOpenNICV.cpp:36
showUsage
void showUsage()
Definition: tools/Calibration/main.cpp:37
rtabmap::CameraStereoFlyCapture2
Definition: CameraStereoFlyCapture2.h:41
rtabmap::CameraRealSense2::available
static bool available()
Definition: CameraRealSense2.cpp:45
camera
Camera camera(Pose3(Rot3().retract(Vector3(0.1, 0.2, 0.3)), Point3(0, 5, 0)), Cal3Bundler0(1, 0, 0))
rtabmap::CalibrationDialog
Definition: CalibrationDialog.h:52
rtabmap::CameraOpenNI2::available
static bool available()
Definition: CameraOpenNI2.cpp:42
UERROR
#define UERROR(...)
i
int i
rtabmap::CameraOpenni
Definition: CameraOpenni.h:55
rtabmap::CameraVideo
Definition: CameraVideo.h:36


rtabmap
Author(s): Mathieu Labbe
autogenerated on Thu Jul 25 2024 02:50:12