Cherry Picking Robot Vision Recognition System Based on OpenCV

. Through OpenCV function, the cherry in a natural environment image after image preprocessing, color recognition, threshold segmentation, morphological filtering, edge detection, circle Hough transform, you can draw the cherry's center and circular contour, to carry out the purpose of the machine picking. The system is simple and effective.


Introduction
Cherry picking operation is the most time-consuming and laborious in cherry production chain of a link.At the same time, picking operation quality directly affects the follow-up and storage products.How to get high quality products at low cost is must pay attention to and consider problems in fruit production.Picking operation due to strong seasonal, labour intensity, high cost, thus ensuring timely harvest fruit harvesting operations and reducing costs are some of the important ways of agricultural income.Because of the complexity of the picking work, picking automation level is still low.At present, the domestic fruit picking jobs are basically carried out manually, which costs about 50% -70% of the total cost, and the time is more concentrated.Because our country totally dependent on manual picking and cherry mature period is short, pick large cost and low efficiency.Cherry often waste caused by not timely harvest, which limits the size of the cherry planting.Development of mechanical harvesting has become the urgent needs of our industry and the inevitable trend of cherries.Cherry is called "spring after the first fruit".It doesn't take good field soil.Planting technology and fruit trees management difficulty is not large, and economic efficiency is high.Cherry picking reduces the cost of picking robot.It brings huge profits to give farmers more planting cherry enthusiasm, and reduce the cost of lower prices.Local cherries are more competitive and market.Cherry picking robots can effective and efficient harvest, the key is the robot vision recognition system for image processing.

OpenCV introduction
Using OpenCV function can be achieved Cherry recognition technology.It does not require additional code in the c + +, basically.It does not require additional code in the c + +, basically.

Recognition Technology
The technology uses Windows 7 as a development platform, using Visual Studio 2010 C ++ and OpenCV 2.4.9 open source library as a development tool for programming cherry picking robot vision recognition system.Figure 1 is a step of cherry picking robot vision recognition system.

Figure 1. Step of cherry picking robot vision recognition system
First of all, we have a cherry image for image preprocessing, with the median filter, and then use the R-1 / 2G-1 / 2B color recognition, followed by thresholding.We then split a good image before morphological closing operation, then the morphological opening operation.Then we have the image edge detection, and finally the image circle Hough transform.Finally it draws a circle and circular contour of cherry.

Image preprocessing (median filter)
Cherry picking robot in the natural environment due to hardware quality objective of the natural environment and shooting equipment and shooting angle, distance and other factors, Cherry captured images typically contain noise.These noises to extract the cherry feature recognition and extraction of the impact is bigger, which can make the image distortion, the extraction results cannot achieve the result of practical application, so we usually need to get rid of the noise of image.This technology is using median filter, the input of a cherry images using OpenCV function library of medianBlur () function to realize the function.The function prototype is void medianBlur (InputArray src, OutputArray dst, int Ksize).The function of the third parameter is the linear size of aperture, it must be an odd number greater than 1, this technology uses a linear aperture size is seven.

Color recognition
Because of the cherry red color with branches and leaves of green has bigger difference, so the recognition with cherry color features is effective method.Due to collect images cherry hardware equipment use RGB model more, so this technology is also used the model.In this model, all the color of the image that is a red, green, and blue, a combination of these three basic colors.Through OpenCV split () function can realize the RGB model of channel separation, separated channels.at(0) blue, channels.at(1) green, channels.at(2) red.But red component separated from the experimental results show that the effect not beautiful.Some scholars use 2 * redgreen -blue, for some fruits better recognition [1].It was found by using a combination of red -1/2 green -1/2 blue component, which can process image than 2 * Red -Green -Blue good color effect [2], so that this technology uses a combination of component.

Threshold segmentation
Threshold segmentation method is to determine an image gray value range of gray threshold, then the image of each pixel gray value compared with the threshold value, and according to the comparison results corresponding pixels can be divided into two categories.These two types of pixel generally belong to the image of two types of areas, so as to achieve the goal of segmentation.A greater difference between the segmentation methods for gray value range image segmentation effect is good.We can use fixed threshold segmentation, the use of OpenCV threshold () function to implement this function.The function prototype is double threshold (InputArray, OutputArray DST, double thresh, double very much, int type) with double thresh parameter values from 0 to 254, how many values according to the specific circumstances of the image.Parameter type of the value is 0, 1,2,3,4 respectively.0 represents binary threshold, 1 representing the anti-binary threshold, 2 representing truncated threshold, 3 representing the anti-threshold value to 0, 4 representing the threshold value to 0. Specific what the threshold type will be according to the actual circumstances of the cherry image.Therefore, the specific values of thresh and type parameters determine the effectiveness of cherries image fixed threshold segmentation process.

Morphological filtering
After threshold segmentation, cherry image due to factors such as the shade of leaves, illumination, the cherry fruit image will appear a few holes, outside the fruit images are some of the small noise, the noise and holes will affect the subsequent processing of the images, so first for closing operation to remove cherry inside the hole, then to open operation to remove cherry external image noise.Closing operations use OpenCV morphological morphologyEx () function and getStructuringElement () function, morphologyEx () function in the identifier selection MORPH_CLOSE.GetStructuringElement () function of the first parameter, there are three kinds of shapes to choose from, MORPH_RECT said rectangle, MORPH_CROSS said cross shape, MORPH_ELLIPSE said oval, the size of the second parameter indicates the kernel function.According to the different images of cherries, in order to optimal effect, we can be on different images with different kernel size for closed operation.This technology uses oval kernel and the kernel size 20 for processing.Open operation in morphologyEx () function in the identifier choose MORPH_OPEN, according to the different images of cherries, in order to optimal effect, we can be on different images using different kernel size to open operation.This technology uses elliptic kernel and the kernel size 70 for processing.

Edge detection
OpenCV provide four kinds of edge detection methods, which respectively is a Canny operator, Sobel operator, Laplacian operator, Scharr filter.We found through experiment contrast using Canny operator to extract the contour which is thinner and cherry fruit good connectivity.Sobel edge operator to extract the contour is slightly rough and uneven thickness.Laplacian operator to extract the edges of cherry is coarse and connectivity is better.Scharr filter to extract the contour edges have fuzzy horizontal line, so the result is bad.The result of edge detection can be shown in figure 2. This technology uses Canny operator to extract the edge.OpenCV use the Canny () function to achieve this function; you need to pay attention to the former first to use this function in addition to Gaussian noise.

Circle Hough transform
Filmed in the actual cameras in the picture, there are different degrees of cherry branches, leaves and cherry occlusion problem between each other.Cherry as approximation is circular, using circle Hough transform to detect the boundary of the cherry.Using OpenCV HoughCircles () function of circle Hough transform, we can find the picture of cherry's center and radius, then Circle () function draws a circle and rounded profile, so the robot can pick operation.

The cherry picking robot vision recognition system of the experimental results and analysis
In order to test the function of this system, we input a cherry image to this system for processing the whole process.Test results can be shown in Figure 3.

Conclusion
This technology for cherry block adjacent to each other and overlap each other more serious problem cannot be effectively solved directly.To solve the above problem is only to shoot a cherry, picking a cherry finish after taking the next cherry images.It is best to deal with no shade of cherries.But the system is simple and effective, which does not need to how much programming basis.It can be run directly calling OpenCV function.For occlusion, due to the direct call OpenCV circle Hough transform function processing results are poor.The solution is to rewrite the code through improved Hough transform to solve.

Figure 2 .
Figure 2. Edge detection image processing results

Figure 3 .
Figure 3.The processing of cherry picking robot vision recognition system