123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118 |
- #ifndef VIEWERAR_H
- #define VIEWERAR_H
- #include <mutex>
- #include <opencv2/core/core.hpp>
- #include <pangolin/pangolin.h>
- #include <string>
- #include"../../../include/System.h"
- namespace ORB_SLAM3
- {
- class Plane
- {
- public:
- Plane(const std::vector<MapPoint*> &vMPs, const cv::Mat &Tcw);
- Plane(const float &nx, const float &ny, const float &nz, const float &ox, const float &oy, const float &oz);
- void Recompute();
-
- cv::Mat n;
-
- cv::Mat o;
-
- float rang;
-
- cv::Mat Tpw;
- pangolin::OpenGlMatrix glTpw;
-
- std::vector<MapPoint*> mvMPs;
-
- cv::Mat mTcw, XC;
- };
- class ViewerAR
- {
- public:
- ViewerAR();
- void SetFPS(const float fps){
- mFPS = fps;
- mT=1e3/fps;
- }
- void SetSLAM(ORB_SLAM3::System* pSystem){
- mpSystem = pSystem;
- }
-
- void Run();
- void SetCameraCalibration(const float &fx_, const float &fy_, const float &cx_, const float &cy_){
- fx = fx_; fy = fy_; cx = cx_; cy = cy_;
- }
- void SetImagePose(const cv::Mat &im, const cv::Mat &Tcw, const int &status,
- const std::vector<cv::KeyPoint> &vKeys, const std::vector<MapPoint*> &vMPs);
- void GetImagePose(cv::Mat &im, cv::Mat &Tcw, int &status,
- std::vector<cv::KeyPoint> &vKeys, std::vector<MapPoint*> &vMPs);
- private:
-
- ORB_SLAM3::System* mpSystem;
- void PrintStatus(const int &status, const bool &bLocMode, cv::Mat &im);
- void AddTextToImage(const std::string &s, cv::Mat &im, const int r=0, const int g=0, const int b=0);
- void LoadCameraPose(const cv::Mat &Tcw);
- void DrawImageTexture(pangolin::GlTexture &imageTexture, cv::Mat &im);
- void DrawCube(const float &size, const float x=0, const float y=0, const float z=0);
- void DrawPlane(int ndivs, float ndivsize);
- void DrawPlane(Plane* pPlane, int ndivs, float ndivsize);
- void DrawTrackedPoints(const std::vector<cv::KeyPoint> &vKeys, const std::vector<MapPoint*> &vMPs, cv::Mat &im);
- Plane* DetectPlane(const cv::Mat Tcw, const std::vector<MapPoint*> &vMPs, const int iterations=50);
-
- float mFPS, mT;
- float fx,fy,cx,cy;
-
- std::mutex mMutexPoseImage;
- cv::Mat mTcw;
- cv::Mat mImage;
- int mStatus;
- std::vector<cv::KeyPoint> mvKeys;
- std::vector<MapPoint*> mvMPs;
- };
- }
- #endif
-
|