From a9f3a84abe93c5bfee60e6734fe51c4744831b27 Mon Sep 17 00:00:00 2001
From: Vignesh S S <85554244+vigneshss16@users.noreply.github.com>
Date: Wed, 30 Mar 2022 00:09:42 +0530
Subject: [PATCH] Add files via upload

---
 Background Substration/ReadME.md          | 21 ++++++++++++++++++++
 Background Substration/subtractor_mog2.py | 24 +++++++++++++++++++++++
 2 files changed, 45 insertions(+)
 create mode 100644 Background Substration/ReadME.md
 create mode 100644 Background Substration/subtractor_mog2.py

diff --git a/Background Substration/ReadME.md b/Background Substration/ReadME.md
new file mode 100644
index 000000000..ec06eacc3
--- /dev/null
+++ b/Background Substration/ReadME.md	
@@ -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
diff --git a/Background Substration/subtractor_mog2.py b/Background Substration/subtractor_mog2.py
new file mode 100644
index 000000000..a3d59529b
--- /dev/null
+++ b/Background Substration/subtractor_mog2.py	
@@ -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")