Difference between revisions of "Bee counter software"
(→Summary) |
(→Background) |
||
(11 intermediate revisions by the same user not shown) | |||
Line 14: | Line 14: | ||
http://hivetool.org/counter/beeTrack1_2.mp4 | http://hivetool.org/counter/beeTrack1_2.mp4 | ||
− | + | At frame 500, the contours are turned off, showing just the tracks. At frame 700, the input image (background) is turned off, showing only the contours and tracks. | |
− | + | ||
− | + | When a track (a series of brown dots for a single bee) ends, it is turned green (out) or red (in) as it is counted, just before it is erased. | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | + | The contour and track colors are based on the area of the contours. The number of bees is estimated by dividing the contour area by an arbitrary bee size. The area depends on how tightly the bee are grouped and settings that affect the size of the contours. | |
<table border=1> | <table border=1> | ||
Line 35: | Line 28: | ||
<tr><td>5 bees</td><td bgcolor="violet">Violet</td></tr> | <tr><td>5 bees</td><td bgcolor="violet">Violet</td></tr> | ||
</table> | </table> | ||
+ | |||
+ | ==Processing steps for each frame== | ||
+ | #Convert image to grey scale. | ||
+ | #[http://docs.opencv.org/doc/tutorials/imgproc/threshold/threshold.html?highlight=threshold Threshold] based on grey value. Result is binary image where dark areas are 0s and light areas are 1s. | ||
+ | #Invert threshold image so bees that were black (0) are now white (1). | ||
+ | #Filter to smooth the noise. (The exact process changes from version to version but currently: | ||
+ | ##[http://docs.opencv.org/doc/tutorials/imgproc/erosion_dilatation/erosion_dilatation.html Erode] the threshold image twice to remove legs, etc and try to separate the bees. | ||
+ | ##[http://docs.opencv.org/doc/tutorials/imgproc/gausian_median_blur_bilateral_filter/gausian_median_blur_bilateral_filter.html Blur] the image to smoth it. | ||
+ | #Draw a color contour around each object and color code it based on size (area). | ||
+ | #Check the last point of each track to see if one falls within a contour of an object. | ||
+ | #If so, append the center coordinates of the object to the track. If not, start a new track. | ||
+ | #The track ends when the last point of a track does not fall within any object, The track may be highlighted (red for returning, green for going out) and counted (IN or OUT counter incremented) depending on where the track starts, ends and length. | ||
==Background== | ==Background== | ||
− | Open Computer Vision ( | + | Open Computer Vision ([http://opencv.org/ openCV]) is an open source computer vision and machine learning software library. The library has more than 2500 optimized algorithms, which includes a comprehensive set of both classic and state-of-the-art computer vision and machine learning algorithms. |
− | |||
− | |||
− | |||
− | + | Kyle Hounslow has posted several YouTube videos on using openCV for object detection: | |
+ | *OpenCV Tutorial: Real-Time Object Tracking Without Colour<br>https://www.youtube.com/watch?v=X6rPdRZzgjg | ||
+ | *Tutorial: Real-Time Object Tracking Using OpenCV<br>https://www.youtube.com/watch?v=bSeFrPrqZ2A | ||
− | Note that what | + | Note that what is commonly called "tracking" is really just object detection. Tracking the object from frame to frame is more involved. It is trivial if there is only one object, but becomes harder and more error prone if there are multiple objects, especially if they can touch or occlude each other. |
Latest revision as of 02:03, 23 March 2015
Summary
beeTrack1 is a c++ program using openCV libraries. Here is an example of it processing video:
http://hivetool.org/counter/beeTrack1_2.mp4
At frame 500, the contours are turned off, showing just the tracks. At frame 700, the input image (background) is turned off, showing only the contours and tracks.
When a track (a series of brown dots for a single bee) ends, it is turned green (out) or red (in) as it is counted, just before it is erased.
The contour and track colors are based on the area of the contours. The number of bees is estimated by dividing the contour area by an arbitrary bee size. The area depends on how tightly the bee are grouped and settings that affect the size of the contours.
Number | Color |
---|---|
1 bee | Brown |
2 bees | Orange |
3 bees | Yellow |
4 bees | Blue |
5 bees | Violet |
Processing steps for each frame
- Convert image to grey scale.
- Threshold based on grey value. Result is binary image where dark areas are 0s and light areas are 1s.
- Invert threshold image so bees that were black (0) are now white (1).
- Filter to smooth the noise. (The exact process changes from version to version but currently:
- Draw a color contour around each object and color code it based on size (area).
- Check the last point of each track to see if one falls within a contour of an object.
- If so, append the center coordinates of the object to the track. If not, start a new track.
- The track ends when the last point of a track does not fall within any object, The track may be highlighted (red for returning, green for going out) and counted (IN or OUT counter incremented) depending on where the track starts, ends and length.
Background
Open Computer Vision (openCV) is an open source computer vision and machine learning software library. The library has more than 2500 optimized algorithms, which includes a comprehensive set of both classic and state-of-the-art computer vision and machine learning algorithms.
Kyle Hounslow has posted several YouTube videos on using openCV for object detection:
- OpenCV Tutorial: Real-Time Object Tracking Without Colour
https://www.youtube.com/watch?v=X6rPdRZzgjg - Tutorial: Real-Time Object Tracking Using OpenCV
https://www.youtube.com/watch?v=bSeFrPrqZ2A
Note that what is commonly called "tracking" is really just object detection. Tracking the object from frame to frame is more involved. It is trivial if there is only one object, but becomes harder and more error prone if there are multiple objects, especially if they can touch or occlude each other.