Abstract:This paper designed a defect online detection system for formed foil based on machine vision, in order to solve several problems in the detection of formed foil, such as inefficiency, high labor intensity and low defection precision. Aiming at low contrast of the images of formed foil, in view of different types of defects needing different light source, with special illumination mode, this system used highperformance CCD to acquire images, was based on OPENCV and programmed for visual operation interface applying VS2008, worked in with the following algorithm to detect defects. In the subsequent processing part, this paper applied the methods of CLAHE and Niblack’s local adaptive threshold working in with the blob analysis to design the extraction algorithm, and applied the methods of Hough transformation and mask to design the removal algorithm of background around edge region. According to many experimental results of the system applying on the actual formed foil production line, this system can detect defects accurately.