Project

General

Profile

BitmapToolkit Scol plugin
sSlam_vins.h
Go to the documentation of this file.
1/*
2-----------------------------------------------------------------------------
3This source file is part of OpenSpace3D
4For the latest info, see http://www.openspace3d.com
5
6Copyright (c) 2012 I-maginer
7
8This program is free software; you can redistribute it and/or modify it under
9the terms of the GNU Lesser General Public License as published by the Free Software
10Foundation; either version 2 of the License, or (at your option) any later
11version.
12
13This program is distributed in the hope that it will be useful, but WITHOUT
14ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
15FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
16
17You should have received a copy of the GNU Lesser General Public License along with
18this program; if not, write to the Free Software Foundation, Inc., 59 Temple
19Place - Suite 330, Boston, MA 02111-1307, USA, or go to
20http://www.gnu.org/copyleft/lesser.txt
21
22-----------------------------------------------------------------------------
23*/
24
25#ifndef __BTK_SSLAM_H__
26#define __BTK_SSLAM_H__
27
28#include "Prerequisites.h"
29#include "ArCameraParam.h"
30#include "ArManager.h"
31#include "BitmapToolkitThread.h"
32
33#include <chrono>
34#include "DSO/dso.h"
35#include "DSO/FullSystem/CoarseInitializer.h"
36#include "DSO/IOWrapper/Output3DWrapper.h"
37#include "DSO/util/Undistort.h"
38#include "DSO/util/NumType.h"
39#include "DSO/util/FrameShell.h"
40#include "DSO/util/settings.h"
41
42struct slamPoint
43{
44 dso::PointHessian* ptr;
45 cv::Point2f point2d;
46 cv::Mat point3d;
47 cv::Scalar color;
48 float depth;
49};
50
51class Plane
52{
53public:
54 Plane() {}
55 cv::Mat DetectPlane(cv::Mat campos, std::vector<slamPoint> &vMPs, const int iterations);
56 void Recompute();
57
58 //normal
59 cv::Mat mNormal;
60 //origin
61 cv::Mat mOrigin;
62 //arbitrary orientation along normal
63 float mRang;
64 //transformation from world to the plane
65 cv::Mat mTpw;
66 //MapPoints that define the plane
67 std::vector<slamPoint> mMvMPs;
68 //camera pose when the plane was first observed (to compute normal direction)
69 cv::Mat mMTcw;
70 cv::Mat mXC;
71};
72
73class Sslam : public dso::IOWrap::Output3DWrapper, btopenutils::Thread
74{
75 public:
78 protected:
79
80 private:
81
82 LASTDATA mLastData;
83 boost::mutex mImuMutex;
84 boost::mutex mResetMutex;
85 boost::mutex mDebugMutex;
86 dso::FullSystem* mSlam;
87 dso::Undistort* mUndistorter;
88 dso::ModelParams mCamParams;
89 Vector3 mLastCamPos;
90 BtQuaternion mLastCamQuat;
91 Vector3 mPrevCamPos;
92 BtQuaternion mPrevCamQuat;
93 std::vector<dso::ImuData> mImuFrame;
94 uint32_t mFrameIdx;
95 cv::Mat mPlane2World;
96 cv::Mat mPlane2Camera;
97 cv::Mat mCameraWorld;
98 cv::Mat mCentroid;
99 float mScaleX;
100 float mScaleY;
101 bool mIsDirty;
102 bool mFound;
103 bool mInitialized;
104 bool mUseSensor;
105 int mReady;
106 std::string mVocFile;
107 std::vector<slamPoint> mCloudPoints;
108 std::chrono::steady_clock::time_point mLastTimeFrame;
109 double mLastUpdate;
110
111 void BuildCameraParam(const aruco::CameraParameters &camparam);
112 void InitDetector();
113 void Detect();
114
115 public:
116 // ==================== Output3DWrapper Functionality ======================
117 virtual void publishGraph(const std::map<uint64_t, Eigen::Vector2i, std::less<uint64_t>, Eigen::aligned_allocator<std::pair<const uint64_t, Eigen::Vector2i>>> &connectivity) override;
118 virtual void publishKeyframes(std::vector<dso::FrameHessian*> &frames, bool final, dso::CalibHessian* HCalib) override;
119 virtual void publishCamPose(dso::FrameShell* frame, dso::CalibHessian* HCalib) override;
120
121 virtual void pushLiveFrame(dso::FrameHessian* image) override;
122 virtual void pushDepthImage(dso::MinimalImageB3* image) override;
123 virtual bool needPushDepthImage() override;
124
125 virtual void join() override;
126 virtual void reset() override;
127
128 bool needUpdate;
129 void GoThread();
130 void SetDirty();
133 bool IsFound();
134 void Reset();
135 void DrawLandmarks(cv::Mat image);
136 protected:
137
138 private:
139};
140
141#endif
Definition sSlam.h:52
cv::Mat mMTcw
Definition sSlam.h:69
float mRang
Definition sSlam.h:63
cv::Mat mXC
Definition sSlam.h:70
cv::Mat mTpw
Definition sSlam.h:65
cv::Mat DetectPlane(cv::Mat campos, std::vector< slamPoint > &vMPs, const int iterations)
std::vector< slamPoint > mMvMPs
Definition sSlam.h:67
Plane()
Definition sSlam_vins.h:54
cv::Mat mOrigin
Definition sSlam.h:61
void Recompute()
cv::Mat mNormal
Definition sSlam.h:59
Definition sSlam.h:74
virtual void publishKeyframes(std::vector< dso::FrameHessian * > &frames, bool final, dso::CalibHessian *HCalib) override
virtual void join() override
BtQuaternion GetCameraOrientation()
void SetDirty()
bool needUpdate
Definition sSlam.h:128
virtual void pushLiveFrame(dso::FrameHessian *image) override
virtual void publishCamPose(dso::FrameShell *frame, dso::CalibHessian *HCalib) override
virtual void pushDepthImage(dso::MinimalImageB3 *image) override
Vector3 GetCameraPosition()
virtual void publishGraph(const std::map< uint64_t, Eigen::Vector2i, std::less< uint64_t >, Eigen::aligned_allocator< std::pair< const uint64_t, Eigen::Vector2i > > > &connectivity) override
void GoThread()
bool IsFound()
virtual bool needPushDepthImage() override
virtual void reset() override
void DrawLandmarks(cv::Mat image)
void Reset()
cv::Mat point3d
Definition sSlam.h:46
dso::PointHessian * ptr
Definition sSlam.h:44
cv::Point2f point2d
Definition sSlam.h:45
cv::Scalar color
Definition sSlam.h:47
float depth
Definition sSlam.h:48