IntruderDet —An Intruder Detection Bot for my Appartment – Telegram Group

IntruderDet —An Intruder Detection Bot for my Appartment

Detected Intruder surrounded by a bounding box — drawn by Hannah Schieber

I recently bought a new camera OAK-D Lite. OAK-D Lite is a small RGB-D camera. It includes neural models and everything else, which let the computer vision enthusiast heart grow. So as I have this thing, what should I do with it?

Why not build a telegram bot which sends me an image if a person is in my appartment? To implement this, a script combines MobileNet-SSD with a telegram bot. The network output is filtered for the class person. With this filter, our script only notifies the owner of the appartment if a person is detected.

Telegram Chat Bot

For the creation of a telegram, many blog posts exist. Therefore I recommend reading the one below and installing the telegram-bot according to this instruction:

python-telegram-bot

A Python framework for the Telegram Bot API

python-telegram-bot.org

The python-telegram-bot is distributed under a LGPLv3 license. Chose a nice name for your bot and maybe do a basic method like echo to test the bot. However, we will not interact with the bot, we just want to be notified in case an intruder is in our appartment. First, get familiar with the chatbot, this example is copied from python-telegram-bot. From the context variable, you can access the chat_id which is necessary for the next steps.

python-telegram-bot Hello World

With the python-telegram-bot you will receive your API token, denoted as TOKEN in the script below. Paste your token and the individual chat id into the script.

Initalize libaries and IDs

To initially notify the user that the script is running the user is notified via text message. The send_message(text) is for this purpose. However, other messages can be sent as text is just a variable that can be called with any string.

Even more important than this init method is the send_photo() method. This method sends the photo of the intruder to your telegram chat.

Bot Part

Intruder Detection

The initial part of our IntroderDet is working. Next, we will figure out how to get an image of an intruder. So now the OAK-D Lite SDK is used as well as the camera. OAK-D Lite already comes with great documentation and two repositories:

  • https://github.com/luxonis/depthai-python/
  • https://github.com/luxonis/depthai

Due to that, I will not explain the code in detail. For GUI support I recommend using depthai repository instead of depthai-python (they both provide python code). If you first want to play around then depthai is useful due to the GUI. We will stick to depthai-python, as we only need the script part and it’s easier for python people without a GUI ;).

Install depthai-python and add it to your imports on top. Next, we mostly reuse the mobilenet-ssd implementation of depthai-python.

import of depthai

depthai-python provides an output via open-cv frames. We will get rid of this code and also remove the sync part otherwise we will never get an RGB image we could send.

We replace:

original source code

The sync part with:

adapted source code, removed sync part

Then we mainly replace the part where the camera output is evaluated to send an image to our chatbot. To not get constantly spamed, the threshold for sending a new image is set to one minute. This threshold can be adapted to whatever interval suits you.

our “magic”, sends the captured image with a person to the chatbot user

Ok so that’s all, let’s run it! I provide an example image, as I do not want to have a picture from me as an intruder on the internet :). Normally, the script above sends the currently captured image via the telegram-bot.

Example of the telegram chatbot

All the code is provided in github. Feel free to fork, adapt and interact 🙂

GitHub – HannahHaensen/IntruderDet: Intruder Detection

IntruderDet combines OAK-D-Lite with a Telegram ChatBot. On OAK-D-Lite MobileNet-SSD is executed, when a person is…

github.com

Ten articles before and after

Send APK automatically to Telegram using Dart/Flutter – Telegram Group

How to build a Telegram bot to show Chainlink price feeds – Telegram Group

Simple Telegram Bot using API’s. A Simple Telegram Bot which can respond… – Telegram Group

Making our First Telegram Bot [Part -2] – Telegram Group

Bots! What are they? Let’s make a Telegram Bot [Part -1] – Telegram Group

Телеграм бот для уведомлений об ордерах Binance – Telegram Group

How to create a Telegram bot with Python in under 10 min! – Telegram Group

Monitor Server with Telegram Bot and Python – Telegram Group

Google Sheets Formula & Telegram Message ✈️ – Telegram Group

How to Create a Telegram Chatbot in 2022 – Telegram Group