Turning a Raspberry Pi into a portable streaming camera

No readers like this yet.
open hardware

Opensource.com

Last month I decided to kick off a new Raspberry Pi project, since it's been a bit too long since my last few (See: Christmas lights and Musicbox).

For a few months now, I've been wanting to play around with a Raspberry Pi Touchscreen, and I've been meaning to buy the Pi Camera as well. I went ahead and ordered them both from Adafruit. (I went with the 3.5" PiTFT touchscreen.)

Once they arrived, I started to do some reading online on how to get them installed. The PiTFT requires you to customize your Raspbian install a bit, but the directions were pretty straightforward and I only had a couple of issues. First, I didn't have the screen seated well enough on the GPIO pins and it didn't turn on. The other one was a bit more complicated. If I used lightdm to auto-login into LXDE, the screen would go black right after the boot screen. If I logged into just a console (i.e., disabled lightdm) everything would work fine.

The fix ended having to tell Xorg to use /dev/fb1 as the display device, and to do that you should do the following:

Install framebuffer driver:

sudo apt-get install xserver-xorg-video-fbdev

Create file: /usr/share/X11/xorg.conf.d/99-fbdev.conf

Section "Device"
Identifier "myfb"
Driver "fbdev"
Option "fbdev" "/dev/fb1" EndSection

(Source)

This should allow lightdm to start up and auto-login to Xorg on your Raspberry Pi, as shown in the picture below.

Photo courtesy of Anderson Silva. CC BY-SA 4.0.

Overall the PiTFT is nice enough for the price, but I found the sensitivity of the touchscreen to be sub-optimal. I haven't tried to see if there is a way to tune it yet, but I will eventually.

To install the PiCam, I just searched on YouTube for a tutorial and made sure I enabled it on the raspi-config cli program. Like the touchscreen, I feel like I didn't plug in the camera quite right the first time around, so I had to adjust the ribbon a bit. One other thing that I did (I can't recall if it was on any of the instructions) was to enable SPI via raspi-config.

The picture below shows the PiCam up and running.

Photo courtesy of Anderson Silva. CC BY-SA 4.0.

The Raspberry Pi comes with a few tools that allows you to interact with the camera. See them on RaspberryPi.org.

The CLI tools are nice, but I wanted to take it one step further. I wanted to be able to move around with the Pi, and possibly stream live video from the PiCam. (Note: This is not my original idea, other people have done this before, I just wanted to do it too.)

The next step was to try to find something a bit more user friendly than CLI commands for me to do the streaming with. For now, I've settled on the Pi Cam Web Interface project.

Again, instructions were pretty straightforward, although it worked better using Apache as a web server than Ngnix. Given memory is limited, and Ngnix is known for its small memory foot print, I definitely want to try re-installing this using Ngnix again in the near future. It is also worth reminding everyone that after installing Pi Cam Web Interface, you have set it to auto-boot. You still have to start up the camera via the RPi_Cam_Web_Interface_Installer.sh. I am sure there is a way to make the camera auto-start as well, I just haven't taken the time to do it.

With Pi Cam Web Interface working, you can easily view live streams from your Pi Cam by hitting the IP/URL of your Raspberry Pi on a browser within your network (or local host if on the Pi itself).

The last piece of the puzzle was setting up the Pi in a way that I could kick off the local browser via touch screen so I can start seeing the video. I decided to install Chromium on the Pi and run it in kiosk mode against localhost. It works really well.

Photo courtesy of Anderson Silva. CC BY-SA 4.0.

The final product. Mounted PiCam on a Raspberry Pi 2 and PiTFT screen running on battery power.

Oh, and of course the battery. I am using an Anker 12000mah external battery which is pretty massive and heavy. I think for demonstration purposes it may be worth picking up a smaller one some time in the future just to show how compact this project can really be. The case you see in my pictures is just the standard case that comes with the Raspberry Pi 2 when you back one with the Canakit.

Photo courtesy of Anderson Silva. CC BY-SA 4.0.

And that's the project so far! It has been a lot of fun, and I've learned a few more things about the capabilities of the Raspberry Pi. I still have quite a few things I want to improve on this particular project, including:

  • Hide "Reboot/Shutdown" server from the Pi Cam Web Interface so I can share live streams with friends without having to worry they are going to troll the server.
  • Make the camera start up under Pi Cam Web Interface automatically after reboot, instead of manually as I am doing now.
  • Auto start Chromium in Kiosk mode. (Right now you have to tap on an icon).
  • Possibly shorter cable and smaller battery.
  • Some memory tuning: use Ngnix, tune RAM usage with raspi-config, possibly kill off other processes that may not be in use, etc.

Photo courtesy of Anderson Silva. CC BY-SA 4.0.

One final and somewhat unrelated thought: I became interested on the PiTFT because I wanted to be able to start and stop my Christmas light show without needing network connectivity or a "normal" monitor around. Given the connectors for this PiTFT plugs over the entire GPIO port, I am going to have to figure out how to map the pins needed for the PiTFT to work, while using the other pins for the light show, but that's the subject of a future project.

User profile image.
Anderson was introduced to Linux by his uncle back in 1996. In the early 2000s, he transitioned from being a developer to a system administrator. Today, Anderson leads the Red Hat Information Security Incident Response team. He is also an active Fedora package maintainer.

7 Comments

Nice! I've actually been contemplating something like this for quite a while now. I'm one of "those people" who don't like having their back to anyone so when I was moved to a new building and put into a cubicle, I'm constantly stressed about someone walking up behind me. I brought a small mirror to help with that but thought it'd be super cool to build a RPi "mirror" instead. Thanks for the tips & most importantly, the motivation!

I have expanded on the project, and I have even put speakers on the Pi, and I keep an eye on my dog, and I can remotely play an ogg file that "yells" at him to get off the couch :-) I will write about that on a future article. :-)

In reply to by BC

See if you could author a fun post of using the Pi in say 10 different fun ways or something. May be a good Sunday afternoon activity for kids. :)

In reply to by ansilva

Great project. I was working on a similar project, but I have no time to finish it, unfortunately. Why don't you add streaming capabilities to what you have done? While seeing the video on the PiTFT, with UV4L you can optionally stream audio and video to a Jitsi Meet Web Conference, for example, or to another peer "out of the box" . two-way audio is also supported which means that you can listen to others via headphones connected to the Rpi. It would be really funny. Also, it's all done via WebRTC so no configuration is required. UV4L: http://linux-projects.org

Creative Commons LicenseThis work is licensed under a Creative Commons Attribution-Share Alike 4.0 International License.