{"id":1796,"date":"2017-08-24T02:52:03","date_gmt":"2017-08-24T00:52:03","guid":{"rendered":"https:\/\/stls.eu\/blog\/?p=1796"},"modified":"2017-08-25T15:38:44","modified_gmt":"2017-08-25T13:38:44","slug":"raspberry-pi-cam-motion-detection-draft","status":"publish","type":"post","link":"https:\/\/stls.eu\/blog\/2017\/08\/24\/raspberry-pi-cam-motion-detection-draft\/","title":{"rendered":"Raspberry Pi Cam Motion Detection (Draft)"},"content":{"rendered":"<p>enable cam<\/p>\n<pre>sudo raspi-config<\/pre>\n<p>-> 5 Interfacing Options -> P1 Camera -> enable<\/p>\n<p>install motion<\/p>\n<pre>sudo apt install motion<\/pre>\n<p>enable video0 device<\/p>\n<pre>sudo modprobe bcm2835-v4l2<\/pre>\n<p>add &#8220;bcm2835-v4l2&#8221; to your <em>\/etc\/modules<\/em> file<\/p>\n<p>create a ramdisk<\/p>\n<pre>sudo mkdir \/mnt\/ramdisk\r\nsudo echo \"ramfs   \/mnt\/ramdisk     ramfs   defaults        0       0\" >> \/etc\/fstab\r\nsudo mount \/mnt\/ramdisk\r\nsudo chmod o+w \/mnt\/ramdisk<\/pre>\n<p>edit your config \/etc\/motion\/motion.conf<\/p>\n<pre>#\r\n# This config file was generated by motion 4.0\r\n\r\n\r\n############################################################\r\n# Daemon\r\n############################################################\r\n\r\n# Start in daemon (background) mode and release terminal (default: off)\r\ndaemon on\r\n\r\n# File to store the process ID, also called pid file. (default: not defined)\r\nprocess_id_file \/var\/run\/motion\/motion.pid\r\n\r\n############################################################\r\n# Basic Setup Mode\r\n############################################################\r\n\r\n# Start in Setup-Mode, daemon disabled. (default: off)\r\nsetup_mode off\r\n\r\n\r\n# Use a file to save logs messages, if not defined stderr and syslog is used. (default: not defined)\r\nlogfile \/var\/log\/motion\/motion.log\r\n\r\n# Level of log messages [1..9] (EMG, ALR, CRT, ERR, WRN, NTC, INF, DBG, ALL). (default: 6 \/ NTC)\r\nlog_level 6\r\n\r\n# Filter to log messages by type (COR, STR, ENC, NET, DBL, EVT, TRK, VID, ALL). (default: ALL)\r\nlog_type all\r\n\r\n###########################################################\r\n# Capture device options\r\n############################################################\r\n\r\n# Videodevice to be used for capturing  (default \/dev\/video0)\r\n# for FreeBSD default is \/dev\/bktr0\r\nvideodevice \/dev\/video0\r\n\r\n# v4l2_palette allows one to choose preferable palette to be use by motion\r\n# to capture from those supported by your videodevice. (default: 17)\r\n# E.g. if your videodevice supports both V4L2_PIX_FMT_SBGGR8 and\r\n# V4L2_PIX_FMT_MJPEG then motion will by default use V4L2_PIX_FMT_MJPEG.\r\n# Setting v4l2_palette to 2 forces motion to use V4L2_PIX_FMT_SBGGR8\r\n# instead.\r\n#\r\n# Values :\r\n# V4L2_PIX_FMT_SN9C10X : 0  'S910'\r\n# V4L2_PIX_FMT_SBGGR16 : 1  'BYR2'\r\n# V4L2_PIX_FMT_SBGGR8  : 2  'BA81'\r\n# V4L2_PIX_FMT_SPCA561 : 3  'S561'\r\n# V4L2_PIX_FMT_SGBRG8  : 4  'GBRG'\r\n# V4L2_PIX_FMT_SGRBG8  : 5  'GRBG'\r\n# V4L2_PIX_FMT_PAC207  : 6  'P207'\r\n# V4L2_PIX_FMT_PJPG    : 7  'PJPG'\r\n# V4L2_PIX_FMT_MJPEG   : 8  'MJPEG'\r\n# V4L2_PIX_FMT_JPEG    : 9  'JPEG'\r\n# V4L2_PIX_FMT_RGB24   : 10 'RGB3'\r\n# V4L2_PIX_FMT_SPCA501 : 11 'S501'\r\n# V4L2_PIX_FMT_SPCA505 : 12 'S505'\r\n# V4L2_PIX_FMT_SPCA508 : 13 'S508'\r\n# V4L2_PIX_FMT_UYVY    : 14 'UYVY'\r\n# V4L2_PIX_FMT_YUYV    : 15 'YUYV'\r\n# V4L2_PIX_FMT_YUV422P : 16 '422P'\r\n# V4L2_PIX_FMT_YUV420  : 17 'YU12'\r\n#\r\nv4l2_palette 17\r\n\r\n# Tuner device to be used for capturing using tuner as source (default \/dev\/tuner0)\r\n# This is ONLY used for FreeBSD. Leave it commented out for Linux\r\n; tunerdevice \/dev\/tuner0\r\n\r\n# The video input to be used (default: -1)\r\n# Should normally be set to 0 or 1 for video\/TV cards, and -1 for USB cameras\r\n# Set to 0 for uvideo(4) on OpenBSD\r\ninput -1\r\n\r\n# The video norm to use (only for video capture and TV tuner cards)\r\n# Values: 0 (PAL), 1 (NTSC), 2 (SECAM), 3 (PAL NC no colour). Default: 0 (PAL)\r\nnorm 0\r\n\r\n# The frequency to set the tuner to (kHz) (only for TV tuner cards) (default: 0)\r\nfrequency 0\r\n\r\n# Override the power line frequency for the webcam. (normally not necessary)\r\n# Values: \r\n# -1 : Do not modify device setting\r\n# 0  : Power line frequency Disabled\r\n# 1  : 50hz\r\n# 2  : 60hz\r\n# 3  : Auto\r\npower_line_frequency -1\r\n\r\n# Rotate image this number of degrees. The rotation affects all saved images as\r\n# well as movies. Valid values: 0 (default = no rotation), 90, 180 and 270.\r\nrotate 0\r\n\r\n# Image width (pixels). Valid range: Camera dependent, default: 352\r\n#width 320\r\nwidth 800\r\n\r\n# Image height (pixels). Valid range: Camera dependent, default: 288\r\n#height 240\r\nheight 608\r\n\r\n# Maximum number of frames to be captured per second.\r\n# Valid range: 2-100. Default: 100 (almost no limit).\r\n#framerate 2\r\nframerate 20\r\n\r\n# Minimum time in seconds between capturing picture frames from the camera.\r\n# Default: 0 = disabled - the capture rate is given by the camera framerate.\r\n# This option is used when you want to capture images at a rate lower than 2 per second.\r\nminimum_frame_time 0\r\n\r\n# URL to use if you are using a network camera, size will be autodetected (incl http:\/\/ ftp:\/\/ mjpg:\/\/ rtsp:\/\/ mjpeg:\/\/ or file:\/\/\/)\r\n# Must be a URL that returns single jpeg pictures or a raw mjpeg stream. A trailing slash may be required for some cameras.\r\n# Default: Not defined\r\n; netcam_url value\r\n\r\n# Username and password for network camera (only if required). Default: not defined\r\n# Syntax is user:password\r\n; netcam_userpass value\r\n\r\n# The setting for keep-alive of network socket, should improve performance on compatible net cameras.\r\n# off:   The historical implementation using HTTP\/1.0, closing the socket after each http request.\r\n# force: Use HTTP\/1.0 requests with keep alive header to reuse the same connection.\r\n# on:    Use HTTP\/1.1 requests that support keep alive as default.\r\n# Default: off\r\nnetcam_keepalive off\r\n\r\n# URL to use for a netcam proxy server, if required, e.g. \"http:\/\/myproxy\".\r\n# If a port number other than 80 is needed, use \"http:\/\/myproxy:1234\".\r\n# Default: not defined\r\n; netcam_proxy value\r\n\r\n# Set less strict jpeg checks for network cameras with a poor\/buggy firmware.\r\n# Default: off\r\nnetcam_tolerant_check off\r\n\r\n# RTSP connection uses TCP to communicate to the camera. Can prevent image corruption.\r\n# Default: on\r\nrtsp_uses_tcp on\r\n\r\n# Name of camera to use if you are using a camera accessed through OpenMax\/MMAL\r\n# Default: Not defined\r\n; mmalcam_name vc.ril.camera\r\n\r\n# Camera control parameters (see raspivid\/raspistill tool documentation)\r\n# Default: Not defined\r\n; mmalcam_control_params -hf\r\n#mmalcam_control_params -ex sports -mm matrix\r\n\r\n# Use the still camera output - limits frame rate, but can show more of frame Default: off\r\n#mmalcam_use_still off\r\n\r\n# Activate a secondary buffer with larger resolution Default: 0 (off)\r\n#mmalcam_secondary_buffer_upscale 2\r\n\r\n# Pre-encode the secondary buffer to this jpeg quality Default: 0 (off), range 1-100\r\n#mmalcam_secondary_buffer_jpeg 100\r\n\r\n# Path to file where raw dump of camera YUV capture will be written (for testing, profiling & debugging) Default: Not defined\r\n; mmalcam_raw_capture_file value\r\n\r\n# Let motion regulate the brightness of a video device (default: off).\r\n# The auto_brightness feature uses the brightness option as its target value.\r\n# If brightness is zero auto_brightness will adjust to average brightness value 128.\r\n# Only recommended for cameras without auto brightness\r\nauto_brightness off\r\n#auto_brightness on\r\n\r\n# Set the initial brightness of a video device.\r\n# If auto_brightness is enabled, this value defines the average brightness level\r\n# which Motion will try and adjust to.\r\n# Valid range 0-255, default 0 = disabled\r\nbrightness 0\r\n\r\n# Set the contrast of a video device.\r\n# Valid range 0-255, default 0 = disabled\r\ncontrast 0\r\n\r\n# Set the saturation of a video device.\r\n# Valid range 0-255, default 0 = disabled\r\nsaturation 0\r\n\r\n# Set the hue of a video device (NTSC feature).\r\n# Valid range 0-255, default 0 = disabled\r\nhue 0\r\n\r\n\r\n############################################################\r\n# Round Robin (multiple inputs on same video device name)\r\n############################################################\r\n\r\n# Number of frames to capture in each roundrobin step (default: 1)\r\nroundrobin_frames 1\r\n\r\n# Number of frames to skip before each roundrobin step (default: 1)\r\nroundrobin_skip 1\r\n\r\n# Try to filter out noise generated by roundrobin (default: off)\r\nswitchfilter off\r\n\r\n\r\n############################################################\r\n# Motion Detection Settings:\r\n############################################################\r\n\r\n# Threshold for number of changed pixels in an image that\r\n# triggers motion detection (default: 1500)\r\n;threshold 1500\r\nthreshold 450\r\n\r\n# Automatically tune the threshold down if possible (default: off)\r\nthreshold_tune off\r\n\r\n# Noise threshold for the motion detection (default: 32)\r\nnoise_level 32\r\n\r\n# Automatically tune the noise threshold (default: on)\r\nnoise_tune on\r\n\r\n# Despeckle motion image using (e)rode or (d)ilate or (l)abel (Default: not defined)\r\n# Recommended value is EedDl. Any combination (and number of) of E, e, d, and D is valid.\r\n# (l)abeling must only be used once and the 'l' must be the last letter.\r\n# Comment out to disable\r\ndespeckle_filter EedDl\r\n\r\n# Detect motion in predefined areas (1 - 9). Areas are numbered like that:  1 2 3\r\n# A script (on_area_detected) is started immediately when motion is         4 5 6\r\n# detected in one of the given areas, but only once during an event.        7 8 9\r\n# One or more areas can be specified with this option. Take care: This option\r\n# does NOT restrict detection to these areas! (Default: not defined)\r\n; area_detect value\r\n\r\n# PGM file to use as a sensitivity mask.\r\n# Full path name to. (Default: not defined)\r\n; mask_file value\r\n\r\n# Dynamically create a mask file during operation (default: 0)\r\n# Adjust speed of mask changes from 0 (off) to 10 (fast)\r\nsmart_mask_speed 0\r\n\r\n# Ignore sudden massive light intensity changes given as a percentage of the picture\r\n# area that changed intensity. Valid range: 0 - 100 , default: 0 = disabled\r\nlightswitch 0\r\n\r\n# Picture frames must contain motion at least the specified number of frames\r\n# in a row before they are detected as true motion. At the default of 1, all\r\n# motion is detected. Valid range: 1 to thousands, recommended 1-5\r\nminimum_motion_frames 1\r\n\r\n# Specifies the number of pre-captured (buffered) pictures from before motion\r\n# was detected that will be output at motion detection.\r\n# Recommended range: 0 to 5 (default: 0)\r\n# Do not use large values! Large values will cause Motion to skip video frames and\r\n# cause unsmooth movies. To smooth movies use larger values of post_capture instead.\r\n#pre_capture 0\r\npre_capture 1\r\n\r\n# Number of frames to capture after motion is no longer detected (default: 0)\r\n#post_capture 0\r\npost_capture 5\r\n\r\n# Event Gap is the seconds of no motion detection that triggers the end of an event.\r\n# An event is defined as a series of motion images taken within a short timeframe.\r\n# Recommended value is 60 seconds (Default). The value -1 is allowed and disables\r\n# events causing all Motion to be written to one single movie file and no pre_capture.\r\n# If set to 0, motion is running in gapless mode. Movies don't have gaps anymore. An\r\n# event ends right after no more motion is detected and post_capture is over.\r\nevent_gap 60\r\n\r\n# Maximum length in seconds of a movie\r\n# When value is exceeded a new movie file is created. (Default: 0 = infinite)\r\nmax_movie_time 0\r\n\r\n# Always save images even if there was no motion (default: off)\r\nemulate_motion off\r\n\r\n\r\n############################################################\r\n# Image File Output\r\n############################################################\r\n\r\n# Output 'normal' pictures when motion is detected (default: on)\r\n# Valid values: on, off, first, best, center\r\n# When set to 'first', only the first picture of an event is saved.\r\n# Picture with most motion of an event is saved when set to 'best'.\r\n# Picture with motion nearest center of picture is saved when set to 'center'.\r\n# Can be used as preview shot for the corresponding movie.\r\noutput_pictures on\r\n\r\n# Output pictures with only the pixels moving object (ghost images) (default: off)\r\noutput_debug_pictures off\r\n\r\n# The quality (in percent) to be used by the jpeg compression (default: 75)\r\n;quality 75\r\nquality 100\r\n\r\n# Type of output images\r\n# Valid values: jpeg, ppm (default: jpeg)\r\npicture_type jpeg\r\n\r\n############################################################\r\n# FFMPEG related options\r\n# Film (movies) file output, and deinterlacing of the video input\r\n# The options movie_filename and timelapse_filename are also used\r\n# by the ffmpeg feature\r\n############################################################\r\n\r\n# Use ffmpeg to encode movies in realtime (default: off)\r\nffmpeg_output_movies on\r\n\r\n# Use ffmpeg to make movies with only the pixels moving\r\n# object (ghost images) (default: off)\r\nffmpeg_output_debug_movies off\r\n\r\n# Use ffmpeg to encode a timelapse movie\r\n# Default value 0 = off - else save frame every Nth second\r\nffmpeg_timelapse 0\r\n\r\n# The file rollover mode of the timelapse video\r\n# Valid values: hourly, daily (default), weekly-sunday, weekly-monday, monthly, manual\r\nffmpeg_timelapse_mode daily\r\n\r\n# Bitrate to be used by the ffmpeg encoder (default: 400000)\r\n# This option is ignored if ffmpeg_variable_bitrate is not 0 (disabled)\r\n#ffmpeg_bps 400000\r\nffmpeg_bps 500000\r\n\r\n# Enables and defines variable bitrate for the ffmpeg encoder.\r\n# ffmpeg_bps is ignored if variable bitrate is enabled.\r\n# Valid values: 0 (default) = fixed bitrate defined by ffmpeg_bps,\r\n# or the range 1 - 100 where 1 means worst quality and 100 is best.\r\nffmpeg_variable_bitrate 0\r\n\r\n# Codec to used by ffmpeg for the video compression.\r\n# Timelapse videos have two options.\r\n#   mpg - Creates mpg file with mpeg-2 encoding.\r\n#     If motion is shutdown and restarted, new pics will be appended\r\n#     to any previously created file with name indicated for timelapse.\r\n#   mpeg4 - Creates avi file with the default encoding.\r\n#     If motion is shutdown and restarted, new pics will create a\r\n#     new file with the name indicated for timelapse.\r\n# Supported formats are:\r\n# mpeg4 or msmpeg4 - gives you files with extension .avi\r\n# msmpeg4 is recommended for use with Windows Media Player because\r\n# it requires no installation of codec on the Windows client.\r\n# swf - gives you a flash film with extension .swf\r\n# flv - gives you a flash video with extension .flv\r\n# ffv1 - FF video codec 1 for Lossless Encoding\r\n# mov - QuickTime\r\n# mp4 - MPEG-4 Part 14 H264 encoding\r\n# mkv - Matroska H264 encoding\r\n# hevc - H.265 \/ HEVC (High Efficiency Video Coding)\r\nffmpeg_video_codec mpeg4\r\n\r\n# When creating videos, should frames be duplicated in order \r\n# to keep up with the requested frames per second\r\n# (default: true)\r\nffmpeg_duplicate_frames true\r\n\r\n############################################################\r\n# SDL Window\r\n############################################################\r\n\r\n# Number of motion thread to show in SDL Window (default: 0 = disabled)\r\n#sdl_threadnr 0\r\n\r\n############################################################\r\n# External pipe to video encoder\r\n# Replacement for FFMPEG builtin encoder for ffmpeg_output_movies only.\r\n# The options movie_filename and timelapse_filename are also used\r\n# by the ffmpeg feature\r\n#############################################################\r\n\r\n# Bool to enable or disable extpipe (default: off)\r\nuse_extpipe off\r\n\r\n# External program (full path and opts) to pipe raw video to\r\n# Generally, use '-' for STDIN...\r\n;extpipe mencoder -demuxer rawvideo -rawvideo w=%w:h=%h:i420 -ovc x264 -x264encopts bframes=4:frameref=1:subq=1:scenecut=-1:nob_adapt:threads=1:keyint=1000:8x8dct:vbv_bufsize=4000:crf=24:partitions=i8x8,i4x4:vbv_maxrate=800:no-chroma-me -vf denoise3d=16:12:48:4,pp=lb -of   avi -o %f.avi - -fps %fps\r\n;extpipe x264 - --input-res %wx%h --fps %fps --bitrate 2000 --preset ultrafast --quiet -o %f.mp4\r\n;extpipe mencoder -demuxer rawvideo -rawvideo w=%w:h=%h:fps=%fps -ovc x264 -x264encopts preset=ultrafast -of lavf -o %f.mp4 - -fps %fps\r\n;extpipe ffmpeg -y -f rawvideo -pix_fmt yuv420p -video_size %wx%h -framerate %fps -i pipe:0 -vcodec libx264 -preset ultrafast -f mp4 %f.mp4\r\n\r\n\r\n############################################################\r\n# Snapshots (Traditional Periodic Webcam File Output)\r\n############################################################\r\n\r\n# Make automated snapshot every N seconds (default: 0 = disabled)\r\nsnapshot_interval 0\r\n\r\n\r\n############################################################\r\n# Text Display\r\n# %Y = year, %m = month, %d = date,\r\n# %H = hour, %M = minute, %S = second, %T = HH:MM:SS,\r\n# %v = event, %q = frame number, %t = camera id number,\r\n# %D = changed pixels, %N = noise level, \\n = new line,\r\n# %i and %J = width and height of motion area,\r\n# %K and %L = X and Y coordinates of motion center\r\n# %C = value defined by text_event - do not use with text_event!\r\n# You can put quotation marks around the text to allow\r\n# leading spaces\r\n############################################################\r\n\r\n# Locate and draw a box around the moving object.\r\n# Valid values: on, off, preview (default: off)\r\n# Set to 'preview' will only draw a box in preview_shot pictures.\r\n;locate_motion_mode off\r\nlocate_motion_mode on\r\n\r\n# Set the look and style of the locate box if enabled.\r\n# Valid values: box, redbox, cross, redcross (default: box)\r\n# Set to 'box' will draw the traditional box.\r\n# Set to 'redbox' will draw a red box.\r\n# Set to 'cross' will draw a little cross to mark center.\r\n# Set to 'redcross' will draw a little red cross to mark center.\r\n;locate_motion_style box\r\nlocate_motion_style redbox\r\n\r\n# Draws the timestamp using same options as C function strftime(3)\r\n# Default: %Y-%m-%d\\n%T = date in ISO format and time in 24 hour clock\r\n# Text is placed in lower right corner\r\ntext_right %Y-%m-%d\\n%T-%q\r\n\r\n# Draw a user defined text on the images using same options as C function strftime(3)\r\n# Default: Not defined = no text\r\n# Text is placed in lower left corner\r\n; text_left CAMERA %t\r\ntext_left Position xyz\r\n\r\n# Draw the number of changed pixed on the images (default: off)\r\n# Will normally be set to off except when you setup and adjust the motion settings\r\n# Text is placed in upper right corner\r\n;text_changes off\r\ntext_changes on\r\n\r\n# This option defines the value of the special event conversion specifier %C\r\n# You can use any conversion specifier in this option except %C. Date and time\r\n# values are from the timestamp of the first image in the current event.\r\n# Default: %Y%m%d%H%M%S\r\n# The idea is that %C can be used filenames and text_left\/right for creating\r\n# a unique identifier for each event.\r\ntext_event %Y%m%d%H%M%S\r\n\r\n# Draw characters at twice normal size on images. (default: off)\r\n;text_double off\r\ntext_double on\r\n\r\n\r\n# Text to include in a JPEG EXIF comment\r\n# May be any text, including conversion specifiers.\r\n# The EXIF timestamp is included independent of this text.\r\n;exif_text %i%J\/%K%L\r\n\r\n############################################################\r\n# Target Directories and filenames For Images And Films\r\n# For the options snapshot_, picture_, movie_ and timelapse_filename\r\n# you can use conversion specifiers\r\n# %Y = year, %m = month, %d = date,\r\n# %H = hour, %M = minute, %S = second,\r\n# %v = event, %q = frame number, %t = camera id number,\r\n# %D = changed pixels, %N = noise level,\r\n# %i and %J = width and height of motion area,\r\n# %K and %L = X and Y coordinates of motion center\r\n# %C = value defined by text_event\r\n# Quotation marks round string are allowed.\r\n############################################################\r\n\r\n# Target base directory for pictures and films\r\n# Recommended to use absolute path. (Default: current working directory)\r\n;target_dir \/var\/lib\/motion\r\ntarget_dir \/mnt\/ramdisk\r\n\r\n# File path for snapshots (jpeg or ppm) relative to target_dir\r\n# Default: %v-%Y%m%d%H%M%S-snapshot\r\n# Default value is equivalent to legacy oldlayout option\r\n# For Motion 3.0 compatible mode choose: %Y\/%m\/%d\/%H\/%M\/%S-snapshot\r\n# File extension .jpg or .ppm is automatically added so do not include this.\r\n# Note: A symbolic link called lastsnap.jpg created in the target_dir will always\r\n# point to the latest snapshot, unless snapshot_filename is exactly 'lastsnap'\r\n;snapshot_filename %v-%Y%m%d%H%M%S-snapshot\r\nsnapshot_filename %v %Y-%m-%d-%H-%M-xyz\r\n\r\n# File path for motion triggered images (jpeg or ppm) relative to target_dir\r\n# Default: %v-%Y%m%d%H%M%S-%q\r\n# Default value is equivalent to legacy oldlayout option\r\n# For Motion 3.0 compatible mode choose: %Y\/%m\/%d\/%H\/%M\/%S-%q\r\n# File extension .jpg or .ppm is automatically added so do not include this\r\n# Set to 'preview' together with best-preview feature enables special naming\r\n# convention for preview shots. See motion guide for details\r\n;picture_filename %v-%Y%m%d%H%M%S-%q\r\npicture_filename xyz_%H-%M-%S_%q\r\n\r\n# File path for motion triggered ffmpeg films (movies) relative to target_dir\r\n# Default: %v-%Y%m%d%H%M%S\r\n# File extensions(.mpg .avi) are automatically added so do not include them\r\nmovie_filename %v-%Y%m%d%H%M%S\r\n\r\n# File path for timelapse movies relative to target_dir\r\n# Default: %Y%m%d-timelapse\r\n# File extensions(.mpg .avi) are automatically added so do not include them\r\ntimelapse_filename %Y%m%d-timelapse\r\n\r\n############################################################\r\n# Global Network Options\r\n############################################################\r\n# Enable IPv6 (default: off)\r\nipv6_enabled off\r\n\r\n############################################################\r\n# Live Stream Server\r\n############################################################\r\n\r\n# The mini-http server listens to this port for requests (default: 0 = disabled)\r\nstream_port 8081\r\n\r\n# Quality of the jpeg (in percent) images produced (default: 50)\r\n;stream_quality 50\r\nstream_quality 100\r\n\r\n# Output frames at 1 fps when no motion is detected and increase to the\r\n# rate given by stream_maxrate when motion is detected (default: off)\r\nstream_motion off\r\n\r\n# Maximum framerate for stream streams (default: 1)\r\n;stream_maxrate 1\r\nstream_maxrate 20\r\n\r\n# Restrict stream connections to localhost only (default: on)\r\n;stream_localhost on\r\nstream_localhost off\r\n\r\n# Limits the number of images per connection (default: 0 = unlimited)\r\n# Number can be defined by multiplying actual stream rate by desired number of seconds\r\n# Actual stream rate is the smallest of the numbers framerate and stream_maxrate\r\nstream_limit 0\r\n\r\n# Set the authentication method (default: 0)\r\n# 0 = disabled\r\n# 1 = Basic authentication\r\n# 2 = MD5 digest (the safer authentication)\r\nstream_auth_method 0\r\n\r\n# Authentication for the stream. Syntax username:password\r\n# Default: not defined (Disabled)\r\n; stream_authentication username:password\r\n\r\n# Percentage to scale the stream image for preview\r\n# Default: 25\r\n; stream_preview_scale 25\r\n\r\n# Have stream preview image start on a new line\r\n# Default: no\r\n; stream_preview_newline no\r\n\r\n############################################################\r\n# HTTP Based Control\r\n############################################################\r\n\r\n# TCP\/IP port for the http server to listen on (default: 0 = disabled)\r\nwebcontrol_port 8080\r\n\r\n# Restrict control connections to localhost only (default: on)\r\n;webcontrol_localhost on\r\nwebcontrol_localhost off\r\n\r\n# Output for http server, select off to choose raw text plain (default: on)\r\nwebcontrol_html_output on\r\n\r\n# Authentication for the http based control. Syntax username:password\r\n# Default: not defined (Disabled)\r\n; webcontrol_authentication username:password\r\n\r\n\r\n############################################################\r\n# Tracking (Pan\/Tilt)\r\n#############################################################\r\n\r\n# Type of tracker (0=none (default), 1=stepper, 2=iomojo, 3=pwc, 4=generic, 5=uvcvideo, 6=servo)\r\n# The generic type enables the definition of motion center and motion size to\r\n# be used with the conversion specifiers for options like on_motion_detected\r\ntrack_type 0\r\n\r\n# Enable auto tracking (default: off)\r\ntrack_auto off\r\n\r\n# Serial port of motor (default: none)\r\n;track_port \/dev\/ttyS0\r\n\r\n# Motor number for x-axis (default: 0)\r\n;track_motorx 0\r\n\r\n# Set motorx reverse (default: 0)\r\n;track_motorx_reverse 0\r\n\r\n# Motor number for y-axis (default: 0)\r\n;track_motory 1\r\n\r\n# Set motory reverse (default: 0)\r\n;track_motory_reverse 0\r\n\r\n# Maximum value on x-axis (default: 0)\r\n;track_maxx 200\r\n\r\n# Minimum value on x-axis (default: 0)\r\n;track_minx 50\r\n\r\n# Maximum value on y-axis (default: 0)\r\n;track_maxy 200\r\n\r\n# Minimum value on y-axis (default: 0)\r\n;track_miny 50\r\n\r\n# Center value on x-axis (default: 0)\r\n;track_homex 128\r\n\r\n# Center value on y-axis (default: 0)\r\n;track_homey 128\r\n\r\n# ID of an iomojo camera if used (default: 0)\r\ntrack_iomojo_id 0\r\n\r\n# Angle in degrees the camera moves per step on the X-axis\r\n# with auto-track (default: 10)\r\n# Currently only used with pwc type cameras\r\ntrack_step_angle_x 10\r\n\r\n# Angle in degrees the camera moves per step on the Y-axis\r\n# with auto-track (default: 10)\r\n# Currently only used with pwc type cameras\r\ntrack_step_angle_y 10\r\n\r\n# Delay to wait for after tracking movement as number\r\n# of picture frames (default: 10)\r\ntrack_move_wait 10\r\n\r\n# Speed to set the motor to (stepper motor option) (default: 255)\r\ntrack_speed 255\r\n\r\n# Number of steps to make (stepper motor option) (default: 40)\r\ntrack_stepsize 40\r\n\r\n\r\n############################################################\r\n# External Commands, Warnings and Logging:\r\n# You can use conversion specifiers for the on_xxxx commands\r\n# %Y = year, %m = month, %d = date,\r\n# %H = hour, %M = minute, %S = second,\r\n# %v = event, %q = frame number, %t = camera id number,\r\n# %D = changed pixels, %N = noise level,\r\n# %i and %J = width and height of motion area,\r\n# %K and %L = X and Y coordinates of motion center\r\n# %C = value defined by text_event\r\n# %f = filename with full path\r\n# %n = number indicating filetype\r\n# Both %f and %n are only defined for on_picture_save,\r\n# on_movie_start and on_movie_end\r\n# Quotation marks round string are allowed.\r\n############################################################\r\n\r\n# Do not sound beeps when detecting motion (default: on)\r\n# Note: Motion never beeps when running in daemon mode.\r\nquiet on\r\n\r\n# Command to be executed when an event starts. (default: none)\r\n# An event starts at first motion detected after a period of no motion defined by event_gap\r\n; on_event_start value\r\n\r\n# Command to be executed when an event ends after a period of no motion\r\n# (default: none). The period of no motion is defined by option event_gap.\r\n; on_event_end value\r\n\r\n# Command to be executed when a picture (.ppm|.jpg) is saved (default: none)\r\n# To give the filename as an argument to a command append it with %f\r\n; on_picture_save value\r\n\r\n# Command to be executed when a motion frame is detected (default: none)\r\n; on_motion_detected value\r\n#on_motion_detected \/home\/pi\/mmal\/motion-mmal\/copy\r\non_motion_detected \/home\/pi\/motion-detect.sh\r\n\r\n# Command to be executed when motion in a predefined area is detected\r\n# Check option 'area_detect'.   (default: none)\r\n; on_area_detected value\r\n\r\n# Command to be executed when a movie file (.mpg|.avi) is created. (default: none)\r\n# To give the filename as an argument to a command append it with %f\r\n; on_movie_start value\r\n\r\n# Command to be executed when a movie file (.mpg|.avi) is closed. (default: none)\r\n# To give the filename as an argument to a command append it with %f\r\n; on_movie_end value\r\n\r\n# Command to be executed when a camera can't be opened or if it is lost\r\n# NOTE: There is situations when motion don't detect a lost camera!\r\n# It depends on the driver, some drivers dosn't detect a lost camera at all\r\n# Some hangs the motion thread. Some even hangs the PC! (default: none)\r\n; on_camera_lost value\r\n\r\n#####################################################################\r\n# Common Options for database features.\r\n# Options require database options to be active also.\r\n#####################################################################\r\n\r\n# Log to the database when creating motion triggered picture file  (default: on)\r\n; sql_log_picture on\r\n\r\n# Log to the database when creating a snapshot image file (default: on)\r\n; sql_log_snapshot on\r\n\r\n# Log to the database when creating motion triggered movie file (default: off)\r\n; sql_log_movie off\r\n\r\n# Log to the database when creating timelapse movies file (default: off)\r\n; sql_log_timelapse off\r\n\r\n# SQL query string that is sent to the database\r\n# Use same conversion specifiers has for text features\r\n# Additional special conversion specifiers are\r\n# %n = the number representing the file_type\r\n# %f = filename with full path\r\n# Default value:\r\n# Create tables :\r\n##\r\n# Mysql\r\n# CREATE TABLE security (camera int, filename char(80) not null, frame int, file_type int, time_stamp timestamp(14), event_time_stamp timestamp(14));\r\n#\r\n# Postgresql\r\n# CREATE TABLE security (camera int, filename char(80) not null, frame int, file_type int, time_stamp timestamp without time zone, event_time_stamp timestamp without time zone);\r\n#\r\n# insert into security(camera, filename, frame, file_type, time_stamp, text_event) values('%t', '%f', '%q', '%n', '%Y-%m-%d %T', '%C')\r\n; sql_query insert into security(camera, filename, frame, file_type, time_stamp, event_time_stamp) values('%t', '%f', '%q', '%n', '%Y-%m-%d %T', '%C')\r\n\r\n\r\n############################################################\r\n# Database Options\r\n############################################################\r\n\r\n# database type : mysql, postgresql, sqlite3 (default : not defined)\r\n; database_type value\r\n\r\n# database to log to (default: not defined)\r\n# for sqlite3, the full path and name for the database.\r\n; database_dbname value\r\n\r\n# The host on which the database is located (default: localhost)\r\n; database_host value\r\n\r\n# User account name for database (default: not defined)\r\n; database_user value\r\n\r\n# User password for database (default: not defined)\r\n; database_password value\r\n\r\n# Port on which the database is located\r\n#  mysql 3306 , postgresql 5432 (default: not defined)\r\n; database_port value\r\n\r\n# Database wait time in milliseconds for locked database to\r\n# be unlocked before returning database locked error (default 0)\r\n; database_busy_timeout 0\r\n\r\n\r\n\r\n############################################################\r\n# Video Loopback Device (vloopback project)\r\n############################################################\r\n\r\n# Output images to a video4linux loopback device\r\n# The value '-' means next available (default: not defined)\r\n; video_pipe value\r\n\r\n# Output motion images to a video4linux loopback device\r\n# The value '-' means next available (default: not defined)\r\n; motion_video_pipe value\r\n\r\n\r\n##############################################################\r\n# camera config files - One for each camera.\r\n# Except if only one camera - You only need this config file.\r\n# If you have more than one camera you MUST define one camera\r\n# config file for each camera in addition to this config file.\r\n##############################################################\r\n\r\n# Remember: If you have more than one camera you must have one\r\n# camera file for each camera. E.g. 2 cameras requires 3 files:\r\n# This motion.conf file AND camera1.conf and camera2.conf.\r\n# Only put the options that are unique to each camera in the\r\n# camera config files.\r\n; camera \/etc\/motion\/camera1.conf\r\n; camera \/etc\/motion\/camera2.conf\r\n; camera \/etc\/motion\/camera3.conf\r\n; camera \/etc\/motion\/camera4.conf\r\n\r\n\r\n##############################################################\r\n# Camera config directory - One for each camera.\r\n##############################################################\r\n#\r\n; camera_dir \/etc\/motion\/conf.d<\/pre>\n<p>enable daemon<\/p>\n<pre>set start_motion_daemon=yes in \/etc\/default\/motion file<\/pre>\n<p>enable service<\/p>\n<pre>sudo systemctl enable motion.service\r\nsudo systemctl start motion.service<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>enable cam sudo raspi-config -> 5 Interfacing Options -> P1 Camera -> enable install motion sudo apt install motion enable video0 device sudo modprobe bcm2835-v4l2 add &#8220;bcm2835-v4l2&#8221; to your \/etc\/modules file create a ramdisk sudo mkdir \/mnt\/ramdisk sudo echo &#8220;ramfs &hellip; <a href=\"https:\/\/stls.eu\/blog\/2017\/08\/24\/raspberry-pi-cam-motion-detection-draft\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[84],"tags":[],"class_list":["post-1796","post","type-post","status-publish","format-standard","hentry","category-raspberrypi"],"_links":{"self":[{"href":"https:\/\/stls.eu\/blog\/wp-json\/wp\/v2\/posts\/1796","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/stls.eu\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/stls.eu\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/stls.eu\/blog\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/stls.eu\/blog\/wp-json\/wp\/v2\/comments?post=1796"}],"version-history":[{"count":8,"href":"https:\/\/stls.eu\/blog\/wp-json\/wp\/v2\/posts\/1796\/revisions"}],"predecessor-version":[{"id":1804,"href":"https:\/\/stls.eu\/blog\/wp-json\/wp\/v2\/posts\/1796\/revisions\/1804"}],"wp:attachment":[{"href":"https:\/\/stls.eu\/blog\/wp-json\/wp\/v2\/media?parent=1796"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/stls.eu\/blog\/wp-json\/wp\/v2\/categories?post=1796"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/stls.eu\/blog\/wp-json\/wp\/v2\/tags?post=1796"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}