def set_objects(self): Builder.load_file("main.kv") self.size = (Window.width, Window.height) self.eyes = Eyes(box=[ self.game_area.x, self.game_area.y + 65, self.game_area.width, self.game_area.height - 175 ]) self.nose = Nose(box=[ self.game_area.x, self.game_area.y + 65, self.game_area.width, self.game_area.height - 175 ]) self.mouth = Mouth(box=[ self.game_area.x, self.game_area.y + 65, self.game_area.width, self.game_area.height - 175 ]) self.game_area.add_widget(self.eyes, index=1) self.eyes.active = True self.game_area.add_widget(self.mouth, index=1) self.mouth.active = True # self.auto_bring_to_front(self.mouth) # nekoja vakva kombinacija da se napravi :) self.game_area.add_widget(self.nose, index=1) self.nose.active = True
def main(args): train_x, train_y, test = make_datasets(path, args.train_size, args.test_size) eyes = Eyes() model = eyes.build_graph() model.summary() plot_model(model, to_file='model.png') tensorboard = TensorBoard(log_dir=args.log_path, histogram_freq=10) earlystop = EarlyStopping(monitor='val_loss', min_delta=0, patience=0, verbose=1, mode='auto') history = model.fit(x=train_x, y=train_y, epochs=args.epochs, verbose=1, batch_size=args.batch_size, validation_split=0.5, callbacks=[earlystop]) model.save_weights(args.save_weights) result = model.predict(test[:10]) imshow(result)
def eyes_py(id): global polePosX, polePosY, dispar, sadws # 初期化宣言 : このソフトウェアは"eyes_py_node"という名前 rospy.init_node('eyes_py_node', anonymous=True) # インスタンスの作成 eyes = Eyes(id) # 処理周期の設定 r = rospy.Rate(PUB_RATE) print("[eyes3] start") # ctl + Cで終了しない限りwhileループで処理し続ける while not rospy.is_shutdown(): #================================================== # Loop ret0, imgL = RP3_Cap_L.read() ret1, imgR = RP3_Cap_R.read() if dispMode == 1: cv2.imshow( "Left Camera", imgL ) cv2.imshow( "Right Camera", imgR ) #-- Create DiparityMap -- disparity = GetDisparityMap() #-- Cal Pole Distance -- capL_target = GetBlueDetect( imgL ) Lx, Ly, Lw, Lh = cv2.boundingRect( capL_target ) capR_target = GetBlueDetect( imgR ) Rx, Ry, Rw, Rh = cv2.boundingRect( capR_target ) # Xは左右中心の更に中心 Lpos = Lx + (Lw / 2) Rpos = Rx + (Rw / 2) polePosX = (Lpos + Rpos) / 2 # Yは片側基準でOK polePosY = Ly + (Lh / 2) # from disparity to dist # Z = f x T / um / disparity poleDist = 6.6 * 62 / 0.003 / disparity[polePosY][polePosX] print polePosX, polePosY, poleDist if dispMode == 1: cv2.rectangle( imgL, (Lx, Ly), (Lx + Lw, Ly + Lh), (0, 0, 255), 1 ) cv2.imshow( "Left Pole", imgL ) cv2.rectangle( imgR, (Rx, Ry), (Rx + Rw, Ry + Rh), (0, 0, 255), 1 ) cv2.imshow( "Right Pole", imgR ) #================================================== # メイン処理 eyes.main() # Sleep処理 r.sleep()
def __init__(self, body, image): self.body = body self.hindbrain = Hindbrain() view_distance = image.get('behaviour', {}).get('target range', 200) self.eyes = Eyes(view_distance=view_distance) self.self_image = image self.parse_behaviour(image.get('behaviour', {})) self.wander_value = 0
def __init__(self, maze, pacman, game_controller): self.CHAR_WIDTH = 100 self.CHAR_HEIGHT = 100 self.maze = maze self.pacman = pacman self.gc = game_controller self.x = maze.WIDTH/2 self.y = maze.TOP_HORIZ self.velocity = 2 self.x_add = self.velocity self.y_add = 0 self.eyes = Eyes() self.looking = (0, 0) self.WIN_PROXIMITY = 80 self.WALL_TOLERANCE = 2
def __init__(self, port=DEFAULT_PORT, logdir='/var/log/xm'): """Creates a new istance of the body. By default it's composed by a thread-safe version of `Legs`, `Mouth` and `Eyes`. Args: port (str): serial port `Legs` will connect to. logdir (str): path where to store logs. """ self.safe_legs = LockAdapter(Legs(port)) eye_log = '{}-eyes.log'.format(str(datetime.date.today())) self.safe_mouth = Mouth() self.safe_eye = Eyes(log=open(os.path.join(logdir, eye_log), 'w')) self.circuits = {} self.add_circuit('forward', target=self.safe_legs.forward, pre=[move_synapse]) self.add_circuit('backward', target=self.safe_legs.backward, pre=[move_synapse]) self.add_circuit('left', target=self.safe_legs.left, pre=[move_synapse]) self.add_circuit('right', target=self.safe_legs.right, pre=[move_synapse]) self.add_circuit('stop', target=self.safe_legs.stop) self.add_circuit('set_speed', target=self.safe_legs.set_speed, pre=[speedvalue_synapse]) self.add_circuit('set_movetime', target=self.safe_legs.set_movetime, pre=[movetime_synapse]) self.add_circuit('say', target=self.safe_mouth.say, pre=[say_synapse]) self.add_circuit('shutup', target=self.safe_mouth.shutup) self.add_circuit('open_eyes', target=self.safe_eye.open) self.add_circuit('close_eyes', target=self.safe_eye.close)
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Face Tracker main application """ # Importing packages from servo import Servo from eyes import Eyes from cv2 import waitKey import time # Create objects camera = Eyes() body = Servo() outX = 90 outY = 90 def translate(x, lowerIn, upperIn, lowerOut, upperOut): """Map in value range to another range""" y = (x - lowerIn) / (upperIn - lowerIn) * (upperOut - lowerOut) + lowerOut return y def millis(): """ Returns current time in milliseconds.""" return int(round(time.time() * 1000))
def capture_action(pred_path, cb, debug=False, log=False): """Facial detection and real time processing credit goes to: https://www.pyimagesearch.com/2017/04/17/real-time-facial-landmark-detection-opencv-python-dlib/ """ action_handler = ActionHandler() detector = dlib.get_frontal_face_detector() predictor = dlib.shape_predictor(pred_path) camera = cv2.VideoCapture(0) while True: _, frame = camera.read() if frame is None: continue _, w_original, _ = frame.shape frame = resize_frame(frame) h, w, _ = frame.shape display_bounds(frame) gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY) rects = detector(gray, 0) for rect in rects: shape = predictor(gray, rect) shape = face_utils.shape_to_np(shape) cur_head = Head(shape, w) cur_eyes = Eyes(shape, frame) eye_action = detect_eyes(shape, cur_eyes) head_action = detect_head(shape, cur_head) COUNTER_LOG[eye_action] += 1 COUNTER_LOG[head_action] += 1 perform, action = action_handler.get_next(eye_action, head_action) if log: display_decisions(frame, head_action, eye_action) display_counters(frame, COUNTER_LOG) if perform: COUNTER_LOG[action] += 1 cb(action) if debug: cur_head.debug(frame) cur_eyes.debug(frame) cv2.imshow("Frame", frame) key = cv2.waitKey(1) & 0xFF if key == ord("q"): break cv2.destroyAllWindows()
# Drawing stuff font = cv2.FONT_HERSHEY_SIMPLEX # Wait until user specifies windows dimensions while len(mouseevents.clicked_positions) < 2: pass # Load settings with open('settings.json', 'r') as f: SETTINGS = json.load(f) # ROI for game window ROI_GAME = get_roi_from_mouse(mouseevents.clicked_positions) # Our eyes for the game eye = Eyes(ROI_GAME, SETTINGS) eye.tune_roi() # Extra print('[!] Calibration complete') print('[!] Loading model') # Loading trained model with open('model.pkl', 'rb') as fid: clf = cPickle.load(fid) print('[!] Loaded model') print('[!] Press "q" to quit') print('[.] Please get ready') print('[!] Press "c" to continue') while not keyevents.pressed_c:
def eyes_py(id): global sidebudsPosX, sidebudsPosY, dispar, sadws # 初期化宣言 : このソフトウェアは"eyes_py_node"という名前 rospy.init_node('eyes_py_node', anonymous=True) # インスタンスの作成 eyes = Eyes(id) # 処理周期の設定 r = rospy.Rate(PUB_RATE) print("[eyes2] start") # ctl + Cで終了しない限りwhileループで処理し続ける while not rospy.is_shutdown(): #================================================== # Loop ret0, imgL = RP3_Cap_L.read() ret1, imgR = RP3_Cap_R.read() if dispMode == 1: cv2.imshow("Left Camera", imgL) cv2.imshow("Right Camera", imgR) #-- Create DiparityMap -- disparity = GetDisparityMap() ################################################### #-- Look for SideBuds -- sbsJpg = cv2.imread('./SideBuds_1.JPG', 0) grayImg = cv2.cvtColor(imgL, cv2.COLOR_BGR2GRAY) result = cv2.matchTemplate(grayImg, sbsJpg, cv2.TM_CCOEFF_NORMED) unused_minVal, unused_maxVal, unused_minLoc, maxLoc = cv2.minMaxLoc( result) top_left = maxLoc w, h = sbsJpg.shape[::-1] bottom_right = (top_left[0] + w, top_left[1] + h) if dispMode == 1: cv2.rectangle(imgL, top_left, bottom_right, (0, 255, 0), 1) cv2.imshow("SideBuds", imgL) sidebudsPosX = top_left[0] + (w / 2) sidebudsPosY = top_left[1] + (h / 2) #-- Cal SideBuds Distance -- sidebudsPosDist = 6.6 * 62 / 0.003 / disparity[sidebudsPosY][ sidebudsPosX] print sidebudsPosX, sidebudsPosY, sidebudsPosDist ################################################### #-- Cal weed Center -- targetL = GetGreenDetect(imgL) targetR = GetGreenDetect(imgR) # target Position Lx, Ly, Lw, Lh = cv2.boundingRect(targetL) Rx, Ry, Rw, Rh = cv2.boundingRect(targetR) if dispMode == 1: cv2.rectangle(imgL, (Lx, Ly), (Lx + Lw, Ly + Lh), (0, 0, 255), 1) cv2.imshow("Weed L", imgL) cv2.rectangle(imgR, (Rx, Ry), (Rx + Rw, Ry + Rh), (0, 0, 255), 1) cv2.imshow("Weed R", imgR) # Xは左右中心の更に中心 Lpos = Lx + (Lw / 2) Rpos = Rx + (Rw / 2) weedPosX = (Lpos + Rpos) / 2 # Yは片側基準でOK weedPosY = Ly + (Lh / 2) # from disparity to dist # Z = f x T / um / disparity weedPosDist = 6.6 * 62 / 0.003 / disparity[weedPosY][weedPosX] print weedPosX, weedPosY, weedPosDist #================================================== # メイン処理 eyes.main() # Sleep処理 r.sleep()
keyevents.start() mouseevents.start() # Wait until user specifies windows dimensions while len(mouseevents.clicked_positions) < 2: pass # Load settings with open('settings.json', 'r') as f: SETTINGS = json.load(f) # ROI for game window ROI_GAME = get_roi_from_mouse(mouseevents.clicked_positions) # Our eyes for the game eye = Eyes(ROI_GAME, SETTINGS, preview=True) eye.tune_roi() # Extra ubfi print('[!] Calibration complete') print('[!] Press "q" to quit') print('[.] Please get ready') # Time for user to get anything ready print('[!] Press "c" to continue') while not keyevents.pressed_c: pass print('[!] Starting...') keyevents.end = False
from eyes import Eyes import pprint e = Eyes() e.auth() e.searchProcesso("5002074-02.2015.404.7005") # e.acessarIntegra() # e.exibirTodosEventos() # print(e.getAdicionais()) # teste = e.getCapa() # print(teste) # e.getAssuntos() # print(e.getPartes()) # eventos = e.getEventos() # pprint.pprint(eventos) # for ev in eventos: # # pprint.pprint(ev['documentos']) # if ev['documentos']: # for doc in ev['documentos']: # if doc['tipo'] == 'html': # e.download_html(doc['url'], doc['nome']) # elif doc['tipo'] == 'pdf': # e.download_pdf(doc['url'], doc['nome']) # input("Press Enter to continue...") # # doc[] e.close()
#!/usr/bin/env python3 from datetime import datetime from models import * from eyes import Eyes from minerador import Minerador import os import time eyes = Eyes(True) eyes.auth() miner = Minerador(eyes) reauth_in = 10 aux_reauth = 1 processos = Processo.select().where(Processo.data_autuacao == None) for processo in processos.iterator(database): sigilo = True print('{} Obtendo {}'.format(datetime.now(), processo.numero)) try: miner.get_processo(processo.numero) data = miner.get_data() miner.get_files(data['eventos']) except Exception as e: print('Falha ao obter dados do processo: {} \n e: {}'.format( processo.numero, str(e))) eyes.takeSs() print('Screenshot salva') continue try: for k, v in data['adicionais'].items():
def test_constructor(): """Test Eyes constructor""" es = Eyes() assert es.left_eye.direction == es.right_eye.direction == (0, 0)
# -*- coding: UTF-8 -*- from eyes import Eyes eyes = Eyes() while True: # 普通 eyes.set_nomal() # 怒り for level in range(1,11,1): eyes.set_anger(level) for level in range(10,0,-1): eyes.set_anger(level) # 普通 eyes.set_nomal() # 驚き for level in range(5,0,-1): eyes.set_surprized(level) for level in range(1,6,1): eyes.set_surprized(level)