navigationGo.pngQuick Navigation
allprojects32.pngAll projects
hardware32.pngHardware
links32.pngLinks

favoriteStar32.pngTop projects
Alan numitron clock
Clapclap 2313/1386
SNES Pi Webserver
USB Volume/USB toys
Smokey amp
Laser cutter
WordClock
ardReveil v3
SNES Arcade cabinet
Game boy projects
cameleon
Home Presence Detector

github32.pngGitHub
AlanFromJapan

navigationMail.pngContact me

alanfjmail.png
3flags.pngWho's Alan?


Akizukidenshi
Elec-lab
Rand Nerd Tut
EEVblog
SpritesMods
AvrFreaks
Gameboy Dev
FLOZz' blog
Switch-science
Sparkfun
Suzusho
Datasheet Lib
Reddit Elec
Ermicro
Carnet du maker (fr)

ipcampy.nocv

Last update: Tue Nov 28 13:33:18 2023
This version works and is simpler to setup/develop than original one that was using OpenCV. Check it on GitHub (MASTER branch, not main)!
It's Ipcampy if you want.

This is the fork of the ipCamPy project (that works by itself) BUT does not uses OpenCV that gave me nightmare to (fail to) install on a Raspberry Pi Zero. This is the main version I'm working on for now.

Presentation

Principle

See ipCamPy project, but basically present a RTSP (IP Camera) stream flow as stills on a website. Therefore I won't have to give internet access to that suspicious webcam I bought on Amz.

Points of interrest

Drops the need of OpenCV (a pain to build on small Raspi Zero), and use regular Pillow (for image processing/saving) and av FFmpeg binding lib to be able to read that stream H.264 from the camera via RTSP protocol. Both are standards and the underlying libraries are just an "apt install" away and do not require building for 14h on the row...
Acquisition of an image will depend on the server running the app, but on my test we're talking about ~3 sec on a raspi Zero or 1.7s on a Orange Pi 2: connect to the camera, get the stream, take a still, save in memory as JPEG and return to the client. Therefore I set the minimum the page allows as refresh rate to 5 sec. Should you need less, just at init connect to the stream and take a shot on request but I'm not sure how well the camera will handle having a perpetual client, or the raspi. This current method is slower and less efficient but more robust I think.

Fun thing, in fact it works better than the OpenCV that was crashing or not updating once every few minutes. This one runs without issue in my (short) tests so far.

Implementation

Bill of materials

  • An number of IP Camera (Amz is your friend) that supports RTSP protocol which is most of the cheap ones
  • Raspberry Pi of any flavor, the Zero W does the work though you might want more muscle if you have more than one camera. I'm having it run on an Orange Pi 2 that was taking dust on my shelf.
  • A dynamic DNS (http://www.duckdns.org/ is your friend 💛)
  • A SSL certificate (https://letsencrypt.org/ is your friend 💛)
  • Schematics

    Source code

    On GitHub https://github.com/AlanFromJapan/ipcampy.nocv Use the MASTER branch not main.

    Installation

  • Go somewhere on your server and git clone -b master https://github.com/AlanFromJapan/ipcampy.nocv.git
  • Run the install-dependencies.sh
  • Run the setup.sh
  • Copy the config.sample.py to config.py and edit(!)
  • Git it a try: run.sh and if all fine try with HTTPS run_ssl.sh
  • Once working ok, schedule to start when machine boots: add the below to /etc/rc.local (on a raspi)
  • #Start the ipcampy web service as "webuser" (NOT ROOT!)
    /usr/local/websites/ipcampy.nocv/start-service.sh &
    
    Using /tmp to store the logs means you'll lose the log file between reboots, something you maybe don't want to maybe, so pick somewhere else (/var/logs/ is usually the consecrated place). Or go to the bitter end and make /tmp in memory with tmpfs.

    Pictures

    Links

    Helpful sources

  • Interesting article to be scared about cheap IP cameras: fear!
  • Inspiration

  • Some guy doing brute force with av (FFMPEG) and not OpenCV https://gitlab.com/woolf/RTSPbrute/-/blob/master/rtspbrute/modules/attack.py Thanks for sharing!
  • The av lib https://pypi.org/project/av/
  • All content on this site is shared under the MIT licence (do what u want, don't sue me, hat tip appreciated)
    electrogeek.tokyo ~ Formerly known as Kalshagar.wikispaces.com and electrogeek.cc (AlanFromJapan [2009 - 2025])