Open CV feature detection in GPU - opencv

I'm using OpenCV 2.4.6 in a prototype of object detection and I was wondering in how to improve the feature detection/extraction performance. Someone knows if is it possible to run feature detection/extraction/matching, like SIFT/SIFT/BF, or even the findHomography, on GPU?
Tks

OpenCV GPU module contains implementations for FAST, ORB and SURF feature detectors/extractors and for BruteForceMatcher.
You can read more in documentation:
http://docs.opencv.org/2.4.6/modules/gpu/doc/feature_detection_and_description.html
http://docs.opencv.org/2.4.6/modules/nonfree/doc/feature_detection.html#gpu-surf-gpu

Related

OpenCV GPU support and TBB

I am going to train my Haar classifier for flowers(which I am highly skeptical about). I have been following the CodingRobin Tut for everything.
http://coding-robin.de/2013/07/22/train-your-own-opencv-haar-classifier.html
Now, it has been emphasized that I use GPU support, multithreading etc. otherwise the training is gonna take days. I am going to use pre-built libraries and therefore the pre-built opencv_traincascade utility.
I want to ask beforehand, Will I be able to leverage GPU support if I use the pre-built libs, given that I install CUDA?
Where does TBB fit in the whole picture?
Do you recommend me building the whole library from scratch with TBB and CUDA support checked, or that would be a waste?
Note: I am using OpenCV 2.4.11. And I am a complete beginner to OpenCV.

Are there any detectors which implemented on GPU and are scale/rotate-invariant?

As known in OpenCV 2.4.9.0 are these feature-detectors: SIFT, SURF, BRISK, FREAK, STAR, FAST, ORB.
http://docs.opencv.org/modules/features2d/doc/feature_detection_and_description.html
http://docs.opencv.org/modules/features2d/doc/common_interfaces_of_feature_detectors.html
All of these have implementation on CPU, but only FAST and ORB on GPU. http://docs.opencv.org/genindex.html
And as known, some are scale/rotate-invariant, but some aren't: Are there any fast alternatives to SURF and SIFT for scale-invariant feature extraction?
These are scale-invariant and rotate-invariant:
SIFT
SURF
BRISK
FREAK
STAR
But these are not scale-invariant and not rotate-invariant:
FAST
ORB
Are there any detectors which implemented on GPU and are scale/rotate-invariant?
Or will be added in OpenCV 3.0 on GPU or OpenCL?
Actually, SURF is the only scale/rotate-invariant feature detector with GPU support in OpenCV.
In OpenCV 3.0 FAST and ORBhave got OCL support and moreover, these two (FAST and ORB) have already got CUDA support.
The OCL/CUDA support of SURF has been already mentioned in the comments of your question, but it is only a contribution to OpenCV and this is how OpenCV's developers about opencv_contrib:
New modules quite often do not have stable API, and they are not
well-tested. Thus, they shouldn't be released as a part of official
OpenCV distribution, since the library maintains binary compatibility,
and tries to provide decent performance and stability.
Based on my previous experiences OpenCV’s implementation of SURF features were much weaker than OpenSURF. It would be reasonable to try it, or find some other open source implementations.
p.s.:
to my knowledge still there is no GPU accelerated version of KAZE/AKAZE.
I recently implemented AKAZE using CUDA with a couple of colleagues, if you are familiar with the original library you should have no problem using it since we respected the API. You can find the current version here:
https://github.com/nbergst/akaze

CudaFy.net and OpenCV

I would like to use some of the OpenCV routines (2D convolve, Region Labeling, and Centroiding) in a CudaFy.net project.
Is this a stupid idea?
Would it be better just to implement the algorithms in C# from opensource examples?
Some of inputs to the OpenCV have will already be in global GPU memory, can you pass pointers to OpenCV GPU routines and say the matrix is already in the GPU?
Are there any simple examples of doing this
I did see one person who used EMGU and openCV but did run into some issues. Is there an example around of someone doing this successfully? [ https://cudafy.codeplex.com/discussions/356649 ]

Image Processing on CUDA or OpenCV?

I need to develop an image processing program for my project in which I have to count the number of cars on the road. I am using GPU programming. Should I go for OpenCV program with GPU processing feature or should I develop my entire program on CUDA without any OpenCV library?
The algorithms which I am using for counting the number of cars is background subtraction, segmentation and edge detection.
You can use GPU functions in OpenCV.
First visit the introduction about this : http://docs.opencv.org/modules/gpu/doc/introduction.html
Secondly, I think above mentioned processes are already implemented in OpenCV optimized for GPU. So It will be much easier to develop with OpenCV.
Canny Edge Detection : http://docs.opencv.org/modules/gpu/doc/image_processing.html#gpu-canny
PerElement Operations (including subtraction): http://docs.opencv.org/modules/gpu/doc/per_element_operations.html#per-element-operations
For other functions, visit OpenCV docs.
OpenCV, no doubt, has the biggest collection of Image processing functionality and recently they've started porting functions to CUDA as well. There's a new GPU module in latest OpenCV with few functions ported to CUDA.
Being said that, OpenCV is not the best option to build a CUDA based application as there are many dedicated CUDA libraries like CUVI that beat OpenCV in Performance. If you're looking for an optimized solution, you should also give them a try.

OpenCV Cascade Classification with Histogram of Oriented Gradients (HOGs) feature type

I am trying to use the OpenCV's cascade classifier based on Histogram of Oriented Objects (HOGs) feature type -- such as the paper "Fast Human Detection Using a Cascade of Histograms of Oriented Gradients".
Searching in the web, I found that the Cascade Classificator of OpenCV only supports HAAR/LBP feature type (OpenCV Cascade Classification).
Is there a way to use HOGs with the OpenCV cascade classifier? What
do you suggest?
Is there a patch or another library that I can use?
Thanks in advance!
EDIT 1
I've kept my search, when I finally found in android-opencv that there is a trunk in Cascade Classifier which allows it to work with HOG features. But I don't know if it works...
Link: http://code.opencv.org/projects/opencv/repository/revisions/6853
EDIT 2
I have not tested the fork above because my problem has changed. But I found an interesting link which may be very useful in the future (when I come back to this problem).
This page contains the source code of the paper "Histograms of Oriented Gradients for
Human Detection". Also, more information. http://pascal.inrialpes.fr/soft/olt/
If you use OpenCV-Python, then you have the option of using some additional libraries, such as scikits.image, that have Histogram of Oriented Gradient built-ins.
I had to solve exactly this same problem a few months ago, and documented much of the work (including very basic Python implementations of HoG, plus GPU implementations of HoG using PyCUDA) at this project page. There is code available there. The GPU code should be reasonably easy to modify for use in C++.
It now seems to be available also in the non-python code. opencv_traincascade in 2.4.3 has a HOG featuretype option (which I did not try):
[-featureType <{HAAR(default), LBP, HOG}>]
Yes, you can use cv::CascadeClassifier with HOG features. To do this just load it with hogcascade_pedestrians.xml that you may find in opencv_src-dir/data/hogcascades.
The classifier works faster and its results are much better when it trained with hogcascade in compare with haarcascade...

Resources