Motion detection based on the improved frame difference method. (a) The previous frame image. (b) The current frame image. (c) The frame difference result image. (d) The resulting image of the thresholding of (c). (e) A diagram showing the result of the region of the moving pixel in (d). It can be seen from (e) that if the optimization process is not performed, directly performing color detection on the rectangle in the image will increase the complexity of the algorithm, and it is not conducive to the use of preprocessed data when extracting advanced features later. (f) The binary image after the expansion of (d). (g) The region image of the moving pixels of (f). Regions of similar motion pixels in (f) are merged. (h) The region diagram of its motion pixels.