Questions tagged [background-subtraction]

Background-subtraction is a Computer-Vision technique that given a frame sequence from a fixed camera, processes pixels and separates them into foreground and background pixels.

Background Subtraction is a type of image segmentation which goal is to separate the parts of the image that are invariant over time (background) from the objects that are moving or changing (foreground).

The simplest techniques use frame differencing and more advanced techniques require using statistical methods. For example, a moving leaf of a tree would be considered foreground using simple frame differencing but with a proper statistical method it can be considered background as the leaf is always there, moving periodically.

Methods:

  • Frame differencing
  • Background as the average or the median of the previous nframes.
  • Background as the running average.
  • Pfinder (one Gaussian)
  • Mixture of K Gaussians
290 questions
2
votes
1 answer

OpenCV foreground detection with adaptive background, static objects too

I have a background image of a plain surface. My goals is to track objects that are positioned/moved over the surface. I'm using MOG2 to find foreground objects with a learning rate of 0, so the background is not updated (otherwise a static object…
blow
  • 12,811
  • 24
  • 75
  • 112
2
votes
3 answers

OpenCV won't properly write to output file (Python)

I have working code for applying background subtraction on a still video but it won't properly write the frames of subtracted background to its output file. I get the .avi file & filename which I specified in cv2.VideoWriter, but it doesn't seem to…
2
votes
2 answers

How to get the boundary of the bubble in the water and output the coordinate using MATLAB?

everyone. I am trying to get to boundary dimension of the bubble inside the water using MATLAB. The code and result are shown below. clear; clc; i1=imread('1.jpg'); i2=imread('14.jpg'); % i1=rgb2gray(i1); %…
2
votes
0 answers

Post BG subtraction(using opencv-python) and saving, output video is 2 GB. How to ensure it doesn't explode in size?

# Below piece of code is to read a video file called v1.mp4(size about 14MB), perform background subtraction on it, rotate the frame and save it. import cv2 import argparse import datetime import imutils import time import numpy as np cap =…
2
votes
0 answers

MOG background subtraction: history parameter not working

I'm trying to use MOG background subtraction but the "history" function doesn't seem to work. OpenCV 2.4.13 Python (2.7.6) Observation: The program appears to use the very first frame it captures for all future background subtractions. Expectation:…
chip
  • 21
  • 4
2
votes
1 answer

OpenCV BackgroundSubtractor yields poor results on objects with similar color as background color

I have kind of challenging task and spent a lot of time on it but without satisfactory results. The sense is to perform a background subtraction for future people counting. I am doing this with Python 3 and OpenCV 3.3. I have applied…
Michael
  • 1,170
  • 2
  • 14
  • 35
2
votes
3 answers

'Module' object has no attribute 'BackgroundSubtractorMOG'

I'm trying to use the default functions to do background subtraction of a video file. I'm using Python 2.7 and OpenCV. I receive this error when using the 'BackgroundSubtractorMOG' module: 'module' object has no attribute…
slow_one
  • 113
  • 1
  • 4
  • 13
2
votes
0 answers

export opencv Gaussian mixture model of backgroundsubtractorMOG2

I'm using the MOG2 algorithm for background subtration in opencv 3.2. I want to look at the learned gaussian mixture models(weights, variance, mean...), however opencv does not provide built-in function to look at the values. In bgfg_gaussmix2.cpp…
2
votes
1 answer

Tracking Multiple Objects Using Opencv Python

I'm trying to build a python program to count the number of people crossing the road in 2 directions. The video file is something like this Now for the detection phase I'm using BackgroundSubtractorMOG() to detect the peoples , now the problem is I…
Arijit
  • 1,506
  • 14
  • 23
2
votes
1 answer

What is the difference of these two parameters in Background Subtraction OpenCV

I using OpenCV for foreground detection, but I have a question if someone can help. The question is in these two parameters: Learn Rate in: bst.apply(currentFame, foregroungMask, learnRate); // -1 for auto, and the range is 0~1 Ratio…
Bahramdun Adil
  • 5,907
  • 7
  • 35
  • 68
2
votes
1 answer

How can i decide the optimal iterations for grabcut algorithm?

Grab cut algorithm gives different results for different number of iterations and settle down after some time without any further change. But for my dataset, if i allow it to settle down, it is cropping foreground also. If i do for 2,3 iterations…
2
votes
1 answer

How do I remove the background from image in Java using OpenCV with only single Image?

It is possible to use the BackgroundSubtractorMOG (OpenCV library) in still images? I want to get only the foreground image from one single still image (captured from camera) using OpenCV library. The still image look like this: The original still…
joshua14
  • 135
  • 2
  • 13
2
votes
1 answer

multiple object detection and tracking

I am new to image processing and I'm working on a project multiple object detection(any object in frame) and tracking. I read few of the detection algorithms and thought of implemnting Gaussian mixture model for detection and tracking using kalman…
2
votes
0 answers

Memory leak opencv cv2.createbackgroundsubtractionmog2

On windows 10, python 2.7.11, recent opencv 3 build with cmake Here is a simple example of trying to create a background model from pictures, not video. This only occurs when using pictures from file, not when using cv2.videocapture from a video…
bw4sz
  • 2,237
  • 2
  • 29
  • 53
2
votes
1 answer

Implement background subtraction in opencv java for video input from webcam?

I want to extract foreground mask of moving human alone in a static background. How to implement this in open-CV java? package com.java.opencv; import org.opencv.core.Mat; import org.opencv.video.BackgroundSubtractor; import…
Avinash S
  • 31
  • 1
  • 6