rtabmap: removed all UtiLite include references for main RTAB-Map classes (to avoid linking to UtiLite when using RTAB-Map as c++ library)

git-svn-id: http://rtabmap.googlecode.com/svn/trunk/rtabmap@811 f169173b-cf89-36c8-b27e-44dbe73f0c83
This commit is contained in:
matlabbe
2013-02-04 16:38:00 +00:00
parent e8e75a9d40
commit 00ac36747e
14 changed files with 462 additions and 294 deletions

View File

@@ -23,75 +23,29 @@
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/features2d/features2d.hpp>
#include <utilite/UThreadNode.h>
#include <utilite/UEventsHandler.h>
#include <utilite/UEvent.h>
#include <utilite/UDirectory.h>
#include <utilite/UTimer.h>
#include "rtabmap/core/Parameters.h"
#include "rtabmap/core/Features2d.h"
#include "rtabmap/core/Image.h"
#include "rtabmap/core/Features2d.h"
#include <set>
#include <stack>
#include <list>
#include <vector>
class UDirectory;
class UTimer;
namespace rtabmap
{
class CameraEvent :
public UEvent
{
public:
enum Code {
kCodeFeatures,
kCodeImage,
kCodeNoMoreImages
};
public:
CameraEvent(const cv::Mat & image, int cameraId = 0) :
UEvent(kCodeImage),
_cameraId(cameraId),
_image(image)
{
}
CameraEvent(const cv::Mat & descriptors, const std::vector<cv::KeyPoint> & keypoints, const cv::Mat & image = cv::Mat(), int cameraId = 0) :
UEvent(kCodeFeatures),
_cameraId(cameraId),
_image(image, 0, descriptors, keypoints)
{
}
CameraEvent(int cameraId = 0) :
UEvent(kCodeNoMoreImages),
_cameraId(cameraId)
{
}
int cameraId() const {return _cameraId;}
// Image or descriptors
const Image & image() const {return _image;}
virtual ~CameraEvent() {}
virtual std::string getClassName() const {return std::string("CameraEvent");}
private:
int _cameraId;
Image _image;
};
class KeypointDetector;
class KeypointDescriptor;
/**
* Class Camera
*
*/
class RTABMAP_EXP Camera :
public UThreadNode,
public UEventsHandler
class RTABMAP_EXP Camera
{
public:
enum State {kStateCapturing, kStateChangingParameters};
public:
virtual ~Camera();
cv::Mat takeImage();
@@ -99,8 +53,6 @@ public:
virtual bool init() = 0;
//getters
bool isPaused() const {return !this->isRunning();}
bool isCapturing() const {return this->isRunning();}
void getImageSize(unsigned int & width, unsigned int & height);
float getImageRate() const {return _imageRate;}
bool isFeaturesExtracted() const {return _featuresExtracted;}
@@ -110,7 +62,6 @@ public:
KeypointDetector::DetectorType detector = KeypointDetector::kDetectorUndef,
KeypointDescriptor::DescriptorType descriptor = KeypointDescriptor::kDescriptorUndef);
void setImageRate(float imageRate) {_imageRate = imageRate;}
void setAutoRestart(bool autoRestart) {_autoRestart = autoRestart;}
void setImageSize(unsigned int width, unsigned int height);
@@ -123,30 +74,17 @@ protected:
*
* @param imageRate : image/second , 0 for fast as the camera can
*/
Camera(float imageRate = 0, bool autoRestart = false, unsigned int imageWidth = 0, unsigned int imageHeight = 0, unsigned int framesDropped = 0, int id = 0);
Camera(float imageRate = 0, unsigned int imageWidth = 0, unsigned int imageHeight = 0, unsigned int framesDropped = 0, int id = 0);
virtual void handleEvent(UEvent* anEvent);
virtual cv::Mat captureImage() = 0;
private:
virtual void mainLoopBegin();
virtual void mainLoop();
void process();
void pushNewState(State newState, const ParametersMap & parameters = ParametersMap());
private:
float _imageRate;
int _id;
bool _autoRestart;
unsigned int _imageWidth;
unsigned int _imageHeight;
unsigned int _framesDropped;
UTimer _frameRateTimer;
UMutex _imageSizeMutex;
UMutex _stateMutex;
std::stack<State> _state;
std::stack<ParametersMap> _stateParam;
UTimer * _frameRateTimer;
bool _featuresExtracted;
KeypointDetector * _keypointDetector;
@@ -154,7 +92,6 @@ private:
};
/////////////////////////
// CameraImages
/////////////////////////
@@ -166,7 +103,6 @@ public:
int startAt = 1,
bool refreshDir = false,
float imageRate = 0,
bool autoRestart = false,
unsigned int imageWidth = 0,
unsigned int imageHeight = 0,
unsigned int framesDropped = 0,
@@ -185,12 +121,9 @@ private:
// If the list of files in the directory is refreshed
// on each call of takeImage()
bool _refreshDir;
UDirectory _dir;
int _count;
UDirectory * _dir;
std::string _lastFileName;
};
@@ -208,14 +141,12 @@ public:
public:
CameraVideo(int usbDevice = 0,
float imageRate = 0,
bool autoRestart = false,
unsigned int imageWidth = 0,
unsigned int imageHeight = 0,
unsigned int framesDropped = 0,
int id = 0);
CameraVideo(const std::string & filePath,
float imageRate = 0,
bool autoRestart = false,
unsigned int imageWidth = 0,
unsigned int imageHeight = 0,
unsigned int framesDropped = 0,

View File

@@ -0,0 +1,72 @@
/*
* 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 <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/features2d/features2d.hpp>
#include <utilite/UEvent.h>
#include "rtabmap/core/Image.h"
namespace rtabmap
{
class CameraEvent :
public UEvent
{
public:
enum Code {
kCodeFeatures,
kCodeImage,
kCodeNoMoreImages
};
public:
CameraEvent(const cv::Mat & image, int cameraId = 0) :
UEvent(kCodeImage),
_cameraId(cameraId),
_image(image)
{
}
CameraEvent(const cv::Mat & descriptors, const std::vector<cv::KeyPoint> & keypoints, const cv::Mat & image = cv::Mat(), int cameraId = 0) :
UEvent(kCodeFeatures),
_cameraId(cameraId),
_image(image, 0, descriptors, keypoints)
{
}
CameraEvent(int cameraId = 0) :
UEvent(kCodeNoMoreImages),
_cameraId(cameraId)
{
}
int cameraId() const {return _cameraId;}
// Image or descriptors
const Image & image() const {return _image;}
virtual ~CameraEvent() {}
virtual std::string getClassName() const {return std::string("CameraEvent");}
private:
int _cameraId;
Image _image;
};
} // namespace rtabmap

View File

@@ -0,0 +1,74 @@
/*
* 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 <http://www.gnu.org/licenses/>.
*/
#pragma once
#include "rtabmap/core/RtabmapExp.h" // DLL export/import defines
#include <utilite/UThreadNode.h>
#include <utilite/UEventsHandler.h>
#include "rtabmap/core/Parameters.h"
#include <stack>
namespace rtabmap
{
class Camera;
/**
* Class CameraThread
*
*/
class RTABMAP_EXP CameraThread :
public UThreadNode,
public UEventsHandler
{
public:
enum State {kStateCapturing, kStateChangingParameters};
public:
// ownership transferred
CameraThread(Camera * camera, bool autoRestart = false);
virtual ~CameraThread();
//getters
bool isPaused() const {return !this->isRunning();}
bool isCapturing() const {return this->isRunning();}
void setAutoRestart(bool autoRestart) {_autoRestart = autoRestart;}
void setImageRate(float imageRate);
protected:
virtual void handleEvent(UEvent* anEvent);
private:
virtual void mainLoop();
void process();
void pushNewState(State newState, const ParametersMap & parameters = ParametersMap());
private:
Camera * _camera;
UMutex _stateMutex;
std::stack<State> _state;
std::stack<ParametersMap> _stateParam;
bool _autoRestart;
};
} // namespace rtabmap

View File

@@ -0,0 +1,53 @@
/*
* 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 <http://www.gnu.org/licenses/>.
*/
#ifndef PARAMEVENT_H_
#define PARAMEVENT_H_
#include "rtabmap/core/Parameters.h"
#include <utilite/UEvent.h>
namespace rtabmap
{
/**
* The parameters event. This event is used to send
* parameters across the threads.
*/
class ParamEvent : public UEvent
{
public:
ParamEvent(const ParametersMap & parameters) : UEvent(0), parameters_(parameters) {}
ParamEvent(const std::string & parameterKey, const std::string & parameterValue) : UEvent(0)
{
parameters_.insert(std::pair<std::string, std::string>(parameterKey, parameterValue));
}
~ParamEvent() {}
virtual std::string getClassName() const {return "ParamEvent";}
const ParametersMap & getParameters() const {return parameters_;}
private:
ParametersMap parameters_; /**< The parameters map (key,value). */
};
}
#endif /* PARAMEVENT_H_ */

View File

@@ -22,7 +22,6 @@
// default parameters
#include "rtabmap/core/RtabmapExp.h" // DLL export/import defines
#include "utilite/UEvent.h"
#include <string>
#include <map>
@@ -219,27 +218,6 @@ private:
static Parameters instance_;
};
/**
* The parameters event. This event is used to send
* parameters across the threads.
*/
class ParamEvent : public UEvent
{
public:
ParamEvent(const ParametersMap & parameters) : UEvent(0), parameters_(parameters) {}
ParamEvent(const std::string & parameterKey, const std::string & parameterValue) : UEvent(0)
{
parameters_.insert(std::pair<std::string, std::string>(parameterKey, parameterValue));
}
~ParamEvent() {}
virtual std::string getClassName() const {return "ParamEvent";}
const ParametersMap & getParameters() const {return parameters_;}
private:
ParametersMap parameters_; /**< The parameters map (key,value). */
};
}
#endif /* PARAMETERS_H_ */

View File

@@ -22,10 +22,6 @@
#include "rtabmap/core/RtabmapExp.h" // DLL export/import defines
#include <utilite/USemaphore.h>
#include <utilite/UMutex.h>
#include <utilite/UVariant.h>
#include "rtabmap/core/Parameters.h"
#include "rtabmap/core/Image.h"
#include "rtabmap/core/Statistics.h"

View File

@@ -24,6 +24,8 @@
#include <utilite/UThreadNode.h>
#include <utilite/UEventsHandler.h>
#include <utilite/USemaphore.h>
#include <utilite/UMutex.h>
#include "rtabmap/core/RtabmapEvent.h"
#include "rtabmap/core/Image.h"