Skip to main content

Initial Release

Major VersionM

by Tyler Burns

Introduction

This guide will walk you step by step through using a Linux or Mac based device to access an RTSP (Real Time Streaming Protocol) stream of a webcam connected to the same local network as your computer and run a simple python script to begin capturing and storing images from the live RTSP feed. Perfect for creating a machine learning data set or gathering images for later analysis!

  1. An RTSP compatible  webcam A Computer that has access to Linux command line utilities (usually a device with MacOS or a Linux/unix operating system) The computer must also have Python 3. As well, as the the openCV Python library installed. Links to instructions to install each are embedded.
    • An RTSP compatible webcam

    • A Computer that has access to Linux command line utilities (usually a device with MacOS or a Linux/unix operating system)

    • The computer must also have Python 3. As well, as the the openCV Python library installed. Links to instructions to install each are embedded.

    • A Network Switch

    • 2x Ethernet cables (Cat 5 or higher)

  2. In order to Connect to the RTSP stream of our camera to establish a live feed we first need to find the IP address (a unique address that identifies a device on a local network) of our camera
    • In order to Connect to the RTSP stream of our camera to establish a live feed we first need to find the IP address (a unique address that identifies a device on a local network) of our camera

    • To find the IP address we first need to determine the network protocol being used on your server switch.

    • To do this first connect just your linux based terminal and camera to the switch via Ethernet and make not of your cameras MAC address

    • This will be found on the camera or in the documentation accompanying it.

  3. Now open the linux terminal on your computer and run the command ifconfig in the terminal this should bring up a list of network protocols along with information that accompanies them
    • Now open the linux terminal on your computer and run the command ifconfig in the terminal this should bring up a list of network protocols along with information that accompanies them

    • Now look at the ether heading under each protocol and find the MAC address that corresponds your camera. The protocol that has your camera in the ether will be your network protocol!

    • Next type the following command into your linux terminal: sudo arp-scan --interface=<your_network_interface> --localnet

    • Note: Replace <your_network_interface> with the name of the network interface that you are using to connect to the switch (e.g., eth0, wlan0, enp3s0, etc.).

    • after the common has finished running look for the entry that corresponds to your webcam. The entry will typically include the manufacturer's name or a model number. The IP address of your webcam will be listed in the first column of the entry.

  4. Congratulations you have found your IP address the hardest part of finding your Camera's RTSP URL. Your camera's specific RTSP URL will depend on the manufacturer of the camera however the formatting for the RTSP URL for nearly every manufacturer can be found here
    • Congratulations you have found your IP address the hardest part of finding your Camera's RTSP URL.

    • Your camera's specific RTSP URL will depend on the manufacturer of the camera however the formatting for the RTSP URL for nearly every manufacturer can be found here

    • The link above will provide specific instructions for your camera based on manufacturer a couple tips that apply across the board however are that the Port field of the stream format will typically be 554 and any usernames or passwords can either be found on your camera or in its documentation unless otherwise changed.

    • You can test your RTSP URL to make sure it is correct and running properly by opening your computers VLC media player going to the media tab going to the open network stream button and typing in your RTSP URL

  5. Now that you have your RTSP Stream URL working it is time to use your simply copy the code I wrote here To run the code first specify the how often you would like the code to collect an image, the file path of the directory you would like the images saved to, the RTSP URL and, the number of images you want to collect!
    • Now that you have your RTSP Stream URL working it is time to use your simply copy the code I wrote here

    • To run the code first specify the how often you would like the code to collect an image, the file path of the directory you would like the images saved to, the RTSP URL and, the number of images you want to collect!

    • The coded has the added ability to display the RTSP feed while images are being collected as well as the functionality to timestamp the images if the timestamp is added in brackets to the fstring that is the image file names

    • Now run your code from the terminal and collect data! Perfect for generating data from a machine learning model or sending data to some sort of image analysis tool!

Finish Line

One other person completed this guide.

Tyler Burns

Member since: 11/16/2020

1 Guide authored

0 Comments

Add Comment

View Statistics:

Past 24 Hours: 0

Past 7 Days: 0

Past 30 Days: 1

All Time: 24