Michael_O
Posts: 23
Joined: Sat Oct 20, 2012 12:28 pm

Take, save and display photo for 10s, repeat

Wed Oct 29, 2014 12:52 pm

Hi
I have been asked by an artist to assist in projecting video of her while working on a drawing. She doesn't want continuous video but felt a series of images at say 10 second intervals would be good. The ideal would be to take a time-lapse series during the work (about 30 min) and display each one until the next is taken, but the standard timelapse instruction does the exact opposite of this by putting the preview up for the delay time and not showing the captured image at all! I would like to save the images as a numbered series so that they can be made into a slideshow later but this is easy.
My question therefore is: what is the best way to display the most recently acquired image until the next one is available and then to replace it with the latest?
I'm hoping there is a simple way to do this and I am looking at Picamera and Python as the most probable solutions but I can't see how to display and update the image from inside Python.
Any help will be gratefully received!
Michael

il_diavolo
Posts: 137
Joined: Mon Dec 02, 2013 7:56 pm

Re: Take, save and display photo for 10s, repeat

Wed Oct 29, 2014 2:19 pm

I have achieved something very similar using pygame.image.load(imagename.jpg) from Pygame in Python.

jamesh
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 23686
Joined: Sat Jul 30, 2011 7:41 pm

Re: Take, save and display photo for 10s, repeat

Wed Oct 29, 2014 2:46 pm

A short Bash script could do that, using raspistill to take the images, and fbi to display them.
Principal Software Engineer at Raspberry Pi (Trading) Ltd.
Contrary to popular belief, humorous signatures are allowed. Here's an example...
"My grief counseller just died, luckily, he was so good, I didn't care."

Michael_O
Posts: 23
Joined: Sat Oct 20, 2012 12:28 pm

Re: Take, save and display photo for 10s, repeat

Wed Oct 29, 2014 3:45 pm

Thanks James,
that sounds like what I am looking for. I have tried acquiring images with no preview but didn't know how to display them.
First question though, what is fbi and secondly, will I be able to take and save a succession of images with a script while displaying them at the same time? Collecting the images for a later slideshow would be very nice. The artistic work will be accompanied by live music which can easily also be recorded. Combining it with the images later will be easy as there are no synchronisation issues - they just. have to begin and end at approximately the same time.

Michael_O
Posts: 23
Joined: Sat Oct 20, 2012 12:28 pm

Re: Take, save and display photo for 10s, repeat

Wed Oct 29, 2014 4:06 pm

OK, I have located and installed fim which seems to be the latest version of fbi and will work on this but I am new to bash scripting and would still appreciate any help.
Michael

jamesh
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 23686
Joined: Sat Jul 30, 2011 7:41 pm

Re: Take, save and display photo for 10s, repeat

Thu Oct 30, 2014 10:05 am

I've not heard of fim, but fbi can be installed.

sudo apt-et install fbi

Do you need to retain each image, or can you overwrite each one as you go along?

I've been looking at fbi and there doesn't appear to be a timeout option on it. You might need to 'kill' it after the required time. Not sure how to do that in bash, but there is certainly a way.
Principal Software Engineer at Raspberry Pi (Trading) Ltd.
Contrary to popular belief, humorous signatures are allowed. Here's an example...
"My grief counseller just died, luckily, he was so good, I didn't care."

jamesh
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 23686
Joined: Sat Jul 30, 2011 7:41 pm

Re: Take, save and display photo for 10s, repeat

Thu Oct 30, 2014 12:26 pm

Just figured out the fbi timeout stuff

fbi -t 10 -1 [filename]

will display <filename> for 10 seconds then return.
Principal Software Engineer at Raspberry Pi (Trading) Ltd.
Contrary to popular belief, humorous signatures are allowed. Here's an example...
"My grief counseller just died, luckily, he was so good, I didn't care."

Michael_O
Posts: 23
Joined: Sat Oct 20, 2012 12:28 pm

Re: Take, save and display photo for 10s, repeat

Thu Oct 30, 2014 5:25 pm

Hi James

Fim seems to be an improved version of fbi but it's a bit unfinished so I think I'll try fbi in parallel. I have got as far as writing a bash script that will capture an image, call fim to display it for a set number of seconds and then quit.
I do indeed want to retain the images so my next task is to see how to make the script create an incrementing filename and feed it to the raspistill command. I have been reading bash tutorials online but if there is a simple way to do this I would be very pleased to hear of it! If I can create the filename as a variable that I can feed to both raspistill and fim (or fbi) that would obviously be perfect.
I would of course prefer to have each image displayed until the next one is ready but bash is waiting until fim is finished before it will run the next line. Is there a way to make it call a function and go on without waiting (as in DOS batch files). I have been working with cutting the preview time in raspistill to 1 sec but I don't know if this is pushing it on the autoexposure. I have the "no preview" flag set so there is 1 sec blank screen followed by a 10 sec image display in my mark 1 version. That's not too bad but if my "client" thinks it should be updated more often it wouldn't look good.

Michael_O
Posts: 23
Joined: Sat Oct 20, 2012 12:28 pm

Re: Take, save and display photo for 10s, repeat

Mon Nov 03, 2014 5:59 pm

The following script acquires an image using a 1 sec suppressed preview and takes about another second to save it. It then displays the image for 9 sceonds before going around again the value of 60 giving a 10 minute sequence. The {001..60} in the for command uses brace expansion to give leading zeros in the filenames so that they can be combined later with mencoder. The "client" is happy with this.

#!/usr/bin/env bash
clear
for i in {001..60} # to put leading zeros in filenames
do
picname=pic"$i.jpg"
# echo "$picname"
raspistill -n -t 1000 -o $picname -w 1024 -h 768
fim -c 'sleep "9" ;q' -- $picname
done

Return to “Camera board”