68 #define LOAD_AND_SET_MASK(ptr, a, stride, dark, bright, dark_mask, bright_mask) \ 70 unsigned char pixel; \ 71 pixel = *(ptr + (int)stride * offsets_s[a][1] + offsets_s[a][0]); \ 72 dark_mask |= (pixel < dark) << a; \ 73 bright_mask |= (pixel > bright) << a; \ 82 #define CHECK_CORNER(bright_mask, dark_mask, isCorner) \ 84 for(int i = 0; i < 16; i++) \ 86 isCorner |= ((bright_mask & 0x1FF) == 0x1FF); \ 87 isCorner |= ((dark_mask & 0x1FF) == 0x1FF); \ 104 uchar
c = convert_uchar_sat((a + b) / 2);
105 unsigned int bright_mask = 0;
106 unsigned int dark_mask = 0;
108 unsigned char p_bright = add_sat(candidate_pixel, c);
109 unsigned char p_dark = sub_sat(candidate_pixel, c);
113 for(uint i = 0; i < 16; i++)
118 bright_mask |= (bright_mask << 16);
119 dark_mask |= (dark_mask << 16);
124 a = convert_short(c);
128 b = convert_short(c);
158 float threshold_value)
163 const unsigned char threshold = (uchar)threshold_value;
165 unsigned int bright_mask = 0;
166 unsigned int dark_mask = 0;
168 unsigned char isCorner = 0;
170 unsigned char p = *in.
ptr;
171 unsigned char p_bright = add_sat(p, threshold);
172 unsigned char p_dark = sub_sat(p, threshold);
179 if(((bright_mask | dark_mask) & 0x1111) == 0)
198 bright_mask |= (bright_mask << 16);
199 dark_mask |= (dark_mask << 16);
209 #ifdef USE_MAXSUPPRESSION 234 __global uint *num_of_points,
237 #ifndef UPDATE_NUMBER 238 if(*num_of_points >= max_num_points)
246 uchar value = *in.
ptr;
250 int id = atomic_inc(num_of_points);
251 if(
id < max_num_points)
253 out[id].strength = value;
254 out[id].x = get_global_id(0) +
offset;
255 out[id].y = get_global_id(1) +
offset;
256 out[id].tracking_status = 1;
258 out[id].orientation = 0.f;
uchar compute_strength(uchar candidate_pixel, __global unsigned char *ptr, unsigned int stride, unsigned char threshold)
constant int offsets_s[16][2]
#define IMAGE_DECLARATION(name)
__global uchar * offset(const Image *img, int x, int y)
Get the pointer position of a Image.
#define LOAD_AND_SET_MASK(ptr, a, stride, dark, bright, dark_mask, bright_mask)
Load a pixel and set the mask values.
#define CONVERT_TO_IMAGE_STRUCT(name)
#define CHECK_CORNER(bright_mask, dark_mask, isCorner)
Checks if a pixel is a corner.
Structure to hold Image information.
__global uchar * ptr
Pointer to the starting postion of the buffer.
__kernel void fast_corners(__global uchar *input_ptr, uint input_stride_x, uint input_step_x, uint input_stride_y, uint input_step_y, uint input_offset_first_element_in_bytes, __global uchar *output_ptr, uint output_stride_x, uint output_step_x, uint output_stride_y, uint output_step_y, uint output_offset_first_element_in_bytes, float threshold_value)
Fast corners implementation.
__kernel void copy_to_keypoint(__global uchar *input_ptr, uint input_stride_x, uint input_step_x, uint input_stride_y, uint input_step_y, uint input_offset_first_element_in_bytes, uint max_num_points, uint offset, __global uint *num_of_points, __global Keypoint *out)
Copy result to Keypoint buffer and count number of corners.
SimpleTensor< T > threshold(const SimpleTensor< T > &src, T threshold, T false_value, T true_value, ThresholdType type, T upper)