Showing posts with label Time Lapse. Show all posts
Showing posts with label Time Lapse. Show all posts

Thursday, June 11, 2015

Long Exposure Time Lapse with a GoPro


Save the text below into a text file called "autoexec.ash", and place them onto the SD Card. Upon power up, the GoPro will start taking Long Exposure pictures in Time Lapse mode. Just push and hold the power button between exposures to stop the script and power it off.

-----------------------------------------
t app appmode photo
sleep 1
t ia2 -ae still_exp 100 55 55
sleep 1
t app button shutter PR
sleep 6
d:\autoexec.ash
REBOOT yes
------------------------------------------
The script above is a 6 Second Exposure at ISO100.

Explanation:
t app appmode photo
sleep 1
t ia2 -ae still_exp P X Y
sleep 1
t app button shutter PR
sleep A
d:\autoexec.ash
REBOOT yes



Key:
P: ISO
X: Exposure time
Y: Iris (exposure time)
A: timelapse interval

Ref:
http://chernowii.com/gopro-longexp

Value (number to write in hack file)Exposure Time (seconds)
18
237
556
855
1204
1803
2552
4001


I have made many scripts, so you can pick a prebuilt one, and copy that one script to the SD card. Here is the download link:
https://www.dropbox.com/s/mwhgtqnmwqe9s99/GoPro%20Long%20Exposure%20Scripts.zip?dl=0

Saturday, August 23, 2014

Automated Time Lapse - Raspberry Pi

Based on a previous Time Lapse generating system, I wanted to build another version with a Raspberry Pi that would be put outside inside an enclosure. I had attempted Time lapse Photography with a Raspberry Pi and a Microsoft Webcam before, but had issues with stability past more than a day. The Raspberry would lockup. I think it had to do with the small power supply and the 3 long USB extension cords, but that's another issue entirely.

This is my current version of my WeatherCam that I use to make Time Lapse Videos. I purchased a Dome Enclosure and mounted it upside down onto a pole. I found a servo at the local toy shop, and mounted the servo to the tripod screw. I am using the Raspberry Pi Camera with the IR Filter, and the servo is being powered form the Raspberry Pi directly (Not optimal, but it works). I also added a RTC to this setup so I can use this camera when it is not on the Internet, and still get accurate timestamps on the images captured. After some testing, I determined a bigger power supply was needed to power the Raspberry and the Servo unit. I am using a 5v 2.1A USB charger for the power supply. 


One of the big drives for this project, was wanting to make a Web Based interface so I could rebuild the unit I deployed for my Mom. This way, she won't have to know CLI to build Time Lapse videos. She already has a Raspberry Pi generating Time Lapse Videos automatically, but I wanted to give her more control over the process. I also have a chance of building one to Time Lapse of storms in Colorado, and I wanted to make it all easy to use. It has came a long way since I first started, but here is the interface.







Main Page showing Image Feed, updates every 60 seconds
Help page explains all sections and settings

Browse images/videos captured on system

Build a previous days images
into a Time Lapse, or process/upload todays

Upload a previously generated Time Lapse

Rotate the camera with the servo

Check System Temperature and free space

System Settings

Here is a video of the camera system automatically taking a panorama image set for post processing. The Panorama below is what I stitched together on my iPad from the images that were captured here.


9 Images captured from this system, and post processed into a Panorama on my iPad. What a view.

Wednesday, July 9, 2014

AirCam to YouTube Time Lapse with Raspberry Pi

I setup a weather station with webcam to feed data to Wunderground. The station setup was an AirBridge with an AirCam. The only issue, was the uploading of a pic to Wunderground was not as reliable as I had hoped, and I couldn't save the time lapse videos offline for use later. So I added a Raspberry Pi to the network to download high quality images from the webcam and create the time lapse videos for uploading to YouTube.

The end result is an automated time lapse (from 4AM to 10 PM - 1 Image Per Minute - 1080 Images - Processed at 24FPS) uploaded to youtube that is 45 seconds long.
What is needed:
A Functional AirCam on the network, with a known IP and Allow Unauthenticated option turned on.
Raspberry Pi with a Raspian image on a least a 4GB card
A thumb drive inserted into the Raspberry Pi with a folder on it called "TimeLapse".
HDMI Cable from the Raspberry to your TV.
An Ethernat connection to the network.
Section 1 - Initial Setup:
Getting started, Update the Pi first:
sudo apt-get update
sudo apt-get upgrade

Install needed apps:
sudo apt-get install ffmpeg mencoder python-gdata python-pycurl python-progressbar

Use "ifconfig" to figure out the IP Address, then use Putty to SSH to the Raspberry Pi.

Section 2 - Building the Scripts
You can download the scripts with these, or paste them in manually.
sudo wget https://www.dropbox.com/s/glrjw1r0c0jp9ip/TimeLapse.sh -P /etc/
sudo wget https://www.dropbox.com/s/65e0hopek114uqc/TimeLapseExport.sh -P /etc/
sudo wget https://www.dropbox.com/s/rbdwkwma5lzrbin/TimeLapseCleanup.sh -P /etc/

*Skip to Section 3 if you downloaded them directly, after you edit TimeLapseExport.sh and change the username/password fields. Don't forget to update the YouTube Keywords and Description.

Run the following to create the script file,
sudo nano /etc/TimeLapse.sh

then paste the script below:
--------------------------------------------------------
#!/bin/sh
#/etc/TimeLapse.sh
export DATETIME=`date +%Y%m%d%H%M`
export DATE=`date +%Y%m%d`
export MONT=`date +%Y%m`
FILE=/mnt/USB/TimeLapse
CAMIP=192.168.1.20
if [ -d $FILE ]
then
echo "Thumb Drive Available @ $FILE"
mkdir /mnt/USB/TimeLapse/$MONT
mkdir /mnt/USB/TimeLapse/$MONT/$DATE
ffmpeg -i rtsp://$CAMIP/live/ch00_0 -y -f image2 -sameq -t 0.001 /mnt/USB/TimeLapse/$MONT/$DATE/$DATETIME.jpeg
else
echo "Thumb Drive not Mounted @ $FILE"
sudo mount -o uid=pi,gid=pi /dev/sda1 /mnt/USB
sudo mount -o uid=pi,gid=pi /dev/sdb1 /mnt/USB
fi
 
--------------------------------------------------------

Use CTRL+S to save, then CTRL+X to close.

Create another script file and paste the script text below (Edit the username, password and youtube data):
sudo nano /etc/TimeLapseExport.sh

--------------------------------------------------------
#!/bin/sh
#/etc/TimeLapseExport.sh
export DATETIME=`date +%Y%m%d%H%M`
export DATE=`date +%Y%m%d`
export MONT=`date +%Y%m`
export USER="someone@gmail.com"
export PASS="*********"

export YTTITLE="Weather Time Lapse KCASQUIR2-$DATE"
export YTDESC="Time Lapse from Squirrel Valley (Mountain Mesa) CA on $DATE"
export YTKEY="Weather, Time, Lapse, KCASQUIRL2, Lake Isabella, Sierra Nevada, SkyWarn, NWS, Hanford, Mountains, Clouds"
FILE=/mnt/USB/TimeLapse
TMP=/var/TimeLapse

UP=/etc/youtube-upload-0.7.3/bin
if [ -d $FILE ]
then
echo "Thumb Drive Available @ $FILE"
echo "Images found:"
ls -l $FILE/$MONT/$DATE | wc -l
echo "Generating List"
ls $FILE/$MONT/$DATE/*.jpeg > $FILE/$MONT/$DATE/stills.txt
echo "Begin processing Time Lapse"
mencoder -nosound -ovc lavc -lavcopts vcodec=mpeg4:aspect=16/9:vbitrate=8000000 -vf scale=1280:720 -o $TMP/TimeLapse-$DATE.avi -mf type=jpeg:fps=24 mf://@$FILE/$MONT/$DATE/stills.txt
echo "Cleanup image list"
rm $FILE/$MONT/$DATE/stills.txt
echo "Start Upload to YouTube"

$UP/youtube-upload --email=$USER --password=$PASS --title=$YTTITLE --description=$YTDESC --category=Entertainment --keywords=$YTKEY $TMP/TimeLapse-$DATE.avi
echo "Cleanup video file"
rm $TMP/TimeLapse-$DATE.avi
else
echo "Thumb Drive not Mounted @ $FILE"
sudo mount -o uid=pi,gid=pi /dev/sda1 /mnt/USB
sudo mount -o uid=pi,gid=pi /dev/sdb1 /mnt/USB
fi

--------------------------------------------------------

One more script to cleanup images older than 30 days:
sudo nano /etc/TimeLapseCleanup.sh
--------------------------------------------------------
#!/bin/bash

#/etc/TimeLapseCleanup.sh
find /mnt/USB -type f -mtime +30 | xargs rm

--------------------------------------------------------
 
Make your scripts executable by running the following:
sudo chmod u+x /etc/TimeLapse.sh
sudo chmod u+x /etc/TimeLapseExport.sh
sudo chmod u+x /etc/TimeLapseCleanup.sh

Section 3 - Setup Youtube-upload
Now we need to get the scripts to upload to youtube. Run the following commands:

cd /etc/
sudo wget http://youtube-upload.googlecode.com/files/youtube-upload-0.7.3.tgz
sudo tar xvzf youtube-upload-0.7.3.tgz
cd youtube-upload-0.7.3
 sudo python setup.py install

Section 4 - Automation
Setup Crontab to launch your scripts on a regular basis:
sudo crontab -e -u root

add the following:
-----------------------------------------------------------
* 4-21 * * * /etc/TimeLapse.sh
0 22 * * * /etc/TimeLapseExport.sh > /var/log/TimeLapseExport.log 2>&1
0 1 * * * /etc/TimeLapseCleanup.sh
0 0 * * * /sbin/shutdown -r now

-----------------------------------------------------------

Section 5 (Optional) - Setup SMB to access files from remote computer
This will allow you to access the files on the thumb drive from a PC:
sudo apt-get install samba samba-common-bin
sudo nano /etc/samba/smb.conf

Add the following:
-----------------------------------------------------------
[pihome]
   comment= Pi Home
   path=/mnt/USB
   browseable=Yes
   writeable=Yes
   only guest=no
   create mask=0777
   directory mask=0777
   public=no
-----------------------------------------------------------

CTRL+S to save, and CTRL+X to exit
Set a password for SMB Access:
sudo smbpasswd -a pi
*Enter password twice

Section 6 - RAM Drive for Video Output
We don't want to beat up the Thumb Drive, so do the following:
sudo mkdir /var/TimeLapse
sudo nano /etc/fstab
Add the following:
--------------------------------------------------------
tmpfs   /var/TimeLapse    tmpfs    defaults,noatime,nosuid,mode=0755,size=100m    0 0
--------------------------------------------------------

Save the file by pressing CTRL-X and select Y to save the changes.

Section 7 (Optional) - Setting a Static IP
Optional, Set a static IP Address for the Pi by running the following:
sudo nano /etc/network/interfaces

Remove the line that reads
iface eth0 inet dhcp

Add the following:
-----------------------------------------------------------
iface eth0 inet static
address 192.168.1.10
netmask 255.255.255.0
network 192.168.1.0
broadcast 192.168.0.255
gateway 192.168.1.1
-----------------------------------------------------------

Save the file by pressing CTRL-X and select Y to save the changes.

If you changed the IP to static, don't forget the DNS servers:
sudo nano /etc/resolv.conf

Replace the text with the following:
-----------------------------------------------------------
nameserver 8.8.8.8
nameserver 8.8.4.4
nameserver 4.2.2.1
-----------------------------------------------------------

Save the file by pressing CTRL-X and select Y to save the changes.

Section 8 (Optional) - Setup Web Interface to view images

Install Apache:
sudo apt-get install apache2

Edit the Apache Web Config:
sudo nano /etc/apache2/sites-enabled/000-default
Edit the Document:
Root and the Directory fields to the following:
DocumentRoot /mnt/USB
<Directory /mnt/USB/>

Save the file by pressing CTRL-X and select Y to save the changes.
Reboot the web service to accept the changes:
sudo service apache2 restart

Test the web portal from your computer/device by putting the IP of the Raspberry in the browser

Section 9 - Reboot
reboot with the following:
sudo reboot

Section 10 - Aircam Tuneup
The Aircam has a few "wonderful" settings that you may want to change to get more picture clarity. Look at these images that were taken around the same time of day. One looks out of focus, but it wasn't.
 
You can telnet into the camera and use the default "ubnt" as the username and password.

View the current settings:
cat /proc/isp0/ae/info 
cat /proc/isp0/awb/info

Execute the following commands to cleanup the image quality during the day:
echo 1 > /proc/isp0/ae/ev_mode
echo "w denoise 0" > /proc/isp0/command
echo "w crosstalk 30" > /proc/isp0/command
echo "w sharpness 100" > /proc/isp0/command

sed -i 's/max_quant.*/max_quant = 20/' /var/etc/ubnt-streamer.conf
sed -i 's/mjpeg_quality.*/mjpeg_quality = 100/' /var/etc/ubnt-streamer.conf
pkill ubnt-streamer

Ref: http://community.ubnt.com/t5/UniFi-Video/Tune-up-your-aircam/td-p/269226
Ref: https://community.ubnt.com/t5/UniFi-Video/snapshot-cgi-chan-0-how-to-reduce-compression-on-AirCam-FW-1-2/td-p/555637