User Tools

Site Tools


software:zoneminder:picamera

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
software:zoneminder:picamera [2021/06/02 16:03] – created rodolicosoftware:zoneminder:picamera [2025/04/15 15:53] (current) rodolico
Line 1: Line 1:
 ====== Raspberry Pi Camera on ZoneMinder ====== ====== Raspberry Pi Camera on ZoneMinder ======
  
-===== Install v4l2rtspserver on camera =====+I spent a lot of time trying to find some good software to run on a Raspberry Pi to turn it into a camera. Even tried to write my own using Perl, but all the libraries are in Python, so it took too much for a simple project.
  
 +I found the v4l2rtspserver (https://github.com/mpromonet/v4l2rtspserver) and decided to try it. The author has a good page, but assumes I knew how to configure ZoneMinder (which was mistaken).
 +
 +Anyway, no GUI needed, so I did the Raspberry Pi OS Lite (https://www.raspberrypi.org/software/operating-systems/) and set it up, then did the following. Ended up with a pretty decent camera that is not "phoning home" with all your images.
 +
 +===== Get raspbian image onto SD =====
 +
 +  - Download the Lite version of Raspbian from [[https://www.raspberrypi.org/downloads/raspbian/]]
 +  - write the downloaded image to the micro-sd (do not uncompress)
 +  - mount /boot from SD onto /mnt
 +<code bash>
 +touch /mnt/boot/ssh # enable ssh
 +# only do the following if you need wifi. Change country code, ssid and psk for your system
 +# see [[https://www.raspberrypi.org/documentation/configuration/wireless/headless.md]]
 +cat <<EOF >/mnt/boot/wpa_supplicant.conf
 +ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
 +update_config=1
 +country=<Insert country code here>
 +
 +network={
 + ssid="<Name of your WiFi>"
 + psk="<Password for your WiFi>"
 +}
 +EOF
 +</code>
 +
 +Insert SD into your Pi and boot up.
 +===== Configure Raspberry Pi =====
 +
 +Enable wlan by adding the following to /etc/wpa_supplicant/wpa_supplicant.conf
 +<file>
 +country=US
 +network={
 +   ssid="your ssid"
 +   psk="your psk"
 +}
 +</file>
 +
 +Now, do the install
 <code bash> <code bash>
 +# Set up Camera
 +raspi-config # go to Interface, and enable camera
 +reboot
 +ls -lh /dev/video*
 +raspistill -v -o test.jpg # Verify camera works
 +# Remove Swap File
 +sudo systemctl stop dphys-swapfile.service
 +sudo systemctl disable dphys-swapfile.service
 +sudo systemctl mask dphys-swapfile.service
 +sudo rm /var/swap
 +# add zram for swap
 +sudo apt-get install zram-tools
 +sed -i 's\.*ALLOCATION=.*\ALLOCATION=100\g' /etc/default/zramswap
 +sudo systemctl enable zramswap
 +sudo systemctl restart zramswap
 +# Set up ntp
 +sudo apt-get install ntp
 +sudo timedatectl set-timezone America/Chicago
 +# add base packages needed
 +sudo apt install \
 +liblivemedia-dev liblog4cpp5-dev libasound2-dev git gdebi-core cmake build-essential v4l-utils
 +# get and build v4l2...
 git clone https://github.com/mpromonet/v4l2rtspserver git clone https://github.com/mpromonet/v4l2rtspserver
 cd v4l2rtspserver cd v4l2rtspserver
Line 9: Line 69:
 make make
 sudo make install sudo make install
-</code> +# do the install 
- +sudo gdebi v4l2rtspserver-0.2.0-6-g3542b6f-Linux-armv6l.deb 
-<code conf v4l2rtspserver.service>+# create systemd module 
 +cat <<EOF >/etc/systemd/system/v4l2rtspserver.service
 # systemd configuration for v4l2rtspserver # systemd configuration for v4l2rtspserver
 # /etc/systemd/system/v4l2rtspserver.service # /etc/systemd/system/v4l2rtspserver.service
 + 
 [Unit] [Unit]
 Description=v4l2rtspserver rtsp streaming server Description=v4l2rtspserver rtsp streaming server
 After=network.target After=network.target
 + 
 [Service] [Service]
 #ExecStartPre=/usr/bin/v4l2-ctl --set-ctrl vertical_flip=1 #ExecStartPre=/usr/bin/v4l2-ctl --set-ctrl vertical_flip=1
 ExecStartPre=/usr/bin/v4l2-ctl --set-ctrl h264_i_frame_period=5 ExecStartPre=/usr/bin/v4l2-ctl --set-ctrl h264_i_frame_period=5
-ExecStart=/usr/local/bin/v4l2rtspserver -F 5 -W 640 -H 480+ExecStart=/usr/local/bin/v4l2rtspserver -F 5 -W 1280 -H 720
 #ExecReload=/bin/kill -HUP $MAINPID #ExecReload=/bin/kill -HUP $MAINPID
 Type=simple Type=simple
Line 28: Line 89:
 Group=video Group=video
 Restart=always Restart=always
 + 
 [Install] [Install]
 WantedBy=multi-user.target WantedBy=multi-user.target
-</code>+EOF
  
-<code bash> +# enable the service 
-systemctl start v4l2rtspserver+sudo systemctl enable --now v4l2rtspserver.service
 </code> </code>
 +
 +At this point, you should be able to get an rtsp by pointing vlc to [[rtsp://{pi zero ip}:8554/unicast]]
  
 ===== Zoneminder Configuration ===== ===== Zoneminder Configuration =====
software/zoneminder/picamera.1622667786.txt.gz · Last modified: 2021/06/02 16:03 by rodolico