The task of "Face Recognition", where you want a computer to figure out who a person is from a photo of them, is a very difficult function to do well. But in some cases such as robotics, it may not be so important to figure out exactly who it is, you might just want to get an idea of where the people are, or to notice when the camera sees the same person again after the camera has moved around in the room. These are cases when Shirt Detection can be used as a simple method to keep track of who is in the room. For example, a robot could just keep track that there is a person wearing a red shirt to its left, a person wearing a blue shirt in front, and a person wearing a yellow shirt on its right side, so that it can track where these people are when they move around or when the robot moves around.
Shirt Detection can be performed quite easily compared to Face Recognition, by using OpenCV's very reliable Face Detection. Once the program knows where a person's face is, it can look in a small region below the face (where a person's shirt would be), and determine the approximate color of their shirt in that shirt region. This can be performed even without a complex method of determining the exact contour region of a person's shirt, since all you need to know is the color of a region below their face, as opposed to the color of their entire shirt or body.
Here you can find a program I have created (named "ShirtDetection") that detects the shirt color of multiple people in a photo. As a demo, here is the input photo:
The program will convert each pixel into an approximate color type (eg: Green or Orange or Purple or Black, etc), based on its HSV color components. In the image below, you can see that some pixels are converted to red, some to orange, some to green, etc.
It will then perform Face Detection to find where the faces are within the original image. For each face that it finds, it will look at the approximate color types in a small rectangle region below the detected face. It will then see if there is a certain color type that is most dominant in that small region, such as if 60% of the pixels in the shirt rectangle are detected as purple pixels, then it will classify the person's shirt as Purple, with a 60% confidence rating. You can see the final image below, where the detected shirt colors are overlayed on top of the person's shirt.
In most photos, it is reliable enough for simple uses such as Human-Robot-Interaction, where a false detection is not such a problem. Note that even though it appears as if image segmentation was performed, there was no segmentation or contour detection being done. It is simply the result of converting each pixel into an approximate color type.
ShirtDetection:
The source-code to my program is available here (opensource freeware), to use as you wish for non-military projects only.
The shirt detection process only takes a few milliseconds to execute, but also does face detection, which can take upto 1 second, depending on the image size. Also, it generates a "Color Image" window so you can see the detected colors of all pixels, for debugging. You can disable that feature by commenting out "SHOW_DEBUG_IMAGE" in the source-code, to run faster.
Click here to download "ShirtDetection": shirtDetection.zip
(182kB Zip file, including C/C++ source code, VS2008 project files and the compiled Win32 program, created 9th Nov 2009).And if you dont have the OpenCV 2.0 SDK then you can just get the Win32 DLLs for running this program here: openCV200_Win32DLLs.zip (1.9MB Zip file).
0 comments:
Post a Comment