changed interface of feature detector. now it returns directly a list of features instead of only corners
This commit is contained in:
@@ -17,8 +17,10 @@
|
||||
#include <string.h>
|
||||
#include <svo/global.h>
|
||||
#include <svo/config.h>
|
||||
#include <svo/frame.h>
|
||||
#include <svo/feature_detection.h>
|
||||
#include <svo/depth_filter.h>
|
||||
#include <svo/feature.h>
|
||||
#include <vikit/timer.h>
|
||||
#include <vikit/vision.h>
|
||||
#include <vikit/abstract_camera.h>
|
||||
@@ -37,38 +39,29 @@ void testCornerDetector()
|
||||
cv::Mat img(cv::imread(img_name, 0));
|
||||
assert(img.type() == CV_8UC1 && !img.empty());
|
||||
|
||||
svo::ImgPyr img_pyr;
|
||||
svo::frame_utils::createImgPyramid(
|
||||
img, max(svo::Config::nPyrLevels(), svo::Config::kltMaxLevel()+1), img_pyr);
|
||||
svo::Features fts;
|
||||
vk::AbstractCamera* cam = new vk::ATANCamera(752, 480, 0.511496, 0.802603, 0.530199, 0.496011, 0.934092);
|
||||
svo::FramePtr frame(new svo::Frame(cam, img, 0.0));
|
||||
|
||||
// Corner detection
|
||||
vk::Timer t;
|
||||
svo::feature_detection::Corners corners;
|
||||
svo::Features fts;
|
||||
svo::feature_detection::FastDetector fast_detector(
|
||||
img.cols, img.rows, svo::Config::gridSize(), svo::Config::nPyrLevels());
|
||||
for(int i=0; i<100; ++i)
|
||||
{
|
||||
fast_detector.detect(img_pyr, fts, svo::Config::triangMinCornerScore(), &corners);
|
||||
fast_detector.detect(frame.get(), frame->img_pyr_, svo::Config::triangMinCornerScore(), fts);
|
||||
}
|
||||
printf("Fast corner detection took %f ms, %zu corners detected (ref i7-W520: 8.06878ms, 416)\n", t.stop()*10, corners.size());
|
||||
printf("Fast corner detection took %f ms, %zu corners detected (ref i7-W520: 8.06878ms, 416)\n", t.stop()*10, fts.size());
|
||||
printf("Note, in this case, feature detection also contains the cam2world projection of the feature.\n");
|
||||
cv::Mat img_rgb = cv::Mat(img.size(), CV_8UC3);
|
||||
cv::cvtColor(img, img_rgb, CV_GRAY2RGB);
|
||||
std::for_each(fts.begin(), fts.end(), [&](svo::Feature* i){
|
||||
cv::circle(img_rgb, cv::Point2f(i->px[0], i->px[1]), 4*(i->level+1), cv::Scalar(0,255,0), 1);
|
||||
});
|
||||
cv::imshow("ref_img", img_rgb);
|
||||
cv::waitKey(0);
|
||||
|
||||
if(false)
|
||||
{
|
||||
cv::Mat img_rgb = cv::Mat(img.size(), CV_8UC3);
|
||||
cv::cvtColor(img, img_rgb, CV_GRAY2RGB);
|
||||
for(svo::feature_detection::Corners::iterator it=corners.begin(); it!=corners.end(); ++it)
|
||||
{
|
||||
// we must check again if the score is above the threshold because the Corners
|
||||
// vector is initialized with dummy corners
|
||||
if(it->score > svo::Config::triangMinCornerScore())
|
||||
{
|
||||
cv::circle(img_rgb, cv::Point2f(it->x, it->y), 4*(it->level+1), cv::Scalar(0,255,0), 1);
|
||||
}
|
||||
}
|
||||
cv::imshow("ref_img", img_rgb);
|
||||
cv::waitKey(0);
|
||||
}
|
||||
std::for_each(fts.begin(), fts.end(), [&](svo::Feature* i){ delete i; });
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
Reference in New Issue
Block a user