MCPcopy Create free account
hub / github.com/arrayfire/arrayfire / sift

Function sift

src/backend/opencl/kernel/sift.hpp:376–729  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

374
375template<typename T, typename convAccT>
376void sift(unsigned* out_feat, unsigned* out_dlen, Param& x_out, Param& y_out,
377 Param& score_out, Param& ori_out, Param& size_out, Param& desc_out,
378 Param img, const unsigned n_layers, const float contrast_thr,
379 const float edge_thr, const float init_sigma, const bool double_input,
380 const float img_scale, const float feature_ratio,
381 const bool compute_GLOH) {
382 using cl::Buffer;
383 using cl::EnqueueArgs;
384 using cl::Local;
385 using cl::NDRange;
386 using std::vector;
387
388 auto kernels = getSiftKernels<T>();
389
390 unsigned min_dim = std::min(img.info.dims[0], img.info.dims[1]);
391 if (double_input) min_dim *= 2;
392
393 const unsigned n_octaves = floor(log(min_dim) / log(2)) - 2;
394
395 Param init_img =
396 createInitialImage<T, convAccT>(img, init_sigma, double_input);
397
398 vector<Param> gauss_pyr =
399 buildGaussPyr<T, convAccT>(init_img, n_octaves, n_layers, init_sigma);
400
401 vector<Param> dog_pyr =
402 buildDoGPyr<T>(gauss_pyr, n_octaves, n_layers, kernels[0]);
403
404 vector<bufptr> d_x_pyr;
405 vector<bufptr> d_y_pyr;
406 vector<bufptr> d_response_pyr;
407 vector<bufptr> d_size_pyr;
408 vector<bufptr> d_ori_pyr;
409 vector<bufptr> d_desc_pyr;
410 vector<unsigned> feat_pyr(n_octaves, 0);
411
412 d_x_pyr.reserve(n_octaves);
413 d_y_pyr.reserve(n_octaves);
414 d_response_pyr.reserve(n_octaves);
415 d_size_pyr.reserve(n_octaves);
416 d_ori_pyr.reserve(n_octaves);
417 d_desc_pyr.reserve(n_octaves);
418 unsigned total_feat = 0;
419
420 const unsigned d = DescrWidth;
421 const unsigned n = DescrHistBins;
422 const unsigned rb = GLOHRadialBins;
423 const unsigned ab = GLOHAngularBins;
424 const unsigned hb = GLOHHistBins;
425 const unsigned desc_len =
426 (compute_GLOH) ? (1 + (rb - 1) * ab) * hb : d * d * n;
427
428 auto d_count = memAlloc<unsigned>(1);
429
430 for (unsigned o = 0; o < n_octaves; o++) {
431 if (dog_pyr[o].info.dims[0] - 2 * ImgBorder < 1 ||
432 dog_pyr[o].info.dims[1] - 2 * ImgBorder < 1)
433 continue;

Callers

nothing calls this directly

Calls 10

floorFunction · 0.85
logFunction · 0.85
ceilFunction · 0.85
EnqueueArgsClass · 0.85
bufferFreeFunction · 0.85
bufferAllocFunction · 0.85
iotaFunction · 0.70
minFunction · 0.50
getQueueFunction · 0.50
getContextFunction · 0.50

Tested by

no test coverage detected