/* * Copyright (C) 2010-2011, Mathieu Labbe and IntRoLab - Universite de Sherbrooke * * This file is part of RTAB-Map. * * RTAB-Map is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * RTAB-Map is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with RTAB-Map. If not, see . */ #include "rtabmap/core/CameraRGBD.h" #include "rtabmap/core/CameraThread.h" #include "rtabmap/utilite/ULogger.h" #include "rtabmap/gui/CalibrationDialog.h" #include void showUsage() { printf("\nUsage:\n" "rtabmap-calibration driver\n" " driver Driver number to use: 0=OpenNI-PCL, 1=OpenNI2, 2=Freenect, 3=OpenNI-CV, 4=OpenNI-CV-ASUS\n\n"); exit(1); } int main(int argc, char * argv[]) { ULogger::setType(ULogger::kTypeConsole); ULogger::setLevel(ULogger::kInfo); int driver = 0; if(argc < 2) { showUsage(); } else { driver = atoi(argv[argc-1]); if(driver < 0 || driver > 4) { UERROR("driver should be between 0 and 4."); showUsage(); } } UINFO("Using driver %d", driver); float imageRate = 1.0f; rtabmap::CameraRGBD * camera = 0; if(driver == 0) { camera = new rtabmap::CameraOpenni("", imageRate); } else if(driver == 1) { if(!rtabmap::CameraOpenNI2::available()) { UERROR("Not built with OpenNI2 support..."); exit(-1); } camera = new rtabmap::CameraOpenNI2(imageRate); } else if(driver == 2) { if(!rtabmap::CameraFreenect::available()) { UERROR("Not built with Freenect support..."); exit(-1); } camera = new rtabmap::CameraFreenect(0, imageRate); } else if(driver == 3) { if(!rtabmap::CameraOpenNICV::available()) { UERROR("Not built with OpenNI from OpenCV support..."); exit(-1); } camera = new rtabmap::CameraOpenNICV(false, imageRate); } else if(driver == 4) { if(!rtabmap::CameraOpenNICV::available()) { UERROR("Not built with OpenNI from OpenCV support..."); exit(-1); } camera = new rtabmap::CameraOpenNICV(true, imageRate); } else { UFATAL(""); } if(!camera->init()) { printf("Camera init failed!\n"); delete camera; exit(1); } rtabmap::CameraThread cameraThread(camera); QApplication app(argc, argv); rtabmap::CalibrationDialog dialog; dialog.registerToEventsManager(); dialog.show(); cameraThread.start(); app.exec(); cameraThread.join(true); }