Go Back   maemo.org - Talk > OS / Platform > Development
 
Register FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools
  #1  
Old 2009-12-24, 02:44
Ricardo Ricardo is offline
 
Join Date: Sep 2009
Location: Brazil
Posts: 59
Thanks!: 39
Thanked 71 Times in 16 Posts
Default 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++;
}

Last edited by Ricardo; 2009-12-24 at 20:41. Reason: Added link for improved script
Reply With Quote
The Following 26 Users Say Thank You to Ricardo For This Useful Post:
  #2  
Old 2009-12-24, 02:49
Sopwith's Avatar
Sopwith Sopwith is offline
 
Join Date: Nov 2009
Location: NYC
Posts: 337
Thanks!: 1,290
Thanked 283 Times in 123 Posts
Default Re: A simple intervalometer for the N900 (time-lapse photography)

Awesome stuff! Thanks!
Reply With Quote
The Following User Says Thank You to Sopwith For This Useful Post:
  #3  
Old 2009-12-24, 03:20
That One Guy That One Guy is offline
 
Join Date: Dec 2009
Location: US
Posts: 377
Thanks!: 18
Thanked 97 Times in 63 Posts
Default 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")
Reply With Quote
  #4  
Old 2009-12-24, 03:24
fatalsaint fatalsaint is offline
 
Join Date: Jul 2008
Posts: 3,428
Thanks!: 2,609
Thanked 2,856 Times in 1,318 Posts
Default 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
__________________
If I've helped you or you use any of my packages feel free to help me out.
-----------------------------------------------------------------------------------
Maintaining:
pyRadio - Pandora Radio on your N900, N810 or N800!
Reply With Quote
The Following User Says Thank You to fatalsaint For This Useful Post:
  #5  
Old 2009-12-24, 03:26
That One Guy That One Guy is offline
 
Join Date: Dec 2009
Location: US
Posts: 377
Thanks!: 18
Thanked 97 Times in 63 Posts
Default Re: A simple intervalometer for the N900 (time-lapse photography)

D'OH!

Now I feel tEh smart... not.

Thanks Saint.
Reply With Quote
  #6  
Old 2009-12-24, 03:30
That One Guy That One Guy is offline
 
Join Date: Dec 2009
Location: US
Posts: 377
Thanks!: 18
Thanked 97 Times in 63 Posts
Default 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.

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#
Reply With Quote
  #7  
Old 2009-12-24, 03:31
fatalsaint fatalsaint is offline
 
Join Date: Jul 2008
Posts: 3,428
Thanks!: 2,609
Thanked 2,856 Times in 1,318 Posts
Default Re: A simple intervalometer for the N900 (time-lapse photography)

Np. Everyone misses the little things once in a while.
__________________
If I've helped you or you use any of my packages feel free to help me out.
-----------------------------------------------------------------------------------
Maintaining:
pyRadio - Pandora Radio on your N900, N810 or N800!
Reply With Quote
  #8  
Old 2009-12-24, 20:39
Ricardo Ricardo is offline
 
Join Date: Sep 2009
Location: Brazil
Posts: 59
Thanks!: 39
Thanked 71 Times in 16 Posts
Default 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!
Reply With Quote
The Following 19 Users Say Thank You to Ricardo For This Useful Post:
  #9  
Old 2009-12-24, 21:43
That One Guy That One Guy is offline
 
Join Date: Dec 2009
Location: US
Posts: 377
Thanks!: 18
Thanked 97 Times in 63 Posts
Default 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.
Reply With Quote
  #10  
Old 2009-12-27, 02:10
Tinnet Tinnet is offline
 
Join Date: Dec 2009
Posts: 39
Thanks!: 116
Thanked 13 Times in 8 Posts
Default Re: A simple intervalometer for the N900 (time-lapse photography)

This is pretty sweet
Thanks!
Reply With Quote
Reply

Tags
camera, photo


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 17:26.