main.cpp
Go to the documentation of this file.
00001 /*
00002 Copyright (c) 2010-2016, Mathieu Labbe - IntRoLab - Universite de Sherbrooke
00003 All rights reserved.
00004 
00005 Redistribution and use in source and binary forms, with or without
00006 modification, are permitted provided that the following conditions are met:
00007     * Redistributions of source code must retain the above copyright
00008       notice, this list of conditions and the following disclaimer.
00009     * Redistributions in binary form must reproduce the above copyright
00010       notice, this list of conditions and the following disclaimer in the
00011       documentation and/or other materials provided with the distribution.
00012     * Neither the name of the Universite de Sherbrooke nor the
00013       names of its contributors may be used to endorse or promote products
00014       derived from this software without specific prior written permission.
00015 
00016 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
00017 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
00018 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
00019 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
00020 DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
00021 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
00022 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
00023 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
00024 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
00025 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00026 */
00027 
00028 #include "rtabmap/core/CameraRGB.h"
00029 #include "rtabmap/core/CameraRGBD.h"
00030 #include "rtabmap/core/CameraStereo.h"
00031 #include "rtabmap/core/CameraThread.h"
00032 #include "rtabmap/utilite/ULogger.h"
00033 #include "rtabmap/utilite/UConversion.h"
00034 #include "rtabmap/gui/CalibrationDialog.h"
00035 #include <QApplication>
00036 
00037 void showUsage()
00038 {
00039         printf("\nUsage:\n"
00040                         "rtabmap-calibration [options]\n"
00041                         "Options:\n"
00042                         "  --driver #     Driver number to use:-1=USB camera\n"
00043                         "                                       0=OpenNI-PCL (Kinect)\n"
00044                         "                                       1=OpenNI2    (Kinect and Xtion PRO Live)\n"
00045                         "                                       2=Freenect   (Kinect)\n"
00046                         "                                       3=OpenNI-CV  (Kinect)\n"
00047                         "                                       4=OpenNI-CV-ASUS (Xtion PRO Live)\n"
00048                         "                                       5=Freenect2  (Kinect v2)\n"
00049                         "                                       6=DC1394     (Bumblebee2)\n"
00050                         "                                       7=FlyCapture2 (Bumblebee2)\n"
00051                         "  --device #     Device id\n"
00052                         "  --debug        Debug log\n"
00053                         "  --stereo       Stereo\n\n");
00054         exit(1);
00055 }
00056 
00057 int main(int argc, char * argv[])
00058 {
00059         ULogger::setType(ULogger::kTypeConsole);
00060         ULogger::setLevel(ULogger::kInfo);
00061         ULogger::setPrintTime(false);
00062         ULogger::setPrintWhere(false);
00063 
00064         int driver = -1;
00065         int device = 0;
00066         bool stereo = false;
00067         for(int i=1; i<argc; ++i)
00068         {
00069                 if(strcmp(argv[i], "--driver") == 0)
00070                 {
00071                         ++i;
00072                         if(i < argc)
00073                         {
00074                                 driver = std::atoi(argv[i]);
00075                                 if(driver < -1)
00076                                 {
00077                                         showUsage();
00078                                 }
00079                         }
00080                         else
00081                         {
00082                                 showUsage();
00083                         }
00084                         continue;
00085                 }
00086                 if(strcmp(argv[i], "--device") == 0)
00087                 {
00088                         ++i;
00089                         if(i < argc)
00090                         {
00091                                 device = std::atoi(argv[i]);
00092                                 if(device < 0)
00093                                 {
00094                                         showUsage();
00095                                 }
00096                         }
00097                         else
00098                         {
00099                                 showUsage();
00100                         }
00101                         continue;
00102                 }
00103                 if(strcmp(argv[i], "--debug") == 0)
00104                 {
00105                         ULogger::setLevel(ULogger::kDebug);
00106                         ULogger::setPrintTime(true);
00107                         ULogger::setPrintWhere(true);
00108                         continue;
00109                 }
00110                 if(strcmp(argv[i], "--stereo") == 0)
00111                 {
00112                         stereo=true;
00113                         continue;
00114                 }
00115                 if(strcmp(argv[i], "--help") == 0)
00116                 {
00117                         showUsage();
00118                 }
00119                 printf("Unrecognized option : %s\n", argv[i]);
00120                 showUsage();
00121         }
00122         if(driver < -1 || driver > 7)
00123         {
00124                 UERROR("driver should be between -1 and 7.");
00125                 showUsage();
00126         }
00127 
00128         UINFO("Using driver %d", driver);
00129         UINFO("Using device %d", device);
00130         UINFO("Stereo: %s", stereo?"true":"false");
00131 
00132         bool switchImages = false;
00133 
00134         rtabmap::Camera * camera = 0;
00135         if(driver == -1)
00136         {
00137                 camera = 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::kTypeColorIR);
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(camera)
00215         {
00216                 if(!camera->init(""))
00217                 {
00218                         printf("Camera init failed!\n");
00219                         delete camera;
00220                         exit(1);
00221                 }
00222                 cameraThread = new rtabmap::CameraThread(camera);
00223         }
00224 
00225         QApplication app(argc, argv);
00226         rtabmap::CalibrationDialog dialog(stereo, ".", switchImages);
00227         dialog.registerToEventsManager();
00228 
00229         dialog.show();
00230         cameraThread->start();
00231         app.exec();
00232         cameraThread->join(true);
00233         delete cameraThread;
00234 }


rtabmap
Author(s): Mathieu Labbe
autogenerated on Sat Jul 23 2016 11:44:16