Tuesday, July 25, 2017

ZoneMinder - My First Zone

My saga with ZoneMinder continues!  In this post I'll discuss adding in my first camera / zone and testing in the web UI on a PC.  In theory at the end of this post there will be a camera setup that will capture motion events.

I'll do a post in the future on my entire infrastructure setup, but for the purposes of this post, here's what you need to know about in terms of what I'll be using:

  • ZoneMinder v1.30.4 running on Ubuntu
  • WBox 0E-40DF28WDR 4MP IP Camera (Made by HikVision)
    • This is what I'll be using, but ZoneMinder has a wide variety of cameras it supports.  This particular camera isn't documented as supported, which I'll be contributing back to the ZoneMinder project with the details soon.
Before I get started, I'll point out the obvious thing here about the ZoneMinder UI:  It's from the 80s!  ZoneMinder is designed to be skinnable and embedded into other solutions, and thankfully they've provided a slightly newer look and feel skin.  Let's enable that before we go any further:
  1. On the main screen, open the Options page.
  2. Go to the System tab.
    1. For CSS_DEFAULT, select "flat", then click Save.
  3. Go to the Display tab.
    1. For ZM_CSS, select "flat", then click Save.
  4. Close the Options window.
Warning: The ZoneMinder setup right now is insecure and allows anyone to access it.  As such, do not publish this to the Internet yet!  I'll cover how easy this is in a future post, but right now I'm focusing on just connecting the camera into ZoneMinder.

Note before continuing: I'm not duplicating the ZoneMinder documentation.  I'm simply going over the high level steps to setup a camera, and some of my required actions to get a basic setup for my desired results.  Please review the ZoneMinder documentation for more details on everything that's possible.

Adding The Camera

I'm going to cover the basics here.  ZoneMinder is very customizable and will let you do a lot.  What I'm going to focus on here is a basic camera that will record an event when motion is detected.  So let's get to it!
  1. On the main page, click "Add New Monitor"
  2. HikVision cameras support ONVIF, which is an auto-detect mechanism of sorts.  So in this step we can cheat a little (but I'll include the details in a later post).  At the top of the window, click on the "ONVIF" link.  Be patient, it will scan your network for cameras.
  3. Once the page loads, pick the camera from the list and enter the credentials needed to connect to the camera, then click on Next.
  4. The page will now show the different profiles that are available for the stream.  For my case, I want to choose "mainStream", which is an H264 feed sized at 2688x1520 at 10FPS.  Then click on Save.
  5. The New Monitor window will now be filled in with values provided by the auto-detect process.  Right now we'll leave all the defaults except for the name, just for clarity's sake.  Change the name field to "Test Camera" or something that makes sense to you, then click "Save".
  6. The window will now close, and the main ZoneMinder window will refresh.  You should see the new camera added in the list.  If everything worked properly, you should be able to click on the name of the camera and it will open a new window with the live feed from the camera.
So now the ZoneMinder main screen should look something like this:


Notice in the Function column, this camera is setup for "Monitor".  This means that all ZoneMinder is doing with this camera is accepting the video feed and making it available to end users.

Setting Up Motion Detection

I don't want my cameras recording all the time.  This is a waste of disk space and processing power.  So now I'll setup how ZoneMinder can detect motion on this camera.

A note on motion detection: What ZoneMinder (and most other systems) are detecting shouldn't be looked at as "motion", but rather "changes in the image".  This could mean a lighting change, pixel noise, or anything that would cause one pixel of the image to be different from one frame to the next.  Understanding this concept before going forward is important.

The base premise of motion detection is Zones.  A zone defines what areas of the image ZoneMinder should watch, and what it should do when a change is detected in that area.  On the main screen, you'll see there is 1 zone defined for our Test Camera.  Click on the "1" under the Zones column, and this will open a pop-up window to edit the zones for this camera.

Each zone is color coded on this view.  By default, ZoneMinder creates one big zone that covers the entire image (as you can see by the entire image being covered in red).  Also, if you scroll to the bottom of the page, you'll see the zones listed, as well as some numbers indicating the size of the area and what type the area is.

The default zone, named "All", has a type of "Active".  The "Active" type means that when ZoneMinder detects any changes in the red area, it will trigger recording.  There are some tolerances we need to configure here to define exactly how much motion will trigger a recording.  The easiest way to edit a zone is to click on it in the image (ie, click on one of the red areas).  Do that now.

The table of variables above the image define the detection properties of the zone.  I like to keep this simple:  ZoneMinder has defined presets that they think is best.  I want to use those for now to get the basics going, then tune and adjust as necessary.  So from the "Preset" drop down, I picked "Fast, medium sensitivity".  Once that's set, go to the bottom of the page and click "Save".

But I'm not done!  My cameras are configured to display their date & time in the top left.  It's a bit redundant since ZoneMinder also does this, but I really don't want to reconfigure all of my cameras.  And remember, while it's not "motion", the pixels are changing and will be detected as motion...every second as the time changes:


This means I need to tell ZoneMinder to ignore motion in that area so that it's not triggering false positives.

To do this, I'll start the click path from the main ZoneMinder screen.  Find the camera name in the list, then go over to the Zones column and click on the number listed there (which should be 1 still since we haven't added any zones yet).  Then in the new window that opens, scroll to the bottom right and click on "Add New Zone".

There are many zones types (which you can read about in the official guides), but I want to make a new Inactive zone on top of the clock.  You can do this for any area really that will be expecting motion as "normal" that is in the middle of the image.  Otherwise it's best to just change the default "All" zone to not include that area.  To make the new zone:
  1. Give it a name, like "Clock"
  2. Set the type to "Inactive"
  3. Down on the image, the default area is a rectangle.  Each corner of the rectangle is represented by green dots.  You can click and drag these dots and move them around to highlight the area you want to mark.  In this case, I'm going to make the box only around the clock.  Once done, click on "Save" at the bottom of the page.  Here's my final area:

A word on zones and performance: I'll try to cover this in depth later, but the more zones you have, the more processing ZoneMinder has to do to detect motion.  Therefore, the fewer zones you have, the lower the load on the CPU.

Now we have two zones configuring motion detection, one to cover the area to watch and one to cover an area to ignore, and are ready to turn on the motion detect feature.  We do this by setting the "Function" of the camera.  It's currently set to "Monitor".  We want to set that to "Modect", which is short for Motion Detection.  To change this, simply click on "Monitor" on the main ZoneMinder screen, change the Function dropdown to "Modect" and click "Save".

Wrap-Up

We now have one camera running, and recording / saving an event when motion is detected.  As a baseline status check, the system is running at a load of 0.79.  The system this is running on consists of 2x quad core processors, so that means one 4MP camera at 10FPS with 2 zones is using 80% of one core.  So far.  I'll let this camera run a few days while I work on the other articles and pieces of ZoneMinder I want to configure and share my experiences on, and we'll come back to this camera and see how it's doing soon!

4 comments:

  1. Positive site, where did u come up with the information on this posting?I have read a few of the articles on your website now, and I really like your style.
    Thanks a million and please keep up the effective work. photo cutout

    ReplyDelete
  2. This comment has been removed by the author.

    ReplyDelete
  3. It is a powerful and professional machine that provides you with a good operating time, all the while not ... Learn more about it in our brush cutter review.

    ReplyDelete
  4. Oster Professional 76023 Pros And Cons: Is this clipper a right one for you? A blog about pros and cons of the clipper.

    ReplyDelete

IT Accountability: Avoiding Murphy

Amongst technology experts, Murphy is someone we all try to avoid.  Murphy's Law states "Anything that can go wrong, will".  E...