Object Detection with IP Camera Using DeepStack

memudu alimatou sadia
DeepQuestAI
Published in
5 min readOct 7, 2021

This tutorial details how to use any IP Camera (e.g your smartphone)with DeepStack to detect objects in camera feeds.

In this tutorial, we’ll walk you through the process of transforming your iPhone or Android smartphone into an IP camera. We’ll also show you how to connect it to DeepStack for real-time object detection in the live camera feed..

What is an IP Camera ?

Internet Protocol Cameras, also known as IP Cameras refer to devices that provide live surveillance video feed wirelessly via an internet/WiFi network and are commonly used as baby monitors, in homes, offices, industrial sites, retail stores, banks, military facilities, traffic intersections, drones, etc. Any one can purchase and setup an IP camera as they come as cheap at $10. They have a unique advantage over analogue cameras as they don’t need complex, long cables installations and they are fast to setup.

Interestingly, you can turn your smartphone into an IP camera by installing some applications.

What is DeepStack ?

DeepStack is an open-source AI API server that empowers developers, IoT experts, research teams and individuals in small and large companies around the world to easily deploy AI systems both on premise and in the cloud. DeepStack is device and programming language agnostic. You can run it on Windows, Mac OS, Linux, Raspberry PI ( + all ARM devices)and NVIDIA Jetson devices with CPU and GPU acceleration. The following are features in-built into DeepStack

  • Face detection, matching and recognition APIs
  • Common objects detection and recognition APIs
  • Scene recognition APIs
  • Custom objects detection APIs
  • API security

Get Started

1) Install DeepStack and run Object Detection API

First, you need to install DeepStack on your machine. DeepStack is available on Docker for multiple operating systems and Windows as a Native application. To install and run DeepStack, ensure you have Docker installed. You can install Docker from the link below.

For other ways to install DeepStack (e.g Windos CPU and GPU), visit the link below.

2) Run DeepStack’s Object Detection

The object detection API can locate and classify 80 different kinds of objects in an image or video feed. Run any of the command below that corresponds to your operating system in Powershell, CMD or Terminal ( depending on your operating system)

Docker CPU

sudo docker run -e VISION-DETECTION=True -v localstorage:/datastore -p 80:5000 deepquestai/deepstack

Docker GPU (for NVIDIA GPU only)

sudo docker run --gpus all -e VISION-DETECTION=True -v localstorage:/datastore -p 80:5000 deepquestai/deepstack:gpu

NVIDIA JetSon

sudo docker run --runtime nvidia -e VISION-DETECTION=True -p 80:5000 deepquestai/deepstack:jetpack-2021.06.1

Raspberry PI & ARM devices

sudo docker run -e VISION-DETECTION=True -p 80:5000 deepquestai/deepstack:arm64-2021.09.1

Now visit localhost:80 or https://127.0.0.1:80 on your web browser

DeepStack

Great ! you have successfully install and run Deepstack on your device.

3) Install DeepStack python SDK

Install the DeepStack Python SDK from Pypi via the command below.

pip3 install deepstack-sdk — upgrade

4) Connect your Phone’s IP camera to DeepStack

Step1 — Install IP Camera

  • Install this IP Camera on your phone

For iPhone user : https://apps.apple.com/gb/app/ip-camera-lite/id1013455241

For android users: https://play.google.com/store/apps/details?id=com.shenyaocn.android.WebCam&hl=en&gl=US

  • Open the App and click on the Menu bar on the top right
  • Select Settings
  • Scroll down bottom where username and password is.
  • Edit the username to admin
  • Edit the password to password
  • At this point, ensure your Laptop and smartphone are in the same Wifi network, which can be done by connecting both devices to same network source
    OR
    the smartphone is tethering/sharing network and the Laptop is connected to the tethered network
  • Then go back to the main App page and click the Turn on IP Camera Server
  • A list of IPs will show on the bottom side of the screen
  • Type in the LAN IP into the laptop browser and add username, password and /video as seen in the sample below. For this tutorial, in the link above I set admin as my new username, password as my new password.

http://admin:password@192.168.1.230:8081/video

Now you see your IP Camera working perfectly !

Step2 — Connect IP camera to DeepStack

To link your IP camera to Deepstack, ensure the following steps are running in accordance.

  • Install Opencv-python with pip3 install opencv-python
  • Copy the Python sample code below, change the IP and run the code in your preferred IDE.

In line 41, replace the URL with your details.

Finally, You should see the detected objects showing on the laptop from the IP camera like mine.

This code outputs a frame that bears some details such as the date and time, phone battery level, the camera use (Back or front) and the app name.

Demo

Now you can run your IP camera live feeds through DeepStack.

Next steps

Are you planning on setting up your surveillance, security and visual analysis flow? You can set this up yourself by taking the following steps

  • Order a few or as many IP cameras you need
  • Place them in strategic locations in the area or facility of interest
  • Setup and run DeepStack on your laptop
  • Run multiple version of the sample Python code provided in this tutorial, one for each IP camera.
  • You can improve the code perform other actions such as save detections to a database, trigger actions based on specific objects detected, etc.
  • For detection of more or any object of interest to you, visit the DeepStack documentation links below.

--

--