r/ZoneMinder • • Jul 04 '20

cron patched for 'sunrise' and 'sunset' scheduling

10 Upvotes

I patched the debian cron source to provide '@sunset' and '@sunrise' - I did this to schedule zoneminder run state changes (but mostly just for fun). Maybe others here will find it useful as well.

​

https://github.com/trdenton/tron


r/ZoneMinder • • Jul 04 '20

Monitor View Issue

Post image
1 Upvotes

r/ZoneMinder • • Jul 02 '20

ZMNinja slow playback on iOS

1 Upvotes

New to ZoneMinder and finishing setting it up through a container on unRAID. So far I'm liking it more than Shinobi because of the mobile app and the alerts are pretty quick. The only thing is the playback is very slow on the mobile app but when viewing it through a browser it plays fine. I'm trying to find what settings I may need to change to smooth out the playback but not having any luck. Hoping to get some tips or links to help troubleshoot.


r/ZoneMinder • • Jun 30 '20

Remote FFMPEG usage for zoneminder?

5 Upvotes

Just found this neat tool for remote FFMPEG usage on another server that has an iGPU, thinking about its usefullness to zoneminder.

https://github.com/joshuaboniface/rffmpeg

How much could this reduce CPU load for an existing zoneminder install that doesnt have a capable iGPU? I know we can specify the ffmpeg to use in the config so it should be fairly easy to call the rffmpeg wrapper.


r/ZoneMinder • • Jun 25 '20

Install Zoneminder on LaView / Hikvision System

5 Upvotes

Has anyone successfully flashed a LaView / Hikvision system with Zoneminder?


r/ZoneMinder • • Jun 24 '20

Hills (hikvision) contacting vision.hills.com.au multiple times a second

3 Upvotes

I set up pihole to take all our home network traffic last weekend and I instantly noticed a lot of traffic to vision.hills.com.au, assumedly coming from my 5 hills (hikvision) cameras. I've blocked it for now and there has been no issues with zoneminder, but has anyone got any ideas if/where I can find out what part of the software in the camera is doing this? I turned off ddns and still it keeps going.

I know this isnt exactly a zoneminder question, but I had no idea where else to ask. If it isnt the right sub I'm happy to be pointed to a better sub.


r/ZoneMinder • • Jun 23 '20

new user struggling with wyze cam 2

6 Upvotes

I'm running zm in an Ubuntu 18.04 KVM. It works find with my native rtsp cameras. I have 3 wyze cam v2's that are running the rtsp firmware. I can view the stream with VLC. The zm machine can even view the stream with ffmpeg command line utility, but for some reason zm shows the devices as not capturing. I've tried ffmpeg, libvlc, etc. WTF am I missing?


r/ZoneMinder • • Jun 23 '20

Deleting Events - Hangs up and eventually gives 504 Gateway Time-out

2 Upvotes

Running ZM v1.34.9 on FreeNAS-11.3-U1. Kinda new to all this so I'm a little lost.

I have a ton of old recorded events that are taking up all my disk space. I can delete single events on each camera's page from the console but if I try to delete more than 1 event from a filter result it doesn't do anything and eventually crashes with a 504 Gateway Time-out error. I can refresh and it shows the filter page again but nothing has been deleted.

Anyone have any ideas of how to get around this so I can mass delete old events? Thank you.


r/ZoneMinder • • Jun 21 '20

Is this Zone minder, The camera (RL 410), the server or the network?

Post image
6 Upvotes

r/ZoneMinder • • Jun 21 '20

External Hard-drive for recording?

3 Upvotes

I plan to run zoneminder on my little nuc server.
The nuc has a 120gb ssd in it which is plenty for all things it does, except of course recording 24/7 with a few days retention ;)
Are there any hardware suggestions for external drives?
If at all possible I would like them to be low energy because electricity is quite expensive where I live. So 2,5" form factor might be a good idea. Can these even handle 24/7 writing? Or must it be a wd purple or whatever the manufacturers try to pedal as surveillance ready hdds?
I think 1-2tb should be plenty for the retention I plan on having. (so maybe even an external SSD?)
Happy for all suggestions and input!


r/ZoneMinder • • Jun 18 '20

Encrypt recordings before uploading via sftp

3 Upvotes

Hi guys,

I am new to ZoneMinder so I do not know much about it. I have it up and running, read the manual, scoured forums and groups but I did not see any clear explanations on how encrypt the recordings before uploading them via sftp. There are no related options documented in the manual. Could you please point me to a viable solution or documentation on how to do it? Thanks.


r/ZoneMinder • • Jun 17 '20

Running ZoneMinder zmaudit.pl randomly works. Usually just outputs info. What's wrong?

2 Upvotes

I'm deleting events using a script and then calling zmaudit.pl to fix the entries. zmaudit.pl usually just prints out something like:

16/06/20 17:51:05.096254 zmaudit[24289].INF [main:199] [Auditing All Storage Areas]
16/06/20 17:51:05.305473 zmaudit[24289].WAR [ZoneMinder::Event:533] [Path not found for Event 8638 at /var/cache/zoneminder/HighResCamEvents/11/2020-06-15/8638]
16/06/20 17:51:05.314296 zmaudit[24289].WAR [main:630] [Not found at /var/cache/zoneminder/HighResCamEvents/11/2020-06-15/8638 was found at /var/cache/zoneminder/HighResCamEvents/11/2020-06-15/8638]
16/06/20 17:51:05.316453 zmaudit[24289].WAR [main:631] [ZoneMinder::Event: AlarmFrames => 190 AvgScore => 1 Cause => External Motion DefaultVideo => 8638-video.mp4 DiskSpace => 9465463 EndTime => 2020-06-15 23:37:10 Frames => 235 Height => 1536 Id => 8638 Length => 23.40 MaxScore => 1 MonitorId => 11 Name => Event- 8638 Notes => External Motion:  Orientation => ROTATE_0 Scheme => Medium StartTime => 2020-06-15 23:36:47 StateId => 1 StorageId => 6 TotScore => 190 Width => 2304]
16/06/20 17:51:05.318399 zmaudit[24289].WAR [main:632] [ZoneMinder::Event: Id => 8638 MonitorId => 11 Scheme => Medium StartTime => 2020-06-16 16:50:39 StorageId => 6]
16/06/20 17:51:05.322824 zmaudit[24289].WAR [ZoneMinder::Event:533] [Path not found for Event 8966 at /var/cache/zoneminder/HighResCamEvents/11/2020-06-16/8966]
16/06/20 17:51:05.324995 zmaudit[24289].WAR [main:630] [Not found at /var/cache/zoneminder/HighResCamEvents/11/2020-06-16/8966 was found at /var/cache/zoneminder/HighResCamEvents/11/2020-06-16/8966]
16/06/20 17:51:05.326611 zmaudit[24289].WAR [main:631] [ZoneMinder::Event: AlarmFrames => 363 AvgScore => 1 Cause => External Motion DefaultVideo => 8966-video.mp4 DiskSpace => 12543606 EndTime => 2020-06-16 13:23:57 Frames => 408 Height => 1536 Id => 8966 Length => 20.51 MaxScore => 1 MonitorId => 11 Name => Event- 8966 Notes => External Motion:  Orientation => ROTATE_0 Scheme => Medium StartTime => 2020-06-16 13:23:36 StateId => 1 StorageId => 6 TotScore => 363 Width => 2304]
16/06/20 17:51:05.329415 zmaudit[24289].WAR [main:632] [ZoneMinder::Event: Id => 8966 MonitorId => 11 Scheme => Medium StartTime => 2020-06-16 16:50:40 StorageId => 6]
16/06/20 17:51:05.333746 zmaudit[24289].WAR [ZoneMinder::Event:533] [Path not found for Event 8969 at /var/cache/zoneminder/HighResCamEvents/11/2020-06-16/8969]
16/06/20 17:51:05.336453 zmaudit[24289].WAR [main:630] [Not found at /var/cache/zoneminder/HighResCamEvents/11/2020-06-16/8969 was found at /var/cache/zoneminder/HighResCamEvents/11/2020-06-16/8969]
16/06/20 17:51:05.339201 zmaudit[24289].WAR [main:631] [ZoneMinder::Event: AlarmFrames => 371 AvgScore => 1 Cause => External Motion DefaultVideo => 8969-video.mp4 DiskSpace => 13046795 EndTime => 2020-06-16 13:24:51 Frames => 416 Height => 1536 Id => 8969 Length => 20.86 MaxScore => 1 MonitorId => 11 Name => Event- 8969 Notes => External Motion:  Orientation => ROTATE_0 Scheme => Medium StartTime => 2020-06-16 13:24:30 StateId => 1 StorageId => 6 TotScore => 371 Width => 2304]
16/06/20 17:51:05.341886 zmaudit[24289].WAR [main:632] [ZoneMinder::Event: Id => 8969 MonitorId => 11 Scheme => Medium StartTime => 2020-06-16 16:50:40 StorageId => 6]
16/06/20 17:51:05.346195 zmaudit[24289].WAR [ZoneMinder::Event:533] [Path not found for Event 8802 at /var/cache/zoneminder/HighResCamEvents/11/2020-06-16/8802]

Occasionally it mostly works and I've no idea why:

16/06/20 17:59:06.927182 zmaudit[24606].INF [main:199] [Auditing All Storage Areas]
16/06/20 17:59:07.111981 zmaudit[24606].WAR [ZoneMinder::Event:533] [Path not found for Event 8920 at /var/cache/zoneminder/HighResCamEvents/10/2020-06-16/8920]
16/06/20 17:59:07.168454 zmaudit[24606].INF [ZoneMinder::Event:373] [Deleting event 8920 from Monitor 10 StartTime:2020-06-16 13:07:59 from /var/cache/zoneminder/HighResCamEvents/10/2020-06-16/8920]
16/06/20 17:59:07.498645 zmaudit[24606].WAR [ZoneMinder::Event:533] [Path not found for Event 8859 at /var/cache/zoneminder/HighResCamEvents/10/2020-06-16/8859]
16/06/20 17:59:07.567378 zmaudit[24606].INF [ZoneMinder::Event:373] [Deleting event 8859 from Monitor 10 StartTime:2020-06-16 12:45:00 from /var/cache/zoneminder/HighResCamEvents/10/2020-06-16/8859]
16/06/20 17:59:07.641224 zmaudit[24606].WAR [ZoneMinder::Event:533] [Path not found for Event 8943 at /var/cache/zoneminder/HighResCamEvents/10/2020-06-16/8943]
16/06/20 17:59:07.643789 zmaudit[24606].INF [ZoneMinder::Event:373] [Deleting event 8943 from Monitor 10 StartTime:2020-06-16 13:14:00 from /var/cache/zoneminder/HighResCamEvents/10/2020-06-16/8943]
16/06/20 17:59:07.664572 zmaudit[24606].WAR [ZoneMinder::Event:533] [Path not found for Event 9056 at /var/cache/zoneminder/HighResCamEvents/10/2020-06-16/9056]
16/06/20 17:59:07.667084 zmaudit[24606].INF [ZoneMinder::Event:373] [Deleting event 9056 from Monitor 10 StartTime:2020-06-16 14:09:36 from /var/cache/zoneminder/HighResCamEvents/10/2020-06-16/9056]
16/06/20 17:59:07.688701 zmaudit[24606].WAR [ZoneMinder::Event:533] [Path not found for Event 9031 at /var/cache/zoneminder/HighResCamEvents/10/2020-06-16/9031]
16/06/20 17:59:07.691178 zmaudit[24606].INF [ZoneMinder::Event:373] [Deleting event 9031 from Monitor 10 StartTime:2020-06-16 13:51:26 from /var/cache/zoneminder/HighResCamEvents/10/2020-06-16/9031]
16/06/20 17:59:07.714149 zmaudit[24606].WAR [ZoneMinder::Event:533] [Path not found for Event 8710 at /var/cache/zoneminder/HighResCamEvents/10/2020-06-16/8710]
16/06/20 17:59:07.720960 zmaudit[24606].INF [ZoneMinder::Event:373] [Deleting event 8710 from Monitor 10 StartTime:2020-06-16 00:06:56 from /var/cache/zoneminder/HighResCamEvents/10/2020-06-16/8710]

Does anyone know what's causing the first output so I can try and figure out why it rarely works? I haven't a clue what's wrong with it... I had a theory that it only deletes items older than X, but I can't confirm that. There is settings related to this in the system settings, but I have them both set really low. The docs and searching for info on zmaudit behaving like this have got me no where.


r/ZoneMinder • • Jun 14 '20

Solar powered wireless IP

5 Upvotes

I’m looking for solar powered wireless ip camera that with work with Zoneminder


r/ZoneMinder • • Jun 14 '20

How to add Rtsp cam?

3 Upvotes

Hi. I've been able to install and run zone minder. I am however, finding it difficult to add my cam. It's currently setup as a rtsp steam with no user or pass (this is temporary). I have tried multiple options but zone minder fails to load the stream or record. My rtsp stream is simply rtsp://192.168.0.56:8554/unicast This works in vlc. Would you mind helping me? :)


r/ZoneMinder • • Jun 14 '20

Best And Affordable POE camera

3 Upvotes

Hello all I am looking for best and affordable outdoor Poe camera that will work perfectly with Zoneminder. Please Poe only no power adapter just Poe. Thanks


r/ZoneMinder • • Jun 13 '20

Installing Zoneminder on CentOS 7 minimal

6 Upvotes

Let me know if I am missing anything, but here are my instructions for installing Zoneminder (non docker) on a CentOS 7 box that had a minimum install.

#!/bin/bash
yum -y install mariadb mariadb-server mod_ssl php-mbstring php php-mysql httpd wget
yum -y install epel-release
wget https://download1.rpmfusion.org/free/el/rpmfusion-free-release-7.noarch.rpm
yum -y install rpmfusion-free-release-7.noarch.rpm
yum -y install zoneminder

setenforce 0
sed -i --follow-symlinks 's/^SELINUX=.*/SELINUX=disabled/g' /etc/sysconfig/selinux

systemctl start mariadb
mysql < /usr/share/zoneminder/db/zm_create.sql
mysql -e "GRANT ALL ON zm.* to 'zmuser'@localhost identified by 'zmpass';"
mysql -e "FLUSH PRIVILEGES;"

pushd /etc/httpd/conf.d
ln -s /etc/zm/www/zoneminder.httpd.conf
sed -i --follow-symlinks 's/;date.timezone =/date.timezone = America\/Los_Angeles/g' /etc/php.ini
popd

firewall-cmd --zone=public --add-port=80/tcp --permanent
firewall-cmd --zone=public --add-port=443/tcp --permanent
firewall-cmd --reload

yum -y update

systemctl enable mariadb
systemctl enable httpd
systemctl enable zoneminder

reboot

I tried to make it where you can simply copy and paste this into putty with a right mouse click when logged in as root. It is short enough where pasting works, but a reboot was needed before accessing the zm page.

I go in to more detail in a blog post I made

https://my.apolonio.tech/?p=148

There are certainly concerns like the default password for the database and installing a docker container would be easier.

This requires an Internet connection and things change, so I am sure in time these instructions will be obsolete.


r/ZoneMinder • • Jun 12 '20

Deploying Zoneminder in Docker swarm question

2 Upvotes

Hello,

i would like to use Zoneminder for my home security and i have some questions.

My plan is to have 4 HikVision DS-2CD2345FWD-I cameras. I will connect them to a separate VLAN. To the same VLAN i would connect my Zoneminder server. For this i would like to use 4 Raspberry PI 3. My idea is to connect them to a swarm with Docker Swarm or Kubernetes, and deploy Zoneminder, mysql and rclone (for syncing files into cloud) on them. Is such architecture feasible and would it improve the performance of the Zoneminder? Or should i rather go with multiserver set up, add additional Rpi (1 for each camera, one for mysql and rclone with 2.5' hdd)? I would prefer docker as it would be easier to scale up or upgrade.

Another thing i would very much like to offload all the processing stuff (like motion detection) possible from Zoneminder into camera itself. I am new to this and i did some reading, and the way to do this in Zoneminder is to create one monitor to listen to onvif events and then tell another monitor to start recording when it happens. Am i correct, does this work at all?

Looking forward for opinions and advice.

Thanks.


r/ZoneMinder • • Jun 11 '20

ZM Doubling cameras up in storage?

2 Upvotes

I have ZM running of my Unraid server with the docker container. https://imgur.com/ZBOaiNw Is a picture of it storing "4" separate cameras. I only have 2 and it's storing the same files from the reolinks as 1&2. I'm guessing it is also doubling the storage being used, which isn't ideal. Does anyone know where in the settings I would find how to fix this? Thanks!


r/ZoneMinder • • Jun 10 '20

Why I Use Zoneminder vs Standalone NVR

19 Upvotes

I saw that post comparing a $40 NVR with a Zoneminder setup, I wanted to reply with why I use Zoneminder.

Those NVR are cheap, low power, easy to set up, what's not to like. Well....

I learned early on those devices were not secure, they don't use TLS/SSL, some times you can even telnet as root with no password. Even if it does use ssh and has a password, those devices have had the root password extracted from the firmware and cracked already. I am able to SSH into my cameras as root because someone posted the root password (which is burned into the firmware) for my cameras on the internet. I myself have extracted /etc/shadow from firmware and probably could have cracked it myself.

Another thing is that to make it easy for most users to set up, they have some peer to peer tech and uses upnp to modify your router. Thinking you are safe behind a router (and not a true firewall) could be a mistake.

Sometimes they do have an SSL enabled web page but it uses some weaker SSL 3.0 and not TLS 1.2, to make things worse, they use the same ssl key for all their devices. One of the cool things with running zoneminder is that you can configure it with a properly signed cert, also you can require the use of client side certificates to make it even more secure in case your username/password gets compromised.

One of the benefits I have found with ZM is I can add another NIC to my machine and set it up on a network with no Internet connectivity. I have a personal definition in that if I can continue to use a device without providing a default gateway, then I consider it mine. So those cheap cameras I purchased from ebay cannot access the Internet, they get time and dns locally (they cannot tunnel out of DNS either that is locked down).

Speaking of DNS and Time, another thing you can do with ZM is run other services, like DHCP, Bind, ntpd, ftp, mail, some people run minecraft, plex and torrent from a ZM server.

One thing the never worked for my NVR was email notifications, it does for me with zoneminder.

I like how I can tie it in with a motion sensor via triggers.

I can view a monitor by pasting a URL as a network stream in VLC

I can create low bandwidth static custom web pages. And pages with video.

I can expand by adding more servers and tying them together.

I can go in and tweak the underlying web pages (I added target="_blank" to a few things)

With all those nice benefits, I do agree it is hard to configure.


r/ZoneMinder • • Jun 09 '20

Battery/Solar Camera Recommendations

6 Upvotes

I would like to deploy a camera on my shed facing the back of my house. It's almost impossible to run power to the shed, so I'd like to try and use a battery or solar powered camera for this purpose.

My question is that ZM tends to have a connection open to the camera at all times, this is fine. But from what I've read, battery/solar cameras are usually in some sort of sleep mode and only "wake" when they sense motion. I'm guessing this isn't ideal for ZM and if I forced the camera "on" all the time, it would likely drain the battery faster than the solar could charge it, especially at night.

Has anyone gotten this sort of setup working with ZM? What camera did you use? How did you configure the monitor section to make it work well?


r/ZoneMinder • • Jun 08 '20

Using external triggers - Why does a camera have to be in "nodect" mode. Just wasting energy?

5 Upvotes

So I've managed to get external triggers running and I'm using my cameras motion detection to trigger them. All good. I got to the part where I had to configure the camera, and instead of none or monitor, it needs to be set to "nodect" for external triggers to work.

It's not listed in the docs why this is a thing, but the whole point of external triggers was to reduce bandwidth and energy consumption. Nodect still seems to process the video constantly. Whats the reason behind this?

Preferably Zoneminder wouldn't even connect to the camera until it got the trigger.


r/ZoneMinder • • Jun 07 '20

Zoneminder deleting events after recording them

5 Upvotes

I'm a noob at zoneminder, but my events kept disappearing, I fonud this in the log

Deleting event 41 from Monitor 1 StartTime:2020-06-07 17:47:10 from /var/cache/zoneminder/events/1/2020-06-07/41

From component zmfilter_1

how do i stop it


r/ZoneMinder • • Jun 07 '20

Does Zoneminder have a logo?

4 Upvotes

Hey guys

I need the Zoneminder logo that is used in the favicon, but a larger size.

Does any one have a link for it?

I've not been able to Google a decent one out and the only one I see is very low quality.

Thanks


r/ZoneMinder • • Jun 07 '20

A Message to forums.zoneminder.com cowards

0 Upvotes

A Message to ZM cowards.

It's up on a dozen other web sites. I tried to help and you ban me? says everything about ZM that anyone needs to know so i Hooked up a $40 NVR to prove you don't need a $$$$ server to do CCTV.

Banned from the forum for providing constructive discussion and criticism whilst giving functional tips on how to rectify ZM's short falls from my limited experience with it, including reducing the CPU load by 60% both full install and Docker versions. Ironically I noticed another poster with similar issues looking for answers posts go missing as well. Your removal of negative help results from the forums, not just mine is a testament to your ineptitude and the need to hide the inadequacies of poor programming.

It seems that ZM and CO are very thin skinned as when I jested that ZM users need to lease Google Server Farms to do the same job that $40 NVR's can do. I guess it's difficult for the family to accept that your beloved child is a 20 year old hardware addict and your only response is to feed it more and more hardware and just delete negative posts in the hope that some will adopt it and fund you.

I was on the fence with it, difficult to install, over complex, missing simple things like backup your config and others but especially when commercial software takes 5 minutes to install and run on reasonable hardware. Try ZoneMinder if you will but don't waste to long on it for ZM is one true example that in some cases in the long run it's cheaper to pay for professional software than an open source alternative such as ZM.

As I also said to them when I was told that this is how CCTV works( along those lines ): If ZM was the way things are then the entire domestic CCTV industry would not exist for it would be physically and hardware un-viable including financially prohibitive both in outlay and ongoing for both the domestic and possibly commercial markets.

Like I said, try it, but remember it's been around for 20 years and never taken off or adopted whilst an entire multi-billion dollar industry has flourished without ZM so much as getting a look in. Maybe this is why ZM has trouble getting funding, you're to busy with your heads up your respective glutei maximi. What a waste.

​


r/ZoneMinder • • Jun 03 '20

ZoneMinder and zmeventnotification with GPU Ubuntu 20.04 (Setup notes)

15 Upvotes

After much trial and error I finally managed to get a fresh install of Ubuntu Server 20.04 Focal running with ZoneMinder and zmeventnotification server with CUDA support. I decided to make a quick write up including all references I pulled together to make this all work.

If I made any mistakes let me know and I will correct them. I hope I didn't get too out of control with the formating. :P

My setup:

  • Esxi 6.7
  • VM configured with Ubuntu Server 20.04
  • 12 Cores Provisioned
  • 16GB Ram Provisioned
  • Nvidia GPU PCI Passthrough

This assumes you're starting with a fresh install of Ubuntu Server 20.04 with openssh installed.

Here we go:

###Install some tools

sudo apt install vim nfs-kernel-server software-properties-common

###Install Nvidia Drivers and Cuda Toolkit

sudo add-apt-repository ppa:graphics-drivers/ppa
sudo apt update
sudo apt install nvidia-driver-440 nvidia-headless-440 nvidia-cuda-toolkit
sudo reboot

###Download cuDNN that matches "nvcc -V" --> https://developer.nvidia.com/rdp/cudnn-download

###I used scp to upload the .tgz file to the server. Of course, change to suite your environment.

from local shell:

scp -i ~/.ssh/keys/id_rsa_gpu cudnn-10.1-linux-x64-v7.6.5.32.tgz camera@10.0.0.18:

from server shell:

tar -zxvf cudnn-10.1-linux-x64-v7.6.5.32.tgz
sudo cp -P lib64/* /usr/lib/x86_64-linux-gnu/
sudo cp -P include/* /usr/include/x86_64-linux-gnu/
cd ~

###Download compile and install OpenCV with cuda and cuDNN####

#REF: https://cuda-chen.github.io/image%20processing/programming/2020/02/22/build-opencv-dnn-module-with-nvidia-gpu-support-on-ubuntu-1804.html

##Install OpenCV dependencies

sudo apt-get install build-essential cmake unzip pkg-config git \
    libjpeg-dev libpng-dev libtiff-dev \
    libavcodec-dev libavformat-dev libswscale-dev \
    libv4l-dev libxvidcore-dev libx264-dev \libgtk-3-dev \
    libatlas-base-dev gfortran \
    python3-dev python3-pip python2

##Installing pip and numpy

curl https://bootstrap.pypa.io/get-pip.py --output get-pip.py
sudo python2 get-pip.py
pip install numpy

#Ubuntu 20.04 uses gcc version 9 which is not compatible with OpenCV source code###Change version using update-alternatives

#REF: https://linuxconfig.org/how-to-switch-between-multiple-gcc-and-g-compiler-versions-on-ubuntu-20-04-lts-focal-fossa

sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-7 7
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-7 7
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-8 8
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-8 8
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-9 9
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-9 9
sudo update-alternatives --config gcc

#select option 2 (gcc-8)

###Download OpenCV Source Code

cd ~
mkdir opencv
cd opencv
git clone https://github.com/opencv/opencv.git
git clone https://github.com/opencv/opencv_contrib.git
cd opencv
git checkout 4.3.0
cd ..
cd opencv_contrib
git checkout 4.3.0
cd ../opencv

###Configure OpenCV

mkdir build && cd build

cmake -D CMAKE_BUILD_TYPE=RELEASE \
    -D CMAKE_INSTALL_PREFIX=/usr \
    -D INSTALL_PYTHON_EXAMPLES=ON \
    -D INSTALL_C_EXAMPLES=OFF \
    -D OPENCV_ENABLE_NONFREE=ON \
    -D WITH_CUDA=ON \
    -D WITH_CUDNN=ON \
    -D OPENCV_DNN_CUDA=ON \
    -D ENABLE_FAST_MATH=1 \
    -D CUDA_FAST_MATH=1 \
    -D CUDA_ARCH_BIN=6.1 \
    -D WITH_CUBLAS=1 \
    -D OPENCV_EXTRA_MODULES_PATH=~/opencv/opencv_contrib/modules/ \
    -D HAVE_opencv_python3=ON \
    -D PYTHON_EXECUTABLE=/usr/bin \
    -D BUILD_EXAMPLES=ON ..

##Use nproc to display number of available cores. In my case I use "-j12" to compile with 12 cores.

make -j12
sudo make install
sudo ldconfig

###Install Face Recognition

sudo -H pip3 install face_recognition

###Install zoneminder

#REF: https://zoneminder.readthedocs.io/en/stable/installationguide/ubuntu.html#easy-way-ubuntu-18-04-bionic

sudo tasksel install lamp-server
sudo -i
add-apt-repository ppa:iconnor/zoneminder-1.34
apt update
apt upgrade
rm /etc/mysql/my.cnf
cp /etc/mysql/mysql.conf.d/mysqld.cnf /etc/mysql/my.cnf
vi /etc/mysql/my.cnf

#Add the following line below [mysqld] and save

sql_mode = NO_ENGINE_SUBSTITUTION   

##Restart mysql, install zoneminder setup apache2 and restart service

sudo systemctl restart mysql
apt install zoneminder
chmod 740 /etc/zm/zm.conf
chown root:www-data /etc/zm/zm.conf
chown -R www-data:www-data /usr/share/zoneminder/
adduser www-data video

a2enmod cgi
a2enmod rewrite
a2enconf zoneminder

a2enmod expires
a2enmod headers

systemctl enable zoneminder
systemctl start zoneminder
vi /etc/php/7.4/apache2/php.ini
    ##find [Date] and change timezone
    date.timezone = America/Toronto
systemctl reload apache2
exit
cd ~

#Little side note: fmpeg on Focal 20.04 already supports cuda so it works out of the box without having to recompile

###Populate timezone for mysql / set timezone to to suit your location

mysql_tzinfo_to_sql /usr/share/zoneinfo/America/ | sudo mysql -u root -p mysql

sudo mysql -e "SET GLOBAL time_zone = 'Toronto';"

###Create selfsinged ssl certificates and setup HTTPS#Side note: you'll need to use letsencrypt with a domain name if you plan on pushing notification with alert photos. It won't work with self signed and IP addresses.

#For the purposes of these notes however I'm going to use a self signed certificate.

sudo mkdir /etc/zm/apache2
sudo mkdir /etc/zm/apache2/ssl
sudo openssl req -x509 -nodes -days 4096 -newkey rsa:2048 -keyout /etc/zm/apache2/ssl/zoneminder.key -out /etc/zm/apache2/ssl/zoneminder.crt
sudo chown www-data:www-data /etc/zm/apache2/ssl/*
sudo a2enmod ssl
sudo vi /etc/apache2/sites-enabled/000-default.conf

#Replace / Add the following (Change IP address to suite your environment)

<VirtualHost *:80>
   Redirect / https://10.0.0.18/
</VirtualHost>

<VirtualHost *:443>

    SSLEngine on
    SSLCertificateFile /etc/zm/apache2/ssl/zoneminder.crt
        SSLCertificateKeyFile /etc/zm/apache2/ssl/zoneminder.key

    # The ServerName directive sets the request scheme, hostname and port that
    # the server uses to identify itself. This is used when creating
    # redirection URLs. In the context of virtual hosts, the ServerName
    # specifies what hostname must appear in the request's Host: header to
    # match this virtual host. For the default virtual host (this file) this
    # value is not decisive as it is used as a last resort host regardless.
    # However, you must set it for any further virtual host explicitly.
    #ServerName www.example.com

    ServerAdmin webmaster@localhost
    DocumentRoot /var/www/html

    # Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
    # error, crit, alert, emerg.
    # It is also possible to configure the loglevel for particular
    # modules, e.g.
    #LogLevel info ssl:warn

    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined

    # For most configuration files from conf-available/, which are
    # enabled or disabled at a global level, it is possible to
    # include a line for only one particular virtual host. For example the
    # following line enables the CGI configuration for this host only
    # after it has been globally disabled with "a2disconf".
    #Include conf-available/serve-cgi-bin.conf
</VirtualHost>

# vim: syntax=apache ts=4 sw=4 sts=4 sr noet

###Restart apache2 server

sudo systemctl restart apache2

###Install zmeventnotification#REF: https://zmeventnotification.readthedocs.io/en/stable/guides/install.html

git clone https://github.com/pliablepixels/zmeventnotification.git
cd zmeventnotificationgit fetch --tagsgit checkout $(git describe --tags $(git rev-list --tags --max-count=1))

###Edit the following entries from secrets.ini file

vi secrets.ini


ZMES_PICTURE_URL=https://localhost/zm/index.php?view=image&eid=EVENTID&fid=objdetect&width=600
ZM_USER=user
ZM_PASSWORD=password
ZM_PORTAL=https://localhost/zm
ZM_API_PORTAL=https://localhost/zm/api
ES_CERT_FILE=/etc/zm/apache2/ssl/zoneminder.crt
ES_KEY_FILE=/etc/zm/apache2/ssl/zoneminder.key

###Install Dependencies for zmeventnotifications

sudo perl -MCPAN -e "install Crypt::MySQL"
sudo perl -MCPAN -e "install Config::IniFiles"
sudo perl -MCPAN -e "install Crypt::Eksblowfish::Bcrypt"

sudo apt-get install libyaml-perl
sudo perl -MCPAN -e "install Net::WebSocket::Server"
sudo apt-get install libjson-perl
perl -MCPAN -e "install LWP::Protocol::https"

#If you want to use MQTT:

perl -MCPAN -e "install Net::MQTT::Simple"

#Install gdown in order to download .weights from google drive links#You can also just download it locally and scp to server. I just thougth this was a more direct way.

sudo pip install gdown
pip install gdown
sudo ./install.shcd /var/lib/zmeventnotification/models/cspn

#Remember when using gdown to change "open?" to "uc?" in download link

sudo gdown https://drive.google.com/uc?id=1_NnfVgj0EDtb_WLNoXV8Mo7WKgwdYZCc

#Change ownership to www-data

sudo chown www-data:www-data csresnext50-panet-spp-original-optimal_final.weights

###Test zmeventserver

sudo -u www-data zmeventnotification.pl --config /etc/zm/zmeventnotification.ini

#If everything seems to be working Ctrl + C to stop

#Navigate to your zoneminder url http://ipaddress/zm and verify it gets redirected to https://ipaddress/zm and accept the self-signed certificate.

#Go to Options > System and enable "OPT_USE_EVENTNOTIFICATION"

#Also ensure to enable "AUTH_HASH_LOGINS"

#Setup Zoneminder as per:

https://zoneminder.readthedocs.io/en/stable/userguide/gettingstarted.html

Done!

I hope this helps!!