Ask Your Question

sammy's profile - activity

2020-05-08 14:28:49 -0600 received badge  Notable Question (source)
2019-11-26 21:59:04 -0600 received badge  Notable Question (source)
2019-06-13 02:03:05 -0600 received badge  Popular Question (source)
2017-05-26 07:35:52 -0600 received badge  Popular Question (source)
2017-03-06 09:38:45 -0600 received badge  Nice Question (source)
2017-03-06 09:38:43 -0600 received badge  Notable Question (source)
2016-10-27 13:45:33 -0600 received badge  Popular Question (source)
2016-06-07 09:25:17 -0600 received badge  Good Question (source)
2016-05-27 15:25:00 -0600 received badge  Good Answer (source)
2016-02-17 19:18:10 -0600 received badge  Nice Answer (source)
2016-01-15 09:10:12 -0600 received badge  Good Answer (source)
2015-12-13 14:53:51 -0600 received badge  Nice Answer (source)
2015-09-09 00:34:44 -0600 received badge  Good Answer (source)
2015-06-16 16:30:54 -0600 received badge  Good Answer (source)
2015-04-15 08:51:33 -0600 received badge  Favorite Question (source)
2015-03-15 00:58:11 -0600 received badge  Popular Question (source)
2014-12-09 13:52:14 -0600 marked best answer How to intuitively interpret Gabor lambda param?

I am playing with the newly added Gabor filters. I know some basics about them, and how they are used for recognition tasks. But I have troubles understanding in an intuitive way (not by writing complicated math formulas) what is the meaning of the lambda parameter.

Here is the formula, from Wiki:

image description

And here are some pictures, where I varied lambda:

lambda = CV_PI

image description

lambda = CV_PI/2

image description

lambda = CV_PI/4

image description

The other parameters are as follows:

gaborKernel = getGaborKernel( cv::Size(15, 15) , 3, -CV_PI/4, lambda, 1, CV_PI, CV_32F );
2014-12-09 13:45:14 -0600 marked best answer test NEON-optimized cv::threshold() on mobile device

I have been writing some optimizations for the OpenCV's threshold function, for ARM devices (mobile phones). It should be working on both Android and iPhone.

However, I do not have a device to test it on, so I am looking for volunteers to give me a little help. If that motivates you more, I am planning to push it to the main OpenCV repo - and hope you guys will accept it

I am interested in code correctness, and if it happens to work as intended, some statistics for original/optimized performance. Do not forget to look at all scenarios.

If this patch format is a nonsense for you, the post here may help you more

Edit

I forgot to mention that you have to activate it by adding #define CV_USE_NEON somewhere at the top of the thresh.cpp function or as compile flag -DCV_USE_NEON

Patch 1/3. Update checkHardwareSupport()

From 5129091430a7423e5c07a4f3c845033adb8ccefe Mon Sep 17 00:00:00 2001
From: sammy <[email protected]>
Date: Tue, 31 Jul 2012 09:59:36 +0300
Subject: [PATCH 1/2] Update checkHardwareSupport and HWFeatures to support
 ARM NEON

---
 modules/core/include/opencv2/core/core_c.h |  3 +++
 modules/core/src/system.cpp                | 17 ++++++++++++++++-
 2 files changed, 19 insertions(+), 1 deletion(-)

diff --git a/modules/core/include/opencv2/core/core_c.h b/modules/core/include/opencv2/core/core_c.h
index df763ab..bdfb879 100644
--- a/modules/core/include/opencv2/core/core_c.h
+++ b/modules/core/include/opencv2/core/core_c.h
@@ -1706,6 +1706,9 @@ CVAPI(double) cvGetTickFrequency( void );
 #define CV_CPU_SSE4_2  7
 #define CV_CPU_POPCNT  8
 #define CV_CPU_AVX    10
+
+#define CV_CPU_ARM_NEON 100
+
 #define CV_HARDWARE_MAX_FEATURE 255

 CVAPI(int) cvCheckHardwareSupport(int feature);
diff --git a/modules/core/src/system.cpp b/modules/core/src/system.cpp
index b8a4661..eeb2a58 100644
--- a/modules/core/src/system.cpp
+++ b/modules/core/src/system.cpp
@@ -176,7 +176,22 @@ struct HWFeatures
             f.have[CV_CPU_POPCNT] = (cpuid_data[2] & (1<<23)) != 0;
             f.have[CV_CPU_AVX]    = (cpuid_data[2] & (1<<28)) != 0;
         }
-
+       
+       // Android check
+       #if defined ANDROID
+       if (android_getCpuFamily() == ANDROID_CPU_FAMILY_ARM &&
+            (android_getCpuFeatures() & ANDROID_CPU_ARM_FEATURE_NEON) != 0)
+        {
+            f.have[CV_CPU_ARM_NEON] = 1;
+        }
+       #endif
+       // iOS check. Automatically activated by GCC/LLVM compiler option
+       #if define TARGET_OS_IPHONE 
+       #if define __ARM_NEON__
+       f.have[CV_CPU_ARM_NEON] = 1;
+       #endif
+       #endif
+       
         return f;
     }

-- 
1.7.11

Patch 2/3. threshold() optimizations

From 9f9e6e0a382b0ec2b5ddb3eedd27bcdf95af9763 Mon Sep 17 00:00:00 2001
From: sammy <[email protected]>
Date: Tue, 31 Jul 2012 10:02:35 +0300
Subject: [PATCH 2/2] NEON-accelerated threshold()

---
 modules/imgproc/src/thresh.cpp | 140 +++++++++++++++++++++++++++++++++++++++++
 1 file changed, 140 insertions(+)

diff --git a/modules/imgproc/src/thresh.cpp b/modules/imgproc/src/thresh.cpp
index 1fb4847..fb01852 100644
--- a/modules/imgproc/src/thresh.cpp
+++ b/modules/imgproc/src/thresh.cpp
@@ -42,6 +42,10 @@

 #include "precomp.hpp"

+#if defined CV_USE_NEON
+#include <arm_neon.h>
+#endif
+
 namespace cv
 {

@@ -226,6 +230,142 @@ thresh_8u( const Mat& _src, Mat& _dst, uchar thresh, uchar maxval, int type )
     }
 #endif

+#if CV_USE_NEON
+    if( checkHardwareSupport(CV_CPU_ARM_NEON) )
+    {
+       uint8x16_t thresh_u = vdupq_n_u8(thresh);
+        uint8x16_t maxval_ = vdupq_n_u8(maxval);
+       
+        j_scalar = roi.width & -8;
+
+        for( i = 0; i < roi.height; i++ )
+        {
+            const uchar ...
(more)
2014-12-09 13:43:04 -0600 marked best answer Bug in the answers site

(I tried to use the feedack form, but it doesn't seem to work. If this is redundant, please let me know, and I will delete it. And I think it would be better for you to delete it after you acknowledge the problem, because it doesn't belong here)

I think a feature of the software that runs this answers site is actually a bug - It seems that if one's answer gets accepted, you receive 15 pts. So far, OK, But if the OP changes the accepted answer to another, it only takes out 5 pts from your karma. It may seem logical to keep some of the karma, because at a given moment in time, the answer seemed to be perfect. But the trouble starts when you switch accepted answer multiple times - every time it happens, you add (15-5=10pts).

You can see it here, on my profile http://answers.opencv.org/users/197/sammy/?sort=reputation

15 0How to enable vectorization in OpenCV? (6 mins ago) (Accepted again. 15pts again!!!)

10 0How to enable vectorization in OpenCV? (6 mins ago) (An upvote)

0 -5 How to enable vectorization in OpenCV? (16 mins ago) (Dis-accepted. Still keep 10 pts)

15 0How to enable vectorization in OpenCV? (16 mins ago) (Got accepted. 15pts )

10 0How to enable vectorization in OpenCV? (16 mins ago) (Upvote)

2014-09-24 15:47:28 -0600 received badge  Taxonomist
2014-09-20 05:39:00 -0600 received badge  Guru (source)
2014-09-20 05:39:00 -0600 received badge  Great Answer (source)
2014-07-28 13:47:10 -0600 received badge  Great Answer (source)
2014-07-28 13:47:10 -0600 received badge  Guru (source)
2014-04-01 03:52:42 -0600 received badge  Good Answer (source)
2014-03-18 06:46:21 -0600 received badge  Great Answer (source)
2014-03-18 06:46:21 -0600 received badge  Guru (source)
2013-12-05 00:51:00 -0600 received badge  Nice Answer (source)
2013-12-04 09:09:47 -0600 commented answer Convert between depth values and depth types

This is not a forum - to discuss based on a question. There is only one question per topic - opened by the first poster, and multiple answers

2013-12-04 09:08:25 -0600 commented question Using OpenCV to detect product availability on a shelf

The previous answer was deleted as self-advertising, contrary to forum rules

2013-12-04 09:07:24 -0600 commented answer Using OpenCV to detect product availability on a shelf

Will be deleted as self-advertisment

2013-11-28 19:16:09 -0600 marked best answer How to use the LshIndexParams?

I want to try out the new matching algorithm in flann, with LSH. But there is no info available.

What is the significance of the parameters in the LshIndexParams constructor?

LshIndexParams(int table_number, int key_size, int multi_probe_level);

Also, can you suggest some default values to start with? For a better context, I want to replace the BruteForceMatcher<Hamming> in the FREAK sample.

I would also want to know whether I should instantiate the matcher with a custom SearchParams.

Edit

I have tried to set the parameters recommended by docs (and some random combinations):

FlannBasedMatcher matcher2(new flann::LshIndexParams(20,10,2));

but it throws an error inside miniflann : cvflann::anyimpl::bad_any_cast

2013-10-31 02:04:39 -0600 commented question Unfortunatly, OCV Face Detection has stopped.

Looks like an unfortunate problem...

2013-08-26 06:22:52 -0600 commented answer ELSE runs even after IF runs!

@sinaras If your code goes on the else statement, that means the if() returned false. That is guaranteed by the C++ language, no need to find crazy explanations for the opposite. Just go find why that isOpened() returns false. Most probably, in Debug mode, it cannot find the video you are trying to open, and Michael said.

2013-08-26 04:19:57 -0600 commented question type and size of calibration pattern for most accurate results

The guys that wrote those calibration algorithms say that circles are far more accurate. But I cannot remember where they wrote that - I think in the Weekly Meeting Notes.

2013-07-25 08:27:24 -0600 received badge  Nice Answer (source)
2013-07-21 21:04:22 -0600 received badge  Great Question (source)
2013-07-08 00:37:06 -0600 commented question Augmented Reality

Your project is not impossible. However, for the same reason students don't build rockets, space ships or car engines from scratch during their summer assignments, it will be quite difficult for you to accomplish the task. I think a wise thing to do is to scale down your project to something manageable, and complete it, than to dream of something for which you would need a team of scientists and a 1 million $.

Something I think can be done is to perfect the barcode scanning, and to build a little web app that tries to get info about that part - a technical spec, or whatever.

Good luck!

2013-06-27 09:59:00 -0600 commented question How to generate unique face id for detected face from image ?

Read some papers on face recognition, and you'll have an idea on where to start. Just that it's not going to be a few lines of code, neither a magical getID(face). It's not something you would answer in a post here.