Computer Vision · Advanced level

Advanced level · Module 7: Video Analytics · Lesson 1 of 3

Processing Video Efficiently

Learners read video with OpenCV, sample frames, reduce resolution and measure processing speed to make analytics feasible on modest computers.

In this lesson you will

  • Read, sample and write video with OpenCV
  • Estimate processing feasibility

Key concepts

cv2.VideoCaptureframes per secondframe samplingresolution reductionthroughput measurement

The lesson

cv2.VideoCapture reads video files or cameras frame by frame; cv2.VideoWriter saves annotated output. A 30-frames-per-second video produces 108,000 frames per hour.

Most tasks do not need every frame at full resolution. Processing every fifth frame at half resolution reduces work about twentyfold. Choose the sampling rate from how fast objects move.

Measure frames processed per second on the lab laptop and compare it with the video's frame rate to know whether real-time processing is possible.

Step by step

  1. Read a public traffic or livestock video and print its frame rate and size.
  2. Process every frame, then every fifth frame at half resolution, timing both.
  3. Write an annotated output video.
  4. Calculate whether real-time processing is feasible.

Practice activity

Write a feasibility note for processing one hour of video on lab hardware.

Expected result: Measured throughput and a realistic processing plan.

Check your understanding

  1. How many frames does one hour of 30 fps video contain?

    Show answer

    108,000.

  2. Name two ways to reduce video processing cost.

    Show answer

    Sample fewer frames and reduce resolution.

Further learning

Taught live by an instructor — online or in person. Free course lessons are for self-study and do not lead to a certificate — see registration options.