The application provides a moving target detection method, an electronic device and a storage medium, and relates to the technical field of terminals. The method comprises the following steps: firstly, in response to a shooting operation triggered by a user on a terminal device, a terminal device acquires a first target image and a second target image, and performs key
point registration processing on the two target images to obtain two target images after registration. Then, after performing binaryzation
processing on a target
optical flow map calculated according to the two target images after registration, a primary selected connected domain in which a moving target is located in the obtained
optical flow binaryzation image is determined. Then, the two target images after registration are subjected to interframe difference and binaryzation
processing to obtain a difference binaryzation image, and the primary selected connected domain is projected onto the difference binaryzation image, so as to filter out a filtered connected domain by using a preset threshold, and the filtered connected domain is used as a position of the moving target. Finally, the filtered connected domain is projected onto the target
optical flow map, and the speed of the moving target in the filtered connected domain can be calculated more accurately.