faldet

A simple fall-detection algorithm using opencv
Log | Files | Refs | LICENSE

commit f1985712bd9e9fd971eaac948e8a40a2a58598f5
Author: Naveen Narayanan <zerous@nocebo.space>
Date:   Sat,  8 Aug 2020 19:12:54 +0200

Initial Commit

Diffstat:
AMakefile | 4++++
Afaldet.py | 22++++++++++++++++++++++
2 files changed, 26 insertions(+), 0 deletions(-)

diff --git a/Makefile b/Makefile @@ -0,0 +1,4 @@ +.PHONY: run + +run: + python3 faldet.py diff --git a/faldet.py b/faldet.py @@ -0,0 +1,22 @@ +import numpy as np +import cv2 + +# cap = cv2.VideoCapture('/home/zerous/src/video-fall-detection/queda.mp4') +cap = cv2.VideoCapture(0) +bgsub = cv2.createBackgroundSubtractorMOG2() + +while(True): + ret, frame = cap.read() + + fgmask = bgsub.apply(frame) + + countours, hierarchy = cv2.findContours(fgmask, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE) + image = cv2.drawContours(frame, countours, -1, (0, 255, 0), 2) + cv2.imshow('win1', image) + + k = cv2.waitKey(30) & 0xff + if k == 27: + break + +cap.release() +cv2.destroyAllWindows()