Overview
This package consists of the core jmotion binary and several shared objects (.so files) which implement various aspects of functionality (eg, image acquisition, motion detection, etc). The core jmotion binary has no special requirements and can be built by pretty much any C compiler. The shared objects however, may need to be linked against various libraries.
Prerequisites And Building
The code has been built and tested on,
- Debian 7 wheezy x86_64
- Ubuntu 14.04.1 LTS Trusty Tahr x86_64
- Centos 6.5 i386
The input_http.so and input_v4l2.so shared objects require :
- libjpeg-turbo or libjpeg8
- libcurl
In order to build the parser, flex/bison are required. To build the code, simply type "make". At this stage, you should have :
jmotion
- The main binary.input_http.so
- Acquires an image from a URL, presumably an IP camera.input_v4l2.so
- Acquires an image using V4L2 API, for example /dev/video0
.std_noise.so
- Sets the noise level for the image and maintains the motion heat map.std_detection.so
- Determines whether motion occured.output_jpeg.so
- Writes jpeg files, maintains image archives.Basic Configuration
The following configuration file can be used if you have a USB camera attached at /dev/video0
.
camera {
name "cam1"
input {
module "input_v4l2.so"
params {
videodev "/dev/video0"
}
}
output {
module "output_jpeg.so"
params {
cur_frame "/tmp/cam1.jpg"
}
}
}
With the above configuration, jmotion uses 2 modules (ie, "input_v4l2.so" and "output_jpeg.so"). It periodically captures an image and saves it to /tmp/cam1.jpg
.
To acquire an image from an IP camera, make sure you can use curl to pull an image from your camera first, then place the URL into the config file. The following config file is similar to the previous example, except that it pulls an image from an IP camera.
camera {
name "cam1"
input {
module "input_http.so"
params {
url "http://admin:admin@192.168.1.10/image.jpg"
}
}
output {
module "output_jpeg.so"
params {
cur_frame "/tmp/cam1.jpg"
}
}
}
Logging
The jmotion program will daemonize by default once it successfully parse its config file. To observe what's going on, logging can be specified in the config file. The following block illustrates this.
global {
log_basedir "/path/to/logs"
log_maxsize 262144
log_rotations 3
log_level 7
}
In the above example, /path/to/logs
is presumed to exist, and jmotion will create log files here. Each log file will be rotated once it exceeds 262144 bytes. Up to 3 generations of log files will be maintained. The log level is set to the maximum level of 7 (see syslog.h). Messages generated from the jmotion program are placed in jmotion.log
while messages from individual camera instances are placed in their own log file (eg, cam1.log
). At any time, the log level may be incremented via SIGUSR2, and decremented by SIGUSR1.
A full dump of jmotion's internal data structures and running statistics can be obtained by sending SIGHUP. The location of the dump file may be specified via :
global {
dump_rt "/path/to/dump.txt"
}
Running
The jmotion program may be launched from the commandline by providing a path to its config file. Once parsed, it daemonizes. Note that since it uses dlopen()
to load the shared objects, the user may need to specify LD_LIBRARY_PATH
for this to work. For example :
$ LD_LIBRARY_PATH=/path/to/jmotion/modules
$ export LD_LIBRARY_PATH
$ ./jmotion mycams.conf
NOTICE: fork()'ing into the background pid:1317.
To prevent jmotion from running as a daemon, turn off daemonize in the config file. For example,
global {
daemonize 0
}