Examples
+-
+ The following provides some sample configuration options and examples for MotionPlus.
+
- Persistent v4l2 device name +
- Sample extpipe commands +
- Loopback device setup +
- FFmpeg as input device +
- Webcontrol pages +
- Database setup +
- Haar setup +
- HOG setup +
- DNN setup + + + +
Persistent v4l2 device name
+-
+ Since the exact device number is set by the kernel upon boot, when there is more than one video device
+ it is possible that the particular cameras that were assigned to /dev/video0 and /dev/video1 may switch. In
+ order to set up Motion so that a particular camera is always assigned the same way, users can set up
+ a symbolic link using udev rules. To do this a unique attribute must be identified for each camera. The
+ camera attributes can be viewed by using the command
+
udevadm info -a -p $(udevadm info -q path -n /dev/video0) while the camera is attached. Usually
+ a serial number can be used. ("Usually" because some cameras have been observed to have the same serial
+ number for different cameras)
+
+ Once a unique attribute has been identified for each camera, edit or create the file
+ /etc/udev/rules.d/99-local.rules.
+
+ Assuming that the unique attribute for the camera was name and was
+ ATTR{name}=="Philips SPC 900NC webcam" you would add the following line to the
+ 99-local.rules file:
+ KERNEL=="video[0-9]*", ATTR{name}=="Philips\ SPC\ 900NC*", SYMLINK+="video-webcam0"
+
+ Once the change has been made and saved, reboot the computer and there should now be a "sticky" device called
+ /dev/video-webcam0
+
+ Sample extpipe commands
+-
+ The following are some sample extpipe commands
+
+
+ movie_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
+
+
+
+ movie_extpipe x264 - --input-res %wx%h --fps %fps --bitrate 2000 --preset ultrafast --quiet -o %f.mp4
+
+
+
+ movie_extpipe mencoder -demuxer rawvideo -rawvideo w=%w:h=%h:fps=%fps -ovc x264 -x264encopts preset=ultrafast -of lavf -o %f.mp4 - -fps %fps
+
+
+
+ movie_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
+
+
+ Loopback device setup
+-
+ The video loopback device can be added installed via apt in many distributions. The package tested
+ with Motion is v4l2loopback-dkms. Once the package is installed, you just need to run
+
sudo modprobe v4l2loopback. This will add a new video device that you
+ can use for the loopback. It is believed that there are additional options associated with the
+ v4l2loopback that allows for adding more than one device. See the documentation of the v4l2loopback
+ project for additional details.
+
+ To activate the vloopback device in Motion set the 'video_pipe' option in the motion.conf file to the
+ device name associated with the one created by v4l2loopback.
+ You can also view the special motion pictures where you see the changed pixels by setting the option + 'video_pipe_motion' in motion.conf. When setting the video_pipe and/or video_pipe_motion options + specify the input device as e.g. /dev/video1. + + De-activating should be done with this command + +
sudo modprobe -r v4l2loopback
+
+ Use ffmpeg as input device
+-
+ Sometimes the particular device is not function for MotionPlus but does work with FFmpeg. In
+ this situation the device can be setup to be used in MotionPlus using FFMpeg as an intermediate
+ application. The process would be to set up a loopback device and then have FFmpeg feed the
+ video into that device and then Motion can read from it. The following are some examples. First set up
+ the loopback device and set it to /dev/video0. Then start ffmpeg using options such as the following.
+
ffmpeg -re -i mymovie.mp4 -f v4l2 /dev/video0 Then in a separate terminal, start MotionPlus
+ with it set to use the /dev/video0 device as input. This method can can also be used to
+ reformat the content to a different format. The following outputs the original movie into a gray pixel format.
+ ffmpeg -re -i mymovie.mp4 -f v4l2 -pix_fmt gray /dev/video0
+ Webcontrol pages
+-
+
{IP}:{port0}/Home html page with streams for all cameras
+
+ The following JSON pages are available via the webcontrol.
+ {IP}:{port0}/0/config.jsonJSON object with the configuration information for all cameras
+ {IP}:{port0}/0/status.jsonJSON object with information about status of all cameras
+ {IP}:{port0}/0/movies.jsonJSON object with information about all movies
+ {IP}:{port0}/{camid}/mjpgPrimary stream for the camera updated as a mjpg
+ {IP}:{port0}/{camid}/mjpg/substreamSubstream for the camera updated as a mjpg
+ {IP}:{port0}/{camid}/mjpg/motionStream of motion images for the camera as a mjpg
+ {IP}:{port0}/{camid}/mjpg/sourceSource image stream of the camera as a mjpg
+ {IP}:{port0}/{camid}/staticPrimary image for the camera
+ {IP}:{port0}/{camid}/static/substreamSubstream image for the camera
+ {IP}:{port0}/{camid}/static/motionMotion image for the camera
+ {IP}:{port0}/{camid}/static/sourceSource image of the camera
+
-
+
-
+
-
+
HAAR setup
+-
+
- Set the following Motionplus items within the secondardy_params +
frame_intervalDefault: 5 | The number of images between each secondary detection
+ image_typeDefault: full | Type of image to process through secondary detection
+ model_fileDefault: None | Full path and file name for the haar model
+ rotateDefault: 0 | Degrees of rotation of the image when processing through secondary detection
+ thresholdDefault: 1.10 | weights of detected values
+ - Set the following parameters to the OpenCV function
CascadeClassifier::detectMultScalewithin the secondardy_params
+
+ scalefactorDefault: 1.10 | Scale factor to apply to the image
+ flagsDefault: 0 |
+ maxsizeDefault: 1024 |
+ minsizeDefault: 8 |
+ minneighborsDefault: 8 |
+
-
+
HOG setup
+-
+
- Set the following items within the secondardy_params +
frame_intervalDefault: 5 | The number of images between each secondary detection
+ image_typeDefault: full | Type of image to process through secondary detection
+ model_fileDefault: None | Full path and file name for the haar model
+ rotateDefault: 0 | Degrees of rotation of the image when processing through secondary detection
+ thresholdDefault: 1.10 | Weights of detected values
+ - Set the following parameters to the OpenCV function
HOGDescriptor::detectMultScalewithin the secondardy_params
+ threshold_modelDefault: 2.00 |
+ scalefactorDefault: 1.05 |
+ paddingDefault: 8 |
+ winstrideDefault: 8 |
+
-
+
-
+
DNN setup
+-
+
- Set the following items within the secondardy_params +
model_fileDefault: None | Full path and file name for the haar model
+ frame_intervalDefault: 5 | The number of images between each secondary detection
+ image_typeDefault: full | Type of image to process through secondary detection
+ rotateDefault: 0 | Degrees of rotation of the image when processing through secondary detection
+ thresholdDefault: 0.75 | Confidence threshold
+ scalefactorDefault: 1.05 |
+
+ backendDefault: 0(DNN_BACKEND_DEFAULT) |
+ targetDefault: 0(DNN_TARGET_CPU) |
+ widthDefault: none | Width for the model (not the source image)
+ heightDefault: none | Height for the model (not the source image)
+ scaleDefault: none | Scale used in the model
+ configDefault: none |
+ classes_fileDefault: none | Full path and name for a file with the names of the classes
+ frameworkDefault: none |
+
-
+
+
+