Taking photos with a USB webcam and saving them on the Omega
This tip covers using the Omega to take photos with a USB webcam and saving them to the file system. We’ll cover installing the required packages as well as how to use the terminal command.
First, let’s update the package feeds on the Omega so we can download and install the fswebcam package that we need to use the webcam. On your Omega, open /etc/opkg/distfeeds.conf for editing:
Find the line that starts with ## src/gz reboot_packages and uncomment it by removing the ## signs and space so it looks like this:
src/gz reboot_packages http://downloads.lede-project.org/snapshots/packages/mipsel_24kc/packages
Now let’s install the package. Run the two commands below:
opkg update opkg install fswebcam
And we’re ready to go!
Now, we can use the fswebcam command to take a photo! We’ll generally use it like this:
fswebcam --no-banner -r [RESOLUTION] [FILENAME]
Here’s an example of it action:
fswebcam --no-banner -r 1280x720 `date +"%Y-%m-%d_%H%M%S"`.jpg
This command takes a 1280×720 resolution photo and saves it to a file in the current directory named after the current date and time.
The backticks in the filename tell the Omega to first run and format the date command, then put the output in the filename like so: 2017-07-10_170732.jpg. The date command is actually really flexible, check out this page for more details if you’re curious.
The Omega2+ is perfect for taking photos because it can store the photo files on an SD card! The files are pretty large and would fill up the filesystem pretty quickly and the USB port is in occupied by the webcam, making an SD card the ideal storage medium.
And that’s it! We’ve learned how to take and store photographs with the Omega using a single command. You can use this for a variety of projects, such as on a robot when it reaches a point of interest, or a motion-triggered camera for a baby monitor.
You can also use this to create your own cool timelapse videos using the cron utility and the ffmpeg package! Just like the Timelapse Camera project in Project Book Vol. 1!
Thanks for reading & have a great week!
Let us know what kind of stuff you would like to see featured on 2-Bullet Tuesday! Send a tweet to @OnionIoT with your suggestions!
P.S. Get free shipping on all Onion Store orders over $75 that include a Dock, Expansion, or a Kit!