Playing with the cheapest computer — Raspberry Pi Zero W (New level unlocked!): Portable baby monitor
Since I put my hands on this small piece of equipment (shared in my previous blog entry), I have been planning to make a low-cost baby monitor as my initial project. That sounds like something achievable with relatively less effort to make. I have been trying to use a camera cost 5$ on eBay, but it was hard to find the right code on this camera to get Pi recognize it. So I put +5$ to get a proper Pi camera from eBay.
Then, I dig into the web forums to find the right guideline for me to follow. Finally, I found this website which clearly explains how to stream from your Pi over HTML. It uses a package called MJPG-streamer. That was very much what I need. No additional software is required to receive the video feed other than a simple web browser. Another good part of this link is that it is from this company called Dataplicity which provides a free online service that let you access and control your Pi remotely and create a link to stream your feed over internet. Even the created web link is unique, not having an option to login for accessing the video feed is quite a security issue. Better keep in mind not to share your sensitive information.
The first image below shows how you will get the HTML feed using MJPEG streamer. Once you successfully install the module, you will get this page as entering your Pi IP to the browser. There are plenty of options for video streaming (java script, VideoLAN…). The second image is the UI of Dataplicity. At the right side you have admin options as creating web link for your Pi, reboot or checking the storage. Left side is the terminal for running your business with Pi. I can say it is quite user friendly.
After all, I had no problem following the instructions in the website. It could take half an hour to 1 hour to setup this server and start streaming, assuming you have no issues throughout this process. I had some troubles with videodev.h file (which cannnot be found somehow). But it was resolved by replacing it with the existing file instead (videodev2.h). To solve this kind of puzzles are kind of fun but could be quite exhausting to find the solution (may be that is the best part?).
Once everything is done, you can simply start streaming within your home network by entering these 2 line of commands each time you start your Pi (you should be in the folder that MJPG-steamer is nested) :
sudo modprobe bcm2835-v4l2
sudo ./mjpg_streamer -i “./input_uvc.so -f 10 -r 640x320 -n -y” -o “./output_http.so -w ./www -p 80”
Creating an .sh file and run it with sudo sh command will be easier instead of finding and writing these commands every time. Save this as a bookmark for quick access to stream only:
(X is the last 3 digit of your Pi’s IP)
Extras & Upgrades
Housing
I upgraded my previous cheap box housing with using total of 2$ Legos. Here is little robot like Pi with camera mounted.
Going mobile
You can connect your Pi to a power bank (I am using 10000 maH). It can give you couple of days lifetime for running wireless (see the image below). Minimum 1A power output is enough to run camera, and connected keyboard and mouse. That would definitely work for locating your baby monitor anywhere that is convenient.
If you have another computer, you can install VNC to remote access Pi’s desktop. It will save your time to connect your Pi to a monitor and keyboard. VNC comes with Raspbian OS. All you need to do is install the software to your computer. For quick checks and easier access, you may use VNC mobile app, available in multiple platforms.
Recording camera feed
Some may need to record the video stream. For that, I found the solution with a simple Python code that you can run in Raspberry Pi (Python software comes with Raspbian OS). Here is what you need to create in a .py file:
from picamera import PiCamera
from time import sleep
camera=PiCamera()
camera.start_recording(‘/home/pi/video.h264’)
sleep(10)
camera.stop_recording()
This is for 10 seconds recording, and saves the created video file at your pi folder. Be aware that you may need a large storage unit for that if you plan to go for hours.
Coming up next: Real time object detection using the video stream from Raspberry Pi
This is the harder but the coolest part. It is the next stage in my Pi projects, simply turning the baby monitor into a smart smart surveillance cam. Right now, I figured out object detection method using single image with manual feeding over Python software. I am looking into finding the way to use the HTML feed for real time object detection. This time I will do the work on my computer rather than Pi because this process requires faster processing for real-time object detection.
Originally published at emresezg.wixsite.com on September 13, 2018.