| Due to the frequent occurrence of food safety incidents,people pay more and more attention to the quality of disposable tableware;and since labor cost is rising year by year,producers’ demand for automated detection of cup quality keeps expanding.This paper aim at the various visual defects such as deformation,size deviation,rim crack,stains,wrinkles,foreign matters,and developed a embedded system based on ZYNQ for detection of paper cup’s visible defects using machine vision technology and embedded system development technology,on the purpose of realizing the automatic detection of paper products,reducing labor intensity,improving production efficiency.The main work of this paper is as follows:1.For the defects of rim size deviation,roundness error and rim crack,this pape proposed a new algorithm for evaluation these defects based on the minimum circumscribed circle method.The basic idea of the algorithm is that we begin with a circle which has two or three contact point with cup contour,On the premise that circles always had two or three contact point with contours and the contact point should meet some certain requirement,we find a bigger circle by replacement of contact point with some point of contours outside the circle,than we repeat until the circle contains all contours,now the circle is the minimum circumscribed circle of cup contours.And next we can evaluation the defects mentioned above based on the minimum circumscribed circle.The test results show that this algorithm has no principle error and high precision;and the principle is simple,easy to program.also the algorithm is efficient,it can meet the requirements for accurate,real-time measurement.2.As the effect of separating the bottom contour of the cup is not stable,this paper proposed "darkest N points method" for automatic threshold calculation to overcome the shortcomings of the fixed threshold,and gave a a method called "cut the circle area then binarization piece by piece" to avoid the problem that the contour points seperated out are not uniform because of uneven illumination.The "internal point expand and exclude method" and "inclusive box scanning method" are used to eliminate the block stains and the spot stains before the circle fitting to improve the fitting accuracy.3.For the reason gray scale change fast in the rim rigion caused by the arc shape the traditional methods for stains detection has a high error rate.So this paper designed "the edge detection operator at tangential direction n to realize the stains detection,and solve the problem of detection error.4.Because the paper cup has dimension in the direction of lens axis,the imaging quality is affected by the dispersion circle.So this paper established the mathematical model,to figure out the related laws and find the rules for choosing lens.5.The driving circuit of CMOS image sensor AR0134 is designed,and the image acquisition channel composed of parallel digital video signal interface and video DMA module is implemented in programmable logic part of the ZYNQ to make high-speed image acquisition.6.Embedded Linux system is transplanted,device drivers are wrote,and the GUI cup’s visible defect detection software is developed based on the proposed algorithm,QT/E and OpenCV library,with some related design for real time performance.7.At present,this paper builded a experimental system based on the ZYNQ development board Zedboard.It turns out the system is useful and the detection result are satisfactory.the average time of detection process is less than 201ms,which make it meet the requirements of real-time.Compared to machine vision system based on industrial cameras and PC,the embedded system this paper developed has the advantages of small volume,low cost,and low energy consumption. |