Skip to content
This repository has been archived by the owner on May 25, 2022. It is now read-only.

Add files via upload #594

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions Background Substration/ReadME.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
Background substraction using python:

Background subtraction is a machine learning algorithm where we remove the background of video.
Using this we can count the number of vehicles moving in a given road.



Libraries Used:

1. Numpy
2. OpenCV

Language:

1.Python


Information:

In the code you have to paste the link of the video if you want to get background removal for the specific video present in your machine.
If u want to test for the live stream, then you can run this code and the output is stored in the same location as the code
24 changes: 24 additions & 0 deletions Background Substration/subtractor_mog2.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import cv2
import numpy as np

#cap = cv2.VideoCapture("Paste the link of the video that you want to work with")
cap = cv2.VideoCapture(0)

subtractor = cv2.createBackgroundSubtractorMOG2(history=100, varThreshold=10, detectShadows=True)

while True:
_, frame = cap.read()

mask = subtractor.apply(frame)

cv2.imshow("Frame", frame)
cv2.imshow("mask", mask)

key = cv2.waitKey(30)
if key == 27:
break

cap.release()
cv2.destroyAllWindows()

print("Project End")