Impurity rate is one of the key performance indicators of the rice combine harvester and is also the main basis for parameter regulation. At present, the tracked rice combine harvester impurity rates cannot be monitored in real time. Due to the lack of parameter regulation basis, the harvest working parameters are set according to the operator's experience and not adjusted during the operation, which leads to the harvest quality fluctuating greatly in a complex environment. In this paper, an impurity-detection system, including a grain-sampling device and machine vision system, was developed. Sampling device structure and impurity extraction algorithm were studied to enhance the impurity identification accuracy. To reduce the effect of impurity occlusion on visual recognition, an infusion-type sampling device was designed. The sampling device light source form was determined based on the brightness histogram analysis of a captured image under different light irradiations. The effect of sampling device structures on impurity visualization, grain distribution, and mass flow rate was investigated by the discrete element method (DEM). The impurity recognition algorithm was proposed based on Mask R-CNN, which mainly includes an impurity feature extraction network, an ROI generation network, and a target segmentation network. The test set experiment showed that the precision rate, recall rate, average precision, and comprehensive evaluation indicator of the impurity recognition model were 92.49%, 88.63%, 81.47%, and 90.52%, respectively. The conversion between impurity pixel number and its actual mass was realized according to the pixel density calibration test and impurity rate correction factor. The bench test result showed that the designed system has a good detection accuracy of 91.15~97.26% for the five varieties. The result relative error was in a range of 5.71~11.72% between the impurity-detection system and manual method in field conditions. The impurity-detection system could be applied to tracked rice combine harvesters to provide a reference for the adjustment of operating parameters.