Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 #include "rtabmap/core/Camera.h"
00029 #include "rtabmap/core/CameraRGBD.h"
00030 #include "rtabmap/core/CameraThread.h"
00031 #include "rtabmap/utilite/ULogger.h"
00032 #include "rtabmap/utilite/UConversion.h"
00033 #include "rtabmap/gui/CalibrationDialog.h"
00034 #include <QApplication>
00035
00036 void showUsage()
00037 {
00038 printf("\nUsage:\n"
00039 "rtabmap-calibration [options]\n"
00040 "Options:\n"
00041 " --driver # Driver number to use:-1=USB camera\n"
00042 " 0=OpenNI-PCL (Kinect)\n"
00043 " 1=OpenNI2 (Kinect and Xtion PRO Live)\n"
00044 " 2=Freenect (Kinect)\n"
00045 " 3=OpenNI-CV (Kinect)\n"
00046 " 4=OpenNI-CV-ASUS (Xtion PRO Live)\n"
00047 " 5=Freenect2 (Kinect v2)\n"
00048 " 6=DC1394 (Bumblebee2)\n"
00049 " 7=FlyCapture2 (Bumblebee2)\n"
00050 " --device # Device id\n"
00051 " --debug Debug log\n"
00052 " --stereo Stereo\n\n");
00053 exit(1);
00054 }
00055
00056 int main(int argc, char * argv[])
00057 {
00058 ULogger::setType(ULogger::kTypeConsole);
00059 ULogger::setLevel(ULogger::kInfo);
00060 ULogger::setPrintTime(false);
00061 ULogger::setPrintWhere(false);
00062
00063 int driver = -1;
00064 int device = 0;
00065 bool stereo = false;
00066 for(int i=1; i<argc; ++i)
00067 {
00068 if(strcmp(argv[i], "--driver") == 0)
00069 {
00070 ++i;
00071 if(i < argc)
00072 {
00073 driver = std::atoi(argv[i]);
00074 if(driver < -1)
00075 {
00076 showUsage();
00077 }
00078 }
00079 else
00080 {
00081 showUsage();
00082 }
00083 continue;
00084 }
00085 if(strcmp(argv[i], "--device") == 0)
00086 {
00087 ++i;
00088 if(i < argc)
00089 {
00090 device = std::atoi(argv[i]);
00091 if(device < 0)
00092 {
00093 showUsage();
00094 }
00095 }
00096 else
00097 {
00098 showUsage();
00099 }
00100 continue;
00101 }
00102 if(strcmp(argv[i], "--debug") == 0)
00103 {
00104 ULogger::setLevel(ULogger::kDebug);
00105 ULogger::setPrintTime(true);
00106 ULogger::setPrintWhere(true);
00107 continue;
00108 }
00109 if(strcmp(argv[i], "--stereo") == 0)
00110 {
00111 stereo=true;
00112 continue;
00113 }
00114 if(strcmp(argv[i], "--help") == 0)
00115 {
00116 showUsage();
00117 }
00118 printf("Unrecognized option : %s\n", argv[i]);
00119 showUsage();
00120 }
00121 if(driver < -1 || driver > 7)
00122 {
00123 UERROR("driver should be between -1 and 7.");
00124 showUsage();
00125 }
00126
00127 UINFO("Using driver %d", driver);
00128 UINFO("Using device %d", device);
00129 UINFO("Stereo: %s", stereo?"true":"false");
00130
00131 bool switchImages = false;
00132
00133 rtabmap::Camera * cameraUsb = 0;
00134 rtabmap::CameraRGBD * camera = 0;
00135 if(driver == -1)
00136 {
00137 cameraUsb = new rtabmap::CameraVideo(device);
00138 }
00139 else if(driver == 0)
00140 {
00141 camera = new rtabmap::CameraOpenni();
00142 }
00143 else if(driver == 1)
00144 {
00145 if(!rtabmap::CameraOpenNI2::available())
00146 {
00147 UERROR("Not built with OpenNI2 support...");
00148 exit(-1);
00149 }
00150 camera = new rtabmap::CameraOpenNI2();
00151 }
00152 else if(driver == 2)
00153 {
00154 if(!rtabmap::CameraFreenect::available())
00155 {
00156 UERROR("Not built with Freenect support...");
00157 exit(-1);
00158 }
00159 camera = new rtabmap::CameraFreenect();
00160 }
00161 else if(driver == 3)
00162 {
00163 if(!rtabmap::CameraOpenNICV::available())
00164 {
00165 UERROR("Not built with OpenNI from OpenCV support...");
00166 exit(-1);
00167 }
00168 camera = new rtabmap::CameraOpenNICV(false);
00169 }
00170 else if(driver == 4)
00171 {
00172 if(!rtabmap::CameraOpenNICV::available())
00173 {
00174 UERROR("Not built with OpenNI from OpenCV support...");
00175 exit(-1);
00176 }
00177 camera = new rtabmap::CameraOpenNICV(true);
00178 }
00179 else if(driver == 5)
00180 {
00181 if(!rtabmap::CameraFreenect2::available())
00182 {
00183 UERROR("Not built with Freenect2 support...");
00184 exit(-1);
00185 }
00186 switchImages = true;
00187 camera = new rtabmap::CameraFreenect2(0, rtabmap::CameraFreenect2::kTypeRGBIR);
00188 }
00189 else if(driver == 6)
00190 {
00191 if(!rtabmap::CameraStereoDC1394::available())
00192 {
00193 UERROR("Not built with DC1394 support...");
00194 exit(-1);
00195 }
00196 camera = new rtabmap::CameraStereoDC1394();
00197 }
00198 else if(driver == 7)
00199 {
00200 if(!rtabmap::CameraStereoFlyCapture2::available())
00201 {
00202 UERROR("Not built with FlyCapture2/Triclops support...");
00203 exit(-1);
00204 }
00205 camera = new rtabmap::CameraStereoFlyCapture2();
00206 }
00207 else
00208 {
00209 UFATAL("");
00210 }
00211
00212 rtabmap::CameraThread * cameraThread = 0;
00213
00214 if(cameraUsb)
00215 {
00216 if(!cameraUsb->init())
00217 {
00218 printf("Camera init failed!\n");
00219 delete cameraUsb;
00220 exit(1);
00221 }
00222 cameraThread = new rtabmap::CameraThread(cameraUsb);
00223 }
00224 else if(camera)
00225 {
00226 if(!camera->init(""))
00227 {
00228 printf("Camera init failed!\n");
00229 delete camera;
00230 exit(1);
00231 }
00232 cameraThread = new rtabmap::CameraThread(camera);
00233 }
00234
00235 QApplication app(argc, argv);
00236 rtabmap::CalibrationDialog dialog(stereo, ".", switchImages);
00237 dialog.registerToEventsManager();
00238
00239 dialog.show();
00240 cameraThread->start();
00241 app.exec();
00242 cameraThread->join(true);
00243 delete cameraThread;
00244 }