Didier Stevens

Monday 29 June 2009

Quickpost: Time Lapse Photography With a Nokia Mobile

Filed under: Hardware,My Software,Quickpost — Didier Stevens @ 2:20

Did you know Nokia mobile phones with the S60 platform can be programmed in Python? During my last holiday, I wrote a small program for time lapse photography with my mobile. Here is the result, showing tidal ebbs and flows in Saint-Vaast-la-Hogue and Cancale:

This is the Python program I wrote to take a picture every minute:

#!/usr/bin/python

__description__ = 'Tool to take pictures with a Nokia phone at regular intervals'
__author__ = 'Didier Stevens'
__version__ = '0.1.1'
__date__ = '2009/06/22'

"""

Source code put in public domain by Didier Stevens, no Copyright
https://DidierStevens.com
Use at your own risk

History:
 2009/06/17: start
 2009/06/22: refactoring

Todo:
 Get Threading to work
"""

import camera
import time
import os

timelapseFolder = 'e:\\timelapse\\'
sleepTime = 57

def TakeAndSavePicture():
    global timelapseFolder

    now = '%04d%02d%02d-%02d%02d%02d' % time.localtime()[0:6]
    pic = camera.take_photo()
    pic.save(os.path.join(timelapseFolder, now, '.jpeg'))
    print 'Picture taken: %s' % now

def Main():
    global timelapseFolder
    global sleepTime

    print 'Timelapse photography started'
    if not os.path.isdir(timelapseFolder):
        os.mkdir(timelapseFolder)
        print 'Timelapse folder created: %s' % timelapseFolder
    print 'Wait between pictures %d' % sleepTime
    while True:
        TakeAndSavePicture()
        time.sleep(sleepTime)

if __name__ == '__main__':
    Main()

And then I use Avisynth to combine the jpeg pictures in a movie like this (I join pictures 00001.jpg through 00197.jpeg, 5 per second and produce a 25 fps movie):

ImageSource("%05d.jpeg", 1, 197, 5).ChangeFPS(25)

Quickpost info


24 Comments »

  1. […] Store for application and extension treats, the more hardcore can simply write their own apps, likeDidier Stevensdid recently. He scribed a simple time lapse photography python script which does exactly what it […]

    Pingback by nokia - 61th Edition — Monday 29 June 2009 @ 13:17

  2. Fantastic.! Would you mind sharing your python script, i would love to try it out for myself.

    Comment by Micky — Monday 29 June 2009 @ 14:58

  3. @Micky The script is included in the post. Let me know if you need more help.

    Comment by Didier Stevens — Monday 29 June 2009 @ 18:43

  4. […] con S60 possono far girare agevolmente applicazioni scritte in Python. Didier Stevens ne ha scritta una che scatta foto in time […]

    Pingback by Un video con immagini in time lapse su S60 con Python | Archivio blog KiAmaNokia - Il blog dei Nokia lovers — Tuesday 30 June 2009 @ 2:15

  5. @Didier, I soo the script, but I don’t know how to install it onto my Nokia. I was looking for a .sis or .sisx file maybe.?

    Comment by Micky — Tuesday 30 June 2009 @ 3:44

  6. @Micky. OK, I understand you now. First you have to install Python for S60 on your Nokia, this comes as a .SIS file (read first link in my post).
    This installation will also create a Python directory on your Nokia with example programs (like ball.py).
    Then save my Python script as timelapse.py in that Python directory.
    Start the Python for S60 application, select Options/Run Script and select timelapse.py

    When timelapse.py runs on my Nokia, the screen doesn’t get updated, and it’s unresponsive. But the script is taking pictures. Using the cancel button I can stop the Python script, but it can take up to a minute before I get control back.
    The script runs indefinitely, until you stop it or you run out of power and the camera gets disabled to save power.

    Comment by Didier Stevens — Tuesday 30 June 2009 @ 6:22

  7. Ok, thanks, I will give it a shot.

    Regards

    Micky

    Comment by Micky — Tuesday 30 June 2009 @ 6:33

  8. Where to download this file?

    Comment by Roman — Wednesday 1 July 2009 @ 9:29

  9. Just copy and paste it from the post, it’s so small I did not host the file. Let me know if you’ve problems with the copy-paste, I’ll send you a copy then.

    Comment by Didier Stevens — Wednesday 1 July 2009 @ 17:30

  10. Thanks for Your work!
    Unfortunately I get an Error after hearing the shutter of the Camera:
    SymbianError: [Errno -12]
    KErrPathNotFound

    Can you tell me what I’m doing wrong?

    Comment by Mike — Wednesday 8 July 2009 @ 19:39

  11. Do you know if the following message was printed when you started the program:

    Timelapse folder created: e:\timelapse\

    Maybe you don’t have an e: drive on your mobile?

    Comment by Didier Stevens — Wednesday 8 July 2009 @ 19:45

  12. Just to show stop-motion is far from dead … http://vimeo.com/3114617?hd=1

    Comment by Joris — Wednesday 15 July 2009 @ 21:51

  13. […] Quickpost: More Picture-Taking with Python Filed under: Hardware, My Software, Quickpost — Didier Stevens @ 9:24 Per @TimelessP’s request, here’s so more Python code that can be used for time-lapse photography. […]

    Pingback by Quickpost: More Picture-Taking with Python « Didier Stevens — Tuesday 21 July 2009 @ 9:25

  14. I had the same problem than #10.
    new folder is created.

    Help please

    Comment by jonn — Wednesday 12 August 2009 @ 15:38

  15. Same as 14.

    Which version of Python are you using?
    I tried PythonForS60_1_4_5_3rdEd.sis with PythonScriptShell_1_4_5_3rdEd.SIS

    thanks

    Comment by fozzillo — Friday 14 August 2009 @ 13:54

  16. I have 1.4.5 final I’ll e-mail you for some tests.

    Comment by Didier Stevens — Thursday 20 August 2009 @ 6:43

  17. […] Update — Didier Stevens @ 14:51 I’ve debugged the issues some people had with my Nokia time lapse Python script, you can find a new version here. Leave a […]

    Pingback by Update: Time Lapse Photography with a Nokia Mobile « Didier Stevens — Friday 21 August 2009 @ 14:51

  18. For those experiencing issues with the code, take a look here at the new version: https://blog.didierstevens.com/2009/08/21/update-time-lapse-photography-with-a-nokia-mobile/

    Comment by Didier Stevens — Friday 21 August 2009 @ 14:56

  19. YES!

    Updated version 0.1.2 works on my 5800!

    Good job!

    Thank you very much.

    P.S.
    Pictures are taken in 640×480, would be great to have higher resolutions, maybe with a parameter to edit inside the script (no dialog) if you can.

    Comment by Fozzillo — Saturday 29 August 2009 @ 17:44

  20. I’ll put that in the todo list

    Comment by Didier Stevens — Sunday 30 August 2009 @ 19:24

  21. I came across this the other day added some code to allow selection of delay and resolution (based on another script I found online):

    ….

    import appuifw
    import camera
    import time
    import os

    sleepTime = appuifw.query(u”Enter time between each photo:”, “number”)
    imageSizesDisplay = [u’2048,1536′,u’1600,1200′,u’1152,864′,u’640,480′]
    imageSizes = [(2048,1536),(1600,1200),(1152,864),(640,480)]

    imageSizeSelect = appuifw.selection_list(choices=imageSizesDisplay)

    timelapseFolder = ‘E:\\timelapse\\’

    def TakeAndSavePicture():
    global timelapseFolder

    now = ‘%04d%02d%02d-%02d%02d%02d’ % time.localtime()[0:6]
    pic = camera.take_photo (size=imageSizes[imageSizeSelect])
    filename = os.path.join(timelapseFolder, now) + ‘.jpeg’
    pic.save(filename)
    print ‘Picture taken: %s’ % now
    print ‘File: %s’ % filename

    ….

    For some reason I had to have the “E:” in caps to avoid the “SymbianError: [Errno -12] KErrPathNotFound” mentioned above
    the code i added was from this post: http://blog.umlungu.co.uk/blog/2007/jan/21/python-s60-time-lapse-photography-using-nokia-n80/

    Comment by Milo — Saturday 27 March 2010 @ 0:33

  22. @Milo Thanks!

    Comment by Didier Stevens — Saturday 27 March 2010 @ 10:18

  23. Thanks for the script, Works great!!
    isn’t it possible to create a similar script for auto exposure bracketing (AEB), to create HDR Images?

    Comment by Kodex — Thursday 3 February 2011 @ 1:57

  24. @Kodex I don’t have that feature on my Nokia.

    Comment by Didier Stevens — Friday 4 February 2011 @ 7:07


RSS feed for comments on this post. TrackBack URI

Leave a Reply (comments are moderated)

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Blog at WordPress.com.