Skip to content

arunishrajput/Motion-Detection

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 

Repository files navigation

Motion Detection with OpenCV and Telegram Notifications

This project detects motion using OpenCV in Python and sends notifications with photos to a Telegram chat.

Features

  • Motion detection using OpenCV and background subtraction.
  • Integration with Telegram Bot API for notifications.
  • Adjustable parameters for motion sensitivity and cooldown periods.

Requirements

  • Python 3.6 or higher
  • Requests library (for sending HTTP requests)
  • Telegram Bot API credentials (Bot Token and Chat ID)

Installation

  1. Clone the repository:

    git clone https://github.com/arunishrajput/motion-detection.git
    cd motion-detection
  2. Install dependencies:

    pip install -r requirements.txt

    Or install the libraries manually:

    pip install opencv-python requests
  3. Setup Telegram Bot:

    • Create a Telegram bot using BotFather and note down the Bot Token.
    • Obtain your Telegram Chat ID using userinfobot.
  4. Configuration:

  • Replace placeholders in the script (TELEGRAM_CHAT_ID and TELEGRAM_BOT_TOKEN) with your actual Telegram credentials.

Usage

  1. Run the Script:

    python main.py
  2. Motion Detection:

    • Adjust camera variable (0 for default camera) or specify a video file path.

    • Customize initial_delay_seconds, motion_cooldown_seconds, and threshold as per your requirements.

  3. Exit:

    • Press Esc key to exit the application.

Functionality

  • Captures frames from the camera or video file.
  • Defines a smaller square area in the frame for motion detection.
  • Sends a Telegram notification with a photo when motion is detected.
  • Uses background subtraction and contour detection for motion identification.

Troubleshooting

  • Ensure Python environment and dependencies are correctly installed.
  • Verify Telegram credentials and network connectivity for sending notifications.

Contribution

  • Feel free to fork this repository, create a feature branch, and submit a pull request. Contributions, issues, and feature requests are welcome!

Acknowledgments

About

Motion Detection using OpenCV and Send Response using Telegram Bot API

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages