It deals with :
- Robot location
- Hammer location and calculation of robot's direction angle
- Balls identification ( with a white and a black ball )
- Robot location
Each time you need to, you can find new positions of robot and balls without dealing with hoops.
So, the first thing to do is to binarize your snapshot, and substract from it the binarized picture of hoops and peg. You have to remove sides of the board with this technique as well, because you can't use the "side eraser" mask here : indeed, balls/robots may be next to a corner, and you may remove them doing this.
At this point, you can clean the image by filling holes, and using Open on the image to clean it.
Then, detecting the robot, biggest element, is easy using enough Erositons and then Reconstructions by dilatation.
The important point here is that hammer must be removed as well, because this will be used after.
Like before, finding extremas gives you the robot location.
- Hammer location and calculation of robot's direction angle
Now you can remove the robot from the initial image.
You'll get an image with balls and the hammer.
As the hammer is thinner, you can get it by :
- Removing it from the image with erosion.
- Substracting the balls image from the initial image to get the hammer alone.

Now you've got the location of the robot, O, and a point on the hammer, B. With arctan function, you can get the value of a angle.
Depending on the result of image processing, B is not necesserally the middle of the hammer, so you can't measure AB distance. However, OA lenght can be measured ( 7.8 cm on my robot ).
So, as you know OB and OA, you can calculate b angle : b = arcsin(OA/OB)
where OA and OB can have negative values.
The direction angle you're looking for is direction angle = a - b
- Balls identification ( with a white and a black ball )
Now, take again the image with the two balls, use it as a mask on the camera snapshot saved, you'll get the image with the two balls only.
Here, use binarization, and an open to get rid of the white ball.
Here you've got the black ball location.
Substract it from the image with the two balls to get the white ball location.
--------------------------------------------
Image Processing Results ( Average values ) :
- Hoops & Peg Detection : 787ms
- Robot & Ball Detection : 963ms





No comments:
Post a Comment