Object detection/recognition using matlab [duplicate] - matlab

This question already exists:
Closed 10 years ago.
Possible Duplicate:
Object recognition system using matlab
I need help to develop an object recognition system. It needs to identify an object in an image by comparing it with an image in an existing database. For example my database may consist of images of cars, buses, cups, etc. If i give a certain image as an input i want the code to check and tell me whether a car(as in the car in the database) can be found to exist in the input image or not. This is strictly to be implemented in matlab. I have tried correlation, image subtraction and a few other algorithms but to no effect. Thanks in advance.

This is a complex subject, that is really on the bleeding edge of technology, but let me give you a few pointers to help start things out.
Somehow, you need to take into account the different sizes, angles, etc that might be around. A car looks very different if photographed from a few feet away as compared to 50 feet, as would it photographed from the front vs the side.
Edge detection algorithms generally work well at pulling the target object's shape away. Take the edges, identify lines in them, and you can try to compare these lines with those from your model.
Range to objects really makes a huge difference in building a successful algorithm. If you know the difference from the front of the car to the back, it can make all of the difference in the world.
Focus, noise, lighting, etc need to somehow be dealt with, to ensure that the system works well.
All in all, I would recommend taking some image analysis classes, reading several papers on the subject, or at least reading the Wikipedia Article, and then starting to work on your project.

The problem you have described is sometimes called object category recognition or object class recognition to emphasize that you are not trying to recognize a particular object, but a member of a category such as "car" or "person".
One popular approach for solving this problem is called Bag of Features of "Bag of Words". If you have access to the Computer Vision System Toolbox for Matlab, it has functions for detecting SURF features, which can be used for this approach.
Also, a better place to ask this question might be Signal and Image Processing stack exchange.

Related

Bald detection using image processing

I was wondering if someone can provide me a guideline to detect if a person in a picture is bald or not, or even better, how much hair s\he has.
So far I tried to detect the face and the eyes position. From that information, I roughly estimate the forehead and bald area by cutting the area above the eyes as high as some portion of the face.
Then I extract HOG features and train the system with bald and not-bald images using SVM.
Now when I'm looking at the test results, I see some pictures classified as bald but some of them actually have blonde hair or long forehead that hair is not visible after the cutting process. I'm using MATLAB for these operations.
So I know the method seems to be a bit naive, but can you suggest a way of finding out the bald area or extracting the hair, if exists. What method would be the most appropriate for that kind of problem?
very general, so answer is general unless further info provided
Use Computer Vision (e.g MATLAB Computer Vision toolkit) to detect face/head
head has analogies (for human faces), using these one can get the area of the head where hair or baldness is (it seems you already have these)
Calculate the (probabilistic color space model) range where the skin of the person lies (most peorple have similar skin collor space range)
Calculate percentage of skin versus other color (meaning hair) in that area
You have it!
To estimate a skin color model check following papers:
http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.56.8637&rep=rep1&type=pdf
http://infoscience.epfl.ch/record/135966
http://www.eurasip.org/Proceedings/Eusipco/Eusipco2010/Contents/papers/1569293757.pdf
Link
If an area does not fit well with skin model it can be taken as non-skin (meaning hair, assuming no hats etc are present in samples)
Head region is very small, hence, using HOG for classification doesn't make much sense.
You can use prior information - like detect faces; baldness/hair is certain to be found on the area above the face. Also, use some denser feature descriptors.
You are probably ending up with very sparse representation or equivalently less information because of which your classifier is not able to classify correctly.

Object Tracking in non static environment

I am working on a drone based video surveillance project. I am required to implement object tracking in the same. I have tried conventional approaches but these seem to fail due to non static environment.
This is an example of what i would want to achieve. But this uses background subtraction which is impossible to achieve with a non static camera.
I have also tried feature based tracking using SURF features, but it fails for smaller objects and is prone to false positives.
What would be the best way to achieve the objective in this scenario ?.
Edit : An object can be anything within a defined region of interest. The object will usually be a person or a vehicle. The idea is that the user will make a bounding box which will define the region of interest. The drone now has to start tracking whatever is within this region of interest.
Tracking local features (like SURF) won't work in your case. Training a classifier (like Boosting with HAAR features) won't work either. Let me explain why.
Your object to track will be contained in a bounding box. Inside this bounding box there could be any object, not a person, a car, or something else that you used to train you classifier.
Also, near the object, in the bounding box there will be also background noise that will change as soon as your target object moves, even if the appearance of the object doesn't change.
Moreover the appearance of you object changes (e.g. a person turns, or drop the jacket, a vehicle get a reflection of the sun, etc...), or the object gets (partially or totally) occluded for a while. So tracking local features is very likely to lose the tracked object very soon.
So the first problem is that you must deal with potentially a lot of different objects, possibly unknown a priori, to track and you cannot train a classifier for each one of these.
The second problem is that you must follow an object whose appearance may change, so you need to update your model.
The third problem is that you need some logic that tells you that you lost the tracked object, and you need to detect it again in the scene.
So what to do? Well, you need a good long term tracker.
One of the best (to my knowledge) is Tracking-Learning-Detection (TLD) by Kalal et. al.. You can see on the dedicated page a lot of example videos, and you can see that it works pretty good with moving cameras, objects that change appearance, etc...
Luckily for us, OpenCV 3.0.0 has an implementation for TLD, and you can find a sample code here (there is also a Matlab + C implementation in the aforementioned site).
The main drawback is that this method could be slow. You can test if it's an issue for you. If so, you can downsample the video stream, upgrade your hardware, or switch to a faster tracking method, but this depends on you requirements and needs.
Good luck!
The simplest thing to try is frame differencing instead of background subtraction. Subtract the previous frame from the current frame, threshold the difference image to make it binary, and then use some morphology to clean up the noise. With this approach you typically only get the edges of the objects, but often that is enough for tracking.
You can also try to augment this approach using vision.PointTracker, which implements the KLT (Kanad-Lucas-Tomasi) point tracking algorithm.
Alternatively, you can try using dense optical flow. See opticalFlowLK, opticalFlowHS, and opticalFlowLKDoG.

Setting area for BlobAnalysis in Matlab

I am using this example from a Computer Vision Made Easy" Matlab Webinar I watched, since I intend to use Computer Vision for my research in order to count cars and/or other types of vehicles.
Although I have changed some of the filter parameters and the detection works quite well, the problem is that the script displays ALL moving objects in the video. I would like to count vehicles from a specific road but my video screenshot includes many roads (screenshot here).
1) Is there a way to set the area of the video that I would like to detect cars? For example, only the "green arrow" road, and leave out the rest? I tried to crop the video but it is not a good solution since a part of another road always appears(screenshot here).
2) Moreover, in which part of the code can I add a counter in order to have an output on how many vehicles passed through the specific segment of the road? Any ideas on that?
If you know ahead of time where the road is, you can create a binary mask image, where the road is marked with 1's, and everything else has the value of 0. Then you can simply check whether or not a moving object is inside your region of interest.
Once you get comfortable with this example, check out a more advanced version, which not only detects moving objects, but also tracks them using the Kalman filter.

comparing a known object in different pictures to find position and orientation error?

I am new to this place. I am doing a project where i use X ray images with known object dimensions. During my scan i want to compare the images with respect to first image to measure the position and orientation errors during my manipulator movement.
1) I use a known object next to my measuring object to check the errors.
How can i compare two or different images with same known objects?
2) I am planning to use matlab toolbox for the further processing. Is it possible to do in matlab? If so can somebody help
3) Is it possible to use POSIT algorithm to just find these errors?
You're asking a fairly complex question, without adding a lot of detail. We can only help you properly if you provide a bit more context, perhaps some examples of images.
By the sound of it: you should use the image processing toolbox.
If you have multiple images of test objects with known objects beside it, it is easiest to use normxcorr2 and friends (see this page for a worked-out example).
If you have a large amount of pictures of the same scene, possibly with rotations, scaling, optical distortions, etc. from image to image, and you still want a sub-pixel accurate estimation of your object's position, perhaps image registration is the better way to go.
But again: you should provide more detail. Only then can we give you a better, less generic answer.

How do I count the number of persons in an image using MATLAB?

Has anyone ever tried doing this kinda job?
Before trying to count the number of people in an image, it is easier to first solve the decision problem of: does this region contain a person? And, it is even simpler if you reduce it to a specific size: does this 20x20 pixel image contain a person? It's even easier, if you only strive for detecting faces.. in which case you can use the Viola-Jones face detection algorithm to determine if there is a face in the image.
Once you can say yes/no there is or is not a person (or face) in a region, you can use a sliding-window approach to cover each possible region and say yes/no there is/isn't a person (or face) in that region. To count the number of people (or faces), you simply tally the number of yes responses.
As I've already stated, detecting faces is a little bit easier than detecting people, and detecting front-facing faces is easier than detecting faces in any orientation. That said, it is possible to create object detectors for pretty much any object provided that you have a large enough dataset. These techniques can be fairly accurate, but they aren't 100% reliable, so you will get false positives and false negatives.
You can find a Matlab face detector at the given link.
There's an active community of research into this problem. Here's a good start:
http://lear.inrialpes.fr/people/triggs/pubs/Dalal-cvpr05.pdf
More info an links to implementations of HOG:
http://en.wikipedia.org/wiki/Histogram_of_oriented_gradients