Permalink
Browse files

Add a real time display of the data and guess.

  • Loading branch information...
ali1234 committed Oct 25, 2012
1 parent ce01f73 commit 9b4064f098de4e9cae17055da5e4fa2c1b52aad8
Showing with 81 additions and 0 deletions.
  1. +5 −0 bruteforce.py
  2. +76 −0 guessview.py
View
@@ -29,6 +29,8 @@
import printer
from vbi import Vbi
+import guessview
+
def process_file(filename):
ans = []
try:
@@ -41,10 +43,12 @@ def process_file(filename):
for th in np.arange(2.1,2.4,0.05):
for g in np.arange(1.1,5.2,1.0):
for go in np.arange(1.1,5.2,1.0):
+ #thresh_low=1.15 thresh_high=2.10 gauss_sd=1.10 gauss_sd_offset=1.10
v = Vbi(vbiraw, thresh_low=tl, thresh_high=th, gauss_sd=g, gauss_sd_offset=go)
tmp = v.find_offset_and_scale()
if tmp:
packet = v.deconvolve()
+ guessview.draw(vbiraw, v.g.convolved*256)
print printer.do_print(packet), "thresh_low=%1.2f thresh_high=%1.2f gauss_sd=%1.2f gauss_sd_offset=%1.2f" % (tl, th, g, go)
else:
packet = None
@@ -57,6 +61,7 @@ def process_file(filename):
if __name__ == '__main__':
+ guessview.main()
#do_file('data/0022/vbi/00171104.vbi')
process_file(sys.argv[1])
View
@@ -0,0 +1,76 @@
+#!/usr/bin/env python
+
+import os, random
+from math import sin,cos,pi,floor
+from OpenGL.GL import *
+from OpenGL.GLU import *
+import pygame, pygame.image, pygame.key
+from pygame.locals import *
+
+w = 1600
+h = 128
+
+def resize((width, height)):
+ if height==0:
+ height=1.0
+ glViewport(0, 0, width, height)
+ glMatrixMode(GL_PROJECTION)
+ glLoadIdentity()
+ gluOrtho2D(0, 2048, 0, 256)
+# gluOrtho2D(-(width/(2*height)), width/(2*height), 0, 1)
+ glMatrixMode(GL_MODELVIEW)
+ glLoadIdentity()
+
+def init():
+ glShadeModel(GL_SMOOTH)
+ glClearColor(1.0, 1.0, 1.0, 0.0)
+ glClearDepth(1.0)
+ glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT )
+ glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST)
+ glDisable(GL_DEPTH_TEST)
+
+def main():
+
+ video_flags = OPENGL|DOUBLEBUF
+
+ pygame.init()
+ surface = pygame.display.set_mode((w,h), video_flags)
+ pygame.key.set_repeat(100,30)
+
+ resize((w,h))
+ init()
+
+
+def draw(data, guess):
+ glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT )
+ glMatrixMode(GL_MODELVIEW)
+ glLoadIdentity()
+
+ glColor4f(1.0,0.0,0.0,1.0)
+ glBegin(GL_LINE_STRIP)
+ for n in range(2048):
+ glVertex2f(n, data[n])
+ glEnd()
+
+ glColor4f(0.0,0.5,0.0,1.0)
+ glBegin(GL_LINE_STRIP)
+ for n in range(2048):
+ glVertex2f(n, guess[n])
+ glEnd()
+
+
+ pygame.display.flip()
+
+
+
+# encode with:
+# transcode --use_rgb -i output.raw -x raw=RGB,null -y xvid4 -o output.xvid.avi -k -z -f 50
+# (for xvid)
+
+# video format looks like:
+# pixel { byte r,g,b }; // 24 bit
+# line { pixel[720] }; // left to right
+# frame { line[576] }; // bottom to top
+# video { frame[n] }; // n frames
+
+if __name__ == '__main__': main()

0 comments on commit 9b4064f

Please sign in to comment.