| With the improvement of people’s living standards, people have higher demands on quality of apple. External quality is an important index for the classification of apple, which will affect consumers’ purchase desire. Shape and color are the two main parameters of the external quality of apples. Traditional PC based apple grading system has the problems of low detection efficiency, slow classification speed, large volume and high system complexity etc. It is difficult to popularize within small and medium enterprises. In order to reduce the cost of fruit grading system, improve accuracy and speed of detection and grading, promote the popularization of automatic detection and grading, so as to improve the income of farmers, developing and studying the fast, accurate and low cost apple quality detection and grading system has very important practical significance. The embedded system has the advantages of small size, low cost and high stability, which is widely used in the fields of machine vision etc. The main research content of this paper is to develop a real-time detection and grading system of apple shape and color based on embedded system and machine vision technology, which can quickly and accurately realize the detection of apple shape and color. It has important significance to improve the economic efficiency and enhance the competitiveness of apple market. The main work in this paper is as follows:(1) Complete the software design of the system platform. The transplant of LCD driver, USB camera driver and NFS file system are completed. The embedded Linux cross-compiling environment is built. Compile and configure QT in the Linux environment, then transplant it to embedded development board.(2) Build the motion control system and image acquisition system of stepping motor. Stepping motor motion control system is mainly driven by stepper motor roller movement, driving apples on the moving platform to move forward. The writing and transplantation of PWM driver is completed, the control of speed and rotation direction of stepping motor is achieved. The image acquisition system mainly completes the image acquisition. The system is based on the V4L2 programming framework, using the CMOS camera to collect the apple images in real time and transmitted these images to the embedded development board. And then through the MMAP mapping, bypassing the memory cache area, real-time display of images and detection results on the LCD screen.(3) Pretreatment of the apple images. When detecting the apple shape and color, the light reinforcement of image was used firstly to reduce the illumination change and unevenness of light source. Secondly, two parameters of R/G and G/B in RGB image were calculated, and the thresholds of these two parameters were obtained using training samples to achieve accurate segmentation of apple and background.(4) Realize the detection and grading of apple shape and color by using machine vision technology. In the apple shape detection process, first of all, the apple image calibration. Then use the roundness to describe apple shape, calculate the ratio of the minimum radius and maximum radius of apple to achieve the apple fruit shape detection. In the apple color detection process, the excess red minus excess green threshold segmentation method was applied to detect and calculate red region on apple surface, and the detection of apple color was achieved. |