In this paper the optimal structure of a neural network based on OpenCV for a golf ball recognition and the intensity of ROI(Region Of Interest) are calculated. The system is composed of preprocess, image processing and machine learning, and a learning model is obtained by multi-layer perceptron using the inputs of 7 Hu's invariant moments, box ration extracted by vertical and horizontal length or π calculated by area of ROI. Simulation results show that optimal numbers of hidden layer and the node of neuron are selected to 2 and 9 respectively considering the recognition rate and running time, and optimal intensity of ROI is selected to 200.