diff --git a/GPU_version/vio/include/vio/cl_class.h b/GPU_version/vio/include/vio/cl_class.h index 99b6168..eb62562 100644 --- a/GPU_version/vio/include/vio/cl_class.h +++ b/GPU_version/vio/include/vio/cl_class.h @@ -12,6 +12,7 @@ #include #include #include +#include class kernel{ public: @@ -114,7 +115,7 @@ public: }; class opencl{ public: - opencl(); + opencl(vk::AbstractCamera* cam); ~opencl(); int32_t make_kernel(std::string name){_kernels.push_back(kernel(program,name));}; template @@ -195,6 +196,7 @@ private: cl::Device* device = nullptr; cl::Program* program = nullptr; cl::CommandQueue* queue= nullptr; + vk::AbstractCamera* cam= nullptr; }; #endif //VIO_OPENCL_CL_CLASS_H diff --git a/GPU_version/vio/src/cl_class.cpp b/GPU_version/vio/src/cl_class.cpp index c47c8be..46cb4bd 100644 --- a/GPU_version/vio/src/cl_class.cpp +++ b/GPU_version/vio/src/cl_class.cpp @@ -2,7 +2,7 @@ // Created by root on 4/27/21. // #include -opencl::opencl() { +opencl::opencl(vk::AbstractCamera* cam):cam(cam) { std::vector all_platforms; cl::Platform::get(&all_platforms); if (all_platforms.size() == 0){ @@ -27,7 +27,6 @@ opencl::opencl() { << "CL_DEVICE_COMPILER_AVAILABLE: " <getInfo()<<'\n' << "CL_DEVICE_LOCAL_MEM_SIZE: " <getInfo()<<'\n' << "CL_DEVICE_GLOBAL_MEM_SIZE: " <getInfo()<<'\n'; - context=new cl::Context({ *device }); cl::Program::Sources sources; read_cl fast(std::string(KERNEL_DIR)+"/fast-gray.cl"); @@ -35,7 +34,13 @@ opencl::opencl() { read_cl compute_residual(std::string(KERNEL_DIR)+"/compute-residual.cl"); sources.push_back({ compute_residual.src_str, compute_residual.size }); program=new cl::Program(*context, sources); - if(program->build({ *device },"-DFAST_THRESH=40 -DPATCH_SIZE=2 -DPATCH_HALFSIZE=1 -DF_X=296.724480 -DF_Y=395.357280 -DC_X=317.877600 -DC_Y=238.752640 -DS=1.016870") !=0) + double* camera=cam->params(); + std::string options="-DFAST_THRESH=40 -DPATCH_SIZE=2 -DPATCH_HALFSIZE=1 -DF_X="+ std::to_string(camera[0]) + + " -DF_Y="+std::to_string(camera[1])+ + " -DC_X="+std::to_string(camera[2])+ + " -DC_Y="+std::to_string(camera[3])+ + " -DS="+std::to_string(camera[4]); + if(program->build({ *device },options.c_str()) !=0) std::cout << " Error building: " << program->getBuildInfo(*device)<<'\n' <getBuildInfo(*device) << '\n'; queue=new cl::CommandQueue(*context,*device,CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE,NULL); diff --git a/GPU_version/vio/src/frame_handler_mono.cpp b/GPU_version/vio/src/frame_handler_mono.cpp index 0b4950a..84cb7b3 100644 --- a/GPU_version/vio/src/frame_handler_mono.cpp +++ b/GPU_version/vio/src/frame_handler_mono.cpp @@ -36,7 +36,7 @@ FrameHandlerMono::FrameHandlerMono(vk::AbstractCamera* cam,Eigen::Matrixmake_kernel("fast_gray"); cv::Mat img=cv::Mat(cv::Size(700, 500),CV_8UC1); gpu_fast_->write_buf(0,0,img);