The invention discloses an online detection method and detection device for cracks in preserved eggs based on machine vision. The detection device includes conveyor belt, dark box, light source, industrial camera, solenoid valve, controller and computer. The method is: ①collection of preserved egg images; ②automatic cropping of preserved egg images; ③preprocessing of preserved egg images; ④extraction of relevant characteristic parameters; ⑤establishment of crack discrimination model; The invention uses machine vision for detection, can realize online detection and grading of cracks in preserved eggs, has low application environment requirements, low equipment cost, and high degree of freedom of choice. Compared with acoustic detection, it has better application and promotion prospects; industrial cameras are used to flip preserved eggs Multi-angle photography, full detection range; using Haar feature detection, automatic frame selection, real-time, concise, accurate, high flexibility; efficient image processing and establishment of a discrimination model, an effective detection method for the vacant part of the online detection of preserved egg cracks method.