OpenCV 2.2 PCA and EigenFaces - opencv

I just wanted to know if the cv::PCA::PCA constructor method in OpenCV 2.2 makes the substraction of the mean, or if I must pass my data already with the mean subtracted.
I tested both ways, but when visualizing eigenfaces neither of them are giving me good results but just a black screen. I have no segmentations faults or errors, I just don't get the eigenfaces visualization as in the papers.

I posted a complete example that shows how to use the PCA and display Eigenfaces here: PCA + SVM using C++ Syntax in OpenCV 2.2 (and on my page: http://www.bytefish.de/blog/pca_in_opencv).

It seems that they substract the mean within the PCA functions (i went to see the declaration of cv::PCA). Anyway I can't get eigenfaces visualization, it is just a black window. What I thought was that they weren't normalized, but no, I printed the L2 norm of each eigenvector and it is exactly 1.

I think to get eigenfaces you need to project the PCA eigenvector to an image.

Related

OpenCV Adaptive Threshold Explanation

Could anyone provide a mathematical explanation of the Adaptive Threshold function in OpenCV?
From the OpenCV 3.1.0 Documentation I found only this explanation:
cv2.ADAPTIVE_THRESH_GAUSSIAN_C : threshold value is the weighted sum of neighbourhood values where weights are a Gaussian window.
Which I do understand and can picture what the algorithm is doing for each pixel, just defining a mathematical solution for it is proving tougher than I thought.
I also found the code for it on the Github repo here but, after trying to walk through the code, I've realised my knowledge of OpenCV doesn't quite cover it.
Also, any sources would be much appreciated.
Thanks in advance!

opencv MSER.detectRegions() vs findContours(): what's the difference?

I am building a generic text parsing algorithm for images.
I was running:
MSER.detectRegions()
vs
findContours(...cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE)
on a binary image. The results where the same.
I know MSER can be done on gray-scale but I wanted to go safer.
I need to select one of them and the findContours() takes less then half the run time MSER does.
Am I missing something?
What would you pick?
As already pointed out, it does not make sense to compute MSER on a binary image. MSER basically thresholds an image (grayscale) multiple times using increasing (decreasing) thresholds and what you get is a so called component tree like this here. The connected components which change their size/shape at least over the different binarizations are the so-calles Maximally Stable Extremal Regions (e.g. the K in the schematic graphic). This is of course a very simplified explanation. Please ask Google for more details, you'll find enough.
As you can see, thresholding an already thresholded image does not make sense. So pass the grayscale image to the MSER algorithm instead. MSER is a common basis for state-of-the-art text detection approaches (see here and here).

Hand sign detection

I am trying to identify static hand signs. Confused with the libraries and algorithms I can use for the project.
What need to it identify hand signs and convert in to text. I managed to get the hand contour.
Can you please tell me what is the best method to classify hand signs.
Is it haar classifier, adaboost classifier, convex hull, orientation histograms, SVM, shift algorithm, or any thing else.
And also pls give me some examples as well.
I tried opencv and emugcv both for image processing. what is best c++ or c# for a real time system.
Any help is highly appreciated.
Thanks
I have implemented a handtracking for web applications in my master deggree. Basically, you should follow those steps:
1 - Detect features of skin color in a Region of Interest. Basically, put a frame in the screen and ask for the user put the hand.
2 - You should have a implementation of a lucas kanade tracker method. Basically, this alghorithm will ensure that your features are not lost through the frames.
3 - Try get more features for each 3 frames interval.
The people use many approaches, so I cannot give a unique. You could make some research using Google Scholar and use the keywords "hand sign", "recognition" and "detection".
Maybe you find some code with the help of Google. An example, the HandVu: http://www.movesinstitute.org/~kolsch/HandVu/HandVu.html
The haar classifier (method of Viola-Jones) help to detect hand, not to recognize them.
Good luck in your research!
I have made the following with OpenCV. Algorithm:
Skin detection made in HSV
Thinning (if pixel has zero neighbor than set zero)
Thicking (if pixel has neighbor nonzero then set it nonzero)
See this Wikipedia page for the details of these.
You can find the best trained cascade to detect hand using OpenCV from the GitHub...
https://github.com/Aravindlivewire/Opencv/blob/master/haarcascade/aGest.xml
Good luck...

Where can I find a good source of information that explains FFT phase correlation scoring

I've been looking to the OpenCV's magnificent source code to understand the score calculation. As you may have noticed the library can find a template in an image with a confidence score. cvMatchTemplate function gives the probability and location of the template in image.
Since DFT is slow, I decided to use FFTW library for phase correlation. I get the image, expanded to a size which is a power of 2, then did the same to the template, first calculated the FFT for both, multiplied the two array, calculated the inverse FFT, finally normalized the result.
If I show this result on a bitmap it clearly shows the location of template, however, I have difficulties calculating the correlation score. I tried to run cvMatchTemplate method line by line under debugger, it didn't help since the library uses DFT and arbitrary image sizes. All the tables used in that method (sum, sqsum etc) created for corresponding arbitrary sizes and FFT uses powers of two.
I would be grateful for any information on how to calculate the score from that result of phase correlation. There are many sources describing "take this, take that, multiply them, you see the white point on the image, yeah you find it" way. I need a score just like cvMatchTemplate did.
I'm kindly asking you to point me to a site or to a paper containing the logic of that calculation or to a book. Source code would be perfect but I have no hope on that anyway.
1) FFTW can work with non-power-of-2 size arrays.
2) The subject area you might to search/study in is the FFT cross-correlation theorem:
"the Fourier transform of the cross-correlation of two functions is equivalent to the product of the individual Fourier transforms, where one of them has been complex conjugated"
First, make sure you are not "expanding the image to a power of 2". I'm sure you didn't mean this, but anyway with FFTW you can calculate an arbitrary size FT.
I don't understand what you are using OpenCV for. If you have the FFT then it is quite easy to calculate the normalised cross power spectrum by yourself, in other words the "phase correlation formula".
Get the largest size FFT of the images that you can, not forgetting to window. Calculate the CPS. Once you have the correlation surface look for the peak.
I don't know what OpenCV offers for Phase Correlation apart from FT, but the paper you want is
G.A. Thomas, Television Motion Measurement for DATV and Other Applications, 1987, BBC Research Department.

Image processing [duplicate]

I need to count out boxes in a warehouse by using edge detection techniques; images will be taken from a 3D model of a warehouse and the propose system will be used 3 images in 3 different angles to cover the whole area of a warehouse.
As I have no experience in image processing before I'm a bit confused about which algorithm to use.
For a quick start I would suggest looking at those two:
Sobel operator
Canny operator
These are the most widely used edge detection filters with pretty good results.
If you are starting to learn computer vision, you should also learn about typical operations in image processing and convolution.
The OpenCV library is a great library which implements many algorithms of computer vision, including the two operators mentioned above.
Check out AForge. It has full C# implementation of some edge detection algorithms.
Take a look at Image Processing Library for C++ question. You can find several useful links there. The suggested libraries not only have algorithm description but also their implementations.
OpenCV has a very nice algorithm which detects closed contours in an image and returns them as lists of points. You can then throw away all contours which don't have 4 points, and then check some constraints of the remaining ones (aspect ratio of the rectangles, etc...) to find your remaining box sides. This should at least solve the image processing part of your problem, though turning this list of contours into a count of boxes in your warehouse is going to be tough.
Check here for the OpenCV function:
http://opencv.willowgarage.com/documentation/structural_analysis_and_shape_descriptors.html#findcontours
http://opencv.willowgarage.com/documentation/drawing_functions.html#drawcontours
'Sujoy Filter' is better than Sobel Filter for Edge-detection. Here's the Julia implementation (with paper link): Sujoy Filter

Resources