The Sliding Window Approach
What you'll learn: You'll understand the naive sliding window method for object detection and why its computational cost makes it impractical for modern applications.
The Core Idea
The sliding window approach is the simplest conceptual method for detecting objects in an image. Imagine you have a small rectangular frame (window) that you systematically slide across an entire image, checking at every position whether an object exists inside that window.
Here's how it works:
- Choose a window size (e.g., 64×64 pixels)
- Start at the top-left corner of your image
- Extract that region and feed it to a classifier (like a CNN)
- Move the window slightly to the right (by a stride amount)
- Repeat across the entire image, row by row
- Change window sizes and repeat everything to detect objects of different scales
Think of it like reading a book with a magnifying glass: you examine one small section at a time, moving methodically across every page.
The Fatal Flaw: Computational Inefficiency
While conceptually straightforward, this approach is extremely slow. For a single 1000×1000 pixel image with a 64×64 window and stride of 4 pixels, you'd need to run your classifier approximately 60,000 times. Then multiply that by several window sizes to handle different object scales, and you're looking at hundreds of thousands of forward passes through your CNN for just one image!
This brute-force method wastes computation by analyzing mostly background patches and performing redundant calculations on overlapping regions.
Key Takeaway: The sliding window approach is intuitive but computationally prohibitive—running a classifier thousands of times per image is too slow for practical object detection, motivating the development of more efficient methods like region proposals and anchor-based detectors.