[arrayfire] 208/248: Added AF_HOMOGRAPHY prefix to af_homography_t enum

Ghislain Vaillant ghisvail-guest at moszumanska.debian.org
Tue Nov 17 15:54:28 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 3e0abfa3660111eb8d471e7aec7df9d2f16eb1d5
Author: Peter Andreas Entschev <peter at arrayfire.com>
Date:   Thu Nov 5 21:44:18 2015 -0500

    Added AF_HOMOGRAPHY prefix to af_homography_t enum
---
 include/af/defines.h                     |  4 ++--
 include/af/vision.h                      | 22 +++++++++++-----------
 src/backend/cpu/homography.cpp           |  8 ++++----
 src/backend/cuda/homography.cu           |  2 +-
 src/backend/cuda/kernel/homography.hpp   | 14 +++++++-------
 src/backend/opencl/homography.cpp        | 10 +++++-----
 src/backend/opencl/kernel/homography.hpp | 12 ++++++------
 test/homography.cpp                      | 14 +++++++-------
 8 files changed, 43 insertions(+), 43 deletions(-)

diff --git a/include/af/defines.h b/include/af/defines.h
index ac97ad0..934d69a 100644
--- a/include/af/defines.h
+++ b/include/af/defines.h
@@ -326,8 +326,8 @@ typedef enum {
 } af_image_format;
 
 typedef enum {
-    AF_RANSAC           = 0,    ///< Computes homography using RANSAC
-    AF_LMEDS            = 1     ///< Computes homography using Least Median of Squares
+    AF_HOMOGRAPHY_RANSAC = 0,   ///< Computes homography using RANSAC
+    AF_HOMOGRAPHY_LMEDS  = 1    ///< Computes homography using Least Median of Squares
 } af_homography_type;
 
 // These enums should be 2^x
diff --git a/include/af/vision.h b/include/af/vision.h
index 1f3bd09..ef96f51 100644
--- a/include/af/vision.h
+++ b/include/af/vision.h
@@ -299,28 +299,28 @@ AFAPI array dog(const array& in, const int radius1, const int radius2);
 
    \param[out] H is a 3x3 array containing the estimated homography.
    \param[out] inliers is the number of inliers that the homography was estimated to comprise,
-               in the case that htype is AF_RANSAC, a higher inlier_thr value will increase the
+               in the case that htype is AF_HOMOGRAPHY_RANSAC, a higher inlier_thr value will increase the
                estimated inliers. Note that if the number of inliers is too low, it is likely
                that a bad homography will be returned.
    \param[in]  x_src x coordinates of the source points.
    \param[in]  y_src y coordinates of the source points.
    \param[in]  x_dst x coordinates of the destination points.
    \param[in]  y_dst y coordinates of the destination points.
-   \param[in]  inlier_thr if htype is AF_RANSAC, this parameter will five the maximum L2-distance
+   \param[in]  inlier_thr if htype is AF_HOMOGRAPHY_RANSAC, this parameter will five the maximum L2-distance
                for a point to be considered an inlier.
-   \param[in]  iterations maximum number of iterations when htype is AF_RANSAC and backend is CPU,
+   \param[in]  iterations maximum number of iterations when htype is AF_HOMOGRAPHY_RANSAC and backend is CPU,
                if backend is CUDA or OpenCL, iterations is the total number of iterations, an
                iteration is a selection of 4 random points for which the homography is estimated
                and evaluated for number of inliers.
-   \param[in]  af_homography_type can be AF_RANSAC, for which a RANdom SAmple Consensus will be
-               used to evaluate the homography quality (e.g., number of inliers), or AF_LMEDS,
+   \param[in]  af_homography_type can be AF_HOMOGRAPHY_RANSAC, for which a RANdom SAmple Consensus will be
+               used to evaluate the homography quality (e.g., number of inliers), or AF_HOMOGRAPHY_LMEDS,
                which will use Least Median of Squares method to evaluate homography quality
    \param[in]  dtype the array type for the homography output.
 
    \ingroup cv_func_homography
 */
 AFAPI void homography(array& H, int& inliers, const array& x_src, const array& y_src,
-                      const array& x_dst, const array& y_dst, const af_homography_type htype=AF_RANSAC,
+                      const array& x_dst, const array& y_dst, const af_homography_type htype=AF_HOMOGRAPHY_RANSAC,
                       const float inlier_thr=3.f, const unsigned iterations=1000, const dtype type=f32);
 #endif
 
@@ -615,21 +615,21 @@ extern "C" {
 
        \param[out] H is a 3x3 array containing the estimated homography.
        \param[out] inliers is the number of inliers that the homography was estimated to comprise,
-                   in the case that htype is AF_RANSAC, a higher inlier_thr value will increase the
+                   in the case that htype is AF_HOMOGRAPHY_RANSAC, a higher inlier_thr value will increase the
                    estimated inliers. Note that if the number of inliers is too low, it is likely
                    that a bad homography will be returned.
        \param[in]  x_src x coordinates of the source points.
        \param[in]  y_src y coordinates of the source points.
        \param[in]  x_dst x coordinates of the destination points.
        \param[in]  y_dst y coordinates of the destination points.
-       \param[in]  inlier_thr if htype is AF_RANSAC, this parameter will five the maximum L2-distance
+       \param[in]  inlier_thr if htype is AF_HOMOGRAPHY_RANSAC, this parameter will five the maximum L2-distance
                    for a point to be considered an inlier.
-       \param[in]  iterations maximum number of iterations when htype is AF_RANSAC and backend is CPU,
+       \param[in]  iterations maximum number of iterations when htype is AF_HOMOGRAPHY_RANSAC and backend is CPU,
                    if backend is CUDA or OpenCL, iterations is the total number of iterations, an
                    iteration is a selection of 4 random points for which the homography is estimated
                    and evaluated for number of inliers.
-       \param[in]  af_homography_type can be AF_RANSAC, for which a RANdom SAmple Consensus will be
-                   used to evaluate the homography quality (e.g., number of inliers), or AF_LMEDS,
+       \param[in]  af_homography_type can be AF_HOMOGRAPHY_RANSAC, for which a RANdom SAmple Consensus will be
+                   used to evaluate the homography quality (e.g., number of inliers), or AF_HOMOGRAPHY_LMEDS,
                    which will use Least Median of Squares method to evaluate homography quality.
        \param[in]  dtype the array type for the homography output.
        \param[out] out is difference of smoothed inputs.
diff --git a/src/backend/cpu/homography.cpp b/src/backend/cpu/homography.cpp
index 50f9b56..d20f0ca 100644
--- a/src/backend/cpu/homography.cpp
+++ b/src/backend/cpu/homography.cpp
@@ -282,7 +282,7 @@ int findBestHomography(Array<T> &bestH,
                                  x_dst_ptr, y_dst_ptr))
             continue;
 
-        if (htype == AF_RANSAC) {
+        if (htype == AF_HOMOGRAPHY_RANSAC) {
             unsigned inliers_count = 0;
             for (unsigned j = 0; j < nsamples; j++) {
                 float z =  H_ptr[6]*x_src_ptr[j] + H_ptr[7]*y_src_ptr[j] + H_ptr[8];
@@ -299,7 +299,7 @@ int findBestHomography(Array<T> &bestH,
                 bestInliers = inliers_count;
             }
         }
-        else if (htype == AF_LMEDS) {
+        else if (htype == AF_HOMOGRAPHY_LMEDS) {
             std::vector<float> err(nsamples);
             for (unsigned j = 0; j < nsamples; j++) {
                 float z =  H_ptr[6]*x_src_ptr[j] + H_ptr[7]*y_src_ptr[j] + H_ptr[8];
@@ -326,7 +326,7 @@ int findBestHomography(Array<T> &bestH,
 
     memcpy(bestH.get(), H.get() + bestIdx*9, 9 * sizeof(T));
 
-    if (htype == AF_LMEDS) {
+    if (htype == AF_HOMOGRAPHY_LMEDS) {
         float sigma = std::max(1.4826f * (1 + 5.f/(nsamples - 4)) * (float)sqrt(minMedian), 1e-6f);
         float dist_thr = sq(2.5f * sigma);
         T* bestH_ptr = bestH.get();
@@ -359,7 +359,7 @@ int homography(Array<T> &bestH,
     const unsigned nsamples = idims[0];
 
     unsigned iter = iterations;
-    if (htype == AF_LMEDS)
+    if (htype == AF_HOMOGRAPHY_LMEDS)
         iter = std::min(iter, (unsigned)(log(1.f - LMEDSConfidence) / log(1.f - pow(1.f - LMEDSOutlierRatio, 4.f))));
 
     af::dim4 rdims(4, iter);
diff --git a/src/backend/cuda/homography.cu b/src/backend/cuda/homography.cu
index 0f9b92f..a7a993a 100644
--- a/src/backend/cuda/homography.cu
+++ b/src/backend/cuda/homography.cu
@@ -45,7 +45,7 @@ int homography(Array<T> &bestH,
 
     unsigned iter = iterations;
     Array<float> err = createEmptyArray<float>(af::dim4());
-    if (htype == AF_LMEDS) {
+    if (htype == AF_HOMOGRAPHY_LMEDS) {
         iter = ::std::min(iter, (unsigned)(log(1.f - LMEDSConfidence) / log(1.f - pow(1.f - LMEDSOutlierRatio, 4.f))));
         err = createValueArray<float>(af::dim4(nsamples, iter), FLT_MAX);
     }
diff --git a/src/backend/cuda/kernel/homography.hpp b/src/backend/cuda/kernel/homography.hpp
index a2947cf..bcf2b04 100644
--- a/src/backend/cuda/kernel/homography.hpp
+++ b/src/backend/cuda/kernel/homography.hpp
@@ -374,7 +374,7 @@ __global__ void computeEvalHomography(
         for (int h = 0; h < 9; h++)
             H_tmp[h] = H_ptr[h];
 
-        if (htype == AF_RANSAC) {
+        if (htype == AF_HOMOGRAPHY_RANSAC) {
             // Compute inliers
             unsigned inliers_count = 0;
             for (unsigned j = 0; j < nsamples; j++) {
@@ -390,7 +390,7 @@ __global__ void computeEvalHomography(
             s_inliers[tid_x] = inliers_count;
             s_idx[tid_x]     = i;
         }
-        else if (htype == AF_LMEDS) {
+        else if (htype == AF_HOMOGRAPHY_LMEDS) {
             // Compute error
             for (unsigned j = 0; j < nsamples; j++) {
                 float z =  H_tmp[6]*x_src.ptr[j] + H_tmp[7]*y_src.ptr[j] + H_tmp[8];
@@ -403,7 +403,7 @@ __global__ void computeEvalHomography(
         }
     }
 
-    if (htype == AF_RANSAC) {
+    if (htype == AF_HOMOGRAPHY_RANSAC) {
         // Find sample with most inliers
         for (unsigned tx = 128; tx > 0; tx >>= 1) {
             if (tid_x < tx) {
@@ -585,7 +585,7 @@ int computeH(
     // Allocate some temporary buffers
     Param<unsigned> idx, inliers;
     Param<float> median;
-    inliers.dims[0] = (htype == AF_RANSAC) ? blocks.x : divup(nsamples, threads.x);
+    inliers.dims[0] = (htype == AF_HOMOGRAPHY_RANSAC) ? blocks.x : divup(nsamples, threads.x);
     inliers.strides[0] = 1;
     idx.dims[0] = median.dims[0] = blocks.x;
     idx.strides[0] = median.strides[0] = 1;
@@ -597,7 +597,7 @@ int computeH(
     }
     idx.ptr = memAlloc<unsigned>(idx.dims[3] * idx.strides[3]);
     inliers.ptr = memAlloc<unsigned>(inliers.dims[3] * inliers.strides[3]);
-    if (htype == AF_LMEDS)
+    if (htype == AF_HOMOGRAPHY_LMEDS)
         median.ptr = memAlloc<float>(median.dims[3] * median.strides[3]);
 
     // Compute (and for RANSAC, evaluate) homographies
@@ -607,7 +607,7 @@ int computeH(
     POST_LAUNCH_CHECK();
 
     unsigned inliersH, idxH;
-    if (htype == AF_LMEDS) {
+    if (htype == AF_HOMOGRAPHY_LMEDS) {
         // TODO: Improve this sorting, if the number of iterations is
         // sufficiently large, this can be *very* slow
         kernel::sort0<float, true>(err);
@@ -665,7 +665,7 @@ int computeH(
         memFree(totalInliers.ptr);
         memFree(median.ptr);
     }
-    else if (htype == AF_RANSAC) {
+    else if (htype == AF_HOMOGRAPHY_RANSAC) {
         Param<unsigned> bestInliers, bestIdx;
         for (int k = 0; k < 4; k++) {
             bestInliers.dims[k] = bestIdx.dims[k] = 1;
diff --git a/src/backend/opencl/homography.cpp b/src/backend/opencl/homography.cpp
index 94e4be9..dbce53b 100644
--- a/src/backend/opencl/homography.cpp
+++ b/src/backend/opencl/homography.cpp
@@ -45,7 +45,7 @@ int homography(Array<T> &bestH,
 
     unsigned iter = iterations;
     Array<float> err = createEmptyArray<float>(af::dim4());
-    if (htype == AF_LMEDS) {
+    if (htype == AF_HOMOGRAPHY_LMEDS) {
         iter = ::std::min(iter, (unsigned)(log(1.f - LMEDSConfidence) / log(1.f - pow(1.f - LMEDSOutlierRatio, 4.f))));
         err = createValueArray<float>(af::dim4(nsamples, iter), FLT_MAX);
     }
@@ -67,13 +67,13 @@ int homography(Array<T> &bestH,
 
     bestH = createValueArray<T>(af::dim4(3, 3), (T)0);
     switch (htype) {
-    case AF_RANSAC:
-        return kernel::computeH<T, AF_RANSAC>(bestH, tmpH, tmpA, tmpV, err,
+    case AF_HOMOGRAPHY_RANSAC:
+        return kernel::computeH<T, AF_HOMOGRAPHY_RANSAC>(bestH, tmpH, tmpA, tmpV, err,
                                               x_src, y_src, x_dst, y_dst,
                                               rnd, iter, nsamples, inlier_thr);
         break;
-    case AF_LMEDS:
-        return kernel::computeH<T, AF_LMEDS> (bestH, tmpH, tmpA, tmpV, err,
+    case AF_HOMOGRAPHY_LMEDS:
+        return kernel::computeH<T, AF_HOMOGRAPHY_LMEDS> (bestH, tmpH, tmpA, tmpV, err,
                                               x_src, y_src, x_dst, y_dst,
                                               rnd, iter, nsamples, inlier_thr);
         break;
diff --git a/src/backend/opencl/kernel/homography.hpp b/src/backend/opencl/kernel/homography.hpp
index fb10e36..7140703 100644
--- a/src/backend/opencl/kernel/homography.hpp
+++ b/src/backend/opencl/kernel/homography.hpp
@@ -74,9 +74,9 @@ int computeH(
                 } else
                     options << " -D EPS=" << FLT_EPSILON;
 
-                if (htype == AF_RANSAC)
+                if (htype == AF_HOMOGRAPHY_RANSAC)
                     options << " -D RANSAC";
-                else if (htype == AF_LMEDS)
+                else if (htype == AF_HOMOGRAPHY_LMEDS)
                     options << " -D LMEDS";
 
                 cl::Program prog;
@@ -115,7 +115,7 @@ int computeH(
         // Allocate some temporary buffers
         Param inliers, idx, median;
         inliers.info.offset = idx.info.offset = median.info.offset = 0;
-        inliers.info.dims[0] = (htype == AF_RANSAC) ? blk_x_eh : divup(nsamples, HG_THREADS);
+        inliers.info.dims[0] = (htype == AF_HOMOGRAPHY_RANSAC) ? blk_x_eh : divup(nsamples, HG_THREADS);
         inliers.info.strides[0] = 1;
         idx.info.dims[0] = median.info.dims[0] = blk_x_eh;
         idx.info.strides[0] = median.info.strides[0] = 1;
@@ -127,7 +127,7 @@ int computeH(
         }
         idx.data = bufferAlloc(idx.info.dims[3] * idx.info.strides[3] * sizeof(unsigned));
         inliers.data = bufferAlloc(inliers.info.dims[3] * inliers.info.strides[3] * sizeof(unsigned));
-        if (htype == AF_LMEDS)
+        if (htype == AF_HOMOGRAPHY_LMEDS)
             median.data = bufferAlloc(median.info.dims[3] * median.info.strides[3] * sizeof(float));
         else
             median.data = bufferAlloc(sizeof(float));
@@ -146,7 +146,7 @@ int computeH(
         CL_DEBUG_FINISH(getQueue());
 
         unsigned inliersH, idxH;
-        if (htype == AF_LMEDS) {
+        if (htype == AF_HOMOGRAPHY_LMEDS) {
             // TODO: Improve this sorting, if the number of iterations is
             // sufficiently large, this can be *very* slow
             kernel::sort0<float, true>(err);
@@ -220,7 +220,7 @@ int computeH(
 
             bufferFree(totalInliers.data);
         }
-        else if (htype == AF_RANSAC) {
+        else if (htype == AF_HOMOGRAPHY_RANSAC) {
             Param bestInliers, bestIdx;
             bestInliers.info.offset = bestIdx.info.offset = 0;
             for (int k = 0; k < 4; k++) {
diff --git a/test/homography.cpp b/test/homography.cpp
index d069ea3..7be9e07 100644
--- a/test/homography.cpp
+++ b/test/homography.cpp
@@ -205,12 +205,12 @@ void homographyTest(string pTestFile, const af_homography_type htype,
                                   htype, rotate, size_ratio);                   \
     }
 
-    HOMOGRAPHY_INIT(Tux_RANSAC, tux, AF_RANSAC, false, 1.0f);
-    HOMOGRAPHY_INIT(Tux_RANSAC_90degrees, tux, AF_RANSAC, true, 1.0f);
-    HOMOGRAPHY_INIT(Tux_RANSAC_resize, tux, AF_RANSAC, false, 1.5f);
-    //HOMOGRAPHY_INIT(Tux_LMedS, tux, AF_LMEDS, false, 1.0f);
-    //HOMOGRAPHY_INIT(Tux_LMedS_90degrees, tux, AF_LMEDS, true, 1.0f);
-    //HOMOGRAPHY_INIT(Tux_LMedS_resize, tux, AF_LMEDS, false, 1.5f);
+    HOMOGRAPHY_INIT(Tux_RANSAC, tux, AF_HOMOGRAPHY_RANSAC, false, 1.0f);
+    HOMOGRAPHY_INIT(Tux_RANSAC_90degrees, tux, AF_HOMOGRAPHY_RANSAC, true, 1.0f);
+    HOMOGRAPHY_INIT(Tux_RANSAC_resize, tux, AF_HOMOGRAPHY_RANSAC, false, 1.5f);
+    //HOMOGRAPHY_INIT(Tux_LMedS, tux, AF_HOMOGRAPHY_LMEDS, false, 1.0f);
+    //HOMOGRAPHY_INIT(Tux_LMedS_90degrees, tux, AF_HOMOGRAPHY_LMEDS, true, 1.0f);
+    //HOMOGRAPHY_INIT(Tux_LMedS_resize, tux, AF_HOMOGRAPHY_LMEDS, false, 1.5f);
 
 ///////////////////////////////////// CPP ////////////////////////////////
 //
@@ -254,7 +254,7 @@ TEST(Homography, CPP)
 
     af::array H;
     int inliers = 0;
-    af::homography(H, inliers, feat_train_x, feat_train_y, feat_query_x, feat_query_y, AF_RANSAC, 3.0f, 1000, f32);
+    af::homography(H, inliers, feat_train_x, feat_train_y, feat_query_x, feat_query_y, AF_HOMOGRAPHY_RANSAC, 3.0f, 1000, f32);
 
     float* gold_t = new float[8];
     for (int i = 0; i < 8; i++)

-- 
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