spodzone/timelapse.py — Issue #1: Uncaught Exceptions during processing
Author: jbarratt
Created: 2012-02-23 08:43:54+00:00
State: open

Hello,

I am attempting to use the script in what seems to be the most basic possible use case -- to pre-process a series of `JPEG` files prior to video-izing.

I ran it basically as per the `README`:

```
~/work/timelapse.py/genconfig.py 'img/*.JPG' > movie.json
~/work/timelapse.py/timelapse.py movie.json
```

I'm getting quite a few errors:

```
Exception in thread Thread-1:
Traceback (most recent call last):
File "/usr/local/Cellar/python/2.7.2/lib/python2.7/threading.py", line 552, in __bootstrap_inner
self.run()
File "/usr/local/Cellar/python/2.7.2/lib/python2.7/threading.py", line 505, in run
self.__target(*self.__args, **self.__kwargs)
File "/Users/jbarratt/work/timelapse.py/timeline.py", line 177, in frameAtTime
ac=s.acAtTime(t)
File "/Users/jbarratt/work/timelapse.py/timeline.py", line 142, in acAtTime
factor=float(t-t1)/float(t2-t1)
ZeroDivisionError: float division by zero
```

```
Eeeek! Failed to blend img/IMG_1935.JPG and img/IMG_1936.JPG
Exception in thread Thread-92:
Traceback (most recent call last):
File "/usr/local/Cellar/python/2.7.2/lib/python2.7/threading.py", line 552, in __bootstrap_inner
self.run()
File "/usr/local/Cellar/python/2.7.2/lib/python2.7/threading.py", line 505, in run
self.__target(*self.__args, **self.__kwargs)
File "/Users/jbarratt/work/timelapse.py/timeline.py", line 186, in frameAtTime
result=imageBlur(result, blur)
File "/Users/jbarratt/work/timelapse.py/interpimage.py", line 146, in imageBlur
b=b.filter(ImageFilter.BLUR)
AttributeError: 'NoneType' object has no attribute 'filter'
```

I was able to work around the first (I think?) by just catching the exception:

```
--- a/timeline.py
+++ b/timeline.py
@@ -139,7 +139,10 @@ class Timeline:
idx-=1
t1, t2=s.ac[idx][0], s.ac[idx+1][0]
b1, b2=s.ac[idx][1], s.ac[idx+1][1]
- factor=float(t-t1)/float(t2-t1)
+ try:
+ factor=float(t-t1)/float(t2-t1)
+ except ZeroDivisionError:
+ factor=0
b=float(b1)+float(b2-b1)*factor
return b
```

... but it's unclear if that should be happening at all. (If it thinks the images were taken at the exact same time, which appears to be the case.)

```
Filelist: [ Filename: [img/IMG_1881.JPG]
Gamma: [(1.0, 1.0, 1.0)]
Time: [1329976852.0]

Filename: [img/IMG_1882.JPG]
Gamma: [(1.0, 1.0, 1.0)]
Time: [1329976852.0]

Filename: [img/IMG_1883.JPG]
Gamma: [(1.0, 1.0, 1.0)]
Time: [1329976852.0]

```

... which is odd because `exiftool` shows

```
IMG_1881: Date/Time Original : 2012:02:21 12:36:43
IMG_1882: Date/Time Original : 2012:02:21 12:41:37
IMG_1883: Date/Time Original : 2012:02:21 12:41:47
```

Although if I look at `imageCtime(s)` in `interpimage.py`, my (poor python skills) lead me to believe that will favor the `ctime` rather than falling through and using the EXIF data?

In any case, if you can provide some extra context or help, that would be most appreciated. I found this tool when searching for a collection of the words in your `README` thinking "this technique surely exists, right?" And lo, it did, and it looks amazing.