Raspberry Pi + Webcam = FUN!

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hey friends and welcome to this new episode i've got a fresh haircut and i had some wisdom teeth removed which was really painful and that's why i'm so late with the next episode in this episode we're going to have some fun with the raspberry pi and some old webcams who wouldn't want to watch plants grow take some time lapses of clouds or spy on their neighbors just kidding don't do that okay roll the intro welcome friends this is part one of a two-part series in this episode we are going to attach a webcam to the raspberry pi and take images in certain intervals so you can easily create a time-lapse from the view of the window or point it at the pod plan and watch it grow or take a time-lapse of your 3d printer printing something and watch the model grow in the second episode which will be up in about a week we will enhance the images by writing some python code to include current weather information in each image provided by an open weather api and upload the image back to web server for a kind of live webcam so let's get tracking first of all i read your commands and thanks for someone to point out that i should increase the font of my console when recording what i'm doing to capture images from the webcam we're going to use fs webcam which is a super lightweight tool to capture frames or sequences from linux video devices make sure you ran an app update and app dist upgrade and then install fs webcam by running apt install fs webcam now you might wonder how to check if linux recognizes your webcam thank god that is super easy to figure out just run the ls usb command it will list all known usb devices you can of course also run usb minus devices but that list is less human readable as you might have noticed my webcam did not appear there's an easy reason for that i did not yet attach it okay let me quickly plug in my webcam and run the lsusb command again here we go lsusb nicely lists our webcam it's a logitech c910 and usb devices also shows it there it is but just like i mentioned before it's not as human readable as lsusb this step now might not be necessary but just to make sure our user pi has access to the linux video devices we add the user pi to the video group now we can start to access the webcam in order to check out all the resolutions and image formats the webcam is capable of we will use the video for linux utilities make sure they are installed by executing sudo apt install v4l minus utils to get a list of possible formats and resolutions we execute v4 l2 minus ctl minus minus list formats xd pipe more the pipe will make the output pause after a full page and wait for a key press so we have time to read as this list can be pretty long my webcam supports yuyv and mjpeg both in a resolution of 1080p which i aim for to capture let's keep this in mind for a moment and capture our first picture with fs webcam in theory fs webcam is quite smart but you will see let's give it a try and capture a 1920x1080 pixels picture and save it as a jpeg and something went wrong while minus r provides the resolution to capture the picture in fs webcam try to figure out the format of the data on its own and failed so we have to specify the exact image format fs webcam should expect from the webcam as derived from the list of formats before we will go by y-u-y-v awesome this worked let's quickly open the file in a web browser and take a look you find the image in your home directory let's quickly talk about some important parameters your picture might look too dark or is only half taken or has other weird issues but no worries we fixed this now fs webcam needs a moment to initialize the camera but often does not really know when it is ready and the auto exposure adjustments of the camera finish doing their magic the most important parameters to handle those issues are minus capital s like skip frames so minus s60 will skip the first 60 captured frames and only use the ones afterwards to save to the file the next one is minus capital d as in delay minus d2 will add to a 2 second delay before even trying to capture any frame so the camera has time to wake up and initialize last but not least minus capital f as in frames this will tell fs webcam not only to capture one frame but any number and combine them into one image you can use this to lower noise levels in the final image but beware fast moving objects might become blurry if too many frames are combined as you can see fs webcam did exactly what we told it to do it delayed the capture for 2 seconds then captured 60 frames skipping them throwing them away then capturing two frames and saving them into the final image initially like capturing and throwing away 60 frames that was far too much and that takes too long we should lower that number but yeah you get the point now it is time to put all this into a nice shell script and get it executed every minute it also should save the files to dedicated folder not just drop them in our home directory so execute make directory webcampigs and open your favorite text editor name the file capture.sh you probably just want to pause the video now for a moment and type in the lines exactly as shown then exit the text editor via control x and save the file make the file executable by typing change mod plus x capture sh now let's run the script it does exactly what it should do as you can see the image was saved to our webcam pix folder and has a nice timestamp in its name let's add the script to our users cron tab which is a configuration file for periodically executed tasks we want to add our script so it runs every minute just copy the following line in there hit ctrl x to exit and save the file now all we have to do is wait a minute and check the webcam pics folder please be patient the file will not appear exactly at the one minute mark first of all we added the delay to fs webcam and i still have that skip the first 60 frames option activated so it takes almost 20 seconds for fs webcam to capture and save the file i definitely should have lowered that value if everything looks ok just find a good spot for your webcam point it out of your window point it at a pot plan point it at anything interesting i hope you enjoyed this video and don't forget there will be a second part to this tutorial and if you feel awesome don't forget to like subscribe follow ring that bell and if you feel super awesome support me on patreon thank you alpha over and out you
Info
Channel: TECH, CODE & COFFEE
Views: 81,991
Rating: undefined out of 5
Keywords: raspberry, pi, webcam, timelapse, video, geek, gamer, geekandgamer
Id: _uVaZalaSbI
Channel Id: undefined
Length: 8min 41sec (521 seconds)
Published: Fri Apr 02 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.