Object recognition methods in OpenCV - image-processing

I am using some functions such as color contour tracking and image matching which are already available in OpenCV .. I am trying to identify a pink duck, more specifically the head of the duck, but these two functions don't give me the outcome I am expecting for some reasons such as :
the color thing don't always work perfect because the change in the lightning , which accordingly would change the color seen by the camera.
when I use the image matching thing, I use one image of the duck which I took from a specific position and it can identify the duck only when he is in that position, but I want to identify it even when I rotate the duck or play around with it.
Does anyone have an ideas about a better way to track a certain object ?
Thank you

Have you tried converting the image into the hsv colourspace? This colourspace tries to remove the effects of lighting so might be able to improve your colour-based segmentation.
To identify the head of the duck, once you have identified the duck as a whole you could perhaps identify the orientation (using template matching with a set of templates from different viewpoints, or haar cascades, or ...) and then use the known orientation and an empirical rule to determine where the head is located. For example, if you detect the duck in an upright position within a certain bounding box, the head is assumed to be located in the top third of that bounding box.

I think it might just take little more than what OpenCV provides straight forward way.
Given your specific question, you might just want to try shape descriptors of some sort.
Basically, try to take Duck's head's pictures shape from various angles and capture the shapes from it.
Now, you can find a likelihood model (forgive me for not a very accurate term) that can validate the hypothesis that a given captured shape indeed belongs to the class of Duck's head or not. Color can just be an additional feature that might help.
If you are a new person in this field - try catch hold of Duda and Hart: Pattern Classification. This doesn't have solution to find-the-duck-problem but will shape your thinking.

Related

How can I transform an image to match a circular model in OpenCV

I'm trying to make a program that can take an image of a dartboard and read the score. So far I can get the position of each dart by comparing it to a model image as you can see here:
However this only works if the input image is practically the same. In this other case the board is slightly in a different perspective so I was thinking maybe I can transform the image to match the model image and then do the process that you can see above.
So my question is: How can I transform this last image to match the shape and pespective of the model dart board with OpenCV?
The dart board is basically planar. Thus, you can model the wanted transformation by a homography. Now you can perform a simple feature extraction and matching like here or if speed is not as important utilize an intensity based parametric alignment algorithm (more accurate).
However, as already mentioned in the comments, it will not be as simple afterwards. The dart flights will (depending on the distortion) most likely cover an area of your board which does not coincide with the actual score. Actually, even with a frontal view it is difficult to say.
I assume you will have to find the point on which the darts stick in your board. Furthermore, I think this will be easier with a view from a certain angle. Maybe, you can fit lines segments just in the area where you detected a difference beforehand.
I don't think comparing an image with the model that was captured using a different subject with a different angle is a good idea. There should be lots of small differences even after perfectly matching them geometrically - like shades, lighting, color differences, etc.
I would just capture an image every time the game begin (reference) and extract the features (straight lines seem good enough) and then after the game, capture an image, subtract the reference, and do blob analysis to find darts.

Finding subpattern position in an image/pattern

Lets say I have an image or two dimensional pattern similar to QRcode and call it a template. Now I have a set of subimages that I want to match with my template and what's important - find their precise location in the template. I think similar problem is being solved in 'smart papers' http://en.wikipedia.org/wiki/Anoto and in kinect's grid of infrared dot pattern.
Does anyone have some clues how something similar can be implemented (even just
keywords to look up)?
I had few ideas:
opencv template matching method - poor results when rotated, scaled, skewed
SURF feature detection and matching - it's pretty good but result is worse when subimage is a really small chunk of the template. Besides I think that specificly picked up pattern would improve location finding rather than arbitary image. Also I think SURF is an overkill and I need something efficient that can handle real time mobile camera streams.
creating an image consisting of many QRcodes that only stores coordinates as data - drawback i that QRcodes will have to pretty small to allow
fine-grained positioning but then it's difficult to recognise them. Pros - they use only black color and have many white spaces (ink conservation)
2-dimensional colorful gradient image (similar to color model map) - I think this will be sensitive to lightness
QRCodes are square. Using feature detection to find the grid, you can unproject it. Then opencv's template matching will work fine.

Suggest template matching algorithm

I want to ask you to help to choose or find a good algorithm for the following problem:
I want to recognize the template in the image, the template is a text of non standard font, so OCR possibly will not handle it. What I want is to recognize it using the template matching algorithm. Please refer to the image:
As you see there is a background, in this image I draw it myself, and the background is simple. Usually it is not so simple: it has illuminance variations and usually colored to one color. So, I want to match this template, but I want the algorithm to be invariant of background color.
I've tryed the opencv's cvMatchTemplate, it handles well if there is a template on the image. But if I rotate object under the camera or remove it so that there will not be any templates, the algorithm finds many false-positive matches.
So I want to find an algorithm that also is rotation-invariant.
Can you suggest any?
Look at Hu Moments - is rotation & size invariant. , OpenCV has a Match shapes method which does most of the work for you.

OpenCV shape matching

I'm new to OpenCV (am actually using Emgu CV C# wrapper) and am attempting to do some object detection.
I'm attempting to determine if an object matches a predefined set of objects (that I will have to define). The background is well lit and does not move. My objects that I am starting with are bottles and cans.
My current approach is:
Do absDiff with a previously taken background image to separate the background.
Then dilate 4x to make the lighter areas (in labels) shrink.
Then I do a binary threshold to get a big blog, followed by finding contours in this image.
I then take the largest contour and draw it, which becomes my shape to either save to the accepted set or compare with the accepted set.
Currently I'm using cvMatchShapes, but the double return value seems to vary widely. I'm guessing it is because it doesn't take into account rotation.
Is this approach a good one? It isn't working well for glass bottles since the edges are hard to find...
I've read about haar classifiers, but thinking that might be overkill for my task.
Maybe this link is useful too. You have the code and library for SIFT, you just need to compile it. Good luck.
http://blogs.oregonstate.edu/hess/sift-library-places-2nd-in-acm-mm-10-ossc/#more-176

how to recognize the object I detect in video frames is a people or a car

I have a problem to detect object in images or video frames.
I have a task that is detect some people or something who enter into the sight of web camera, and then my system will be alarm.
Next step is recognize which kind of thing the object is, in this phase I know use Hough transform to detect line, circle, even rectangle. But when a people come into the sight of camera, people's profile is more complex than line, circle and rectangle. How can i recognize the object is people not a car.
I need help to know that.
thanks in advance
I suggest you look at the paper "Histograms of Oriented Gradients for Human Detection" by Dalal and Triggs. They used Histograms of Oriented Gradients to detect humans in images
I think one method is to use Bayesian analysis on your image and see how that matches with a database of known images. I believe some people run a wavelet transform to emphasize more noticeable features.

Resources