Compute Library  18.05
harris_corners.cl File Reference
#include "helpers.h"

Go to the source code of this file.

Functions

__kernel void harris_score_3x3 (__global uchar *src_gx_ptr, uint src_gx_stride_x, uint src_gx_step_x, uint src_gx_stride_y, uint src_gx_step_y, uint src_gx_offset_first_element_in_bytes, __global uchar *src_gy_ptr, uint src_gy_stride_x, uint src_gy_step_x, uint src_gy_stride_y, uint src_gy_step_y, uint src_gy_offset_first_element_in_bytes, __global uchar *vc_ptr, uint vc_stride_x, uint vc_step_x, uint vc_stride_y, uint vc_step_y, uint vc_offset_first_element_in_bytes, float sensitivity, float strength_thresh, float pow4_normalization_factor)
 Function running harris score on 3x3 block size. More...
 
float16 harris_score_1x5 (Image *src_gx, Image *src_gy, int row)
 Function for calculating harris score 1x5. More...
 
__kernel void harris_score_5x5 (__global uchar *src_gx_ptr, uint src_gx_stride_x, uint src_gx_step_x, uint src_gx_stride_y, uint src_gx_step_y, uint src_gx_offset_first_element_in_bytes, __global uchar *src_gy_ptr, uint src_gy_stride_x, uint src_gy_step_x, uint src_gy_stride_y, uint src_gy_step_y, uint src_gy_offset_first_element_in_bytes, __global uchar *vc_ptr, uint vc_stride_x, uint vc_step_x, uint vc_stride_y, uint vc_step_y, uint vc_offset_first_element_in_bytes, float sensitivity, float strength_thresh, float pow4_normalization_factor)
 Function running harris score on 5x5 block size. More...
 
float16 harris_score_1x7 (Image *src_gx, Image *src_gy, int row)
 Function for calculating harris score 1x7. More...
 
__kernel void harris_score_7x7 (__global uchar *src_gx_ptr, uint src_gx_stride_x, uint src_gx_step_x, uint src_gx_stride_y, uint src_gx_step_y, uint src_gx_offset_first_element_in_bytes, __global uchar *src_gy_ptr, uint src_gy_stride_x, uint src_gy_step_x, uint src_gy_stride_y, uint src_gy_step_y, uint src_gy_offset_first_element_in_bytes, __global uchar *vc_ptr, uint vc_stride_x, uint vc_step_x, uint vc_stride_y, uint vc_step_y, uint vc_offset_first_element_in_bytes, float sensitivity, float strength_thresh, float pow4_normalization_factor)
 Function running harris score on 7x7 block size. More...
 

Function Documentation

float16 harris_score_1x5 ( Image src_gx,
Image src_gy,
int  row 
)
inline

Function for calculating harris score 1x5.

Parameters
[in]src_gxPointer to gx gradient image.
[in]src_gyPointer to gy gradient image.
[in]rowRelative row.

Definition at line 138 of file harris_corners.cl.

References DATA_TYPE, offset(), and VEC_DATA_TYPE.

Referenced by harris_score_5x5().

139 {
140  float4 gx2 = 0.0f;
141  float4 gy2 = 0.0f;
142  float4 gxgy = 0.0f;
143 
144  /* Row */
146  temp_gx = vload8(0, (__global DATA_TYPE *)offset(src_gx, -2, row));
148  temp_gy = vload8(0, (__global DATA_TYPE *)offset(src_gy, -2, row));
149 
150  float4 gx = convert_float4(temp_gx.s0123);
151  float4 gy = convert_float4(temp_gy.s0123);
152  gx2 += (gx * gx);
153  gy2 += (gy * gy);
154  gxgy += (gx * gy);
155 
156  gx = convert_float4(temp_gx.s1234);
157  gy = convert_float4(temp_gy.s1234);
158  gx2 += (gx * gx);
159  gy2 += (gy * gy);
160  gxgy += (gx * gy);
161 
162  gx = convert_float4(temp_gx.s2345);
163  gy = convert_float4(temp_gy.s2345);
164  gx2 += (gx * gx);
165  gy2 += (gy * gy);
166  gxgy += (gx * gy);
167 
168  gx = convert_float4(temp_gx.s3456);
169  gy = convert_float4(temp_gy.s3456);
170  gx2 += (gx * gx);
171  gy2 += (gy * gy);
172  gxgy += (gx * gy);
173 
174  gx = convert_float4(temp_gx.s4567);
175  gy = convert_float4(temp_gy.s4567);
176  gx2 += (gx * gx);
177  gy2 += (gy * gy);
178  gxgy += (gx * gy);
179 
180  return (float16)(gx2, gy2, gxgy, (float4)0);
181 }
#define DATA_TYPE
__global uchar * offset(const Image *img, int x, int y)
Get the pointer position of a Image.
Definition: helpers.h:303
#define VEC_DATA_TYPE(type, size)
Definition: fixed_point.h:93
float16 harris_score_1x7 ( Image src_gx,
Image src_gy,
int  row 
)
inline

Function for calculating harris score 1x7.

Parameters
[in]src_gxPointer to gx gradient image.
[in]src_gyPointer to gy gradient image.
[in]rowRelative row.

Definition at line 253 of file harris_corners.cl.

References DATA_TYPE, offset(), and VEC_DATA_TYPE.

Referenced by harris_score_7x7().

254 {
255  float4 gx2 = 0.0f;
256  float4 gy2 = 0.0f;
257  float4 gxgy = 0.0f;
258 
259  /* Row */
261  temp_gx0 = vload8(0, (__global DATA_TYPE *)offset(src_gx, -3, row));
263  temp_gy0 = vload8(0, (__global DATA_TYPE *)offset(src_gy, -3, row));
264  VEC_DATA_TYPE(DATA_TYPE, 2)
265  temp_gx1 = vload2(0, (__global DATA_TYPE *)offset(src_gx, 5, row));
266  VEC_DATA_TYPE(DATA_TYPE, 2)
267  temp_gy1 = vload2(0, (__global DATA_TYPE *)offset(src_gy, 5, row));
268 
269  float4 gx = convert_float4(temp_gx0.s0123);
270  float4 gy = convert_float4(temp_gy0.s0123);
271  gx2 += (gx * gx);
272  gy2 += (gy * gy);
273  gxgy += (gx * gy);
274 
275  gx = convert_float4(temp_gx0.s1234);
276  gy = convert_float4(temp_gy0.s1234);
277  gx2 += (gx * gx);
278  gy2 += (gy * gy);
279  gxgy += (gx * gy);
280 
281  gx = convert_float4(temp_gx0.s2345);
282  gy = convert_float4(temp_gy0.s2345);
283  gx2 += (gx * gx);
284  gy2 += (gy * gy);
285  gxgy += (gx * gy);
286 
287  gx = convert_float4(temp_gx0.s3456);
288  gy = convert_float4(temp_gy0.s3456);
289  gx2 += (gx * gx);
290  gy2 += (gy * gy);
291  gxgy += (gx * gy);
292 
293  gx = convert_float4(temp_gx0.s4567);
294  gy = convert_float4(temp_gy0.s4567);
295  gx2 += (gx * gx);
296  gy2 += (gy * gy);
297  gxgy += (gx * gy);
298 
299  gx = convert_float4((VEC_DATA_TYPE(DATA_TYPE, 4))(temp_gx0.s567, temp_gx1.s0));
300  gy = convert_float4((VEC_DATA_TYPE(DATA_TYPE, 4))(temp_gy0.s567, temp_gy1.s0));
301  gx2 += (gx * gx);
302  gy2 += (gy * gy);
303  gxgy += (gx * gy);
304 
305  gx = convert_float4((VEC_DATA_TYPE(DATA_TYPE, 4))(temp_gx0.s67, temp_gx1.s01));
306  gy = convert_float4((VEC_DATA_TYPE(DATA_TYPE, 4))(temp_gy0.s67, temp_gy1.s01));
307  gx2 += (gx * gx);
308  gy2 += (gy * gy);
309  gxgy += (gx * gy);
310 
311  return (float16)(gx2, gy2, gxgy, (float4)0);
312 }
#define DATA_TYPE
__global uchar * offset(const Image *img, int x, int y)
Get the pointer position of a Image.
Definition: helpers.h:303
#define VEC_DATA_TYPE(type, size)
Definition: fixed_point.h:93
__kernel void harris_score_3x3 ( __global uchar *  src_gx_ptr,
uint  src_gx_stride_x,
uint  src_gx_step_x,
uint  src_gx_stride_y,
uint  src_gx_step_y,
uint  src_gx_offset_first_element_in_bytes,
__global uchar *  src_gy_ptr,
uint  src_gy_stride_x,
uint  src_gy_step_x,
uint  src_gy_stride_y,
uint  src_gy_step_y,
uint  src_gy_offset_first_element_in_bytes,
__global uchar *  vc_ptr,
uint  vc_stride_x,
uint  vc_step_x,
uint  vc_stride_y,
uint  vc_step_y,
uint  vc_offset_first_element_in_bytes,
float  sensitivity,
float  strength_thresh,
float  pow4_normalization_factor 
)

Function running harris score on 3x3 block size.

Attention
: The input data type should be passed using a compile option -DDATA_TYPE. Supported types: short and int. e.g. -DDATA_TYPE=short.
Parameters
[in]src_gx_ptrPointer to the first source image. Supported data types: S16, S32
[in]src_gx_stride_xStride of the source image in X dimension (in bytes)
[in]src_gx_step_xsrc_gx_stride_x * number of elements along X processed per workitem(in bytes)
[in]src_gx_stride_yStride of the source image in Y dimension (in bytes)
[in]src_gx_step_ysrc_gx_stride_y * number of elements along Y processed per workitem(in bytes)
[in]src_gx_offset_first_element_in_bytesThe offset of the first element in the source image
[in]src_gy_ptrPointer to the second source image. Supported data types: S16, S32
[in]src_gy_stride_xStride of the destination image in X dimension (in bytes)
[in]src_gy_step_xsrc_gy_stride_x * number of elements along X processed per workitem(in bytes)
[in]src_gy_stride_yStride of the destination image in Y dimension (in bytes)
[in]src_gy_step_ysrc_gy_stride_y * number of elements along Y processed per workitem(in bytes)
[in]src_gy_offset_first_element_in_bytesThe offset of the first element in the destination image
[out]vc_ptrPointer to the destination image. Supported data types: F32
[in]vc_stride_xStride of the destination image in X dimension (in bytes)
[in]vc_step_xvc_stride_x * number of elements along X processed per workitem(in bytes)
[in]vc_stride_yStride of the destination image in Y dimension (in bytes)
[in]vc_step_yvc_stride_y * number of elements along Y processed per workitem(in bytes)
[in]vc_offset_first_element_in_bytesThe offset of the first element in the destination image
[in]sensitivitySensitivity threshold k from the Harris-Stephens equation
[in]strength_threshMinimum threshold with which to eliminate Harris Corner scores
[in]pow4_normalization_factorNormalization factor to apply harris score

Definition at line 53 of file harris_corners.cl.

References CONVERT_TO_IMAGE_STRUCT, DATA_TYPE, offset(), Image::ptr, and VEC_DATA_TYPE.

60 {
61  Image src_gx = CONVERT_TO_IMAGE_STRUCT(src_gx);
62  Image src_gy = CONVERT_TO_IMAGE_STRUCT(src_gy);
64 
65  /* Gx^2, Gy^2 and Gx*Gy */
66  float4 gx2 = (float4)0.0f;
67  float4 gy2 = (float4)0.0f;
68  float4 gxgy = (float4)0.0f;
69 
70  /* Row0 */
72  temp_gx = vload8(0, (__global DATA_TYPE *)offset(&src_gx, -1, -1));
74  temp_gy = vload8(0, (__global DATA_TYPE *)offset(&src_gy, -1, -1));
75 
76  float4 l_gx = convert_float4(temp_gx.s0123);
77  float4 m_gx = convert_float4(temp_gx.s1234);
78  float4 r_gx = convert_float4(temp_gx.s2345);
79 
80  float4 l_gy = convert_float4(temp_gy.s0123);
81  float4 m_gy = convert_float4(temp_gy.s1234);
82  float4 r_gy = convert_float4(temp_gy.s2345);
83 
84  gx2 += (l_gx * l_gx) + (m_gx * m_gx) + (r_gx * r_gx);
85  gy2 += (l_gy * l_gy) + (m_gy * m_gy) + (r_gy * r_gy);
86  gxgy += (l_gx * l_gy) + (m_gx * m_gy) + (r_gx * r_gy);
87 
88  /* Row1 */
89  temp_gx = vload8(0, (__global DATA_TYPE *)offset(&src_gx, -1, 0));
90  temp_gy = vload8(0, (__global DATA_TYPE *)offset(&src_gy, -1, 0));
91 
92  l_gx = convert_float4(temp_gx.s0123);
93  m_gx = convert_float4(temp_gx.s1234);
94  r_gx = convert_float4(temp_gx.s2345);
95 
96  l_gy = convert_float4(temp_gy.s0123);
97  m_gy = convert_float4(temp_gy.s1234);
98  r_gy = convert_float4(temp_gy.s2345);
99 
100  gx2 += (l_gx * l_gx) + (m_gx * m_gx) + (r_gx * r_gx);
101  gy2 += (l_gy * l_gy) + (m_gy * m_gy) + (r_gy * r_gy);
102  gxgy += (l_gx * l_gy) + (m_gx * m_gy) + (r_gx * r_gy);
103 
104  /* Row2 */
105  temp_gx = vload8(0, (__global DATA_TYPE *)offset(&src_gx, -1, 1));
106  temp_gy = vload8(0, (__global DATA_TYPE *)offset(&src_gy, -1, 1));
107 
108  l_gx = convert_float4(temp_gx.s0123);
109  m_gx = convert_float4(temp_gx.s1234);
110  r_gx = convert_float4(temp_gx.s2345);
111 
112  l_gy = convert_float4(temp_gy.s0123);
113  m_gy = convert_float4(temp_gy.s1234);
114  r_gy = convert_float4(temp_gy.s2345);
115 
116  gx2 += (l_gx * l_gx) + (m_gx * m_gx) + (r_gx * r_gx);
117  gy2 += (l_gy * l_gy) + (m_gy * m_gy) + (r_gy * r_gy);
118  gxgy += (l_gx * l_gy) + (m_gx * m_gy) + (r_gx * r_gy);
119 
120  /* Compute trace and determinant */
121  float4 trace = gx2 + gy2;
122  float4 det = gx2 * gy2 - (gxgy * gxgy);
123 
124  /* Compute harris score */
125  float4 mc = (det - (sensitivity * (trace * trace))) * pow4_normalization_factor;
126 
127  mc = select(0.0f, mc, mc > (float4)strength_thresh);
128 
129  vstore4(mc, 0, (__global float *)vc.ptr);
130 }
#define DATA_TYPE
__global uchar * offset(const Image *img, int x, int y)
Get the pointer position of a Image.
Definition: helpers.h:303
#define CONVERT_TO_IMAGE_STRUCT(name)
Definition: helpers.h:104
Structure to hold Image information.
Definition: helpers.h:142
#define VEC_DATA_TYPE(type, size)
Definition: fixed_point.h:93
__kernel void harris_score_5x5 ( __global uchar *  src_gx_ptr,
uint  src_gx_stride_x,
uint  src_gx_step_x,
uint  src_gx_stride_y,
uint  src_gx_step_y,
uint  src_gx_offset_first_element_in_bytes,
__global uchar *  src_gy_ptr,
uint  src_gy_stride_x,
uint  src_gy_step_x,
uint  src_gy_stride_y,
uint  src_gy_step_y,
uint  src_gy_offset_first_element_in_bytes,
__global uchar *  vc_ptr,
uint  vc_stride_x,
uint  vc_step_x,
uint  vc_stride_y,
uint  vc_step_y,
uint  vc_offset_first_element_in_bytes,
float  sensitivity,
float  strength_thresh,
float  pow4_normalization_factor 
)

Function running harris score on 5x5 block size.

Attention
: The input data type should be passed using a compile option -DDATA_TYPE. Supported types: short and int. e.g. -DDATA_TYPE=short.
Parameters
[in]src_gx_ptrPointer to the first source image. Supported data types: S16, S32
[in]src_gx_stride_xStride of the source image in X dimension (in bytes)
[in]src_gx_step_xsrc_gx_stride_x * number of elements along X processed per workitem(in bytes)
[in]src_gx_stride_yStride of the source image in Y dimension (in bytes)
[in]src_gx_step_ysrc_gx_stride_y * number of elements along Y processed per workitem(in bytes)
[in]src_gx_offset_first_element_in_bytesThe offset of the first element in the source image
[in]src_gy_ptrPointer to the second source image. Supported data types: S16, S32
[in]src_gy_stride_xStride of the destination image in X dimension (in bytes)
[in]src_gy_step_xsrc_gy_stride_x * number of elements along X processed per workitem(in bytes)
[in]src_gy_stride_yStride of the destination image in Y dimension (in bytes)
[in]src_gy_step_ysrc_gy_stride_y * number of elements along Y processed per workitem(in bytes)
[in]src_gy_offset_first_element_in_bytesThe offset of the first element in the destination image
[out]vc_ptrPointer to the destination image. Supported data types: F32
[in]vc_stride_xStride of the destination image in X dimension (in bytes)
[in]vc_step_xvc_stride_x * number of elements along X processed per workitem(in bytes)
[in]vc_stride_yStride of the destination image in Y dimension (in bytes)
[in]vc_step_yvc_stride_y * number of elements along Y processed per workitem(in bytes)
[in]vc_offset_first_element_in_bytesThe offset of the first element in the destination image
[in]sensitivitySensitivity threshold k from the Harris-Stephens equation
[in]strength_threshMinimum threshold with which to eliminate Harris Corner scores
[in]pow4_normalization_factorNormalization factor to apply harris score

Definition at line 210 of file harris_corners.cl.

References CONVERT_TO_IMAGE_STRUCT, harris_score_1x5(), and Image::ptr.

217 {
218  Image src_gx = CONVERT_TO_IMAGE_STRUCT(src_gx);
219  Image src_gy = CONVERT_TO_IMAGE_STRUCT(src_gy);
221 
222  /* Gx^2, Gy^2 and Gx*Gy */
223  float16 res = (float16)0.0f;
224 
225  /* Compute row */
226  for(int i = -2; i < 3; i++)
227  {
228  res += harris_score_1x5(&src_gx, &src_gy, i);
229  }
230 
231  float4 gx2 = res.s0123;
232  float4 gy2 = res.s4567;
233  float4 gxgy = res.s89AB;
234 
235  /* Compute trace and determinant */
236  float4 trace = gx2 + gy2;
237  float4 det = gx2 * gy2 - (gxgy * gxgy);
238 
239  /* Compute harris score */
240  float4 mc = (det - (sensitivity * (trace * trace))) * pow4_normalization_factor;
241 
242  mc = select(0.0f, mc, mc > (float4)strength_thresh);
243 
244  vstore4(mc, 0, (__global float *)vc.ptr);
245 }
float16 harris_score_1x5(Image *src_gx, Image *src_gy, int row)
Function for calculating harris score 1x5.
#define CONVERT_TO_IMAGE_STRUCT(name)
Definition: helpers.h:104
Structure to hold Image information.
Definition: helpers.h:142
__global uchar * ptr
Pointer to the starting postion of the buffer.
Definition: helpers.h:144
__kernel void harris_score_7x7 ( __global uchar *  src_gx_ptr,
uint  src_gx_stride_x,
uint  src_gx_step_x,
uint  src_gx_stride_y,
uint  src_gx_step_y,
uint  src_gx_offset_first_element_in_bytes,
__global uchar *  src_gy_ptr,
uint  src_gy_stride_x,
uint  src_gy_step_x,
uint  src_gy_stride_y,
uint  src_gy_step_y,
uint  src_gy_offset_first_element_in_bytes,
__global uchar *  vc_ptr,
uint  vc_stride_x,
uint  vc_step_x,
uint  vc_stride_y,
uint  vc_step_y,
uint  vc_offset_first_element_in_bytes,
float  sensitivity,
float  strength_thresh,
float  pow4_normalization_factor 
)

Function running harris score on 7x7 block size.

Attention
: The input data type should be passed using a compile option -DDATA_TYPE. Supported types: short and int. e.g. -DDATA_TYPE=short.
Parameters
[in]src_gx_ptrPointer to the first source image. Supported data types: S16, S32
[in]src_gx_stride_xStride of the source image in X dimension (in bytes)
[in]src_gx_step_xsrc_gx_stride_x * number of elements along X processed per workitem(in bytes)
[in]src_gx_stride_yStride of the source image in Y dimension (in bytes)
[in]src_gx_step_ysrc_gx_stride_y * number of elements along Y processed per workitem(in bytes)
[in]src_gx_offset_first_element_in_bytesThe offset of the first element in the source image
[in]src_gy_ptrPointer to the second source image. Supported data types: S16, S32
[in]src_gy_stride_xStride of the destination image in X dimension (in bytes)
[in]src_gy_step_xsrc_gy_stride_x * number of elements along X processed per workitem(in bytes)
[in]src_gy_stride_yStride of the destination image in Y dimension (in bytes)
[in]src_gy_step_ysrc_gy_stride_y * number of elements along Y processed per workitem(in bytes)
[in]src_gy_offset_first_element_in_bytesThe offset of the first element in the destination image
[out]vc_ptrPointer to the destination image. Supported data types: F32
[in]vc_stride_xStride of the destination image in X dimension (in bytes)
[in]vc_step_xvc_stride_x * number of elements along X processed per workitem(in bytes)
[in]vc_stride_yStride of the destination image in Y dimension (in bytes)
[in]vc_step_yvc_stride_y * number of elements along Y processed per workitem(in bytes)
[in]vc_offset_first_element_in_bytesThe offset of the first element in the destination image
[in]sensitivitySensitivity threshold k from the Harris-Stephens equation
[in]strength_threshMinimum threshold with which to eliminate Harris Corner scores
[in]pow4_normalization_factorNormalization factor to apply harris score

Definition at line 341 of file harris_corners.cl.

References CONVERT_TO_IMAGE_STRUCT, harris_score_1x7(), and Image::ptr.

348 {
349  Image src_gx = CONVERT_TO_IMAGE_STRUCT(src_gx);
350  Image src_gy = CONVERT_TO_IMAGE_STRUCT(src_gy);
352 
353  /* Gx^2, Gy^2 and Gx*Gy */
354  float16 res = (float16)0.0f;
355 
356  /* Compute row */
357  for(int i = -3; i < 4; i++)
358  {
359  res += harris_score_1x7(&src_gx, &src_gy, i);
360  }
361 
362  float4 gx2 = res.s0123;
363  float4 gy2 = res.s4567;
364  float4 gxgy = res.s89AB;
365 
366  /* Compute trace and determinant */
367  float4 trace = gx2 + gy2;
368  float4 det = gx2 * gy2 - (gxgy * gxgy);
369 
370  /* Compute harris score */
371  float4 mc = (det - (sensitivity * (trace * trace))) * pow4_normalization_factor;
372 
373  mc = select(0.0f, mc, mc > (float4)strength_thresh);
374 
375  vstore4(mc, 0, (__global float *)vc.ptr);
376 }
#define CONVERT_TO_IMAGE_STRUCT(name)
Definition: helpers.h:104
Structure to hold Image information.
Definition: helpers.h:142
__global uchar * ptr
Pointer to the starting postion of the buffer.
Definition: helpers.h:144
float16 harris_score_1x7(Image *src_gx, Image *src_gy, int row)
Function for calculating harris score 1x7.