Skip to content

Commit

Permalink
working on project
Browse files Browse the repository at this point in the history
  • Loading branch information
gaoxiang12 committed May 2, 2019
1 parent 0501be4 commit 8eee8ac
Show file tree
Hide file tree
Showing 14 changed files with 215 additions and 98 deletions.
3 changes: 1 addition & 2 deletions ch13/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
cmake_minimum_required(VERSION 2.8)
project(myslam)

set(CMAKE_BUILD_TYPE "Release")
set(CMAKE_CXX_FLAGS "-std=c++11 -march=native -O3")
set(CMAKE_CXX_FLAGS "-std=c++11 -march=native -Wall")

list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake_modules)
set(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/bin)
Expand Down
5 changes: 4 additions & 1 deletion ch13/config/default.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,7 @@ camera.fy: 516.5
camera.cx: 325.1
camera.cy: 249.7

camera.depth_scale: 5000
camera.depth_scale: 5000

num_features: 200
num_features_init: 100
21 changes: 21 additions & 0 deletions ch13/include/myslam/backend.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
//
// Created by gaoxiang on 19-5-2.
//

#ifndef MYSLAM_BACKEND_H
#define MYSLAM_BACKEND_H

#include "myslam/common_include.h"

namespace myslam {
class Backend {
public:
typedef std::shared_ptr<Backend> Ptr;

private:

};

}

#endif //MYSLAM_BACKEND_H
19 changes: 1 addition & 18 deletions ch13/include/myslam/camera.h
Original file line number Diff line number Diff line change
@@ -1,21 +1,4 @@
/*
* <one line to give the program's name and a brief idea of what it does.>
* Copyright (C) 2016 <copyright holder> <email>
*
* This program 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.
*
* This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#pragma once

#ifndef MYSLAM_CAMERA_H
#define MYSLAM_CAMERA_H
Expand Down
24 changes: 13 additions & 11 deletions ch13/include/myslam/common_include.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,20 @@
#pragma once
#ifndef MYSLAM_COMMON_INCLUDE_H
#define MYSLAM_COMMON_INCLUDE_H

// std
#include <vector>
#include <typeinfo>
#include <list>
#include <memory>
#include <string>
#include <iostream>
#include <set>
#include <unordered_map>
#include <map>


// define the commonly included file to avoid a long include list
// for Eigen
#include <Eigen/Core>
#include <Eigen/Geometry>

Expand Down Expand Up @@ -94,16 +106,6 @@ typedef Sophus::SO3d SO3;

using cv::Mat;

// std
#include <vector>
#include <list>
#include <memory>
#include <string>
#include <iostream>
#include <set>
#include <unordered_map>
#include <map>

// glog
#include <glog/logging.h>

Expand Down
1 change: 1 addition & 0 deletions ch13/include/myslam/config.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#pragma once
#ifndef MYSLAM_CONFIG_H
#define MYSLAM_CONFIG_H

Expand Down
7 changes: 6 additions & 1 deletion ch13/include/myslam/feature.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
//
// Created by gaoxiang on 19-5-2.
//
#pragma once

#ifndef MYSLAM_FEATURE_H
#define MYSLAM_FEATURE_H
Expand All @@ -17,9 +18,13 @@ struct Feature {
public:
std::weak_ptr<Frame> frame_;
cv::KeyPoint position_;
std::weak_ptr<MapPoint> map_point;
std::weak_ptr<MapPoint> map_point_;
bool is_outlier_ = false;

public:
Feature() {}

Feature(const cv::KeyPoint &kp) : position_(kp) {}
};
}

Expand Down
38 changes: 14 additions & 24 deletions ch13/include/myslam/frame.h
Original file line number Diff line number Diff line change
@@ -1,32 +1,16 @@
/*
* <one line to give the program's name and a brief idea of what it does.>
* Copyright (C) 2016 <copyright holder> <email>
*
* This program 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.
*
* This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
*
*/

#ifndef FRAME_H
#define FRAME_H
#pragma once

#ifndef MYSLAM_FRAME_H
#define MYSLAM_FRAME_H

#include "myslam/common_include.h"
#include "myslam/camera.h"

namespace myslam {

// forward declare
class MapPoint;
struct MapPoint;
struct Feature;

struct Frame {
public:
Expand All @@ -39,10 +23,16 @@ struct Frame {
SE3 pose_; // Tcw, transform from world to camera
Mat left_img_, right_img_; // stereo images

// extracted features in left image
std::vector<std::shared_ptr<Feature>> features_left_;

// corresponding features in right image, set to nullptr if no corresponding feature is found
std::vector<std::shared_ptr<Feature>> features_right_;

public: // data members
Frame() {}

Frame(long id, double time_stamp, const SE3& pose, const Mat& left, const Mat& right);
Frame(long id, double time_stamp, const SE3 &pose, const Mat &left, const Mat &right);

~Frame();

Expand All @@ -52,4 +42,4 @@ struct Frame {

}

#endif // FRAME_H
#endif // MYSLAM_FRAME_H
78 changes: 78 additions & 0 deletions ch13/include/myslam/frontend.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
#pragma once
#ifndef MYSLAM_FRONTEND_H
#define MYSLAM_FRONTEND_H

#include "myslam/common_include.h"
#include "myslam/frame.h"
#include "myslam/map.h"

namespace myslam {

class Backend;

class Frontend {
public:
typedef std::shared_ptr<Frontend> Ptr;
enum FrontendStatus {
INITING,
TRACKING_GOOD,
TRACKING_BAD,
LOST
};

Frontend();

bool AddFrame(Frame::Ptr frame);

void SetMap(Map::Ptr map) { map_ = map; }

void SetBackend(std::shared_ptr<Backend> backend) { backend_ = backend; }

FrontendStatus GetStatus() const { return status_; }

private:
/**
* Try init the frontend with stereo images saved in current_frame_
* @return true if success
*/
bool StereoInit();

/**
* Detect features in left image in current_frame_
* keypoints will be saved in current_frame_
* @return
*/
int DetectFeatures();

/**
* Find the corresponding features in right image of current_frame_
* @return num of features found
*/
int FindFeaturesInRight();

/**
* Build the initial map with single image
* @return true if succeed
*/
bool BuildInitMap();

// data
FrontendStatus status_ = INITING;

Frame::Ptr current_frame_ = nullptr;
Frame::Ptr ref_frame_ = nullptr;
Camera::Ptr camera_ = nullptr;

Map::Ptr map_ = nullptr;
std::shared_ptr<Backend> backend_ = nullptr;

// params
int num_features_init_ = 100;

// utilities
cv::Ptr<cv::GFTTDetector> gftt_; // feature detector in opencv
};

}

#endif //MYSLAM_FRONTEND_H
20 changes: 1 addition & 19 deletions ch13/include/myslam/map.h
Original file line number Diff line number Diff line change
@@ -1,22 +1,4 @@
/*
* <one line to give the program's name and a brief idea of what it does.>
* Copyright (C) 2016 <copyright holder> <email>
*
* This program 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.
*
* This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
*
*/

#pragma once
#ifndef MAP_H
#define MAP_H

Expand Down
20 changes: 1 addition & 19 deletions ch13/include/myslam/mappoint.h
Original file line number Diff line number Diff line change
@@ -1,22 +1,4 @@
/*
* <one line to give the program's name and a brief idea of what it does.>
* Copyright (C) 2016 <copyright holder> <email>
*
* This program 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.
*
* This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
*
*/

#pragma once
#ifndef MYSLAM_MAPPOINT_H
#define MYSLAM_MAPPOINT_H

Expand Down
8 changes: 5 additions & 3 deletions ch13/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@ add_library(myslam SHARED
map.cpp
camera.cpp
config.cpp
feature.cpp)
feature.cpp
frontend.cpp
# backend.cpp
)

target_link_libraries(myslam
${THIRD_PARTY_LIBS}
)
${THIRD_PARTY_LIBS})
9 changes: 9 additions & 0 deletions ch13/src/backend.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
//
// Created by gaoxiang on 19-5-2.
//

#include "myslam/backend.h"

namespace myslam {

}
Loading

0 comments on commit 8eee8ac

Please sign in to comment.