Skip to content

Commit

Permalink
Merge pull request BVLC#99 from clancyian/master
Browse files Browse the repository at this point in the history
Fix to ignore 255 key as suggested by JimKlingshirn in BVLC#95
  • Loading branch information
yosinski authored Mar 21, 2017
2 parents 78523b8 + 62defa0 commit 479811e
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions live_vis.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@ class LiveVis(object):
def __init__(self, settings):
self.settings = settings
self.bindings = bindings

self.app_classes = OrderedDict()
self.apps = OrderedDict()

for module_path, app_name in settings.installed_apps:
module = importlib.import_module(module_path)
print 'got module', module
Expand All @@ -62,7 +62,7 @@ def __init__(self, settings):
app = app_class(settings, self.bindings)
self.apps[app_name] = app
self.help_mode = False
self.window_name = 'Deep Visualization Toolbox'
self.window_name = 'Deep Visualization Toolbox'
self.quit = False
self.debug_level = 0

Expand All @@ -79,7 +79,7 @@ def __init__(self, settings):
'thick': self.settings.help_thick
}


def init_window(self):
cv2.namedWindow(self.window_name)
max_i, max_j = 0, 0
Expand Down Expand Up @@ -145,7 +145,7 @@ def run_loop(self):
for heartbeat in heartbeat_functions:
#print 'Heartbeat: calling', heartbeat
heartbeat()

# Handle key presses
keys = []
# Collect key presses (multiple if len(range)>1)
Expand All @@ -155,15 +155,16 @@ def run_loop(self):
if key == -1:
break
else:
keys.append(key)
if (key != 255):
keys.append(key)
#print 'Got key:', key
now = time.time()
#print 'Since last:', now - last_render

skip_imshow = False
#if now - last_render > .05 and since_imshow < 1:
# skip_imshow = True

if skip_imshow:
since_imshow += 1
else:
Expand Down Expand Up @@ -267,7 +268,7 @@ def run_loop(self):
app.quit()

print 'Input thread joined and apps quit; exiting run_loop.'

def handle_key_pre_apps(self, key):
tag = self.bindings.get_tag(key)
if tag == 'freeze_cam':
Expand Down Expand Up @@ -321,7 +322,7 @@ def display_frame(self, frame):
def draw_help(self):
self.help_buffer[:] = self.help_buffer[:] * .7
self.help_pane.data[:] = self.help_pane.data[:] * .7

loc = self.settings.help_loc[::-1] # Reverse to OpenCV c,r order
defaults = self.help_pane_defaults
lines = []
Expand Down

0 comments on commit 479811e

Please sign in to comment.