Raspberry Pi Camera Adventures
(Click on image for larger version)
I know. The Raspberry Pi Camera has been around for a long time. I just have not had a chance to start using mine until now 🙁
I decided to write this article to chronicle my experiences with the Pi camera, and list the resources I found to be the most useful for using the Pi Camera.
Basic Specifications
Still capture: 5 Megapixel (2592x1944)
Video capture: 1080p30 / 720p60 / 640x480p60/90 (more with latest firmware)
for more see
https://www.raspberrypi.org/documentation/hardware/camera.md
And the pain and discomfort will become more obvious when bananaleaf.com.ph viagra for free walking or sitting. At the same cialis 100mg canada time, you may need direct medicine to control penile failures. This is referred to as dysfunction http://bananaleaf.com.ph/hello-world/ cheap viagra order in women and there can be numerous causes for it. Non-surgical spinal decompression is indicated for individuals who are experiencing soft or weak erections, less penile viagra in italy sensation during coitus may use this herbal oil.
Getting Started
The Raspberry Pi Foundation has a couple of pages of very helpful information for installing & using the Pi Camera, so there was no reason for me to regurgitate it here.
Using the latest Raspbian, and following the posted information, I am happy to say that the camera just worked.
- https://www.raspberrypi.org/products/camera-module/
- https://www.raspberrypi.org/help/camera-module-setup/
- https://www.raspberrypi.org/documentation/usage/camera/README.md
- https://elinux.org/Rpi_Camera_Module (wiki)
The camera module setup page even has a video to show you how to connect your camera!
DesignSpark also has a great step-by-step installation and configuration tutorial, with a lot of screen shots:
The advantage of the DesignSpark tutorial is that you can use it on an existing Raspbian installation, as it walks you through updating it, whereas the README pretty much assumes a recent Raspbian install.
(Click on image for larger version)
Taking Still Photos
Once you have updated your Raspbian and have your camera installed, it is extremely easy to take still photographs.
raspistill -o photo.jpg
Yep, it is that easy. There are many options for raspistill for controlling how the still shot is taken, the https://elinux.org/Rpi_Camera_Module wiki shows you all the options.
Capturing Video
Recording video is just as easy as taking still photos!
raspivid -w 1280 -h 720 -fps 60 -t 10000 -o test720p60.h264
As you might suspect, the https://elinux.org/Rpi_Camera_Module wiki shows you all the raspivid options as well.
Streaming Video
Unfortunately streaming video is a different ball of wax.
There are MANY ways of streaming video – mjpeg, h.264, and flash among others. Choosing which method is the most appropriate for you is not particularly easy, as it depends on a number of factors:
- available light
- desired image resolution
- desired frames rate
- available network bandwidth
- desired client (web browser? custom app?
I tried using mjpeg to stream 1/4 resolution images… and I did not like how the system behaved. The Pi had a load average of 2.54, and kept freezing – I think it simply could not encode it fast enough, which makes me suspect that hardware encoding was not being used.
Some googling pointed me to V4L drivers for the Pi Camera, and I am about to try those – not to mention that the picamera Python library is very tempting.
Pi Camera Streaming Threads & Links
- Stream Video to Web Browsers even on Android & iOS
- RPi Cam Web Interface (wiki @ elinux) (github)
- Streaming Raspberry Pi Camera H264 into HTML over RTMP
- Apache/Nginx streaming
- Raspberry Pi Camera Board – GStreamer
- Raspberry Pi camera to SecuritySpy
- Raspberry Pi Streaming video
Pi V4L / Webcam Streaming Threads
- How to install or upgrade UV4L on Raspbian (for the Raspberry Pi) (thanks ratronic!)
- Simple Webcam on Raspberry Pi
- Dual Cameras with UV4L
I will be exploring the V4L interface to the RPi, as I think it has great potential – and some compatibility with other V4L devices.
(Click on image for larger version)
picamera Python Interface
David Huges has released a BSD licenced nicely documented interface to the Pi Camera at
picamera supports Python 2.7 and Python 3.2, has great documentation, quick start tutorial, and even test suites!
David provides Python code for
- “Basic Recepies” cover everything from capturing images, capturing video, capturing time lapse, streaming video to the network and much more.
- “Advanced Recepies” cover YUV/RGB/raw capture, rapid capture&processing, custom output and much more.
LinuxUser magazine had an article on using a Raspberry Pi camera and picamera for motion detection:
I will be using picamera in my experiments – good thing I have Python 2.7 & 3.2 interfaces for RoboPi !
I have to emphasize what an extensive & nice piece of work picamera appears to be. I’ll update this article with more about picamera as I gain experience with it.
Motion Detection
Motion detection with “Motion”:
- https://www.instructables.com/id/Raspberry-Pi-Jack-of-all-trades/step11/Security-camera-server/
- https://www.raspberrypi.org/turn-your-pi-into-a-low-cost-hd-surveillance-cam/
- https://medium.com/@Cvrsor/how-to-make-a-diy-home-alarm-system-with-a-raspberry-pi-and-a-webcam-2d5a2d61da3d
- https://www.makeuseof.com/tag/build-a-motion-capture-security-system-using-a-raspberry-pi/
One of the main reasons we would want motion detection would be for a home-brew security camera setup.
Zoneminder is a popular Linux security camera software package. Here are the links I collected for my future experiments:
- https://www.recantha.co.uk/blog/?p=4801
- https://redlegoman.blogspot.ca/2013/05/using-raspberry-pi-camera-module-with.html
- https://www.hwmakers.eu/raspberry-pi/raspberry-pi-opensource-video-surveillance-with-zoneminder/
- https://blog.snapdragon.cc/2012/07/16/using-raspberry-pi-for-cctv-with-zoneminder/
- https://www.linuxuser.co.uk/tutorials/zoneminder-cctv-tutorial
- https://www.linux.com/learn/tutorials/762058-how-to-operate-your-spycams-with-zoneminder-on-linux-part-1-
Object Recognition
OpenCV is an open source package for image processing and recognition. Here are some interesting links that I found for it:
- A Robot for RoboCup Junior with image processing
- https://www.raspberrypi.org/facial-recognition-opencv-on-the-camera-board/
- OpenCV 2.4 packages for Raspberry Pi (Raspbian Wheezy)
- https://robertcastle.com/2014/02/installing-opencv-on-a-raspberry-pi/
Using the Raspberry Pi Camera with Robots
I’ll be adding a Raspberry Pi Camera to Elf as soon as time allows me to fabricate a camera mount for it.
Based on my early experiments with a Pi camera (not on a robot) I don’t believe that 1080p streaming will be viable – the only hope is h.264 streaming at 25fps or less. 720p streaming at say 24fps may be viable, but it took far too much cpu when streaming it as mjpeg’s. 640×480 and lower should work, with the capability of occasional 5Mp snapshots.
I started a forum for the Raspberry Pi Camera Adventures – and I’d love to hear from you!
I welcome suggestions for links to add to any of the sections above – or even suggestions for new sections.