Detecting a red ball in any background

Using binary image technique, detecting a red ball.
Program done using cpp because i am comfortable with cpp than with
python....