 #include <inttypes.h>
 
 using namespace popart;
+
+// Lowe wants at most 3 orientations at every extremum,
+// VLFeat uses at most 4, OpenCV all it can find
+#undef  LOWE_ORIENTATION_MAX
+
+#undef  V2_WITH_BEMAP_SMOOTHING
+#undef  V2_WITH_VLFEAT_SMOOTHING
+#define V2_WITH_OPENCV_SMOOTHING
+
+#ifdef LOWE_ORIENTATION_MAX
+#define ORIENTATION_MAX_COUNT 3
+#else
+#define ORIENTATION_MAX_COUNT 4
+#endif
 
 /*************************************************************
  * V1: device side

                xcoord[bin] = prev + newbin;
                yval[bin]   = -(num*num) / (4.0f * denB) + hist[prev];

                if( yval[bin] > y_max[0] ) {
                    y_max[2]  = y_max[1];
                    y_max[1]  = y_max[0];


    float factor = __fdividef( -0.5f, (sigw * sigw) );
    int sq_thres  = rad * rad;

    int32_t xmin = max(1,     (int32_t)floor(x - rad));
    int32_t xmax = min(w - 2, (int32_t)floor(x + rad));
    int32_t ymin = max(1,     (int32_t)floor(y - rad));
