logo
Kurashizu Blogwhere ideas flow
  • Home
  • News
  • Blog
  • About
  • Home
  • News
  • Blog
  • About

© 2026 Kurashizu. All rights reserved.

Admin·New Post·Service Status
Powered by Cloudflare·01.11.26
← Back to news

Show HN: CheapSecurity – Lightweight, Self-Hosted CCTV for Linux SBCs

Original article
github.com|28 points|6 comments|by zeldone|Jul 26, 2026

CheapSecurity: A Budget-Friendly, Private CCTV System for Linux SBCs

Welcome to CheapSecurity, a streamlined, self-hosted surveillance solution tailored specifically for Linux-based Single-Board Computers (SBCs) utilizing standard USB webcams.

This project is designed to be a costly cloud-based affordable and privacy-centric alternative to commercial home monitoring, ensuring that your visual data remains entirely under your own jurisdiction.


🛡️ Project Philosophy

"True security comes from ownership."

The core tenets of CheapSecurity are:

  • Privacy-First: By keeping all footage on local storage, the system removes the need for third-party cloud subscriptions and guarantees that your data never exits your local network.
  • Cost-Effective: Instead of buying expensive proprietary kits, you can repurpose a spare Linux board and a basic USB webcam.
  • Minimalist Architecture: The codebase is optimized for low-power environments, ensuring smooth operation even on entry-level hardware.

🚀 Key Capabilities

General Highlights

  • Hardware Agnostic: Works with nearly any standard USB webcam.
  • Resource Efficient: Specifically tuned for boards like the Raspberry Pi or Orange Pi.
  • Data Sovereignty: You define the storage paths, how long files are kept, and who can access them.
  • Rapid Deployment: Built for a "plug-and-play" experience with minimal maintenance.

Detailed Feature Set

FeatureDescription
Live StreamMJPEG stream accessible via a dedicated web dashboard.
Motion DetectionUses frame differencing to trigger events.
Smart RecordingAutomatic clips with a pre-motion buffer to capture the lead-up to an event.
Email AlertsSends a snapshot image immediately upon motion detection.
Telegram BotAutomatic video uploads and interactive commands: /snapshot, /video [seconds], and /help.
Night ModeSoftware-based enhancement using CLAHE + brightness/contrast boosts.
File ManagementBulk actions: select all, download as ZIP, send to Telegram, or delete.
Auto-CleanupStorage management based on file age, total disk size, or emergency low-disk triggers.
OS IntegrationReady for systemd autostart.

License: This project is distributed under the GNU AGPLv3.


🛠️ Technical Workflow

The following diagram illustrates how CheapSecurity processes video data:

The Math Behind Motion

Motion is detected by calculating the absolute difference between frames. If the number of pixels exceeding a certain threshold τ\tauτ is greater than the minimum area AminA_{min}Amin​, motion is triggered:

Motion=∑∣Framet−Framet−1∣>τ where Area>Amin\text{Motion} = \sum | \text{Frame}_{t} - \text{Frame}_{t-1} | > \tau \text{ where Area} > A_{min}Motion=∑∣Framet​−Framet−1​∣>τ where Area>Amin​


📦 Installation Guide

Prerequisites

  • Python: Version 3.10 or higher.
  • OpenCV: Must have V4L2 support.
  • Hardware: A USB webcam (defaults to /dev/video0).
  • Optional: SMTP details (Email) and a Bot Token/Chat ID (Telegram).

Setup Steps

  • Verify OpenCV: Run the following command to check your version: python3 -c "import cv2; print(cv2.__version__)"

  • Install OpenCV (If missing):

    • Option A (Recommended for ARM/SBCs): Use the system package manager for optimized binaries.
    • Option B (x86/amd64): Use pip install opencv-python-headless (no GUI needed).
  • Environment Setup: Choose the method that matches your OpenCV installation:

    Method A: System OpenCV (ARM)

    cd $HOME/CheapSecurity
    python3 -m venv venv --system-site-packages
    source venv/bin/activate
    pip install -e .
    

    Method B: Pure Pip (x86)

    cd $HOME/CheapSecurity
    python3 -m venv venv
    source venv/bin/activate
    pip install opencv-python-headless
    pip install -e .
    
  • Hardware Configuration: Identify your camera: v4l2-ctl --list-devices

  • Application Configuration:

    cp config.json.example config.json
    nano config.json
    

    Note: config.json is ignored by git for security; never commit your credentials.

  • Launch:

    ./venv/bin/python -m cheapsecurity.app
    

    Access the UI at: http://<your-device-ip>:5000


⚙️ Configuration Reference

Modify config.json to tune the system behavior:

SectionKeyPurpose
CameradeviceV4L2 index (e.g., 0 for /dev/video0)
width, height, fpsResolution and frame rate settings
night_modeToggle low-light enhancement
night_mode_fpsTarget FPS during night mode
night_mode_gainAnalog gain target
night_mode_brightnessBrightness boost level
night_mode_contrastContrast boost level
MotionthresholdPixel difference sensitivity (0-255)
min_areaMinimum pixel area to trigger (full-res)
cooldown_secondsDuration to keep recording after motion stops
scaleDownscale factor to reduce CPU load
RecordingdirLocal directory for video storage
max_duration_secondsMaximum length of a single clip
pre_buffer_secondsAmount of lead-in footage to save

System Dashboard Placeholder