Parts Recognition / Classification with OpenCV

From my experience, I would suggest you the following. You know better than most of us how to classify manually, right? So think what happens in your brain while you classify. Suppose, you see a circular shape from the top view, so now your problem becomes how to identify that shape? Post such problems here, it will be lot easier for other people. Feature extraction is nothing but what brain thinks when you see that object.

For this question, I would suggest you first keep a dark background so that it will become necessary to binarize that image. Then if its a top view, you can see either a circle, hexagon etc. Then get only edges. Then get a minimal bounding circle and get its diameter. Algorithm and code to find minimum bounding circle can be obtained here.

As far as shape is concerned, I suggest you take gradient of that binary image and then calculate the angle of that gradients only at the edge points (which you got in top view). Histogram of that gradients will be your feature vector. See the bar plot of different shapes. If your brain can distinguish, then you can think about which classifier to use. I would rather not comment on that now since it depends on lot of things, such as distribution of features, their separability and most importantly speed requirement. But don't worry about classifier now.

Now, lets try to tackle the height. I assume you can get the front view, then just calculate the bounding box (you can get that from regionprops function in MATLAB).

Note that I am just imagining and talking all these things. You have to first do what I said in the first paragraph and then see if other part of the answer makes sense to you. I assume you have certain mathematical background to understand certain terminologies in this answer. If not, please do not hesitate to ask.

P.S. +1 for a good question.


Your problem is a typical pattern recognition task. In your scenario I would use a shape descriptor and then use it for recognition. An interesting approach is described in paper "Shape Matching and Object Recognition using Shape contexts".

One of the authour Jitendra Malik is the teacher of an interesting coursera computer vision course I attend a couple of months ago.