The invention relates to a subway door anti-pinch method and device based on video analysis and a medium, and the method comprises the steps: S1, collecting a continuous video
stream in real time when a subway door is dynamically closed, and taking a current frame image as a to-be-detected image; s2, the to-be-detected image is processed through the
Gaussian mixture background model, whether a target exists or not is judged, if not, the step S1 is executed, if yes, the target is extracted, the step S3 is executed, and the
background image is the image when the subway door is in the open state; s3, calculating a pixel
motion vector field between the to-be-detected image and the previous frame of image; and S4, on the basis of the pixel
motion vector field, detecting a normal
optical flow generated by the motion of the subway door and an abnormal
optical flow of the target, if the abnormal
optical flow is detected, judging a target door rushing behavior and triggering an anti-pinch mechanism by combining a background difference method, and if the abnormal optical flow is not detected, returning to the step S1. Compared with the prior art, the method has the advantages of safety, reliability and the like.