debug gpu version done
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user