Surveillance equipment helps prevent thefts and mishaps around the world on a large scale. Have you ever faced a situation wherein having a camera around would have made things easier? For example, if your car got stolen, and you had a camera in the walkway, you might have gotten a photo of the culprit, helping to solve the case. That is why having a camera around can be quite useful in several cases.
Read more..
Looking to build project on Surveillance Camera using IoT?:
Skyfi Labs gives you the easiest way to learn and build this project.
- Surveillance Camera using IoT Kit will be shipped to you (anywhere in the world!)
- Use high quality videos to understand concepts and build the project
- Get 1 to 1 expert assistance from Skyfi Labs engineers while doing the project
- Earn a smart certificate on finishing the project
You can start for free and pay only if you like it!
Also, streaming video helps you keep track of what’s going around in your home or office when you aren’t there. It works as a sort of surveillance and is a great way to monitor things. In this OpenCV project, we will be taking a look at how to stream videos onto a web page directly.
Project Description
If you have ever tried live video streaming using OpenCV, then you already know that there are a lot of different options available. Users can choose between using Raspberry Pi cameras or IP cameras. They can also rely on different programs or modules, such as Flask or even ImageZMQ. IP cameras tend to be more complicated when compared to Raspberry Pi cams, better known as Raspis as they do not allow
Real-time Streaming Protocol access. Several types of IP cameras are not compatible with the cv2.VideoCapture function, making their usage a tad bit difficult. Furthermore, they tend to be more expensive than Raspi and that is why for this OpenCV project, we are going to be using a Raspberry Pi camera. So, let’s get started with the basics.
In this project, we will use our basic knowledge of Flask, which is a micro web framework built for Python and integrated with the OpenCV framework to enable the streaming of videos onto a specified URL, which may then be viewed on a browser. We will make use of background subtraction techniques to build a motion detection algorithm which will help us switch the Raspberry Pi camera on and off whenever required. We will then utilize Flask to access the footage captured, process them and then stream the resulting video onto a web page.
Concepts Used
- Fundamentals of Programming
- Python Programming
- Fundamentals of OpenCV
Latest projects on Computer Vision
Want to develop practical skills on Computer Vision? Checkout our latest projects and start learning for free
- Basics of Flask
- Database Management
- Segmentation and Image Processing
- Motion Detection Algorithms
- Background Subtraction Techniques
Components Required
- A device with a suitable OS installed, such as Windows/Linux or Mac
- Adequate RAM
- Adequate Disc-space on the hard disk
- Python 2 or above installed
- OpenCV library installed
- Flask installed
- Required extended libraries- NumPy and imutils
Project Implementation
- Flask and Django are the most popular Python web frameworks available. The first towards completing this project is successfully installing Flask on your device.
- Use $ pip install flask to install the framework.
- Also, install the libraries NumPy and imutils.
- Next, define a major class to perform the required background subtraction and motion detection, this class should be the one that does most of the image processing and is a major part of the project.
Did you know
Skyfi Labs helps students learn practical skills by building real-world projects.
You can enrol with friends and receive kits at your doorstep
You can learn from experts, build working projects, showcase skills to the world and grab the best jobs.
Get started today!
- The output frames from this function have to go through Flask and then on to our web browser.
- To allow the web browser to display the video, we have to use some basic HTML markup and then use Flask to send the stream to the browser for us.
- Now to build the motion detector algorithm we need to understand the concept of background subtraction.
- Background subtraction works by first calculating the weighted average of all the previous frames.
- It then subtracts that value from the current frame’s value.
- Thresholding allows you to differentiate between the outputs of the subtraction, so that you can make out between regions in the frames that have undergone substantial differences in pixel values, indicating motion or change.
- By utilising image processing techniques like erosion and dilation, we remove the background noise and create a softer and more even image.
- Next, we make use of contour detection to extract only the regions which have undergone a change.
- Now, import the motion detection function onto a new Python workstation.
- Use a VideoStream class to access the Raspberry Pi camera module you are using to record the images.
- Next, import the required Flask packages to create an index.html template, and also a threading library so that multiple browsers can utilise the same IP address.
- Now create a function to gather footage from the camera, pass it through the motion detection module, and then display the results.
- Finally, use app.route to establish a URL endpoint and serve footage to http://your_ip_address/video_feed.
- The output is then encoded as a byte array and displayed by the web browser as a live feed.
- You can also add a final code block to handle parsing and launching of the Flask app.
Kit required to develop Streaming Video to a web-page using Open CV:
Technologies you will learn by working on Streaming Video to a web-page using Open CV:
Streaming Video to a web-page using Open CV
Skyfi Labs
•
Published:
2019-11-02 •
Last Updated:
2021-07-03