Coder Social home page Coder Social logo

video-summarisation-object-detection's Introduction

Overview

This code uses OpenCV to summarise long, redundant, cctv/surveillance camera or similar footage, and uses YOLOv5 to conduct object detection on the summarised video. We will be using cctv.mp4 as an example.

How does it work?

The code can be split into 2 sections:

  • Video summarisation using summarisevideo(), which mainly utilises the cv2 library
  • Object detection via the class detection, which mainly utilises the torch library to access YOLOv5 (yolov5s.yaml)

summarisevideo() - This function takes an input .mp4 video, in our case cctv.mp4, and starts reading its frames one by one. It calculates the difference between the first frame of the video with the next, and the next frame with its next, and so on via image subtraction. Frames that are similar have a small difference, frames where big changes happen (unique) have a larger difference. If this difference value exceeds a user-set threshold, the frame is saved as a .jpeg and written into the summarised video. This ensures redundant parts of the footage are cut out.

class detection - This class contains the various functions needed to detect objects in the summarised video, that utilises the pytorch and the Yolov5s model we will be using. It also draws the rectangles and labels over the detected objects.

This section is based on Nicolai Nielsen's code so go check him or his YouTube channel out for a more in depth explanation:
https://github.com/niconielsen32/ComputerVision/blob/master/yoloCustomObjectDetection.py https://www.youtube.com/c/nicolainielsencomputervisionai

Results

Prerequisites

Before you run the code, please ensure to change the directory paths accordingly as well.
You will also need to download pytorch: https://pytorch.org/
You can find the YOLOv5 models here: https://github.com/ultralytics/yolov5/tree/master/models

video-summarisation-object-detection's People

Contributors

crookiee avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

vibhor0911

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.