本文整理汇总了Python中gui.Gui.redraw_elements方法的典型用法代码示例。如果您正苦于以下问题:Python Gui.redraw_elements方法的具体用法?Python Gui.redraw_elements怎么用?Python Gui.redraw_elements使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gui.Gui
的用法示例。
在下文中一共展示了Gui.redraw_elements方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Recorder
# 需要导入模块: from gui import Gui [as 别名]
# 或者: from gui.Gui import redraw_elements [as 别名]
#.........这里部分代码省略.........
'bottom': Color(0, 0, 255)
}
self.gui.draw_line(real_mean.x, real_mean.y, added.x, added.y, stroke_color = colors[border_name])
self.gui.draw_circle((real_mean.x, real_mean.y), 5, stroke_color = colors[border_name])
corners = {}
# Calculate corners from border intersections
for border1, border2 in [('top', 'left'), ('top', 'right'), ('bottom', 'left'), ('bottom', 'right')]:
o1 = borders[border1]['real_mean']
d1 = borders[border1]['direction_mean']
o2 = borders[border2]['real_mean']
d2 = borders[border2]['direction_mean']
corner = V.intersection(o1, d1, o2, d2)
if not corner:
self.gui.update()
return
print corner
corners[border1+"_"+border2] = corner
self.gui.draw_circle((corner.x, corner.y), 10, Color(255, 0, 255))
print corners
# Calculate transformation matrix
self.gui.calibration_matrix = calibration.calibration_transformation_matrix(width, height, self.gui.width, self.gui.height, corners)
m = self.gui.calibration_matrix
b = corners['top_left']
p = m[b.y+10][b.x+10]
self.gui.draw_circle((p.x, p.y), 3, stroke_color = Color(0,1,0))
b = corners['top_right']
p = m[b.y+10][b.x-10]
self.gui.draw_circle((p.x, p.y), 3, stroke_color = Color(0,1,0))
b = corners['bottom_left']
p = m[b.y-10][b.x+10]
self.gui.draw_circle((p.x, p.y), 3, stroke_color = Color(0,1,0))
b = corners['bottom_right']
p = m[b.y-10][b.x-10]
self.gui.draw_circle((p.x, p.y), 3, stroke_color = Color(0,1,0))
self.gui.update()
print "Calibration successful."
def handle_custom_event(self, event):
""" Child classes can override this to do additional event handling. """
pass
def handle_events(self):
# Handle Api events
while self.ser.inWaiting():
if self.ser.readline().strip() == 'press':
print "saving video"
self.save_buffer_to_video()
# Check on subprocesses
still_running = []
for p in self.encoding_subprocesses:
print p.poll()
if p.poll() is None:
still_running.append(p)
self.encoding_subprocesses = still_running
if not self.encoding_subprocesses and datetime.datetime.now() - self.encoding_started > datetime.timedelta(seconds=1):
self.stop_encoding_animation()
# Handle Api events
with self.api_lock:
for event in self.api.events:
if event == "save":
recorder.save_buffer_to_video()
elif event == "quit":
self.keep_running = False
self.api.events = []
if self.gui:
event = self.gui.process_events()
if event.key == 'c':
self.calibrate()
self.gui.redraw_elements()
elif event.key == 'p':
self.keep_running = False
elif event.key == 'f':
matrix = numpy.zeros((640, 480))
matrix[150:160, 150:160] = 1
self.gui.trigger_event_matrix(matrix, event_type="mouse_move")
else:
self.handle_custom_event(event)
def debugging_output(self, frame):
if DEBUG:
print "Buffer index: %s" % self.buffer_index
if SHOW_WINDOW:
cv2.imshow("preview", frame)
def capture_frame(self, as_array=True):
raise NotImplementedError()
def handle_frame(self, *args, **kwargs):
raise NotImplementedError()
def start(self):
raise NotImplementedError()