1st Problem (what color has the sphere)
I intended the tracker to work with a color-filter in order to find the glowing sphere in the camera image. Therefore it is important to know the actual color of the sphere in the camera image!
The color may be highly influenced by the current lighting conditions, the cameras sensor and driver-functionality of the camera like auto-whitebalance, auto-exposure and auto-gain. This gets even worse with respect to the fact, that lighting conditions may change over time (switching on/off lights, closing curtains ...).
The main idea to bypass this problem is to take two pictures within a short time, on in which the sphere is off and one in which it is lit. From this pair it'd be easy to compute its difference with cvAbsDiff() in order to find the area in the image where the sphere is located an then extract the color information of the lit sphere with cvAvg() for that area.
However as there may be motion in the picture, either by the user it self or someon/someting else, calculating a single difference-image is not enough. e.g. like it can be seen in the following picture.
difference-image with a lot user-motion (white areas) |
Still this procedure may produce unexpected behaviour if the user moves a lot. Therefore i introduced further checks.
For all images where the sphere was lit (of the previous series) do:
- filter the image with the color we just approximated with the help of cvInRangeS(). In the resulting binary image perform a search for contours with cvFindContours(). If there is not exactly ONE contour found, discard the color and start with the color-calibration again.
- If the area of that contour is too small (e.g. <100px) --> discard color and start again
- If the the area of the contour differs to much from image to image --> discard color and start again
These steps show to be quite robust for different lighing conditions.
If you like the check out the code use the tag https://github.com/benniven/psmoveapiplayground/tree/ex1 to get the code from github.
system requirements:
- psmove-api headers --> https://github.com/benniven/psmoveapi
- psmove-api library build
- CL-Driver for the PS-Eye
- Windows operating system
- OpenCV 2.4 headers --> http://opencv.willowgarage.com/wiki/
- OpenCV 2.4 library build --> OpenCV 2.4 win binary
Keine Kommentare:
Kommentar veröffentlichen