Easy setup for motion detection camera compatible with next generation 64-bit machines.
MoCam is an implementation of motion-project.github.io for capturing video and images when motion is detected and Rclone to quickly upload captures to a cloud provider of your choice.
git clone https://github.com/xcollantes/mocam.git
Create an rclone.conf
file to be able to upload captured media to a cloud provider of your choice. See list of 60+ cloud storage providers: https://rclone.org/#providers
Some providers include:
- Install Rclone locally:
sudo -v ; curl https://rclone.org/install.sh | sudo bash
- Run
rclone config
and follow the prompt to generate anrclone.conf
- Generated config can be found in
~/.config/rclone/rclone.conf
. Copy or move file tomocam/
repo directory like so:mocam/rclone.conf
.
-
Review
motion.conf
. The default settings are calibrated for a USB camera on a RPI4.See motion-project.github.io for full options.
-
Build Docker image:
docker build -t mocam .
Make sure you have the following:
- Connect camera to machine
- Get your camera device name by running
v4l2-ctl --list-devices
on your machine. - Run command:
docker run --rm --device=MY_DEVICE_NAME --env RCLONE_DEST=MY_RCLONE_PROFILE:/MY_DIR MY_IMAGE_NAME
--rm
Remove the container if stopped.--device
Docker flag to let container use the host machine's camera.MY_DEVICE_NAME
--env
Set ENV variables.RCLONE_DEST
Rclone destination location with format asMY_RCLONE_PROFILE:/MY_DIR
.MY_RCLONE_PROFILE
Rclone profile name as founc in therclone.conf
file created.MY_DIR
Folder in the cloud provider you setup. This can be a path with nested folders.MY_IMAGE_NAME
Docker image name set in Docker build step.
Example:
docker run --rm --device=/dev/video0 --env RCLONE_DEST=remote-mega:/mo_cam mocam
- See machine logs at
/motion/log/motion.log
if enabled in themotion.conf
. You will also see the logs from the container by usingdocker logs CONTAINER_HASH
MoCam depends on Motion to capture video and images when motion is detected and Rclone to quickly upload captures to a cloud provider.
How do I get my device name?
Run v4l2-ctl --list-devices
to see the devices attached to your machine.
Processor compatibility: arm64
Since this was tested on RPI4 which is uses arm64 processor, by default the Docker base image is python:bullseye
which works with arm64 processor.
Previously, raspberrypi4-64-debian
was used as the base image which worked with no issue.
Choose a base image which matches the processor of the machine.
Depending on the camera's environment, the camera, the procesing power of the machine, and the network the camera is on, the Motion config might need to be adjusted. The settings and their values are most explained at https://motion-project.github.io/motion_config.html.
Below are the calibration notes I took for my setup:
My goals in order of priority:
- capture accuracy (does the camera capture the subject fully?)
- image quality (is the subject's face visible?)
- network conservation (can the videos upload to the cloud in under 2 seconds?)
framrate
setting is MAX and seems to fluctuate- I'm using
event_gap
of 1 for testing so upload occurs right away