Hakan Ardo avatar Hakan Ardo committed 1c0e3f5

part2 back

Comments (0)

Files changed (3)

talk/dls2012/demo/analytics.py

         #view(self.background.image)
         #view(255 * fg)
 
+

talk/dls2012/demo/demo.py

         raise SkipToEnd
 
 def demo(skip1=False):
-    if not skip1:
-        with open('analytics.py', 'w') as fd:
+    with open('analytics.py', 'w') as fd:
+        if not skip1:
             print >>fd, """
 from reloader import ReloadHack
 from io import view
     def update(self, frame):
         view(frame)
 """
+        else:
+            print >>fd, """
+from reloader import ReloadHack
+from io import view
+from background import Background
+from foreground import foreground
+from detect import find_objects
+
+class Tracker(ReloadHack):
+    def __init__(self):
+        self.background = Background()
+
+    def update(self, frame):
+        self.background.update(frame)
+        fg = foreground(frame, self.background.image)
+        find_objects(fg)
+        #view(self.background.image)
+        view(255 * fg)
+
+"""
+
     vim = Vim('analytics.py')
+    time.sleep(0.1)
     vim.send('<ESC>:winpos 0 30<CR>:winsize 75 30<CR>')
     time.sleep(0.5)
     runner = Popen([sys.executable, 'run.py', 'demo.avi'])
     pause("That's a bit slow, but this operation is separable, let's see\n"+
           "if it is faster with two passes.")
     vim.send(':e detect.py<CR>')
-    vim.type('7ggix<ESC>9ggix<ESC>jddOfor dx in xrange(-r, r+1):<ESC>')
+    vim.type('7ggix<ESC>9ggix<ESC>jddkofor dx in xrange(-r, r+1):<ESC>')
     vim.type('11ggix<ESC>9wix<ESC>13wxxx', 0.2)
     vim.type('VkkkkyP5jx', 0.2)
     vim.type('14ggx7wcwxres<ESC>')
     vim.type('51ggA.labels<ESC>:w<CR>')
 
     pause("It still seems to work as before. Now lets add the second pass")
-    vim.type('O<CR><BS><BS>for x, y in reversed(seg.indexes()):<CR>if seg[x, y]:<CR>ll = [labels[x, y], labels[x+1, y], labels[x-1, y+1],<CR>labels[x, y+1], labels[x+1, y+1]]<CR>labels.update(x, y, ll)<CR><ESC>:w<CR>', 0.01)
+    vim.type('O<ESC>jOfor x, y in reversed(seg.indexes()):<CR>if seg[x, y]:<CR>ll = [labels[x, y], labels[x+1, y], labels[x-1, y+1],<CR>labels[x, y+1], labels[x+1, y+1]]<CR>labels.update(x, y, ll)<CR><ESC>:w<CR>', 0.01)
 
     pause("That's starting to look good, but in complicated cases we can still\n" + 
           "get multiple lables per segment, so we need to repeat until convergance")
     vim.type('56ggVkkkkkkkkkk', 0.2)
     vim.send('>')
-    vim.type('Owhile not labels.done:<CR>labels.done = True<ESC>')
+    vim.type('kowhile not labels.done:<CR>labels.done = True<ESC>')
     vim.type('28ggoself.done = False<ESC>')
-    vim.type('43gg39ggO<BS>if self.labels[x, y] != l:<CR>self.done = False<ESC>:w<CR>')
+    vim.type('43gg39ggOif self.labels[x, y] != l:<CR>self.done = False<ESC>:w<CR>')
 
     pause("As a final touch, lets renumber the labels be consecutative\n" + 
           "integers.")

talk/dls2012/demo/detect.py

         for x, y in seg.indexes():
             if seg[x, y]:
                 ll = [labels[x, y], labels[x-1, y], labels[x-1, y-1],
-                      labels[x, y-1], labels[x+1, y-1]]
+                        labels[x, y-1], labels[x+1, y-1]]
                 labels.update(x, y, ll)
 
         for x, y in reversed(seg.indexes()):
             if seg[x, y]:
                 ll = [labels[x, y], labels[x+1, y], labels[x-1, y+1],
-                      labels[x, y+1], labels[x+1, y+1]]
+                        labels[x, y+1], labels[x+1, y+1]]
                 labels.update(x, y, ll)
 
     labels.renumber()
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.