home/ atoms/ computer-vision-frame-differencing

Frame differencing detects motion by comparing pixel values between consecutive video frames

The simplest motion detection compares each pixel of the current video frame with the same pixel in the previous frame. Large differences indicate motion. Subtracting RGB components independently and summing the absolute differences gives a motion score per pixel. This score can be thresholded to produce a binary motion mask, or used directly as a grayscale motion image. Background subtraction is a related technique: the first frame (or a user-captured key frame) serves as the reference rather than the immediately previous frame, enabling detection of presence vs absence rather than motion vs stillness.

Examples

int diffR = abs(currR - prevR); int diffG = abs(currG - prevG); int diffB = abs(currB - prevB); movementSum += diffR + diffG + diffB;

Assessment

Explain the difference between frame differencing and background subtraction; describe a situation where each would fail to detect what you want.

“int currR = (currColor >> 16) & 0xFF;// Like red(), but faster”
corpus · processing-handbook-no-login-mirror-pdf-reas-and-fry · chunk 117