maemo.org - Talk

maemo.org - Talk (https://talk.maemo.org/index.php)
-   Development (https://talk.maemo.org/forumdisplay.php?f=13)
-   -   A simple intervalometer for the N900 (time-lapse photography) (https://talk.maemo.org/showthread.php?t=38275)

Ricardo 2009-12-24 02:44

A simple intervalometer for the N900 (time-lapse photography)
 
Hi All!

I'm part of the KAPing with the N900 team, developing a KAP (Kite Aerial Photography) system for the Push N900 project.

While testing some ideas, I wrote this simple, quick-and-dirty intervalometer in Perl that you can run from the X Terminal of your N900. Install gstreamer, since this script will use it. You can take as many pictures as you want ($max) with a fixed interval in seconds ($delay). Just be sure to save them in a valid folder ($dir). I compiled a video with the pictures I took in a session, check it out if you want to.

So, here is the code, as requested:

EDIT: a better one is down on this page

Code:

#!/usr/bin/perl -w

# A simple intervalometer for the Nokia N900
# Author: Ricardo Mendonca Ferreira - ric@mpcnet.com.br
# Date: 2009.12.17

use strict;

my $dir = '/home/user/MyDocs/test';
my $gst = '/usr/bin/gst-launch v4l2camsrc device=/dev/video0 num-buffers=1 ! omx_jpegenc ! filesink location=';
my $max=1000;
my $delay=2;

my $num=0;

while ($num < $max) {
        $num=sprintf'%05d',$num;
        `$gst$dir/$num.jpg`;
        print "($num/$max - ", $max-$num, " to go)\n";
        sleep $delay;
        $num++;
}


Sopwith 2009-12-24 02:49

Re: A simple intervalometer for the N900 (time-lapse photography)
 
Awesome stuff! Thanks!

That One Guy 2009-12-24 03:20

Re: A simple intervalometer for the N900 (time-lapse photography)
 
I must be doing something horribly wrong.

Nokia-N900-42-11:/home/user/MyDocs# sh photo.sh
photo.sh: line 1: #!/usr/bin/perl: not found
photo.sh: line 7: use: not found
photo.sh: line 9: =: not found
photo.sh: line 10: =: not found
photo.sh: line 11: =100: not found
photo.sh: line 12: =1: not found
photo.sh: line 14: my: not found
photo.sh: line 16: syntax error: "{" unexpected (expecting "do")

fatalsaint 2009-12-24 03:24

Re: A simple intervalometer for the N900 (time-lapse photography)
 
Yes you are. This is a perl script, not a shell script.

Quote:

mv photo.sh photo.pl
perl photo.pl
:)

That One Guy 2009-12-24 03:26

Re: A simple intervalometer for the N900 (time-lapse photography)
 
D'OH!

Now I feel tEh smart... not.

Thanks Saint.

That One Guy 2009-12-24 03:30

Re: A simple intervalometer for the N900 (time-lapse photography)
 
This is friggin sweet! Thank you both. OP for the script, and Saint for helping me pull my head out of my arse. :D

Nokia-N900-42-11:/home/user/MyDocs# perl photo.pl
(00000/100 - 100 to go)
(00001/100 - 99 to go)
(00002/100 - 98 to go)
(00003/100 - 97 to go)
(00004/100 - 96 to go)
(00005/100 - 95 to go)
^C
Nokia-N900-42-11:/home/user/MyDocs#

fatalsaint 2009-12-24 03:31

Re: A simple intervalometer for the N900 (time-lapse photography)
 
Np. Everyone misses the little things once in a while. ;)

Ricardo 2009-12-24 20:39

Re: A simple intervalometer for the N900 (time-lapse photography)
 
I'm glad you liked it... but the first version I posted doesn't work well with higher resolutions. In fact, it reseted my device when I tried to capture images slightly larger than 900 lines...

I found out a better pipeline and improved the script a bit. It's still rough and there's very little error checking, but still, it's better than nothing. :P

Code:

#!/usr/bin/perl -w

# A simple intervalometer for the Nokia N900.
# Author: Ricardo Mendonca Ferreira - ric@mpcnet.com.br
# http://talk.maemo.org/showthread.php?t=38275

# This script requires gstreamer installed on your N900.
# See the link above for more info.
# Run this script on an X Terminal in your device with:
#  perl intervalometer.pl

# 2009.12.17  First version.
# 2009.12.24  Better gstreamer pipeline; more options, with better descriptions.

use strict;

#---- CONFIG SECTION ---- [BEGIN] ----

 my ($x,$y) = (640, 480);              # image resolution - try (2592, 1968)
 my $cam    = 0;                        # camera: 0 = back, 1 = front
 my $dir    = '/home/user/MyDocs/test'; # folder where images will be saved
 my $max    = 10;  # total number of images to take
 my $delay  =  5;  # interval between pictures

#---- CONFIG SECTION ----  [END]  ----

die "$dir not found!\n" if !-d $dir;

my $gst = "/usr/bin/gst-launch v4l2camsrc device=/dev/video$cam num-buffers=1 ! ffmpegcolorspace ! video/x-raw-yuv,width=$x,height=$y ! jpegenc ! filesink location=";

my $num=0;

print "Intervalometer started - will take $max pictures at $x x $y\n";

while ($num < $max) {
        $num=sprintf'%05d',$num;
        `$gst$dir/$num.jpg`;
        printf "saved %d of %d", $num+1, $max;
        $num++;
        if ($num < $max) { print " - sleeping $delay sec."; sleep $delay; }
        print "\n";
}

And BTW, Merry Xmas to all!

That One Guy 2009-12-24 21:43

Re: A simple intervalometer for the N900 (time-lapse photography)
 
Seems to work fine with 2592x1968 set at .5 second intervals, on my unit. It's strange yours doesn't like anything over 900 lines... I know, that's a little overkill, but wanted to see if it can be done.

Granted, I only had it take 50 images at that resolution and duration. Maybe later, I'll set it up for 1000 pics and just let it go.

Tinnet 2009-12-27 02:10

Re: A simple intervalometer for the N900 (time-lapse photography)
 
This is pretty sweet :)
Thanks!


All times are GMT. The time now is 11:58.

vBulletin® Version 3.8.8