Added CameraRGBD with openni from OpenCV, removed feature2D stuff from Camera

git-svn-id: http://rtabmap.googlecode.com/svn/trunk/rtabmap@1358 f169173b-cf89-36c8-b27e-44dbe73f0c83
This commit is contained in:
matlabbe
2014-06-13 03:47:39 +00:00
parent f423b1b743
commit 0bba363f5f
11 changed files with 345 additions and 309 deletions

View File

@@ -22,10 +22,7 @@
#include "rtabmap/core/RtabmapExp.h" // DLL export/import defines
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/features2d/features2d.hpp>
#include "rtabmap/core/Parameters.h"
#include "rtabmap/core/Image.h"
#include "rtabmap/core/Features2d.h"
#include <set>
#include <stack>
#include <list>
@@ -37,9 +34,6 @@ class UTimer;
namespace rtabmap
{
class KeypointDetector;
class KeypointDescriptor;
/**
* Class Camera
*
@@ -48,24 +42,20 @@ class RTABMAP_EXP Camera
{
public:
virtual ~Camera();
cv::Mat takeImage();
cv::Mat takeImage(cv::Mat & descriptors, std::vector<cv::KeyPoint> & keypoints);
cv::Mat takeImage(); // backward compatibility
void takeImage(cv::Mat & rgb);
void takeImage(cv::Mat & rgb, cv::Mat & depth, float & depthConstant);
virtual bool init() = 0;
//getters
void getImageSize(unsigned int & width, unsigned int & height);
float getImageRate() const {return _imageRate;}
bool isFeaturesExtracted() const {return _featuresExtracted;}
const Transform & getLocalTransform() const {return _localTransform;}
//setters
void setFeaturesExtracted(bool featuresExtracted,
KeypointDetector::DetectorType detector = KeypointDetector::kDetectorUndef,
KeypointDescriptor::DescriptorType descriptor = KeypointDescriptor::kDescriptorUndef);
void setImageRate(float imageRate) {_imageRate = imageRate;}
void setImageSize(unsigned int width, unsigned int height);
virtual void parseParameters(const ParametersMap & parameters);
void setLocalTransform(const Transform & localTransform) {_localTransform= localTransform;}
protected:
/**
@@ -78,18 +68,15 @@ protected:
unsigned int imageHeight = 0,
unsigned int framesDropped = 0);
virtual cv::Mat captureImage() = 0;
virtual void captureImage(cv::Mat & rgb, cv::Mat & depth, float & depthConstant) = 0;
private:
float _imageRate;
unsigned int _imageWidth;
unsigned int _imageHeight;
unsigned int _framesDropped;
Transform _localTransform;
UTimer * _frameRateTimer;
bool _featuresExtracted;
KeypointDetector * _keypointDetector;
KeypointDescriptor * _keypointDescriptor;
};
@@ -113,7 +100,7 @@ public:
std::string getPath() const {return _path;}
protected:
virtual cv::Mat captureImage();
virtual void captureImage(cv::Mat & rgb, cv::Mat & depth, float & depthConstant);
private:
std::string _path;
@@ -156,7 +143,7 @@ public:
const std::string & getFilePath() const {return _filePath;}
protected:
virtual cv::Mat captureImage();
virtual void captureImage(cv::Mat & rgb, cv::Mat & depth, float & depthConstant);
private:
// File type
@@ -170,4 +157,28 @@ private:
};
/////////////////////////
// CameraRGBD
/////////////////////////
class RTABMAP_EXP CameraRGBD :
public Camera
{
public:
CameraRGBD(float imageRate = 0,
bool asus = false);
virtual ~CameraRGBD();
virtual bool init();
protected:
virtual void captureImage(cv::Mat & rgb, cv::Mat & depth, float & depthConstant);
private:
bool _asus;
cv::VideoCapture _capture;
};
} // namespace rtabmap

View File

@@ -39,11 +39,8 @@ class Camera;
*/
class RTABMAP_EXP CameraThread :
public UThreadNode,
public UEventsHandler
public UEventsSender
{
public:
enum State {kStateCapturing, kStateChangingParameters};
public:
// ownership transferred
CameraThread(Camera * camera, bool autoRestart = false);
@@ -57,19 +54,11 @@ public:
void setAutoRestart(bool autoRestart) {_autoRestart = autoRestart;}
Camera * getCamera() {return _camera;}
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;
int _seq;
};