debug gpu version done
This commit is contained in:
@@ -96,3 +96,4 @@ TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${LINK_LIBS} )
|
||||
set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 14)
|
||||
set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD_REQUIRED ON)
|
||||
target_compile_features(${PROJECT_NAME} PRIVATE cxx_range_for)
|
||||
ADD_DEFINITIONS(-DKERNEL_DIR=\"${PROJECT_SOURCE_DIR}/kernel\")
|
||||
|
||||
+1
-1
@@ -17,7 +17,7 @@
|
||||
#ifndef SVO_BUNDLE_ADJUSTMENT_H_
|
||||
#define SVO_BUNDLE_ADJUSTMENT_H_
|
||||
|
||||
#include <svo/global.h>
|
||||
#include <gpu_svo/global.h>
|
||||
|
||||
namespace g2o {
|
||||
class EdgeProjectXYZ2UV;
|
||||
@@ -67,13 +67,15 @@ public:
|
||||
};
|
||||
int32_t reload(size_t id,cv::Mat& buf,cl::Context* context){
|
||||
try{
|
||||
for(auto i:_images)if(i.second==id)
|
||||
for(auto i:_images)if(i.second==id){
|
||||
i.first=cl::Image2D(*context, CL_MEM_READ_ONLY | CL_MEM_COPY_HOST_PTR,
|
||||
cl::ImageFormat(CL_R, CL_UNSIGNED_INT8),
|
||||
buf.size().width,
|
||||
buf.size().height,
|
||||
0,
|
||||
reinterpret_cast<uchar*>(buf.data));
|
||||
}
|
||||
|
||||
return CL_SUCCESS;
|
||||
}catch (std::exception& err){
|
||||
std::cerr<<"Reload buffer on GPU failed\n"<<err.what()<<'\n';
|
||||
@@ -127,7 +129,7 @@ public:
|
||||
_kernels.at(id1).write(id2,buf,context);
|
||||
return CL_SUCCESS;
|
||||
}catch (std::exception& err){
|
||||
std::cerr<<"Write buffer on GPU failed\n"<<err.what()<<'\n';
|
||||
std::cerr<<"Write image on GPU failed\n"<<err.what()<<'\n';
|
||||
return CL_MAP_FAILURE;
|
||||
}
|
||||
}
|
||||
+3
-3
@@ -21,9 +21,9 @@
|
||||
#include <boost/thread.hpp>
|
||||
#include <boost/function.hpp>
|
||||
#include <vikit/performance_monitor.h>
|
||||
#include <svo/global.h>
|
||||
#include <svo/feature_detection.h>
|
||||
#include <svo/matcher.h>
|
||||
#include <gpu_svo/global.h>
|
||||
#include <gpu_svo/feature_detection.h>
|
||||
#include <gpu_svo/matcher.h>
|
||||
|
||||
namespace svo {
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
#ifndef SVO_FEATURE_H_
|
||||
#define SVO_FEATURE_H_
|
||||
|
||||
#include <svo/frame.h>
|
||||
#include <gpu_svo/frame.h>
|
||||
|
||||
namespace svo {
|
||||
|
||||
+1
-1
@@ -17,7 +17,7 @@
|
||||
#ifndef SVO_FEATURE_ALIGNMENT_H_
|
||||
#define SVO_FEATURE_ALIGNMENT_H_
|
||||
|
||||
#include <svo/global.h>
|
||||
#include <gpu_svo/global.h>
|
||||
|
||||
namespace svo {
|
||||
|
||||
+5
-6
@@ -17,9 +17,9 @@
|
||||
#ifndef SVO_FEATURE_DETECTION_H_
|
||||
#define SVO_FEATURE_DETECTION_H_
|
||||
|
||||
#include <svo/global.h>
|
||||
#include <svo/frame.h>
|
||||
#include <svo/cl_class.h>
|
||||
#include <gpu_svo/global.h>
|
||||
#include <gpu_svo/frame.h>
|
||||
#include <gpu_svo/cl_class.h>
|
||||
|
||||
namespace svo {
|
||||
|
||||
@@ -51,8 +51,6 @@ public:
|
||||
const int n_pyr_levels);
|
||||
|
||||
virtual ~AbstractDetector() {
|
||||
gpu_fast_->clear_buf();
|
||||
gpu_fast_->make_kernel("fast_gray");
|
||||
};
|
||||
|
||||
virtual void detect(
|
||||
@@ -66,7 +64,6 @@ public:
|
||||
|
||||
/// Set grid cells of existing features as occupied
|
||||
void setExistingFeatures(const Features& fts);
|
||||
opencl* gpu_fast_= nullptr;
|
||||
|
||||
protected:
|
||||
|
||||
@@ -95,6 +92,7 @@ public:
|
||||
const int img_width,
|
||||
const int img_height,
|
||||
const int cell_size,
|
||||
opencl* gpu_fast_,
|
||||
const int n_pyr_levels);
|
||||
|
||||
virtual ~FastDetector() {}
|
||||
@@ -104,6 +102,7 @@ public:
|
||||
const ImgPyr& img_pyr,
|
||||
const double detection_threshold,
|
||||
Features& fts);
|
||||
opencl* gpu_fast_;
|
||||
};
|
||||
|
||||
} // namespace feature_detection
|
||||
@@ -21,7 +21,7 @@
|
||||
#include <vikit/math_utils.h>
|
||||
#include <vikit/abstract_camera.h>
|
||||
#include <boost/noncopyable.hpp>
|
||||
#include <svo/global.h>
|
||||
#include <gpu_svo/global.h>
|
||||
|
||||
namespace g2o {
|
||||
class VertexSE3Expmap;
|
||||
+2
-2
@@ -23,8 +23,8 @@
|
||||
#include <boost/noncopyable.hpp>
|
||||
#include <boost/function.hpp>
|
||||
#include <boost/thread.hpp>
|
||||
#include <svo/global.h>
|
||||
#include <svo/map.h>
|
||||
#include <gpu_svo/global.h>
|
||||
#include <gpu_svo/map.h>
|
||||
|
||||
namespace vk
|
||||
{
|
||||
+9
-8
@@ -19,10 +19,11 @@
|
||||
|
||||
#include <set>
|
||||
#include <vikit/abstract_camera.h>
|
||||
#include <svo/frame_handler_base.h>
|
||||
#include <svo/reprojector.h>
|
||||
#include <svo/initialization.h>
|
||||
#include <svo/imu_integration.h>
|
||||
#include <gpu_svo/frame_handler_base.h>
|
||||
#include <gpu_svo/reprojector.h>
|
||||
#include <gpu_svo/initialization.h>
|
||||
#include <gpu_svo/imu_integration.h>
|
||||
#include <gpu_svo/cl_class.h>
|
||||
|
||||
namespace svo {
|
||||
|
||||
@@ -48,8 +49,8 @@ public:
|
||||
const set<FramePtr>& coreKeyframes() { return core_kfs_; }
|
||||
|
||||
/// Return the feature track to visualize the KLT tracking during initialization.
|
||||
const vector<cv::Point2f>& initFeatureTrackRefPx() const { return klt_homography_init_.px_ref_; }
|
||||
const vector<cv::Point2f>& initFeatureTrackCurPx() const { return klt_homography_init_.px_cur_; }
|
||||
const vector<cv::Point2f>& initFeatureTrackRefPx() const { return klt_homography_init_->px_ref_; }
|
||||
const vector<cv::Point2f>& initFeatureTrackCurPx() const { return klt_homography_init_->px_cur_; }
|
||||
|
||||
/// Access the depth filter.
|
||||
DepthFilter* depthFilter() const { return depth_filter_; }
|
||||
@@ -69,9 +70,9 @@ protected:
|
||||
FramePtr last_frame_; //!< Last frame, not necessarily a keyframe.
|
||||
set<FramePtr> core_kfs_; //!< Keyframes in the closer neighbourhood.
|
||||
vector< pair<FramePtr,size_t> > overlap_kfs_; //!< All keyframes with overlapping field of view. the paired number specifies how many common mappoints are observed TODO: why vector!?
|
||||
initialization::KltHomographyInit klt_homography_init_; //!< Used to estimate pose of the first two keyframes by estimating a homography.
|
||||
initialization::KltHomographyInit* klt_homography_init_; //!< Used to estimate pose of the first two keyframes by estimating a homography.
|
||||
DepthFilter* depth_filter_; //!< Depth estimation algorithm runs in a parallel thread and is used to initialize new 3D points.
|
||||
|
||||
opencl* gpu_fast_;
|
||||
|
||||
/// Initialize the visual odometry algorithm.
|
||||
virtual void initialize();
|
||||
+1
-1
@@ -13,7 +13,7 @@
|
||||
#include <gtsam/slam/ProjectionFactor.h>
|
||||
#include <gtsam/nonlinear/ISAM2.h>
|
||||
#include <sophus/se3.h>
|
||||
#include <svo/frame.h>
|
||||
#include <gpu_svo/frame.h>
|
||||
|
||||
using gtsam::symbol_shorthand::B; // Bias (ax,ay,az,gx,gy,gz)
|
||||
using gtsam::symbol_shorthand::V; // Vel (xdot,ydot,zdot)
|
||||
+6
-3
@@ -17,7 +17,8 @@
|
||||
#ifndef SVO_INITIALIZATION_H
|
||||
#define SVO_INITIALIZATION_H
|
||||
|
||||
#include <svo/global.h>
|
||||
#include <gpu_svo/global.h>
|
||||
#include <gpu_svo/cl_class.h>
|
||||
|
||||
namespace svo {
|
||||
|
||||
@@ -35,7 +36,7 @@ public:
|
||||
EIGEN_MAKE_ALIGNED_OPERATOR_NEW
|
||||
|
||||
FramePtr frame_ref_;
|
||||
KltHomographyInit() {};
|
||||
KltHomographyInit(opencl* gpu_fast_):gpu_fast_(gpu_fast_) {};
|
||||
~KltHomographyInit() {};
|
||||
InitResult addFirstFrame(FramePtr frame_ref);
|
||||
InitResult addSecondFrame(FramePtr frame_ref);
|
||||
@@ -50,13 +51,15 @@ protected:
|
||||
vector<int> inliers_; //!< inliers after the geometric check (e.g., Homography).
|
||||
vector<Vector3d> xyz_in_cur_; //!< 3D points computed during the geometric check.
|
||||
SE3 T_cur_from_ref_; //!< computed transformation between the first two frames.
|
||||
opencl* gpu_fast_;
|
||||
};
|
||||
|
||||
/// Detect Fast corners in the image.
|
||||
void detectFeatures(
|
||||
FramePtr frame,
|
||||
vector<cv::Point2f>& px_vec,
|
||||
vector<Vector3d>& f_vec);
|
||||
vector<Vector3d>& f_vec,
|
||||
opencl* gpu_fast);
|
||||
|
||||
/// Compute optical flow (Lucas Kanade) for selected keypoints.
|
||||
void trackKlt(
|
||||
@@ -20,7 +20,7 @@
|
||||
#include <queue>
|
||||
#include <boost/noncopyable.hpp>
|
||||
#include <boost/thread.hpp>
|
||||
#include <svo/global.h>
|
||||
#include <gpu_svo/global.h>
|
||||
|
||||
namespace svo {
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
#ifndef SVO_MATCHER_H_
|
||||
#define SVO_MATCHER_H_
|
||||
|
||||
#include <svo/global.h>
|
||||
#include <gpu_svo/global.h>
|
||||
|
||||
namespace vk {
|
||||
class AbstractCamera;
|
||||
@@ -18,7 +18,7 @@
|
||||
#define SVO_POINT_H_
|
||||
|
||||
#include <boost/noncopyable.hpp>
|
||||
#include <svo/global.h>
|
||||
#include <gpu_svo/global.h>
|
||||
|
||||
namespace g2o {
|
||||
class VertexSBAPointXYZ;
|
||||
+1
-1
@@ -17,7 +17,7 @@
|
||||
#ifndef SVO_POSE_OPTIMIZER_H_
|
||||
#define SVO_POSE_OPTIMIZER_H_
|
||||
|
||||
#include <svo/global.h>
|
||||
#include <gpu_svo/global.h>
|
||||
|
||||
namespace svo {
|
||||
|
||||
+2
-2
@@ -17,8 +17,8 @@
|
||||
#ifndef SVO_REPROJECTION_H_
|
||||
#define SVO_REPROJECTION_H_
|
||||
|
||||
#include <svo/global.h>
|
||||
#include <svo/matcher.h>
|
||||
#include <gpu_svo/global.h>
|
||||
#include <gpu_svo/matcher.h>
|
||||
|
||||
namespace vk {
|
||||
class AbstractCamera;
|
||||
+1
-1
@@ -19,7 +19,7 @@
|
||||
|
||||
#include <vikit/nlls_solver.h>
|
||||
#include <vikit/performance_monitor.h>
|
||||
#include <svo/global.h>
|
||||
#include <gpu_svo/global.h>
|
||||
|
||||
namespace vk {
|
||||
class AbstractCamera;
|
||||
+1
-1
@@ -12,7 +12,7 @@
|
||||
#include <gtsam/geometry/Pose3.h>
|
||||
#include <vikit/robust_cost.h>
|
||||
#include <vikit/math_utils.h>
|
||||
#include <svo/frame.h>
|
||||
#include <gpu_svo/frame.h>
|
||||
|
||||
namespace svo {
|
||||
|
||||
@@ -26,12 +26,12 @@
|
||||
#include <g2o/solvers/dense/linear_solver_dense.h>
|
||||
#include <g2o/types/sba/types_six_dof_expmap.h>
|
||||
#include <g2o/solvers/structure_only/structure_only_solver.h>
|
||||
#include <svo/bundle_adjustment.h>
|
||||
#include <svo/frame.h>
|
||||
#include <svo/feature.h>
|
||||
#include <svo/point.h>
|
||||
#include <svo/config.h>
|
||||
#include <svo/map.h>
|
||||
#include <gpu_svo/bundle_adjustment.h>
|
||||
#include <gpu_svo/frame.h>
|
||||
#include <gpu_svo/feature.h>
|
||||
#include <gpu_svo/point.h>
|
||||
#include <gpu_svo/config.h>
|
||||
#include <gpu_svo/map.h>
|
||||
|
||||
#define SCHUR_TRICK 1
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
//
|
||||
// Created by root on 4/27/21.
|
||||
//
|
||||
#include "svo/cl_class.h"
|
||||
#include "gpu_svo/cl_class.h"
|
||||
opencl::opencl() {
|
||||
std::vector<cl::Platform> all_platforms;
|
||||
cl::Platform::get(&all_platforms);
|
||||
@@ -12,7 +12,7 @@ opencl::opencl() {
|
||||
//get default device of the default platform
|
||||
std::vector<cl::Device> all_devices;
|
||||
for(auto i:all_platforms){
|
||||
std::cout << "Find platform: " << i.getInfo<CL_PLATFORM_NAME>() << "\n";
|
||||
std::cout << "Find platform number:"<< i.getInfo<CL_PLATFORM_NAME>() << "\n";
|
||||
i.getDevices(CL_DEVICE_TYPE_GPU, &all_devices);
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ opencl::opencl() {
|
||||
|
||||
context=new cl::Context({ device });
|
||||
cl::Program::Sources sources;
|
||||
read_cl fast("../kernel/fast-gray.cl");
|
||||
read_cl fast(std::string(KERNEL_DIR)+"/fast-gray.cl");
|
||||
sources.push_back({ fast.src_str, fast.size });
|
||||
program=new cl::Program(*context, sources);
|
||||
if(program->build({ device },"-DFAST_THRESH=40") !=0)
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
#ifdef SVO_USE_ROS
|
||||
#include <vikit/params_helper.h>
|
||||
#endif
|
||||
#include <svo/config.h>
|
||||
#include <gpu_svo/config.h>
|
||||
|
||||
namespace svo {
|
||||
|
||||
|
||||
@@ -20,14 +20,14 @@
|
||||
#include <vikit/vision.h>
|
||||
#include <boost/bind.hpp>
|
||||
#include <boost/math/distributions/normal.hpp>
|
||||
#include <svo/global.h>
|
||||
#include <svo/depth_filter.h>
|
||||
#include <svo/frame.h>
|
||||
#include <svo/point.h>
|
||||
#include <svo/feature.h>
|
||||
#include <svo/matcher.h>
|
||||
#include <svo/config.h>
|
||||
#include <svo/feature_detection.h>
|
||||
#include <gpu_svo/global.h>
|
||||
#include <gpu_svo/depth_filter.h>
|
||||
#include <gpu_svo/frame.h>
|
||||
#include <gpu_svo/point.h>
|
||||
#include <gpu_svo/feature.h>
|
||||
#include <gpu_svo/matcher.h>
|
||||
#include <gpu_svo/config.h>
|
||||
#include <gpu_svo/feature_detection.h>
|
||||
|
||||
namespace svo {
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
#ifdef __ARM_NEON__
|
||||
#include <arm_neon.h>
|
||||
#endif
|
||||
#include <svo/feature_alignment.h>
|
||||
#include <gpu_svo/feature_alignment.h>
|
||||
|
||||
namespace svo {
|
||||
namespace feature_alignment {
|
||||
|
||||
@@ -14,8 +14,8 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
#include <svo/feature_detection.h>
|
||||
#include <svo/feature.h>
|
||||
#include <gpu_svo/feature_detection.h>
|
||||
#include <gpu_svo/feature.h>
|
||||
#include <vikit/vision.h>
|
||||
|
||||
namespace svo {
|
||||
@@ -32,14 +32,6 @@ AbstractDetector::AbstractDetector(
|
||||
grid_n_rows_(ceil(static_cast<double>(img_height)/cell_size_)),
|
||||
grid_occupancy_(grid_n_cols_*grid_n_rows_, false)
|
||||
{
|
||||
gpu_fast_= new opencl();
|
||||
cv::Mat init=cv::Mat::zeros(cv::Size(img_width, img_height),CV_8UC1);
|
||||
gpu_fast_->write_buf(0,0,init);
|
||||
cl_int2 corners[img_width*img_height];
|
||||
gpu_fast_->write_buf(0,1,img_width*img_height,corners);
|
||||
int icorner[1]={0};
|
||||
gpu_fast_->write_buf(0,2,1,icorner);
|
||||
gpu_fast_->write_buf(0,3,(1 << 18));
|
||||
}
|
||||
|
||||
void AbstractDetector::resetGrid()
|
||||
@@ -67,9 +59,11 @@ FastDetector::FastDetector(
|
||||
const int img_width,
|
||||
const int img_height,
|
||||
const int cell_size,
|
||||
opencl* gpu_fast_,
|
||||
const int n_pyr_levels) :
|
||||
AbstractDetector(img_width, img_height, cell_size, n_pyr_levels)
|
||||
{}
|
||||
AbstractDetector(img_width, img_height, cell_size, n_pyr_levels),gpu_fast_(gpu_fast_)
|
||||
{
|
||||
}
|
||||
|
||||
void FastDetector::detect(
|
||||
Frame* frame,
|
||||
@@ -81,26 +75,28 @@ void FastDetector::detect(
|
||||
for(int L=0; L<n_pyr_levels_; ++L)
|
||||
{
|
||||
const int scale = (1<<L);
|
||||
gpu_fast_->reload_buf(0,0,img_pyr[L].data);
|
||||
cv::Mat img=img_pyr.at(L);
|
||||
gpu_fast_->reload_buf(0,0,img);
|
||||
int icorner[1]={0};
|
||||
gpu_fast_->reload_buf(0,2,icorner);
|
||||
gpu_fast_->run(0,img_pyr[L].cols,img_pyr[L].rows);
|
||||
cl_int2* fast_corners;
|
||||
cl_int2 fast_corners[1000000];
|
||||
gpu_fast_->read(0,1,fast_corners);
|
||||
int count[1]={0};
|
||||
gpu_fast_->read(0,2,count);
|
||||
//vector<int> scores, nm_corners;
|
||||
//fast::fast_corner_score_10((fast::fast_byte*) img_pyr[L].data, img_pyr[L].cols, fast_corners, 20, scores);
|
||||
//fast::fast_nonmax_3x3(fast_corners, scores, nm_corners);
|
||||
|
||||
for(uint i=0;i<count[0];++i)
|
||||
{
|
||||
if(fast_corners[i].x<0 || fast_corners[i].x>img_pyr[L].cols || fast_corners[i].y>img_pyr[L].rows || fast_corners[i].y<0)continue;
|
||||
if(fast_corners[i].x<0 || fast_corners[i].x>img_pyr[L].cols || fast_corners[i].y>img_pyr[L].rows || fast_corners[i].y<0)
|
||||
continue;
|
||||
|
||||
const int k = static_cast<int>((fast_corners[i].y*scale)/cell_size_)*grid_n_cols_
|
||||
+ static_cast<int>((fast_corners[i].x*scale)/cell_size_);
|
||||
|
||||
if(grid_occupancy_[k])
|
||||
continue;
|
||||
|
||||
const float score = vk::shiTomasiScore(img_pyr[L], fast_corners[i].x, fast_corners[i].y);
|
||||
|
||||
if(score > corners.at(k).score)
|
||||
corners.at(k) = Corner(fast_corners[i].x*scale, fast_corners[i].y*scale, score, L, 0.0f);
|
||||
}
|
||||
|
||||
@@ -15,10 +15,10 @@
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
#include <stdexcept>
|
||||
#include <svo/frame.h>
|
||||
#include <svo/feature.h>
|
||||
#include <svo/point.h>
|
||||
#include <svo/config.h>
|
||||
#include <gpu_svo/frame.h>
|
||||
#include <gpu_svo/feature.h>
|
||||
#include <gpu_svo/point.h>
|
||||
#include <gpu_svo/config.h>
|
||||
#include <vikit/math_utils.h>
|
||||
#include <vikit/vision.h>
|
||||
#include <vikit/performance_monitor.h>
|
||||
|
||||
@@ -19,12 +19,12 @@
|
||||
#include <Eigen/StdVector>
|
||||
#include <boost/bind.hpp>
|
||||
#include <fstream>
|
||||
#include <svo/frame_handler_base.h>
|
||||
#include <svo/config.h>
|
||||
#include <svo/feature.h>
|
||||
#include <svo/matcher.h>
|
||||
#include <svo/map.h>
|
||||
#include <svo/point.h>
|
||||
#include <gpu_svo/frame_handler_base.h>
|
||||
#include <gpu_svo/config.h>
|
||||
#include <gpu_svo/feature.h>
|
||||
#include <gpu_svo/matcher.h>
|
||||
#include <gpu_svo/map.h>
|
||||
#include <gpu_svo/point.h>
|
||||
|
||||
namespace svo
|
||||
{
|
||||
|
||||
@@ -14,18 +14,18 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
#include <svo/config.h>
|
||||
#include <svo/frame_handler_mono.h>
|
||||
#include <svo/map.h>
|
||||
#include <svo/frame.h>
|
||||
#include <svo/feature.h>
|
||||
#include <svo/point.h>
|
||||
#include <svo/pose_optimizer.h>
|
||||
#include <svo/sparse_img_align.h>
|
||||
#include <gpu_svo/config.h>
|
||||
#include <gpu_svo/frame_handler_mono.h>
|
||||
#include <gpu_svo/map.h>
|
||||
#include <gpu_svo/frame.h>
|
||||
#include <gpu_svo/feature.h>
|
||||
#include <gpu_svo/point.h>
|
||||
#include <gpu_svo/pose_optimizer.h>
|
||||
#include <gpu_svo/sparse_img_align.h>
|
||||
#include <vikit/performance_monitor.h>
|
||||
#include <svo/depth_filter.h>
|
||||
#include <gpu_svo/depth_filter.h>
|
||||
#ifdef USE_BUNDLE_ADJUSTMENT
|
||||
#include <svo/bundle_adjustment.h>
|
||||
#include <gpu_svo/bundle_adjustment.h>
|
||||
#endif
|
||||
|
||||
namespace svo {
|
||||
@@ -36,6 +36,16 @@ FrameHandlerMono::FrameHandlerMono(vk::AbstractCamera* cam,Sophus::SE3& SE_init)
|
||||
reprojector_(cam_, map_),
|
||||
depth_filter_(NULL)
|
||||
{
|
||||
gpu_fast_= new opencl();
|
||||
gpu_fast_->make_kernel("fast_gray");
|
||||
cv::Mat img=cv::Mat(cv::Size(1000, 1000),CV_8UC1);
|
||||
gpu_fast_->write_buf(0,0,img);
|
||||
cl_int2 corners_[1000000];
|
||||
gpu_fast_->write_buf(0,1,1000000,corners_);
|
||||
int icorner[1]={0};
|
||||
gpu_fast_->write_buf(0,2,1,icorner);
|
||||
gpu_fast_->write_buf(0,3,(1 << 18));
|
||||
klt_homography_init_=new initialization::KltHomographyInit(gpu_fast_);
|
||||
initialize();
|
||||
imu_integPtr_=std::make_unique<Imu_Integration>(SE_init);
|
||||
}
|
||||
@@ -44,7 +54,7 @@ void FrameHandlerMono::initialize()
|
||||
{
|
||||
feature_detection::DetectorPtr feature_detector(
|
||||
new feature_detection::FastDetector(
|
||||
cam_->width(), cam_->height(), Config::gridSize(), Config::nPyrLevels()));
|
||||
cam_->width(), cam_->height(), Config::gridSize(),gpu_fast_, Config::nPyrLevels()));
|
||||
DepthFilter::callback_t depth_filter_cb = boost::bind(
|
||||
&MapPointCandidates::newCandidatePoint, &map_.point_candidates_, _1, _2);
|
||||
depth_filter_ = new DepthFilter(feature_detector, depth_filter_cb);
|
||||
@@ -90,7 +100,7 @@ void FrameHandlerMono::addImage(const cv::Mat& img, const double timestamp)
|
||||
FrameHandlerMono::UpdateResult FrameHandlerMono::processFirstFrame()
|
||||
{
|
||||
new_frame_->T_f_w_ = SE3(Matrix3d::Identity(), Vector3d::Zero());
|
||||
if(klt_homography_init_.addFirstFrame(new_frame_) == initialization::FAILURE)
|
||||
if(klt_homography_init_->addFirstFrame(new_frame_) == initialization::FAILURE)
|
||||
return RESULT_NO_KEYFRAME;
|
||||
new_frame_->setKeyframe();
|
||||
map_.addKeyframe(new_frame_);
|
||||
@@ -101,7 +111,7 @@ FrameHandlerMono::UpdateResult FrameHandlerMono::processFirstFrame()
|
||||
|
||||
FrameHandlerBase::UpdateResult FrameHandlerMono::processSecondFrame()
|
||||
{
|
||||
initialization::InitResult res = klt_homography_init_.addSecondFrame(new_frame_);
|
||||
initialization::InitResult res = klt_homography_init_->addSecondFrame(new_frame_);
|
||||
if(res == initialization::FAILURE)
|
||||
return RESULT_FAILURE;
|
||||
else if(res == initialization::NO_KEYFRAME)
|
||||
@@ -120,7 +130,7 @@ FrameHandlerBase::UpdateResult FrameHandlerMono::processSecondFrame()
|
||||
// add frame to map
|
||||
map_.addKeyframe(new_frame_);
|
||||
stage_ = STAGE_DEFAULT_FRAME;
|
||||
klt_homography_init_.reset();
|
||||
klt_homography_init_->reset();
|
||||
SVO_INFO_STREAM("Init: Selected second frame, triangulated initial map.");
|
||||
return RESULT_IS_KEYFRAME;
|
||||
}
|
||||
|
||||
@@ -2,16 +2,16 @@
|
||||
// Created by gfuse on 4/9/21.
|
||||
//
|
||||
//#define NDEBUG
|
||||
#include "svo/imu_integration.h"
|
||||
#include "gpu_svo/imu_integration.h"
|
||||
#include <memory>
|
||||
#include <utility>
|
||||
#include "svo/feature.h"
|
||||
#include "svo/point.h"
|
||||
#include "svo/svoVisionFactor.h"
|
||||
#include "gpu_svo/feature.h"
|
||||
#include "gpu_svo/point.h"
|
||||
#include "gpu_svo/svoVisionFactor.h"
|
||||
#include <gtsam/nonlinear/Marginals.h>
|
||||
#include <gtsam/geometry/Pose3.h>
|
||||
#include <vikit/params_helper.h>
|
||||
#include <svo/config.h>
|
||||
#include <gpu_svo/config.h>
|
||||
|
||||
Imu_Integration::Imu_Integration(Sophus::SE3& SE_init){
|
||||
graphPtr=std::make_shared<gtsam::NonlinearFactorGraph>();
|
||||
|
||||
@@ -14,12 +14,12 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
#include <svo/config.h>
|
||||
#include <svo/frame.h>
|
||||
#include <svo/point.h>
|
||||
#include <svo/feature.h>
|
||||
#include <svo/initialization.h>
|
||||
#include <svo/feature_detection.h>
|
||||
#include <gpu_svo/config.h>
|
||||
#include <gpu_svo/frame.h>
|
||||
#include <gpu_svo/point.h>
|
||||
#include <gpu_svo/feature.h>
|
||||
#include <gpu_svo/initialization.h>
|
||||
#include <gpu_svo/feature_detection.h>
|
||||
#include <vikit/math_utils.h>
|
||||
#include <vikit/homography.h>
|
||||
|
||||
@@ -29,7 +29,7 @@ namespace initialization {
|
||||
InitResult KltHomographyInit::addFirstFrame(FramePtr frame_ref)
|
||||
{
|
||||
reset();
|
||||
detectFeatures(frame_ref, px_ref_, f_ref_);
|
||||
detectFeatures(frame_ref, px_ref_, f_ref_,gpu_fast_);
|
||||
if(px_ref_.size() < 100)
|
||||
{
|
||||
SVO_WARN_STREAM_THROTTLE(2.0, "First image has less than 100 features. Retry in more textured environment.");
|
||||
@@ -107,11 +107,12 @@ void KltHomographyInit::reset()
|
||||
void detectFeatures(
|
||||
FramePtr frame,
|
||||
vector<cv::Point2f>& px_vec,
|
||||
vector<Vector3d>& f_vec)
|
||||
vector<Vector3d>& f_vec,
|
||||
opencl* gpu_fast)
|
||||
{
|
||||
Features new_features;
|
||||
feature_detection::FastDetector detector(
|
||||
frame->img().cols, frame->img().rows, Config::gridSize(), Config::nPyrLevels());
|
||||
frame->img().cols, frame->img().rows, Config::gridSize(), gpu_fast,Config::nPyrLevels());
|
||||
detector.detect(frame.get(), frame->img_pyr_, Config::triangMinCornerScore(), new_features);
|
||||
|
||||
// now for all maximum corners, initialize a new seed
|
||||
|
||||
@@ -15,10 +15,10 @@
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
#include <set>
|
||||
#include <svo/map.h>
|
||||
#include <svo/point.h>
|
||||
#include <svo/frame.h>
|
||||
#include <svo/feature.h>
|
||||
#include <gpu_svo/map.h>
|
||||
#include <gpu_svo/point.h>
|
||||
#include <gpu_svo/frame.h>
|
||||
#include <gpu_svo/feature.h>
|
||||
#include <boost/bind.hpp>
|
||||
|
||||
namespace svo {
|
||||
|
||||
@@ -19,12 +19,12 @@
|
||||
#include <vikit/vision.h>
|
||||
#include <vikit/math_utils.h>
|
||||
#include <vikit/patch_score.h>
|
||||
#include <svo/matcher.h>
|
||||
#include <svo/frame.h>
|
||||
#include <svo/feature.h>
|
||||
#include <svo/point.h>
|
||||
#include <svo/config.h>
|
||||
#include <svo/feature_alignment.h>
|
||||
#include <gpu_svo/matcher.h>
|
||||
#include <gpu_svo/frame.h>
|
||||
#include <gpu_svo/feature.h>
|
||||
#include <gpu_svo/point.h>
|
||||
#include <gpu_svo/config.h>
|
||||
#include <gpu_svo/feature_alignment.h>
|
||||
|
||||
namespace svo {
|
||||
|
||||
|
||||
@@ -16,9 +16,9 @@
|
||||
|
||||
#include <stdexcept>
|
||||
#include <vikit/math_utils.h>
|
||||
#include <svo/point.h>
|
||||
#include <svo/frame.h>
|
||||
#include <svo/feature.h>
|
||||
#include <gpu_svo/point.h>
|
||||
#include <gpu_svo/frame.h>
|
||||
#include <gpu_svo/feature.h>
|
||||
|
||||
namespace svo {
|
||||
|
||||
|
||||
@@ -15,10 +15,10 @@
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
#include <stdexcept>
|
||||
#include <svo/pose_optimizer.h>
|
||||
#include <svo/frame.h>
|
||||
#include <svo/feature.h>
|
||||
#include <svo/point.h>
|
||||
#include <gpu_svo/pose_optimizer.h>
|
||||
#include <gpu_svo/frame.h>
|
||||
#include <gpu_svo/feature.h>
|
||||
#include <gpu_svo/point.h>
|
||||
#include <vikit/robust_cost.h>
|
||||
#include <vikit/math_utils.h>
|
||||
|
||||
|
||||
@@ -16,12 +16,12 @@
|
||||
|
||||
#include <algorithm>
|
||||
#include <stdexcept>
|
||||
#include <svo/reprojector.h>
|
||||
#include <svo/frame.h>
|
||||
#include <svo/point.h>
|
||||
#include <svo/feature.h>
|
||||
#include <svo/map.h>
|
||||
#include <svo/config.h>
|
||||
#include <gpu_svo/reprojector.h>
|
||||
#include <gpu_svo/frame.h>
|
||||
#include <gpu_svo/point.h>
|
||||
#include <gpu_svo/feature.h>
|
||||
#include <gpu_svo/map.h>
|
||||
#include <gpu_svo/config.h>
|
||||
#include <boost/bind.hpp>
|
||||
#include <boost/thread.hpp>
|
||||
#include <vikit/abstract_camera.h>
|
||||
|
||||
@@ -15,11 +15,11 @@
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
#include <algorithm>
|
||||
#include <svo/sparse_img_align.h>
|
||||
#include <svo/frame.h>
|
||||
#include <svo/feature.h>
|
||||
#include <svo/config.h>
|
||||
#include <svo/point.h>
|
||||
#include <gpu_svo/sparse_img_align.h>
|
||||
#include <gpu_svo/frame.h>
|
||||
#include <gpu_svo/feature.h>
|
||||
#include <gpu_svo/config.h>
|
||||
#include <gpu_svo/point.h>
|
||||
#include <vikit/abstract_camera.h>
|
||||
#include <vikit/vision.h>
|
||||
#include <vikit/math_utils.h>
|
||||
|
||||
Reference in New Issue
Block a user