18 #ifndef PIC_FEATURES_MATCHING_FAST_CORNER_DETECTOR_HPP 19 #define PIC_FEATURES_MATCHING_FAST_CORNER_DETECTOR_HPP 21 #include "../util/vec.hpp" 22 #include "../util/std_util.hpp" 24 #include "../image.hpp" 25 #include "../filtering/filter_luminance.hpp" 26 #include "../filtering/filter_gaussian_2d.hpp" 28 #include "../features_matching/general_corner_detector.hpp" 30 #ifndef PIC_DISABLE_EIGEN 32 #ifndef PIC_EIGEN_NOT_BUNDLED 33 #include "../externals/Eigen/Dense" 35 #include <Eigen/Dense> 42 #ifndef PIC_DISABLE_EIGEN 95 if(img == NULL || corners == NULL) {
109 std::vector< Eigen::Vector3f > corners_w_quality;
115 int x[] = {0, 1, 2, 3, 3, 3, 2, 1, 0, -1, -2, -3, -3, -3, -2, -1};
116 int y[] = {3, 3, 2, 1, 0, -1, -2, -3, -3, -3, -2, -1, 0, 1, 2, 3};
121 bool *corners_map =
new bool[width * height];
123 memset(corners_map, 0,
sizeof(
bool) * width * height);
125 Image V(1,width, height, 1);
128 for(
int i=3; i<(height - 3); i++) {
129 for(
int j=3; j<(width - 3); j++) {
130 int ind = i * width + j;
140 for(
int k=0; k<16; k++){
141 float value = (*lum_flt)(j + x[k], i + y[k])[0];
149 thr = 0.2f * sum / 16.0f;
157 float p_thr_dark = p - thr;
158 float p_thr_bright = p + thr;
160 for(
int k=0; k<16; k++){
161 bDark[k] = v[k] <= p_thr_dark;
162 bBright[k] = v[k] >= p_thr_bright;
166 int cDark = bDark[0] + bDark[4] + bDark[8] + bDark[12];
167 int cBright = bBright[0] + bBright[4] + bBright[8] + bBright[12];
169 if((cDark < 3) && (cBright < 3) ){
175 int counter_dark = 0;
176 int counter_bright = 0;
179 for(
int k=0; k<16; k++){
192 if((counter_bright > 11) || (counter_dark > 11)) {
193 corners_map[ind] =
true;
197 float V_bright = 0.0f;
198 for(
int k=0; k<16; k++){
200 V_bright += fabsf(v[k] - p) - thr;
204 V_dark += fabsf(p - v[k]) - thr;
207 V.
data[ind] =
MAX(V_bright, V_dark);
216 int side =
radius * 2 + 1;
217 int *indices =
new int[side * side];
219 for(
int i=3; i<(height - 3); i++) {
220 for(
int j=3; j<(width - 3); j++) {
221 int ind = i * width + j;
223 if(!corners_map[ind]){
231 int yy =
CLAMP(i + k, height);
235 if((l == 0)&&(k == 0)) {
239 int xx =
CLAMP(j + l, width);
241 ind = yy * width + xx;
243 if(corners_map[ind]){
244 indices[counter] = ind;
254 float V_value = V.
data[indices[0]];
257 for(
int k=1; k<counter; k++){
258 if(V.
data[indices[k]] > V_value) {
259 V_value = V.
data[indices[k]];
265 corners_w_quality.push_back(Eigen::Vector3f (
float(j),
float(i), 1.0f) );
268 corners_w_quality.push_back(Eigen::Vector3f (
float(j),
float(i), 1.0f) );
Definition: filter_luminance.hpp:28
float * data
data is the main buffer where pixel values are stored.
Definition: image.hpp:91
void setZero()
setZero sets data to 0.0f.
int channels
Definition: image.hpp:80
T * delete_s(T *data)
delete_s
Definition: std_util.hpp:123
~FastCornerDetector()
Definition: fast_corner_detector.hpp:69
bool bexecuteThreshold
Definition: fast_corner_detector.hpp:48
void update(float sigma=1.0f, int radius=1, float threshold=0.001f)
update
Definition: fast_corner_detector.hpp:81
FastCornerDetector(float sigma=1.0f, int radius=1, float threshold=0.001f)
FastCornerDetector.
Definition: fast_corner_detector.hpp:60
float sigma
Definition: fast_corner_detector.hpp:50
static Image * execute(Image *imgIn, Image *imgOut, LUMINANCE_TYPE type=LT_CIE_LUMINANCE)
execute
Definition: filter_luminance.hpp:166
Image * Process(ImageVec imgIn, Image *imgOut)
Process.
Definition: filter_npasses.hpp:310
The GeneralCornerDetector class.
Definition: general_corner_detector.hpp:42
The Image class stores an image as buffer of float.
Definition: image.hpp:60
bool bLum
Definition: general_corner_detector.hpp:46
int radius
Definition: fast_corner_detector.hpp:51
PIC_INLINE ImageVec Single(Image *img)
Single creates an std::vector which contains img; this is for filters input.
Definition: image_vec.hpp:36
Definition: bilateral_separation.hpp:25
Definition: fast_corner_detector.hpp:44
Image * lum
Definition: general_corner_detector.hpp:45
#define CLAMP(x, a)
Definition: math.hpp:77
#define MAX(a, b)
Definition: math.hpp:73
The FilterGaussian2D class.
Definition: filter_gaussian_2d.hpp:31
int width
Definition: image.hpp:80
int height
Definition: image.hpp:80
float threshold
Definition: fast_corner_detector.hpp:50
static void sortCornersAndTransfer(std::vector< Eigen::Vector3f > *corners, std::vector< Eigen::Vector2f > *cornersOut, int nBestPoints=-1, bool bDescend=true)
sortCornersAndTransfer
Definition: general_corner_detector.hpp:127
void execute(Image *img, std::vector< Eigen::Vector2f > *corners)
execute
Definition: fast_corner_detector.hpp:93
Image * lum_flt
Definition: fast_corner_detector.hpp:47