Reading Time: 2 minutes
This article shows
I have setup remote camera system with Raspberry Pi and USB camera
In this article I use Docker container to clean up after trial.
This is sample of image which you can see by this system.
You can see camera captured image by browser,
http://<IP address of Raspberry Pi>:50081
I use this camera which is not used now and put in closet in my home.
– Microsoft Lifecam Studio
Let’s see my Dockerfile.
FROM debian:latest RUN \ # Update to latest apt -y update && \ apt -y upgrade && \ # Install general packages apt -y install motion && \ sed -i -E 's/^stream_port(.*)/stream_port 50081/' /etc/motion/motion.conf && \ sed -i -E 's/^width(.*)/width 640/' /etc/motion/motion.conf && \ sed -i -E 's/^height(.*)/height 480/' /etc/motion/motion.conf && \ sed -i -E 's/^output_pictures(.*)/output_pictures on/' /etc/motion/motion.conf && \ sed -i -E 's/^locate_motion_mode(.*)/locate_motion_mode on/' /etc/motion/motion.conf && \ sed -i -E 's/^locate_motion_style(.*)/locate_motion_style redbox/' /etc/motion/motion.conf && \ sed -i -E 's/^stream_localhost(.*)/stream_localhost off/' /etc/motion/motion.conf && \ echo "Build complete." ENTRYPOINT motion
Parameter tuning is baseon on this article.
– Japanese IT news site.
Briefly I explain each parameter.
motion has lots of parameters other than them, but I think they are enough to use normally.
stream_port: Port number to be accessed from outside. width/height: Image size. output_picture: Select on/off whether you want to save picture files. locate_motion_mode: Select on/off whether you want to see the point which moving object is detected. locate_motion_style: Select look/feel of marking when moving object is detected. stream_localhost: Select on/off whether you want to limit access from localhost only.
Here you can download my Dockerfile.
To create image you can do it with Dockerfile the same directory.
sudo docker build -t motion-image .
Below is example of running container with camera device whose device file is /dev/video0.
–restart=always enables to restart automatically when container dies or system boot.
–device maps device file to container so that container inside you can use this device.
-p specified which port to be open.
sudo docker run -dit --restart=always --device=/dev/video0:/dev/video0 -p 50081:50081 motion-image
How was it?
This sample is very simple, so another function should be introduced!
– Post image to LINE chat.
– Upload cloud storage service.