Skip to content

BallSpotProvider

TJArk-Robotics edited this page Nov 14, 2016 · 2 revisions

#BallSpotProvider There are mainly two steps in BallSpotProvider. ##First step The first step is realized by the function called searchScanLines(). It searches all the white regions obtained by the scan lines that scan from the top to the bottom of the image, which is provided by representation called ScanlineRegionsClipped. Then it calculates the midpoint of the segment that was the overlapping part of scanlines and white regions. We use this point as an initial point to scan up, down, left and right to find the edge points of the white regions. Those edge points might be the edge points of realistic ball. When the color changes from black or white to green, we consider it is ready to reach the edge points. In order to eliminate the influence of noises, we set a parameter called skipped. Only when it skips several green pixels consecutively, can we stop the scan. After that we can get four possible edge points and calculate the ballspot center position by using the following fomula:


x = ((left_stop_pixel + left_skipped) + (right_stop_pixel – right_skipped)) / 2
y = ((up_stop_pixel + up_skipped) + (up_stop_pixel – up_skipped)) / 2


Then we can calculate the center and radius of the ballspot according to the four edge points, which will be used by the filter in second step.

##Second step The second step is realized by the function call getBallSpot(). It uses three criteria to judge whether it is a valid ballspot, if not, just discard it. Those criteria are detailed as follow:


(1) Is the ballspot on robots? Discard it if return true. It is realized by the function called isOnRobot().
(2) Is the ballspot's distance to the robot valid? Discard it if return false.
(3) the center of the ballspot a white pixel or a black pixel? Discard it if return false.


After filtering the candidate ballspots using the above three criteria, we can discard a lot of invalid ballspots and reduce a lot of computation.

Clone this wiki locally