Giter Site home page Giter Site logo

real0x0a1 / webcam-motion-sensor Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 0.0 2 KB

This simple C++ program uses OpenCV to perform motion detection using a webcam or IP camera stream. It captures consecutive frames, calculates the absolute difference between them, and applies a threshold to identify motion.

C++ 100.00%
cpp-language cpp-programming cpp-programming-language cpp-project webcam-motion-detector

webcam-motion-sensor's Introduction

Webcam Motion Detector

This simple C++ program uses OpenCV to perform motion detection using a webcam or IP camera stream. It captures consecutive frames, calculates the absolute difference between them, and applies a threshold to identify motion.

Prerequisites

  • OpenCV library installed. You can install it using the following command:
    sudo apt-get install libopencv-dev

Usage

  1. Clone the repository:

    git clone https://github.com/real0x0a1/Webcam-Motion-Sensor.git
  2. Navigate to the project directory:

    cd Webcam-Motion-Sensor
  3. Compile the code:

    g++ WebcamMotionSensor.cpp -o WebcamMotionSensor `pkg-config --cflags --libs opencv`
  4. Run the executable:

    ./WebcamMotionSensor

    Note: If you're using an IP camera, replace the URL in the cv::VideoCapture constructor with your camera's IP address.

  5. Press the 'ESC' key to exit the application.

Features

  • Real-time motion detection using OpenCV.
  • Supports both webcam and IP camera streams.

Troubleshooting

  • If the program fails to connect to the camera, check the camera's IP address or ensure it is correctly connected.
  • Make sure the OpenCV library is properly installed.

How to Run

To run this program:

  1. Make sure you have a C compiler installed on your computer.
  2. Copy the code into a file with a .cpp extension, for example, WebcamMotionSensor.cpp.
  3. Open a terminal or command prompt and navigate to the directory where your file is located.
  4. Compile the program by entering: g++ WebcamMotionSensor.cpp -o WebcamMotionSensor
  5. Run the compiled program: ./WebcamMotionSensor

Or you can run this program also using:

   make WebcamMotionSensor

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.