Hintergrundunterschied, Python, Mog, gmg, opencv3.1

Wenn es im Netz geschrieben wäre, könnte ich es nicht so verwenden, wie es war, also nur ein bisschen.

Ich habe gerade bgsegm hinzugefügt.


 mog2 hat aus irgendeinem Grund nicht funktioniert.

# Umgebung
Python 3.5.2
opencv '3.1.0'

## Prüfmethode (Python)

$ python --version Python 3.5.2 :: Anaconda 2.4.1 (x86_64)


## Prüfmethode (opencv)

$ python Python 3.5.2 |Anaconda 2.4.1 (x86_64)| (default, Jul 2 2016, 17:52:12) [GCC 4.2.1 Compatible Apple LLVM 4.2 (clang-425.0.28)] on darwin Type "help", "copyright", "credits" or "license" for more information.

import cv2 cv2.version '3.1.0'



 codes


#### **`mog.py`**
```py

# coding=utf-8
import cv2
cap = cv2.VideoCapture(0)
fgbg = cv2.bgsegm.createBackgroundSubtractorMOG()

while True:
    ret, src = cap.read()
    fgmask = fgbg.apply(src, learningRate=0.01)
    dst = src.copy()
    dst = cv2.bitwise_and(src, src, mask=fgmask)

    cv2.imshow('frame',dst)

    k = cv2.waitKey(30) & 0xff
    if k == 27:  # ESC key
        break
cap.release()
cv2.destroyAllWindows()

gmg.py


# coding=utf-8
import cv2
cap = cv2.VideoCapture(0)
fgbg = cv2.bgsegm.createBackgroundSubtractorGMG()

while True:
    ret, src = cap.read()
    fgmask = fgbg.apply(src, learningRate=0.01)
    dst = src.copy()
    dst = cv2.bitwise_and(src, src, mask=fgmask)

    cv2.imshow('frame',dst)

    k = cv2.waitKey(30) & 0xff
    if k == 27:  # ESC key
        break
cap.release()
cv2.destroyAllWindows()

results mog https://youtu.be/GSFa-6DObLI

gmg https://youtu.be/Qaq1Y8w5Bjk

refs http://www.weed.nagoya/entry/2015/07/21/154130

http://docs.opencv.org/3.1.0/db/d5c/tutorial_py_bg_subtraction.html

http://answers.opencv.org/question/77435/cannot-find-backgroundsubtractormog-and-backgroundsubtractorgmg-in-opencv-30-with-python-27/

check opencv ver http://qiita.com/PeaceAndHiLight/items/8372c5719ca73aa11d46

Recommended Posts

Hintergrundunterschied, Python, Mog, gmg, opencv3.1
Python2.7 + CentOS7 + OpenCV3
OpenCV-Beispiele (Python)
[Hinweis] openCV + Python
Python OpenCV Installation (Memo)
Binarisierung mit OpenCV / Python
Zusammenfassung über Python3 + OpenCV3
Einführung in OpenCV (Python) - (2)
Liste der Python-APIs für OpenCV3
Füllen Sie den Hintergrund mit einer einzigen Farbe mit OpenCV2 + Python
Python OpenCV Tutorial Memo
Python, OpenCV-Kameraerfassung
OpenCV für Python-Anfänger
"Apple-Verarbeitung" mit OpenCV3 + Python3
Bildbearbeitung mit Python OpenCV
Kameraerfassung mit Python + OpenCV
OpenCV3-Installation für Python3 @macOS
Installieren Sie OpenCV unter Ubuntu + Python
Stellen Sie Opencv in Python zur Verfügung
Gesichtserkennung mit Python + OpenCV
Verwenden von OpenCV mit Python @Mac
Die Farbextraktion mit Python + OpenCV löste das Rätsel des grünen Hintergrunds