One of the first scripts I vibecoded did exactly this. It works well, but is limited by framerate when there's high motion.