Timelapse with video surveillance elements.
Hello, habrapolzovateli.
Having read on Habré about timelapse with Raspberry Pi ( one , two ) and after three cars in the parking lot struck the wheels in one night, and a week before one car was opened, I decided that low-budget video surveillance should be organized.
There is no budget for a super-cool HD IP camera with wi-fi, and, frankly, there is no desire, because I like to delve into configs, poke wires and everything else.
In general, anyone interested, I ask for a cat.
• The center ofthe processing universe - Raspberry Pi ($ 43 for a fee with an SD 8Gb card + 16 UAH for delivery by New mail from the regional branch of DHL).
• Video capture card - EasyCap on the STK1160 chipset ($ 12 from China).
• Connection with the world - Wi-fi dongle COMFAST ($ 6 from China).
• Backup power - NONAME PowerBank ($ 6 from China).
• An analog camera, like Sony's CCD (has been in stock for many years).
• Cheap NONAME webcam for example ($ 7 from China).
• Charger for PowerBank at 1A, power supply for an analog camera at 9V, a pair of microUSB wires (all the good was in stock).
Install on Raspberry Pi Debian Wheezy ( taken here ). I did not bother with the Unix dd and Windows Win32DiskImager utility and downloaded Noobs Lite, with which I later installed the coveted Raspbian Wheezy.
At the first start, we are welcomed by raspi-config, where you can change the locale, user password pi, overclock the processor (I advise you to do it only after installing radiators). Next is a reboot and here we are in Linux.
Immediately I advise you to do:
Install the driver on the wi-fi module:
Next, we register in our wi-fi network
Save. We execute the command:
and disconnect from the wired connection.
For a long time I was looking for something suitable, sorted through the various options presented, including on Habré, but the choice fell on FSwebcam. Install it:
And in the config we write:
Save.
By the config, I hope everything is simple:
• device / dev / video0 - our video device
• loop 10 - capture a picture every 10 seconds
• skip 20 - skip 20 frames before capturing a picture
Run FSwebcam:
And look how the picture is updated.
I will not climb into the jungle of nginx, and so there are many simple examples on the Internet. All the good is displayed on a web page with one image, which is saved in the /wez/share/nginx/www/wc/capture.jpg in the FSwebcam config.
An example of a picture from a webcam in the morning
An example of a picture from an analog camera in the morning
From the photo, we can assume that the photo from the webcam is better, more “colorful,” but everything changes at night. Moreover, on the webcam there is a maximum of night quality that can be pulled out, and on the analogue - default settings, which can still be pulled.
An example of a picture from a webcam at night
An example of a picture from an analog camera at night
Yes, and the viewing angle of the analog is greater. Move on.
Since the power of the Raspberry Pi will not be enough to compile the video, I decided that it would be better to do this on an old Toshiba Satellite A100 laptop.
We connect to the laptop via sshfs (it seemed to me that it would be easier).
It is installed simply:
and finally:
I did not bother to enter the password every time and scored this command in crontab upon reboot. Now all the pictures with a time stamp in the file name are stored on the laptop, where the command runs on the crown at 8 am:
Next, rename all the photos according to one template so that aconv eats them:
We glue the video:
We clear the folder from the photo. After that, upload the video manually or automatically to YouTube and put music in order not to be bored to watch.
Sorry for the video from the old webcam, since I connected the analog only yesterday and did not have time to adjust everything and glue the video.
System view
Prices for products from China are listed on the Aliexpress website at the time of purchase.
The Raspberry Pi is powered by PowerBank, which is connected to charging, which allows the system to work autonomously with a power failure of up to 4 hours. True, the power to the analog camera is reserved through the UPS.
Script to upload video to Youtube
Installing drivers on wi-fi Ralink
Connecting to a wi-fi network
Mounting a remote folder
About FSwebcam
Why you need to buy EasyCap on the STK1160 chipset That
's all. I would be glad if someone would be useful and interesting.
Having read on Habré about timelapse with Raspberry Pi ( one , two ) and after three cars in the parking lot struck the wheels in one night, and a week before one car was opened, I decided that low-budget video surveillance should be organized.
There is no budget for a super-cool HD IP camera with wi-fi, and, frankly, there is no desire, because I like to delve into configs, poke wires and everything else.
In general, anyone interested, I ask for a cat.
Iron part
• The center of
• Video capture card - EasyCap on the STK1160 chipset ($ 12 from China).
• Connection with the world - Wi-fi dongle COMFAST ($ 6 from China).
• Backup power - NONAME PowerBank ($ 6 from China).
• An analog camera, like Sony's CCD (has been in stock for many years).
• Cheap NONAME webcam for example ($ 7 from China).
• Charger for PowerBank at 1A, power supply for an analog camera at 9V, a pair of microUSB wires (all the good was in stock).
Software part
operating system
Install on Raspberry Pi Debian Wheezy ( taken here ). I did not bother with the Unix dd and Windows Win32DiskImager utility and downloaded Noobs Lite, with which I later installed the coveted Raspbian Wheezy.
At the first start, we are welcomed by raspi-config, where you can change the locale, user password pi, overclock the processor (I advise you to do it only after installing radiators). Next is a reboot and here we are in Linux.
Immediately I advise you to do:
sudo apt-get update
sudo apt-get upgrade
Network connection
Install the driver on the wi-fi module:
sudo apt-get install firmware-ralink
Next, we register in our wi-fi network
sudo nano /etc/network/interfaces
allow-hotplug wlan0
auto wlan0
iface wlan0 inet dhcp
wpa-ssid “ИМЯ_ВАШЕЙ_СЕТИ”
wpa-psk “ПАРОЛЬ_К_ВАШЕЙ_СЕТИ”
Save. We execute the command:
sudo /etc/init.d/networking restart
and disconnect from the wired connection.
Capture program
For a long time I was looking for something suitable, sorted through the various options presented, including on Habré, but the choice fell on FSwebcam. Install it:
sudo apt-get install fswebcam
cd /home/pi
touch fswebcam.conf
sudo nano /home/pi/fswebcam.conf
And in the config we write:
device /dev/video0
pid 9990
input 0
loop 10
skip 20
resolution 720x576
top-banner
title "Stoyanka@RPi"
timestamp "%d-%m-%Y %H:%M:%S (%Z)"
palette YUYV
jpeg 100
save /home/pi/webcam/capture."%Y%m%d%H%M%S".jpg
save /usr/share/nginx/www/wc/capture.jpg
Save.
By the config, I hope everything is simple:
• device / dev / video0 - our video device
• loop 10 - capture a picture every 10 seconds
• skip 20 - skip 20 frames before capturing a picture
Run FSwebcam:
sudo fswebcam –c /home/pi/fswebcam.conf –b
And look how the picture is updated.
I will not climb into the jungle of nginx, and so there are many simple examples on the Internet. All the good is displayed on a web page with one image, which is saved in the /wez/share/nginx/www/wc/capture.jpg in the FSwebcam config.
An example of a picture from a webcam in the morning
An example of a picture from an analog camera in the morning
From the photo, we can assume that the photo from the webcam is better, more “colorful,” but everything changes at night. Moreover, on the webcam there is a maximum of night quality that can be pulled out, and on the analogue - default settings, which can still be pulled.
An example of a picture from a webcam at night
An example of a picture from an analog camera at night
Yes, and the viewing angle of the analog is greater. Move on.
Since the power of the Raspberry Pi will not be enough to compile the video, I decided that it would be better to do this on an old Toshiba Satellite A100 laptop.
We connect to the laptop via sshfs (it seemed to me that it would be easier).
It is installed simply:
sudo apt-get install sshfs
and finally:
sudo echo 'ROOT_PASSWORD' | sshfs root@192.168.1.1:/usr/storage/primary/webcam /home/pi/webcam -o password_stdin
I did not bother to enter the password every time and scored this command in crontab upon reboot. Now all the pictures with a time stamp in the file name are stored on the laptop, where the command runs on the crown at 8 am:
mv -a /usr/storage/primary/webcam/. /home/note/webcam
Next, rename all the photos according to one template so that aconv eats them:
ls *.jpg| awk 'BEGIN{ a=0 }{ printf "mv %s cap_%04d.jpg\n", $0, a++ }' | bash
We glue the video:
avconv -i cap_%04d.jpg -c:v libx264 -r 24 -crf 21 test.mkv
We clear the folder from the photo. After that, upload the video manually or automatically to YouTube and put music in order not to be bored to watch.
Sorry for the video from the old webcam, since I connected the analog only yesterday and did not have time to adjust everything and glue the video.
System view
Notes
Prices for products from China are listed on the Aliexpress website at the time of purchase.
The Raspberry Pi is powered by PowerBank, which is connected to charging, which allows the system to work autonomously with a power failure of up to 4 hours. True, the power to the analog camera is reserved through the UPS.
List of links
Script to upload video to Youtube
Installing drivers on wi-fi Ralink
Connecting to a wi-fi network
Mounting a remote folder
About FSwebcam
Why you need to buy EasyCap on the STK1160 chipset That
's all. I would be glad if someone would be useful and interesting.