Irregular shape recognition opencv - c++

I am new to opencv, I made some examples and I played around with it.
But I want to do a more complex project for school that includes irregular shape detection in an image.
Here a some of the shapes just to make an idea:
Can anyone give me some general guides on what are the steps for achieving this and what should I use from opencv. I want to do it in the c++ version.
Note: the image might also be colored.

You can use SURF feature of opencv to extract shape features and match with flannMatcher or BFMatcher.
Please see the examples:
1/ SURF Feature Extraction
2/ Flann Matcher
3/ BF Matcher
Hope this will help you.

Related

Stitching images can't detect common feature points

I wish to stitch two or more images using OpenCV and C++. The images have regions of overlap but they are not being detected. I tried using homography detector. Can someone please suggest as to what other methods I should use. Also, I wish to use the ORB algorithm, and not SIFT or SURF.
The images can be found at-
https://drive.google.com/open?id=133Nbo46bgwt7Q4IT2RDuPVR67TX9xG6F
This a very common problem. Because images like this, they actually do not have much in common. The overlap region is not rich in feature. What you can do is dig into opencv stitcher code and there they use confidence factor for feature matching, you can play with that confidence factor to get matches in this case. But this will only work if your feature detector is able to detect some features in overlapping resion.
You can also look at this post:
Related Question
It might be helpful for you.
"OpenCV stitching code"
This is full pipleline of OPencv Stitching code. You can see that there are lot of parameters you can change to make your code give some good stitching result. Also I would suggest using a small image (640 X480) for the feature detection step. Using small images is better than using very large images

How to detect face in python open cv?

I am a newbie in python. I am working on a real time facial expression detection project. For the first module, my aim is to detect the face.
Is there any way to detect face without using any predefined classifiers(Haar Cascade)?
Is there any algorithm to implement the Haar cascade in my own way?
Ypu can use [Haar Cascades]:http://opencv-python-tutroals.readthedocs.io/en/latest/py_tutorials/py_objdetect/py_face_detection/py_face_detection.html
Hope this helps.

How to extract LBP features from a hand contour using opencv c++

I am currently working on a hand recognition system. I have been able to detect the hand and draw a contour for it. Now, I have to extract features from the hand region. What is the best feature extraction method that i can use?
I was thinking to use Local Binary Pattern, but since i am new to computer vision i don't know how to use it.
Perhaps you must look at histogram of gradients (HOG), which can be considered as a more general version of LBP. You can have multiple images of hands; by extracting HOG features from each image and using an SVM or neural network classifier, you can learn a statistical model of hand poses. This will help in recognizing an unseen hand. Look also at the current literature on deep learning.
A C++ implementation of HOG is available from vlfeat library [1], which can be called from OpenCV. HOG can be computer from OpenCV also [2].
[1] http://www.vlfeat.org/overview/hog.html
[2] http://goo.gl/8jTetR

OpenCV and Normal Bayes Classifier with custom features

I'm doing a project right now for emotion recognition. What I'm doing is to detect key points in the face using an ASM model, that way I can detect points of the mouth, eyes, etc. What I want to do, is to manually define some features from these points and use them to train a Normal Bayes Classifier with OpenCV.
It's possible to do something like this with the OpenCV implementation instead using a feature extractor algorithm? Can I just create Mat objects with the features I defined? and add them to the bowTrainer? if possible, how?
I'm following this tutorial:
http://www.app-solut.com/blog/2011/07/using-the-normal-bayes-classifier-for-image-categorization-in-opencv/
thanks!!

Sift Extraction - opencv

I'm trying to get started working with sift feature extraction using (C++) OpenCv. I need to extract features using SIFT, match them between the original image (e.g. a book) and a scene, and after that calculate the camera pose.
So far I have found this algorithm using SURF. Does anyone know a base code from which I can get started, or maybe a way to convert the algorithm in the link from SURF to SIFT?
Thanks in advance.
EDIT:
Ok, I worked out a solution for the sift problem. Now I'm trying to figure the camera pose. I'm trying to use: solvePnP, can anyone help me with an example?
Check out the feature2d tutorial section of the new OpenCV docs website.
There tutorials with code showing:
Feature detection with e.g. SURF
Feature Description
Feature Matching
If you have managed to find matches between the image and the scene, then I suggest you apply cv::findHomography(). It will calculate the homography matrix using 4 matches as input.
You can convert to camera pose from the homography matrix directly.
For using SIFT instead of SURF, I changed SurfFeatureDetector to SiftFeatureDetector and SurfDescriptorExtractor to SiftDescriptorExtractor. For some images, I found that the combination SURF detector <--> SIFT descriptor yields relatively accurate results, but you should experiment with other combinations (FAST detector - FREAK descriptor or ORB detector - BRISK descriptor), depending on your requirements.
Please follow this tutorial for solving the homography part of your question:
Feature Matching and Homography
Also, maybe this will help: Pose Estimation