IT

OpenCV-Python: 가우시안 혼합을 이용한 배경 제거 알고리즘 (1)

유병혁 2020. 5. 26. 13:07

안녕하세요? 이번 글은 가우시안 혼합을 이용한 배경 제거(background subtraction) 알고리즘에 관해 알아보도록 하겠습니다.

 

OpenCV: How to Use Background Subtraction Methods

Next Tutorial: Meanshift and Camshift Background subtraction (BS) is a common and widely used technique for generating a foreground mask (namely, a binary image containing the pixels belonging to moving objects in the scene) by using static cameras. As the

docs.opencv.org

배경 제거(background subtraction)란, 정적 카메라를 사용하여 전경 마스크(foreground mask: 동영상에서 움직이는 물체에 속하는 화소를 포함한 이진 영상)를 생성하는데 일반적으로 사용되는 기법입니다. 이름에서 알 수 있듯이 현재 프레임과 배경 모형(background model) 사이의 감산을 수행함으로써 전경 마스크를 생성합니다. 배경 모형은 동영상의 정적 부분, 또는 일반적으로 관측된 동영상의 특성을 고려하여 배경으로 간주할 수 있는 모든 것을 계산합니다.

 

배경 모형화(background modeling)는 두 가지 주요 단계로 구성됩니다:

1. 배경 초기화(background initialization): 배경의 초기 모형 계산

2. 배경 갱신(background update): 동영상 내 가능한 변화에 적응하기 위한 모형 갱신

 

OpenCV를 통해 배경 제거를 수행하는 방법은 다음과 같습니다:

1. cv :: VideoCapture를 사용하여 비디오 또는 이미지 시퀀스에서 데이터를 읽습니다.

2. cv :: BackgroundSubtractor를 사용하여 배경 모형을 작성하고 갱신합니다.

3. cv :: imshow를 사용하여 전경 마스크를 가져와 보여줍니다.

 

cv :: BackgroundSubtractor는 배경/전경 분할(background/foreground segmentation)의 기본 클래스입니다. 이 클래스의 상속 다이어그램(inheritance diagram)은 다음과 같습니다. 우리는 이중 가우시안 혼합 기반의 배경/전형 분할 알고리즘들을 학습해보고자 합니다.

첫번째 학습할 알고리즘은 'BackgroundSubtractorMOG'입니다.

OpenCV-Python을 통한 알고리즘 구현은 아래 링크를 참조하시면 됩니다.

 

Background Subtraction — OpenCV-Python Tutorials 1 documentation

Background Subtraction Goal In this chapter, We will familiarize with the background subtraction methods available in OpenCV. Basics Background subtraction is a major preprocessing steps in many vision based applications. For example, consider the cases li

opencv-python-tutroals.readthedocs.io

 

해당 알고리즘은 다음 연구에 기반합니다.

Pakorn KaewTraKulPong and Richard Bowden. An improved adaptive background mixture model for real-time tracking with shadow detection. In Video-Based Surveillance Systems, pages 135–144. Springer, 2002.

 

An Improved Adaptive Background Mixture Model for Real-time Tracking with Shadow Detection

Real-time segmentation of moving regions in image sequences is a fundamental step in many vision systems including automated visual surveillance, human-machine interface, and very low-bandwidth...

link.springer.com

이 연구는 Grimson et al (1999)이 제안한 '가우시안 혼합 기반 배경 제거 알고리즘'을 두가지 측면에서 개선한 것입니다. 첫번째는 학습 속도의 개선이며, 두번째는 그림자 감지 체계(shadow detection scheme: 움직이는 그림자와 객체를 구별하는 것)의 도입입니다. 저는 Grimson et al (1999) 연구를 먼저 학습해보고자 합니다.

 

Stauffer, C., Grimson, W. E. L. Adaptive background mixture models for real-time tracking. in Proceedings. 1999 IEEE Computer Society Conference on Computer Vision and Pattern Recognition. IEEE Computer. Soc. Part Vol. 2, 1999.

PDF 파일 다운로드 | http://www.ai.mit.edu/projects/vsam/Publications/stauffer_cvpr98_track.pdf