Yolo 비전 선전
선전
지금 참여하기
용어집

옵티컬 플로우

Explore how optical flow enables motion analysis in computer vision. Learn about sparse vs. dense flow, real-world applications, and integration with YOLO26.

Optical flow is the pattern of apparent motion of objects, surfaces, and edges in a visual scene caused by the relative motion between an observer and a scene. In the field of computer vision, this concept is fundamental for understanding temporal dynamics within video sequences. By analyzing the displacement of pixels between two consecutive frames, optical flow algorithms generate a vector field where each vector represents the direction and magnitude of movement for a specific point. This low-level visual cue enables artificial intelligence systems to perceive not just what is in an image, but how it is moving, bridging the gap between static image analysis and dynamic video understanding.

광학 흐름의 핵심 메커니즘

광학 흐름 계산은 일반적으로 밝기 불변성 가정에 의존하며, 이는 물체가 움직이는 동안에도 물체 상의 픽셀 강도가 프레임 간에 일정하게 유지된다는 것을 전제로 합니다. 알고리즘은 이 원리를 활용하여 두 가지 주요 접근법을 통해 운동 벡터를 구합니다:

  • Sparse Optical Flow: This method calculates the motion vector for a specific subset of distinct features, such as corners or edges, detected via feature extraction. Algorithms like the Lucas-Kanade method are computationally efficient and ideal for real-time inference tasks where tracking specific points of interest is sufficient.
  • Dense Optical Flow: This approach computes a motion vector for every single pixel in the frame. While significantly more computationally intensive, it provides a comprehensive motion map essential for fine-grained tasks like image segmentation and structural analysis. Modern deep learning architectures often outperform traditional mathematical methods in dense flow estimation by learning complex motion patterns from large datasets.

옵티컬 플로우 vs. 객체 추적

While often used in tandem, it is vital to distinguish optical flow from object tracking. Optical flow is a low-level operation that describes instantaneous pixel motion; it does not inherently understand object identity or persistence.

In contrast, object tracking is a high-level task that locates specific entities and assigns them a consistent ID over time. Advanced trackers, such as those integrated into Ultralytics YOLO26, typically perform object detection to find the object and then use motion cues—sometimes derived from optical flow—to associate detections across frames. Optical flow answers "how fast are these pixels moving right now," whereas tracking answers "where did Car #5 go?"

실제 애플리케이션

픽셀 단위의 움직임 추정 능력은 다양한 정교한 기술의 기반이 됩니다:

  • Autonomous Vehicles and Robotics: Optical flow is used for visual odometry, allowing a robot or car to estimate its own movement relative to the environment. It also assists in depth estimation and obstacle avoidance by analyzing how rapidly objects in the visual field are expanding or moving.
  • Video Stabilization: Cameras and editing software use flow vectors to detect unintentional camera shake. By compensating for this global motion, systems can digitally stabilize footage. This is a standard feature in modern consumer electronics like smartphones and action cameras.
  • Action Recognition: In sports analytics and security, analyzing the temporal flow of pixels helps systems identify complex human actions. For example, pose estimation models can be augmented with flow data to distinguish between a person walking versus running based on the speed of limb movement.
  • Video Compression: Standards like MPEG video coding rely heavily on motion estimation. Instead of storing every full frame, the codec stores the optical flow (motion vectors) and the difference (residual) between frames, significantly reducing file sizes for streaming and storage.

구현 예시

The following example demonstrates how to compute dense optical flow using the OpenCV library, a standard tool in the computer vision ecosystem. This snippet uses the Farneback algorithm to generate a flow map between two consecutive frames.

import cv2
import numpy as np

# Simulate two consecutive frames (replace with actual image paths)
frame1 = np.zeros((100, 100, 3), dtype=np.uint8)
frame2 = np.zeros((100, 100, 3), dtype=np.uint8)
cv2.rectangle(frame1, (20, 20), (40, 40), (255, 255, 255), -1)  # Object at pos 1
cv2.rectangle(frame2, (25, 25), (45, 45), (255, 255, 255), -1)  # Object moved

# Convert to grayscale for flow calculation
prvs = cv2.cvtColor(frame1, cv2.COLOR_BGR2GRAY)
next = cv2.cvtColor(frame2, cv2.COLOR_BGR2GRAY)

# Calculate dense optical flow
flow = cv2.calcOpticalFlowFarneback(prvs, next, None, 0.5, 3, 15, 3, 5, 1.2, 0)

# Compute magnitude and angle of 2D vectors
mag, ang = cv2.cartToPolar(flow[..., 0], flow[..., 1])

print(f"Max motion detected: {np.max(mag):.2f} pixels")

For high-level applications requiring object persistence rather than raw pixel motion, users should consider the tracking modes available in Ultralytics YOLO11 and YOLO26. These models abstract the complexity of motion analysis, providing robust object IDs and trajectories out of the box for tasks ranging from traffic monitoring to retail analytics.

Ultralytics 커뮤니티 가입

AI의 미래에 동참하세요. 글로벌 혁신가들과 연결하고, 협력하고, 성장하세요.

지금 참여하기