[arrayfire] 99/248: Added C API for GLOH

Ghislain Vaillant ghisvail-guest at moszumanska.debian.org
Tue Nov 17 15:54:09 UTC 2015


This is an automated email from the git hooks/post-receive script.

ghisvail-guest pushed a commit to branch dfsg-clean
in repository arrayfire.

commit 037d2f7af4eaf497c7546e34c09a6965edc4f33b
Author: Peter Andreas Entschev <peter at arrayfire.com>
Date:   Wed Oct 7 16:14:58 2015 -0400

    Added C API for GLOH
---
 src/api/c/sift.cpp | 50 ++++++++++++++++++++++++++++++++++++++++++++++----
 1 file changed, 46 insertions(+), 4 deletions(-)

diff --git a/src/api/c/sift.cpp b/src/api/c/sift.cpp
index ef68c30..6a2fb60 100644
--- a/src/api/c/sift.cpp
+++ b/src/api/c/sift.cpp
@@ -23,7 +23,8 @@ using namespace detail;
 template<typename T, typename convAccT>
 static void sift(af_features& feat_, af_array& descriptors, const af_array& in, const unsigned n_layers,
                  const float contrast_thr, const float edge_thr, const float init_sigma,
-                 const bool double_input, const float img_scale, const float feature_ratio)
+                 const bool double_input, const float img_scale, const float feature_ratio,
+                 const bool compute_GLOH)
 {
     Array<float> x     = createEmptyArray<float>(dim4());
     Array<float> y     = createEmptyArray<float>(dim4());
@@ -36,7 +37,7 @@ static void sift(af_features& feat_, af_array& descriptors, const af_array& in,
 
     feat.n = sift<T, convAccT>(x, y, score, ori, size, desc, getArray<T>(in),
                                n_layers, contrast_thr, edge_thr, init_sigma,
-                               double_input, img_scale, feature_ratio);
+                               double_input, img_scale, feature_ratio, compute_GLOH);
 
     feat.x           = getHandle(x);
     feat.y           = getHandle(y);
@@ -73,10 +74,10 @@ af_err af_sift(af_features* feat, af_array* desc, const af_array in, const unsig
         switch(type) {
             case f32: sift<float , float >(*feat, tmp_desc, in, n_layers, contrast_thr,
                                            edge_thr, init_sigma, double_input,
-                                           img_scale, feature_ratio); break;
+                                           img_scale, feature_ratio, false); break;
             case f64: sift<double, double>(*feat, tmp_desc, in, n_layers, contrast_thr,
                                            edge_thr, init_sigma, double_input,
-                                           img_scale, feature_ratio); break;
+                                           img_scale, feature_ratio, false); break;
             default : TYPE_ERROR(1, type);
         }
         std::swap(*desc, tmp_desc);
@@ -88,3 +89,44 @@ af_err af_sift(af_features* feat, af_array* desc, const af_array in, const unsig
 
     return AF_SUCCESS;
 }
+
+af_err af_gloh(af_features* feat, af_array* desc, const af_array in, const unsigned n_layers,
+               const float contrast_thr, const float edge_thr, const float init_sigma,
+               const bool double_input, const float img_scale, const float feature_ratio)
+{
+    try {
+#ifdef AF_BUILD_SIFT
+        ArrayInfo info = getInfo(in);
+        af::dim4 dims  = info.dims();
+
+        ARG_ASSERT(2, (dims[0] >= 15 && dims[1] >= 15 && dims[2] == 1 && dims[3] == 1));
+        ARG_ASSERT(3, n_layers > 0);
+        ARG_ASSERT(4, contrast_thr > 0.0f);
+        ARG_ASSERT(5, edge_thr >= 1.0f);
+        ARG_ASSERT(6, init_sigma > 0.5f);
+        ARG_ASSERT(8, img_scale > 0.0f);
+        ARG_ASSERT(9, feature_ratio > 0.0f);
+
+        dim_t in_ndims = dims.ndims();
+        DIM_ASSERT(1, (in_ndims <= 3 && in_ndims >= 2));
+
+        af_array tmp_desc;
+        af_dtype type  = info.getType();
+        switch(type) {
+            case f32: sift<float , float >(*feat, tmp_desc, in, n_layers, contrast_thr,
+                                           edge_thr, init_sigma, double_input,
+                                           img_scale, feature_ratio, true); break;
+            case f64: sift<double, double>(*feat, tmp_desc, in, n_layers, contrast_thr,
+                                           edge_thr, init_sigma, double_input,
+                                           img_scale, feature_ratio, true); break;
+            default : TYPE_ERROR(1, type);
+        }
+        std::swap(*desc, tmp_desc);
+#else
+        AF_ERROR("ArrayFire was not built with nonfree support, GLOH disabled\n", AFF_ERR_NONFREE);
+#endif
+    }
+    CATCHALL;
+
+    return AF_SUCCESS;
+}

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/arrayfire.git



More information about the debian-science-commits mailing list