def __init__(self, source=0): self.cap = Capture(source) # Input instance: # def. source == 0 (webcamera) self.out = Output() self.height = self.cap.height # Frame height self.width = self.cap.width # Frame width self.output_img_height = self.height * 2 self.output_img_width = self.output_img_height self.output_img_centre_x = self.height self.output_img_centre_y = self.height self.fps = self.cap.fps self.ORD_DICT = {'q':ord('q'), \ 'f':ord('f'), \ 'o':ord('o'), \ 'r':ord('r'), \ 'p':ord('p'), \ 'm':ord('m')} self.grab_cut = GrabCut(self.height, self.width) self.face_ex = None self.pos = {} # Dict with trackbars values self.pos['m_cntr'] = 0 # Centre of the mask in output_img self.pos['m_btm'] = 1 # Mask bottom corner position self.pos['m_side'] = 1.5 # Mask side corners pos self.pos['m_y_offset'] = 1 # Offset ratio of y mask coord. self.pos['i_x'] = int(self.width / 2) # frame x pos self.pos['i_y'] = int(self.height / 2) # frame y pos self.pos['scale'] = 1 # frame scale factor self.pos['loop_video'] = 1 # on/off self.pos['tracking_on'] = 0 # FaceTracking on/off self.pos['gc_iters'] = 0 # GrabCut iterations self.pos['contrast'] = 1 # contrast adj. self.pos['brightness'] = 0 # brightness adj. self.gui = Gui(self.height, self.width, self.pos) # GUI instance self.counter = 0 # Frame counter
def test_draw_world_in_gui(self): world = World({ Cell(0, 0, 'A'), Cell(0, 0, 'B'), Cell(0, 0, 'C'), Cell(0, 0, 'D'), }) gui = Gui() gui.set_args(0, 0, 10, 10) gui.draw(world)
Cell(4, 5, 'C'), Cell(4, 4, 'C'), Cell(2, 4, 'C'), Cell(3, 4, 'C'), Cell(-1, -1, 'A'), Cell(-2, -1, 'A'), Cell(0, -1, 'A'), Cell(-3, -1, 'D'), Cell(-4, -1, 'D'), Cell(-5, -1, 'D'), Cell(-6, -1, 'D'), # Cell(-0, -5, 'A'), # Cell(-7, -1, 'A'), }) gui = Gui(20) class Application(tk.Frame): def __init__(self, master=None): super().__init__(master) self.master = master self.pack() self.create_widgets() def create_widgets(self): # self.hi_there = tk.Button(self) # self.hi_there["text"] = "Hello World\n(click me)" # self.hi_there["command"] = self.say_hi # self.hi_there.pack(side="top")
def test_set_arggs_method(self): world = World() gui = Gui() gui.set_args(0, 0, 10, 10)