Skip to content

0000xFFFF/dahua_camera_motion

Repository files navigation

dahua_camera_motion

motion detection kiosk for dahua cameras

Requirements

  • make
  • clang++
  • argparse
  • OpenCV (libopencv)
  • sdl2
  • sdl2_mixer

Build & Install

make release
sudo make install

Example

./dcm_master -i <ip> -u <user> -p <password> -fs

Usage

./dcm_master --help
Usage: dcm_master [--help] [--version] --ip ip --username username --password password [--width NUMBER] [--height NUMBER] [--fullscreen] [--detect] [--resolution 0,1,2,...] [--subtype 0/1] [--display_mode 0-4] [--current_channel 1-8] [--enable_fullscreen_channel 0/1] [--enable_motion 0/1] [--area 0/1] [--rarea 0/1] [--motion_detect_min_ms NUMBER] [--enable_motion_zoom_largest 0/1] [--enable_tour 0/1] [--tour_ms NUMBER] [--enable_info 0/1] [--enable_info_line 0/1] [--enable_info_rect 0/1] [--enable_minimap 0/1] [--enable_minimap_fullscreen 0/1] [--ignore_alarm_make] [--enable_ignore_contours 0/1] [--ignore_contours "<x>x<y> ...,<x>x<y> ..."] [--ignore_contours_file ignore.txt] [--enable_alarm_pixels 0/1] [--alarm_pixels "<x>x<y> <x>x<y> ..."] [--alarm_pixels_file alarm.txt] [--focus_channel 1-8] [--focus_channel_area "<x>x<y> <w>x<h>"] [--focus_channel_sound 0/1] [--low_cpu 0/1] [--low_cpu_hq_motion 0/1] [--low_cpu_hq_motion_dual 0/1]

motion detection kiosk for dahua cameras

Optional arguments:
  -h, --help                           shows help message and exits 
  -v, --version                        prints version information and exits 

Required Options (detailed usage):
  -i, --ip ip                          ip to connect to [required]
  -u, --username username              account username [required]
  -p, --password password              account password [required]

Window Options (detailed usage):
  -ww, --width                         window width [nargs=0..1] [default: 1536]
  -wh, --height                        window height [nargs=0..1] [default: 864]
  -fs, --fullscreen                    start in fullscreen mode 
  -d, --detect                         detect screen size with xrandr 
  -r, --resolution                     index of resolution to use [nargs=0..1] [default: 0]

Start Options (detailed usage):
  -st, --subtype                       witch subtype to use (0 = full hq, 1 = smaller resolution) [nargs=0..1] [default: 0]
  -dm, --display_mode                  display mode for cameras (0 = single, 1 = all, 2 = sort, 3 = king, 4 = top [nargs=0..1] [default: 3]
  -ch, --current_channel               which channel to start with [nargs=0..1] [default: 1]
  -efc, --enable_fullscreen_channel    enable fullscreen channel [nargs=0..1] [default: 0]

Motion Detection Options (detailed usage):
  -em, --enable_motion                 enable motion [nargs=0..1] [default: 1]
  -a, --area                           min contour area for motion detection [nargs=0..1] [default: 10]
  -ra, --rarea                         min contour's bounding rectangle area for detection [nargs=0..1] [default: 0]
  -ms, --motion_detect_min_ms          minimum milliseconds of detected motion to switch channel [nargs=0..1] [default: 1000]
  -emzl, --enable_motion_zoom_largest  zoom channel on largest detected motion [nargs=0..1] [default: 1]

Tour Options (detailed usage):
  -et, --enable_tour                   tour, switch channels every X ms (set with -tms) [nargs=0..1] [default: 0]
  -tms, --tour_ms                      how many ms to focus on a channel before switching [nargs=0..1] [default: 3000]

Info Options (detailed usage):
  -ei, --enable_info                   enable drawing info [nargs=0..1] [default: 0]
  -eil, --enable_info_line             enable drawing line info (motion, linger, tour, ...) [nargs=0..1] [default: 1]
  -eir, --enable_info_rect             enable drawing motion rectangles and contours [nargs=0..1] [default: 1]
  -emm, --enable_minimap               enable minimap [nargs=0..1] [default: 0]
  -emf, --enable_minimap_fullscreen    enable minimap fullscreen [nargs=0..1] [default: 0]

Ignore & Alarm Options (detailed usage):
  -iamake, --ignore_alarm_make         start creating ignore area and alarm pixels 

Ignore Options (detailed usage):
  -eic, --enable_ignore_contours       enable ignoring contours/areas (specify with -ic) [nargs=0..1] [default: 1]
  -ic, --ignore_contours               specify ignore contours/areas (points seperated by space, contours seperated by comma) (e.g.: "<x>x<y> ...,<x>x<y> ...") [nargs=0..1] [default: ""]
  -icf, --ignore_contours_file         specify ignore contours/areas inside file (points seperated by space, contours seperated by new line) (e.g.: "<x>x<y> ...\n<x>x<y> ...") [nargs=0..1] [default: ""]

Alarm Options (detailed usage):
  -eap, --enable_alarm_pixels          enable alarm pixels (specify with -ap) [nargs=0..1] [default: 1]
  -ap, --alarm_pixels                  specify alarm pixels (seperated by space) (e.g.: "<x>x<y> <x>x<y> ...") [nargs=0..1] [default: ""]
  -apf, --alarm_pixels_file            specify alarm pixels inside file (seperated by new line) (e.g.: "<x>x<y>\n<x>x<y>...") [nargs=0..1] [default: ""]

Focus Channel Options (detailed usage):
  -fc, --focus_channel                 special mode that focuses on single channel when detecting motion (don't load other channels) [nargs=0..1] [default: -1]
  -fca, --focus_channel_area           specify motion area to zoom to (work with) (e.g.: "<x>x<y> <w>x<h>" [nargs=0..1] [default: ""]
  -fcs, --focus_channel_sound          make sound if motion is detected [nargs=0..1] [default: 0]

Special Options (detailed usage):
  -lc, --low_cpu                       low cpu mode (uses only channel 0 to draw everything) [nargs=0..1] [default: 0]
  -lchqm, --low_cpu_hq_motion          if motion is detected get high quality after switching channel [nargs=0..1] [default: 0]
  -lchqmd, --low_cpu_hq_motion_dual    keep last 2 channels running in high quality (use this if motion is detected on 2 channels and it swaps them frequently) [nargs=0..1] [default: 0]

Setting ignore area and alarm pixels

./dcm_master -i <ip> -u <username> -p <password> -iamake

Creating ignore contours

  • zoom into image using mouse (clicking on image will tell you pixel coords in console)
  • press 'C' to draw a vertex point for current contour (must draw min 2 pixels so it shows actual line)
  • press 'V' to close the contour
  • press 'B' to clear all contours
  • you can load contours from cmd line args or file (see options -ic & -icf in --help)

Creating alarm pixels

  • press 'X' to set alarm pixel (when motion is detected in this pixel it will play a sound)
  • peess 'Z' to clear all alarm pixels
  • you can load alarm pixels from cmd line args or file (see options -ap & -apf in --help)