Commits

Hakan Ardo  committed 4c815eb

stage 3

  • Participants
  • Parent commits eedcfe0

Comments (0)

Files changed (4)

File talk/dls2012/demo/fgbg.py

+from reloader import ReloadHack
+
+@ReloadHack
+def background(video):
+    bkg = fcnt = 0
+    for img in video:
+        bkg = (fcnt * bkg + img) / (fcnt + 1)
+        fcnt += 1
+        fg = ((bkg - img) ** 2) > 40
+        #yield img
+        yield fg * 255
+    
+    

File talk/dls2012/demo/image.py

     __sub__ = binop(float.__sub__)
     __mul__ = binop(float.__mul__)
     __div__ = binop(float.__div__)
+    __pow__ = binop(float.__pow__)
 
     __radd__ = binop(float.__radd__)
     __rsub__ = binop(float.__rsub__)
     __rmul__ = binop(float.__rmul__)
     __rdiv__ = binop(float.__rdiv__)
+    __rpow__ = binop(float.__rpow__)
 
     __lt__ = binop(float.__lt__)
     __le__ = binop(float.__le__)

File talk/dls2012/demo/process.py

 from reloader import ReloadHack
+from fgbg import background
 
 @ReloadHack
 def process(video):
-    for img in video:
-        yield img * 2 
+    bkg = background(video)
+    for img in bkg:
+        yield img 
 
 

File talk/dls2012/demo/reloader.py

                                 reload(self.module)
                                 self.iterator_class = getattr(self.module, self.name).iterator_class
                                 obj = iter(self.iterator_class(*args, **kwargs))
+                                halted = False
                         except Exception as e:
                             print
                             traceback.print_exc()
                         else:
-                            break
-                yield obj.next()
+                            if not halted:
+                                break
+                try:
+                    yield obj.next()
+                except Exception as e:
+                    print
+                    traceback.print_exc()
+                    halted = True
+
 
         return wrapper()