1 | initial version |
The silhouette or contour would be a bad idea: when you move the contour is changing! You can try interest points (SIFT/SURF/etc.) and compare the descriptors obtain. The results will depended on objects (texture, size, etc.). If your object are different in colors, you can used histograms comparisons. Otherwise, maybe you have to train a classifier (SVM,...) with the objects you want recognized, using critical points or whatever you want. See the literature about objects recognition to have ideas.
2 | merge previous answer |
The silhouette or contour would be a bad idea: when you move the contour is changing! You can try interest points (SIFT/SURF/etc.) and compare the descriptors obtain. The results will depended on objects (texture, size, etc.). If your object are different in colors, you can used histograms comparisons. Otherwise, maybe you have to train a classifier (SVM,...) with the objects you want recognized, using critical points or whatever you want. See the literature about objects recognition to have ideas.
[Update] To find if the pixel is inside a contour: draw each contour with a different color, get the color of selected pixel by user => if the pixel is white, it is outside any contour, otherwise, you know the contour (one for the first, two for the second, etc. as you have specified in drawContour). After, your algorithm is fine (draw the contour, get the bounding box of your contour to set the ROI, return only the silhouette of object). Try to display image at each step to debug...