Code Monkey home page Code Monkey logo

eloquentsurveillance's Introduction

EloquentSurveillance for Arduino

EloquentSurveillance is an Arduino library that makes it a breeze to integrate pure video motion detection (whitout pir!) in your project.

It comes with batteries included:

  • easy camera configuration
  • HTTP streaming server
  • HTTP file browser
  • Motion detection
  • SPIFFS / SD file storage
  • Telegram notifications

Every feature have been carefully designed to be as easy to use as possible, often requiring only 2-3 lines of code.

A complete motion dashboard

Motion detection is only the beginning. EloquentSurveillance comes with a fully-featured admin dashboard to manage your motion events.

It stores your motion pictures and delivers notifications to many channels:

  • Telegram
  • Email
  • Web push
  • Slack
  • Webhook

Eloquent Surveillance Dashboard

Go check it out at the Eloquent Motion website.

Motion Detection Example

The following sketch performs basic motion detection. You can then perform the action you prefer based on the detection result.

#define VERBOSE
#include "EloquentSurveillance.h"


EloquentSurveillance::Motion motion;


/**
 *
 */
void setup() {
    Serial.begin(115200);
    delay(3000);
    debug("INFO", "Init");

    // configure camera
    camera.m5wide();
    camera.qvga();
    camera.highQuality();

    // configure motion detection
    //  > setMinChanges accepts a number from 0 to 1 (percent) or an integer
    //    At least the given number of pixels must change from one frame to the next
    //    to trigger the motion
    motion.setMinChanges(0.1);
    //  > setMinPixelDiff accepts an integer
    //    Each pixel value must differ at least of the given amount from one frame to the next
    //    to trigger the motion
    motion.setMinPixelDiff(10);
    //  > setMinSizeDiff accepts a number from 0 to 1 (percent) or an integer
    //    The filesize of one frame from the next must change of at least the given amount
    //    to check for motion
    motion.setMinSizeDiff(0.05);

    while (!camera.begin())
        debug("ERROR", camera.getErrorMessage());
    
    debug("SUCCESS", "Camera is initalized");
}

/**
 *
 */
void loop() {
    if (!camera.capture()) {
        debug("ERROR", camera.getErrorMessage());
        return;
    }

    if (motion.update()) {
        debug("INFO", String("Motion detected in ") + motion.getExecutionTimeInMicros() + " us");
    }
}

Motion Detection to Telegram Example

The following sketch sends a notification to Telegram when motion is detected.

#define VERBOSE

#include "EloquentSurveillance.h"
#include "TelegramChat.h"

#define WIFI_SSID "Abc"
#define WIFI_PASS "12345678"
#define BOT_TOKEN "XXXXXXXXXX:yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy"
#define CHAT_ID 1234567890

EloquentSurveillance::Motion motion;
EloquentSurveillance::TelegramChat chat(BOT_TOKEN, CHAT_ID);


/**
 *
 */
void setup() {
    Serial.begin(115200);
    delay(3000);
    debug("INFO", "Init");

    // configure camera
    camera.m5wide();
    camera.vga();
    camera.highQuality();

    // configure motion detection
    motion.setMinChanges(0.05);
    motion.setMinPixelDiff(7);
    motion.setMinSizeDiff(100);

    while (!camera.begin())
        debug("ERROR", camera.getErrorMessage());

    while (!connectToWiFi(WIFI_SSID, WIFI_PASS))
        debug("ERROR", "Cannot connect to WiFi");

    debug("SUCCESS", "Camera OK, WiFi connected");
}

/**
 *
 */
void loop() {
    if (!camera.capture()) {
        debug("ERROR", camera.getErrorMessage());
        return;
    }

    if (motion.update()) {
        debug("INFO", String("Motion detected in ") + motion.getExecutionTimeInMicros() + " us");

        bool messageResponse = chat.sendMessage("Motion");
        debug("TELEGRAM MSG", messageResponse ? "OK" : "ERR");

        bool photoResponse = chat.sendPhoto();
        debug("TELEGRAM PHOTO", photoResponse ? "OK" : "ERR");
    }
}

eloquentsurveillance's People

Contributors

eloquentarduino avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

eloquentsurveillance's Issues

Region coords question

Hello

is still .x and .y TOP/LEFT in the region definition when I use
camera.vflip();
camera.hflip();
in camera settings?
Or they are "moved to BOTTOM/RIGHT"?

Thanx

Bugs (typo) in src/motion.h

libraries\eloquentsurveillance\src\motion.h:443:104: error: 'uitn16_t' has not been declared
void forEachBlock(Callback callback, Reducer& reducer, uint16_t x, uint16_t y, uint16_t width, uitn16_t height, uint8_t size) {
^

libraries\eloquentsurveillance\src\motion.h: In member function 'void EloquentSurveillance::Motion::locate2()':
libraries\eloquentsurveillance\src\motion.h:412:61: error: expected primary-expression before ';' token
for (uint16_t y = _location.y > blockSize / 2 ? ; y < _location.y + blockSize; y += blockSize / 2) {
^
libraries\eloquentsurveillance\src\motion.h:412:61: error: expected ':' before ';' token
libraries\eloquentsurveillance\src\motion.h:412:61: error: expected primary-expression before ';' token
libraries\eloquentsurveillance\src\motion.h:418:47: error: 'W' was not declared in this scope
uint32_t offset = j * W;
^

Supported cameras

Hello,
how can I configure the parameters for the XIAIO ESP32S3 Sense ?

Which Arduino IDE version and "Arduino core for ESP32" version to use?

My AiThinker camera runs other program correctly but I'm get the following error:

18:14:28.621 -> [INFO] Init
18:14:28.668 -> E (3918) camera: Camera probe failed with error 0x105(ESP_ERR_NOT_FOUND)
18:14:28.668 -> [ERROR] Init error
18:14:28.668 -> E (3919) gpio: gpio_install_isr_service(449): GPIO isr service already installed
18:14:28.715 -> E (3954) camera: Camera probe failed with error 0x105(ESP_ERR_NOT_FOUND)

Correction for WifiHelper.h file

On line 58, a missing ) makes it to bug

Correct line 58 should be:
return String(ip[0] + '.' + ip[1] + '.' + ip[2] + '.' + ip[3])

Motion File Server example bug

While this example works OK under 1.0.12, It does not display files under 1.0.13. When a file is selected from the list, I get a page with a "Rotate" button. This page references an image "/rawcapture_xx.jpg" and receives a 404 when trying to download it. The image file name apparently should be "/capture_xx.jpg"!

<button id="rotate" style="position:absolute;top:10px;left:10px;z-index:1;">Rotate</button><div id="frame" style="display:flex"><img id="image" src="/rawcapture_57.jpg" ...

Furthermore, with both versions of the library, the file list web page omits the first letter of each file e.g. "apture_xx.jpg" instead of "capture_xx.jpg". It also includes the filename "ystem Volume Information".

Bugs (typo) in src/motion.h

c:\users\e.nouranian\documents\arduino\libraries\eloquentsurveillance-main\src\motion.h:412:61: error: expected primary-expression before ';' token
for (uint16_t y = _location.y > blockSize / 2 ? ; y < _location.y + blockSize; y += blockSize / 2) {
^
c:\users\e.nouranian\documents\arduino\libraries\eloquentsurveillance-main\src\motion.h:418:47: error: 'W' was not declared in this scope
uint32_t offset = j * W;
^

FileServer.h --> not showing right path to images

Great library! Thanks !

I found one error in file: FileServer.h
line 60: html += F("</td><td><a href=\"/view");
should end with an / after view/
line 60: html += F("</td><td><a href=\"/view/");

and
line 63: html += filename.substring(0);
instead of filename.substring(1)

Truncated image

Hello,
I use your library with an ESP32-CAM/OV2640 in SXGA format to detect a motion and send the image (I do not use the SD card at all) using camera.getBuffer() to get the buffer address and camera.getFileSize() to get the buffer length. Sometimes, the image gets truncated. What am I doing wrong ?
Many thanks for your support.

as at 1May23 your top "Motion Detection Example" and "MotionDetectionSaveToSpiffs.ino" won't compile

Using your "github.com/eloquentarduino/EloquentSurveillance" software as at 1May23 and "github.com/espressif/arduino-esp32" as at 1May23 with the arduino-IDE, compiling the above example (or your "MotionDetectionSaveToSpiffs.ino" example) fails to compile with the error messages:

In file included from C:\Users\Arduino\libraries\github_eloquentarduino_EloquentSurveillance-main\src/EloquentSurveillance.h:14,
                 from C:\Users\Arduino\motion_v1\motion_v1.ino:2:
c:\users\arduino\libraries\github_eloquentarduino_eloquentsurveillance-main\src\motion.h:443:104: error: 'uitn16_t' has not been declared
         void forEachBlock(Callback callback, Reducer& reducer, uint16_t x, uint16_t y, uint16_t width, uitn16_t height, uint8_t size) {
                                                                                                        ^~~~~~~~
c:\users\arduino\libraries\github_eloquentarduino_eloquentsurveillance-main\src\motion.h: In member function 'void EloquentSurveillance::Motion::locate2()':
c:\users\arduino\libraries\github_eloquentarduino_eloquentsurveillance-main\src\motion.h:412:61: error: expected primary-expression before ';' token
             for (uint16_t y = _location.y > blockSize / 2 ? ; y < _location.y + blockSize; y += blockSize / 2) {
                                                             ^
c:\users\arduino\libraries\github_eloquentarduino_eloquentsurveillance-main\src\motion.h:412:60: error: expected ':' before ';' token
             for (uint16_t y = _location.y > blockSize / 2 ? ; y < _location.y + blockSize; y += blockSize / 2) {
                                                            ^~
                                                            :
c:\users\arduino\libraries\github_eloquentarduino_eloquentsurveillance-main\src\motion.h:412:61: error: expected primary-expression before ';' token
             for (uint16_t y = _location.y > blockSize / 2 ? ; y < _location.y + blockSize; y += blockSize / 2) {
                                                             ^
c:\users\arduino\libraries\github_eloquentarduino_eloquentsurveillance-main\src\motion.h:418:47: error: 'W' was not declared in this scope
                         uint32_t offset = j * W;
 

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.