The invention discloses a cloth surface defect detection device and method based on machine vision. The detection device is assembled by modules, and comprises a preprocessing module, a visual detection module and a rolling module. The method comprises the steps of: using an area-array camera module in the visual detection module to shoot a defect-free cloth image as a standard sample, calculating a flat field correction matrix according to the standard sample, and realizing brightness compensation; calculating a clustering center and other characteristic parameters of the standard sample by adopting a principle of a K-means clustering algorithm; shooting cloth to be detected in real time and performing flat-field correction by the area-array camera module; carrying out edge detection and area cutting according to a brightness value difference between the background and the cloth image; calculating the Euclidean distance from a pixel of a to-be-detected image to a clustering center, and judging whether defects exist or not according to a threshold value; and if so, storing the defect image. The problems that traditional manual visual inspection is low in detection speed, low in precision, high in omission ratio and high in false detection rate are solved, and automatic detection development in the textile field is promoted.