The purpose of this study is to introduce a method based on color space and object shape, in order to get data of ball by openni and to obtain a coordinate of the point. The distance from robot to basketball with respect to basketball position was achieved. Our results shows that the method has strong stability and real-time performance to use in robots.