According to a first aspect embodiment of the invention, the invention provides a violation detection model generation method, which comprises the steps of receiving a sample picture; extracting samples in the sample pictures based on pixel segmentation, and forming a training set by a plurality of samples; and training the to-be-trained model by using the training set to generate a violation detection model. According to the violation detection model generation method provided by the invention, after the sample pictures are received, the samples in the sample pictures are extracted based on the pixel segmentation technology, so that the samples are extracted according to the contours of the samples, and a training set is formed by a plurality of samples; the to-be-trained model is trainedthrough the training set, the violation detection model is generated, for articles needing to be transported or stored in a covering mode such as coal piles and sand piles, recognition is conducted according to the contours, background information can be prevented from being extracted, overlapping extraction of multiple samples is avoided, the risk of false detection or missing detection is reduced or even avoided, and the accuracy of the detection result is improved.