Welcome to another Raspberry Pi Post, This time we will get to know more about Motion, A highly configurable program that monitors video signals from many types of cameras. We will configure and Install MotionEye on Raspberry Pi raspbian stack, and see how to setup, record and activate motion services across your home or office.
What Is Motion/Eye?
Motion (Github) is a Unix CLI-tool to watch, record and manage multiple types of cameras under one roof. In Short it can :
- Create videos or save pictures of the activity
- Passthrough recording from many IP cameras
- View live stream of cameras
- Invoke scripts when activities occur
- Log activity into multiple types of databases
- Fully customizable masks for privacy or motion detection
- Full TLS(https) support with authentication for webcontrol and streams
MotionEye (Github) is a Web-Frontend written in Python. It sets up a very aesthetic view on a defined port, Which you can access over network via IP address or a Domain name.
Does MotionEye suffice your project requirements ?
MotionEye is a utility to collect video via different camera hardwares, It provides us with hitbox type of Motion Detection, Also it can send you notifications, Save video streams and control camera functions.
People often mistake MotionEye for a Computer Vision program, IT IS NOT. For facial-recognition, Speed tracking and object detection, OpenCV is what you want.
Installing MotionEye On Raspberry Pi :
We shall install Motion, Its repos and the GUI on our Raspbian stack on a Raspberry Pi 3B+. We have also set another Pi zero as a sleeper camera (Active Mediacenter) inside the house, And we have another IP Camera mounted outside the house. Assuming our Pi is updated, and we have root access by issuing sudo -i,
We start the installation progress :
- Install
ffmpeg
and othermotion
dependencies:apt-get install ffmpeg libmariadb3 libpq5 libmicrohttpd12
- Install
motion
:wget https://github.com/Motion-Project/motion/releases/download/release-4.2.2/pi_buster_motion_4.2.2-1_armhf.deb dpkg -i pi_buster_motion_4.2.2-1_armhf.deb
- Get the dependencies from the repositories:
apt-get install python-pip python-dev libssl-dev libcurl4-openssl-dev libjpeg-dev libz-dev
- Install
motioneye on Raspbery Pi
, which will automatically pull Python dependencies (tornado
,jinja2
,pillow
andpycurl
):pip install motioneye
- Prepare the configuration directory:
mkdir -p /etc/motioneye cp /usr/local/share/motioneye/extra/motioneye.conf.sample /etc/motioneye/motioneye.conf
- Prepare the media directory:
mkdir -p /var/lib/motioneye
- Add an init script, configure it to run at startup and start the
motionEye
server:cp /usr/local/share/motioneye/extra/motioneye.systemd-unit-local /etc/systemd/system/motioneye.service systemctl daemon-reload systemctl enable motioneye systemctl start motioneye
8. To upgrade to the newest version of motionEye, just issue:
pip install motioneye --upgrade
systemctl restart motioneye
Setting Up MotionEye and our Cameras :
After completing the above steps, Our MotionEye on Raspberry Pi will be visible at IPofPi:8765, Like This :
When accessing the portal for the first time, You can use root as username and login, No password is necessary. Its a good choice to update it after log-in.
Go to Add Camera, and paste the address of the stream of your camera. Once successfully paired, Motion-eye will present you with dozens of options :
You can now enable Video Recording, Motion Detection and other features by following on-screen steps.
Congratulations on having a successful setup of MotionEye on Raspberry Pi, And a step towards making your home more secure.
problem with the update command, ended with an exception:
99% |████████████████████████████████| 37.8MB 3.4MB/s eta 0:00:01Exception:
Traceback (most recent call last):
File “/usr/lib/python2.7/dist-packages/pip/basecommand.py”, line 215, in main
status = self.run(options, args)
File “/usr/lib/python2.7/dist-packages/pip/commands/install.py”, line 353, in run
wb.build(autobuilding=True)
File “/usr/lib/python2.7/dist-packages/pip/wheel.py”, line 749, in build
self.requirement_set.prepare_files(self.finder)
File “/usr/lib/python2.7/dist-packages/pip/req/req_set.py”, line 380, in prepare_files
ignore_dependencies=self.ignore_dependencies))
File “/usr/lib/python2.7/dist-packages/pip/req/req_set.py”, line 620, in _prepare_file
session=self.session, hashes=hashes)
File “/usr/lib/python2.7/dist-packages/pip/download.py”, line 821, in unpack_url
hashes=hashes
File “/usr/lib/python2.7/dist-packages/pip/download.py”, line 659, in unpack_http_url
hashes)
File “/usr/lib/python2.7/dist-packages/pip/download.py”, line 882, in _download_http_url
_download_url(resp, link, content_file, hashes)
File “/usr/lib/python2.7/dist-packages/pip/download.py”, line 603, in _download_url
hashes.check_against_chunks(downloaded_chunks)
File “/usr/lib/python2.7/dist-packages/pip/utils/hashes.py”, line 46, in check_against_chunks
for chunk in chunks:
File “/usr/lib/python2.7/dist-packages/pip/download.py”, line 571, in written_chunks
for chunk in chunks:
File “/usr/lib/python2.7/dist-packages/pip/utils/ui.py”, line 139, in iter
for x in it:
File “/usr/lib/python2.7/dist-packages/pip/download.py”, line 560, in resp_read
decode_content=False):
File “/usr/share/python-wheels/urllib3-1.19.1-py2.py3-none-any.whl/urllib3/response.py”, line 432, in stream
data = self.read(amt=amt, decode_content=decode_content)
File “/usr/share/python-wheels/urllib3-1.19.1-py2.py3-none-any.whl/urllib3/response.py”, line 380, in read
data = self._fp.read(amt)
File “/usr/share/python-wheels/CacheControl-0.11.7-py2.py3-none-any.whl/cachecontrol/filewrapper.py”, line 63, in read
self._close()
File “/usr/share/python-wheels/CacheControl-0.11.7-py2.py3-none-any.whl/cachecontrol/filewrapper.py”, line 50, in _close
self.__callback(self.__buf.getvalue())
File “/usr/share/python-wheels/CacheControl-0.11.7-py2.py3-none-any.whl/cachecontrol/controller.py”, line 275, in cache_response
self.serializer.dumps(request, response, body=body),
File “/usr/share/python-wheels/CacheControl-0.11.7-py2.py3-none-any.whl/cachecontrol/serialize.py”, line 55, in dumps
“body”: _b64_encode_bytes(body),
File “/usr/share/python-wheels/CacheControl-0.11.7-py2.py3-none-any.whl/cachecontrol/serialize.py”, line 12, in _b64_encode_bytes
return base64.b64encode(b).decode(“ascii”)
MemoryError