Active Topics

 


Reply
Thread Tools
Posts: 59 | Thanked: 71 times | Joined on Sep 2009 @ Brazil
#1
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
 

The Following 26 Users Say Thank You to Ricardo For This Useful Post:
Sopwith's Avatar
Posts: 337 | Thanked: 283 times | Joined on Nov 2009 @ NYC
#2
Awesome stuff! Thanks!
 

The Following User Says Thank You to Sopwith For This Useful Post:
Posts: 377 | Thanked: 97 times | Joined on Dec 2009 @ US
#3
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")
 
Posts: 3,428 | Thanked: 2,856 times | Joined on Jul 2008
#4
Yes you are. This is a perl script, not a shell script.

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!
 

The Following User Says Thank You to fatalsaint For This Useful Post:
Posts: 377 | Thanked: 97 times | Joined on Dec 2009 @ US
#5
D'OH!

Now I feel tEh smart... not.

Thanks Saint.
 
Posts: 377 | Thanked: 97 times | Joined on Dec 2009 @ US
#6
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#
 
Posts: 3,428 | Thanked: 2,856 times | Joined on Jul 2008
#7
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!
 
Posts: 59 | Thanked: 71 times | Joined on Sep 2009 @ Brazil
#8
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!
 

The Following 19 Users Say Thank You to Ricardo For This Useful Post:
Posts: 377 | Thanked: 97 times | Joined on Dec 2009 @ US
#9
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.
 
Posts: 39 | Thanked: 13 times | Joined on Dec 2009
#10
This is pretty sweet
Thanks!
 
Reply

Tags
camera, photo


 
Forum Jump


All times are GMT. The time now is 14:21.