42 #include <pcl/common/point_tests.h>
43 #include <pcl/keypoints/agast_2d.h>
72 template <
typename Po
intInT,
typename Po
intOutT = pcl::Po
intWithScale,
typename IntensityT = pcl::common::IntensityFieldAccessor<Po
intInT> >
76 using Ptr = shared_ptr<BriskKeypoint2D<PointInT, PointOutT, IntensityT> >;
77 using ConstPtr = shared_ptr<const BriskKeypoint2D<PointInT, PointOutT, IntensityT> >;
91 : threshold_ (threshold)
95 name_ =
"BriskKeypoint2D";
107 threshold_ = threshold;
141 remove_invalid_3D_keypoints_ =
remove;
150 return (remove_invalid_3D_keypoints_);
159 int u =
static_cast<int>(x);
160 int v =
static_cast<int>(y);
162 pt.x = pt.y = pt.z = 0;
164 const PointInT &p1 = (*cloud)(u, v);
165 const PointInT &p2 = (*cloud)(u+1, v);
166 const PointInT &p3 = (*cloud)(u, v+1);
167 const PointInT &p4 = (*cloud)(u+1, v+1);
169 float fx = x -
static_cast<float>(u), fy = y - static_cast<float>(v);
170 float fx1 = 1.0f - fx, fy1 = 1.0f - fy;
172 float w1 = fx1 * fy1, w2 = fx * fy1, w3 = fx1 * fy, w4 = fx * fy;
205 pt.x = pt.y = pt.z = std::numeric_limits<float>::quiet_NaN ();
208 weight = 1.0f / weight;
209 pt.x *= weight; pt.y *= weight; pt.z *= weight;
224 IntensityT intensity_;
234 bool remove_invalid_3D_keypoints_{
false};
262 Layer (
const std::vector<unsigned char>& img,
263 int width,
int height,
264 float scale = 1.0f,
float offset = 0.0f);
277 getAgastPoints (std::uint8_t threshold, std::vector<
pcl::PointUV, Eigen::aligned_allocator<pcl::PointUV> > &keypoints);
286 getAgastScore (
int x,
int y, std::uint8_t threshold);
293 getAgastScore_5_8 (
int x,
int y, std::uint8_t threshold);
301 getAgastScore (
float xf,
float yf, std::uint8_t threshold,
float scale = 1.0f);
312 getValue (
const std::vector<unsigned char>& mat,
313 int width,
int height,
float xf,
float yf,
float scale);
316 const std::vector<unsigned char>&
333 return (img_height_);
351 inline const std::vector<unsigned char>&
360 halfsample (
const std::vector<unsigned char>& srcimg,
361 int srcwidth,
int srcheight,
362 std::vector<unsigned char>& dstimg,
363 int dstwidth,
int dstheight);
367 twothirdsample (
const std::vector<unsigned char>& srcimg,
368 int srcwidth,
int srcheight,
369 std::vector<unsigned char>& dstimg,
370 int dstwidth,
int dstheight);
373 std::vector<unsigned char> img_;
378 std::vector<unsigned char> scores_;
405 constructPyramid (
const std::vector<unsigned char>& image,
406 int width,
int height);
413 getKeypoints (
const int threshold,
414 std::vector<
pcl::PointWithScale, Eigen::aligned_allocator<pcl::PointWithScale> > &keypoints);
419 isMax2D (
const std::uint8_t layer,
const int x_layer,
const int y_layer);
423 refine1D (
const float s_05,
const float s0,
const float s05,
float& max);
427 refine1D_1 (
const float s_05,
const float s0,
const float s05,
float& max);
431 refine1D_2 (
const float s_05,
const float s0,
const float s05,
float& max);
435 subpixel2D (
const int s_0_0,
const int s_0_1,
const int s_0_2,
436 const int s_1_0,
const int s_1_1,
const int s_1_2,
437 const int s_2_0,
const int s_2_1,
const int s_2_2,
438 float& delta_x,
float& delta_y);
442 refine3D (
const std::uint8_t layer,
443 const int x_layer,
const int y_layer,
444 float& x,
float& y,
float& scale,
bool& ismax);
448 getScoreAbove (
const std::uint8_t layer,
const int x_layer,
const int y_layer);
451 getScoreBelow (
const std::uint8_t layer,
const int x_layer,
const int y_layer);
455 getScoreMaxAbove (
const std::uint8_t layer,
456 const int x_layer,
const int y_layer,
457 const int threshold,
bool& ismax,
458 float& dx,
float& dy);
461 getScoreMaxBelow (
const std::uint8_t layer,
462 const int x_layer,
const int y_layer,
463 const int threshold,
bool& ismax,
464 float& dx,
float& dy);
468 std::vector<pcl::keypoints::brisk::Layer>
pyramid_;
475 float safety_factor_{1.0};
476 float basic_size_{12.0};
483 #include <pcl/keypoints/impl/brisk_2d.hpp>
bool isFinite(const PointT &pt)
Tests if the 3D components of a point are all finite param[in] pt point to be tested return true if f...
BRISK Scale Space helper.
A layer in the BRISK detector pyramid.
typename Keypoint< PointInT, PointOutT >::PointCloudOut PointCloudOut
~BriskKeypoint2D() override=default
Destructor.
std::size_t getThreshold()
Get the threshold for corner detection, as set by the user.
std::vector< pcl::keypoints::brisk::Layer > pyramid_
shared_ptr< AgastDetector5_8 > Ptr
void bilinearInterpolation(const PointCloudInConstPtr &cloud, float x, float y, PointOutT &pt)
int getImageWidth() const
Get the width of the image used.
shared_ptr< OastDetector9_16 > Ptr
typename PointCloudIn::ConstPtr PointCloudInConstPtr
std::string name_
The key point detection method's name.
float getOffset() const
Get the offset used.
shared_ptr< BriskKeypoint2D< PointInT, PointOutT, IntensityT > > Ptr
Keypoint represents the base class for key points.
A 2D point structure representing pixel image coordinates.
typename Keypoint< PointInT, PointOutT >::KdTree KdTree
shared_ptr< const BriskKeypoint2D< PointInT, PointOutT, IntensityT > > ConstPtr
int getOctaves()
Returns the number of octaves used.
static const int HALFSAMPLE
bool initCompute() override
Initializes everything and checks whether input data is fine.
int k_
The number of K nearest neighbors to use for each point.
int getImageHeight() const
Get the height of the image used.
float getScale() const
Get the scale used.
bool getRemoveInvalid3DKeypoints()
Specify whether the keypoints that do not have a valid 3D position are kept (false) or removed (true)...
void setRemoveInvalid3DKeypoints(bool remove)
Specify whether we should do a 2nd pass through the list of keypoints found, and remove the ones that...
Detects BRISK interest points based on the original code and paper reference by.
BriskKeypoint2D(int octaves=4, int threshold=60)
Constructor.
A point structure representing a 3-D position and scale.
std::uint8_t safe_threshold_
void setOctaves(const int octaves)
Set the number of octaves to use.
typename Keypoint< PointInT, PointOutT >::PointCloudIn PointCloudIn
void setThreshold(const int threshold)
Sets the threshold for corner detection.
const std::vector< unsigned char > & getScores() const
Get the scores obtained.
const std::vector< unsigned char > & getImage() const
Get the image used.
static const int TWOTHIRDSAMPLE
void detectKeypoints(PointCloudOut &output) override
Detects the keypoints.