Tutorial: Build a Motion Detector in Video with Streamlit & OpenCV

Hey Streamlit Community!

I’m excited to share a new project and tutorial I’ve put together: a Motion Detector in Video application, built entirely with Streamlit and OpenCV.

What does it do?
Imagine you have a long video file (like from a security camera) and need to find the exact moments where movement occurs. This app allows a user to upload a video, processes it frame-by-frame, and then presents an interactive timeline showing the precise seconds where motion was detected. You can click on a timestamp to jump directly to that part of the video!

The Tutorial (Spanish with English Dubbing!)
I’ve created a full video tutorial walking through the code and the concepts behind the app.

  • Language Note: The original video is in Spanish. However, YouTube’s AI has provided a clear English-dubbed audio track ! To switch, simply click the Settings (:gear:) icon on the player, go to Audio Track , and select English .

:right_arrow: Watch the full tutorial on YouTube here!

Get the Code on GitHub
For those who want to jump right in, the complete source code is available on GitHub. Feel free to clone it, experiment, and adapt it for your own ideas.

:right_arrow: Access the GitHub repository here!

Key Features You’ll Learn to Build:

  • Using st.file_uploader to handle video files.

  • Integrating a powerful backend library like OpenCV for video processing.

  • Providing real-time visual feedback to the user while the process is running.

  • Using st.segmented_control to create an interactive navigation bar for video timestamps.

  • Usint st.video to show specific seconds where the movement was detected

I’d love to hear your feedback on the project and the video. What other computer vision applications would you be interested in building with Streamlit?

Happy Streamlit-ing