Coder Social home page Coder Social logo

asrani1 / live-cctv Goto Github PK

View Code? Open in Web Editor NEW
45.0 1.0 1.0 67.68 MB

To detect any reasonable change in a live cctv to avoid large storage of data. Once, we notice a change, our goal would be track that object or person causing it. We would be using Computer vision concepts. Our major focus will be on Deep Learning and will try to add as many features in the process.

License: MIT License

Python 81.40% Jupyter Notebook 18.60%
deep-learning computer-vision neural-network python convolutional-neural-networks yolov3 yolo machine-learning cosine-similarity object-detection cctv-cameras cctv motion-detection frame-change-detection image-classification euclidean-distances darknet

live-cctv's Introduction

LIVE-CCTV

To detect any reasonable change in a live cctv to avoid large storage of data. Once, we notice a change, our goal would be track that object or person causing it. We would be using Computer vision concepts. Our major focus will be on Deep Learning and will try to add as many features in the process.

image

TABLE OF CONTENTS

About The Project

Aim: The project aims at storing only relevant data in a CCTV camera (in this case a traffic camera) to prevent storage loss and also detects the object that is causing the change in a frame and classifies them.

Description: The project uses Yolov3 pre-trained weights and config file. It calculates the distance between 2 consecutive frames of a video and then records if the change found is relevant. It further uses the OpenCV library's DNN module to load the Yolov3 weights and then classifies the object in front of the camera, also encloses the object detected with a bounding box

Tech Stack

The project uses:

File Structure

MAIN BRANCH
📦Notes                                    -Contains the notes for reference 
 ┣ 📜CNN (Eklavya).pdf                         -Notes on Convolutional Neural Networks
 ┣ 📜Eklavya (Linear Algebra).pdf              -Notes on Linear Algebra
 ┣ 📜Eklavya (Neural Networks).pdf             -Notes on Basics of Neural Networks
 ┗ 📜Handwritten_Notes.pdf                     -Handwritten notes on all topics
 
📦Live_CCTV_Cosine
 ┣📜Bounding_Boxes.py                           -Python file, contains function for Object Classification, Labeling them and further bounding them
 ┣📜Cos_sim.py                                  -Python file, Containing the function to calculate Cosine Similarity between 2 consecutive frames of a video
 ┣📜Main.py                                     -The Main Python file that exexutes the code
 ┣📜labels.txt                                  -Contains the labels for the objects that it detects
 ┣📜yolov3-tiny.weights                         -Pre-trained Yolov3 weights
 ┗📜yolov3.cfg                                  -Pre-trained Yolov3 Configuration file
 
 
 📦assets
 ┣ 📜LiveCCTV_Report.pdf                       -Report on the project
 ┣ 📜Output.mp4                                -Output video from test.mp4
 ┗ 📜result.png                                -Result on an image
 
 
┣📜Bounding_Boxes.py                           -Python file, contains function for Object Classification, Labeling them and further bounding them
┣📜Euclidean_dist.py                           -Python file, Containing the function to calculate Euclidean Distance between 2 consecutive frames of a video
┣📜Main.py                                     -The Main Python file that exexutes the code
┣📜Read.me.txt                                 -Contains the instructions
┣📜coco.txt                                    -Contains the labels for the objects that it detects
┣📜test.mp4                                    -Testing video
┣📜yolov3-tiny.weights                         -Pre-trained Yolov3 weights
┗📜yolov3.cfg                                  -Pre-trained Yolov3 Configuration file

Approach

The approach of this project is to basically record relevant changes in a video. By checking the similarity between 2 consecutive frames of a video we can decide wether a change is relevant or no based on the magnitude of similarity.

Theory

Neural Networks

A neural network is a network or circuit of neurons, or in a modern sense, an artificial neural network, composed of artificial neurons or nodes.

There are different types of Neural Networks:

  • Standard Neural Networks
  • Convolutional Neural Networks

Euclidean distance

It is a method to calcuate the distance between 2 vectors in a given space. In the project Euclidean distance is used to calculate distance between image vectors of 2 consecutive frames of the video. image

Yolo

The Yolo algorithm or You Only Look Once algorithm, is an object classification algorithm that divides the image into small grids and applies object classification to each of them. The algorithm then assigns bounding boxes to the objects which further uses NMS(Non-Max Supression).

Flowchart for code execution

Flowchart

Getting Started

Prerequisites

Install these on the conda prompt:

  • Python 3 (conda already consists of Python)
  • OpenCV: In conda prompt type
    conda install -c conda-forge opencv
    
  • numpy
    conda install -c anaconda numpy
    

Installation

Clone the repo

git clone https://github.com/AsRaNi1/live-cctv.git

Usage

After cloning the repo, open the file and run the Main file in each of the folders in the Command line Example:

$ Python Main.py

After running the main file, it will ask for the paths, so enter the paths as asked.

Input video file path:
Output path:

Results and Demo

The project clearly identifies an object in the video frame and assigns a bounding box to it along with labels i.e classifying the object, it also records the relevant motion taking place in the video. The video is saved in the Path folder.

Output.mp4

result

Future Work

The motion tracking algorithm the current project uses is derived from Eucidean diatnce, but this can further be bettered by the use of feature vectors i.e adding a Conv-net and then linear regression to the Euclidean distance found between 2 consecutive frames of a video. Further, the project can be enhanced by making it a Realtime car tracker which will not only be able to identify defaulters while driving but will also be able to save their numberplate and then we will be able to track their vehicle using out program in various CCTV's:

Troubleshooting

  • Common errors while configuring the project:
    • OpenCV not installed in conda
    • numpy not installed in conda
    • Using an older Python version
    • One can change the threshold vale for movement detection, so choose a suitable one.
    • When giving the output path in command line be sure to add .avi, Recording.avi

Mentors

A very special thanks to the mentors!!

Contributors

Acknowledgements and Resources

live-cctv's People

Contributors

asrani1 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

brahimmade

live-cctv's Issues

Week 2 (Arnav)

WEEK 2

DAY 1(13/09/21): Finished Linear algebra(16/16) and neural network(3/3) playlist (3B1B)
Held a meet with seniors regarding the project, ideas and the way to
move forward.

DAY 2(14/09/21): Saw some research papers on scene change detection. Will look for more
and finalize some to read.

DAY 3(15/09/21): Started with the Coursera course on Deep learning (first week).

DAY 4(16/09/21): Completed first week of the 1st course, started with the second week.

DAY 5(17/09/21): Completed the second week of the course and also downloaded VM ware and ubuntu
20.04 LTS and set it up. Had a meet with the mentor regarding the way
ahead with the project.

Week 5 (Arnav)

WEEK 5 (ARNAV)

DAY 1: Coursera course 4 started, also reading reasearch paper regarding the project.

DAY 2: Looked about YOLO and many more algorithms for object detection. Continued with the coursera course.
Learned more about openCV from various sources

DAY 3: Coursera course 4 week 1 completed with ideas of basic CNN.

DAY 4: Learned about Cosine similarity and implemented it to calculate similarity between 2 images. Started to study the YOLO
algorithm.

DAY 5: Studied YOLO algorithm and also read and implemented euclidean and manhattam distance for image similarity.

WEEK 6 (Arnav)

WEEK 6 (ARNAV)

DAY 1: Implemented the cosine difference algorithm in video to calculate similarity between 2 consecutive frames of a video

DAY 2: Implemented euclidean distance and manhattan diatance to realtime video. The program was also set to record the video
if significant changes were detected in any frame

DAY 3: Tried to implement the YOLO algorithm with pretrained models for object detection

DAY 4: Implemented cv2 functions to detect object in an image and make a bounding box around it.

DAY 5: The code now detectes moving object in a realtime and also records if significant changes are detected in the frames of
the video

Week 4 (Arnav)

WEEK 4 (ARNAV)

DAY 1: -

DAY 2: continued with coursera course on deep learning (completed week 2 and assignement).

DAY 3: Continued with coursera course on deep learining, put darknet in ubuntu.

DAY 4: Continued with coursera course (completed week 3 and assignment)

DAY 5: Continued with coursera course (week 4)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.