def set_camera(self, camera=Camera()): if camera == None: camera = Camera() crp = camera.o.dup().add(camera.right, 0.1) crf = camera.focus.dup().add(camera.right, 0.1) clp = camera.o.dup().add(camera.right, -0.1) clf = camera.focus.dup().add(camera.right, -0.1) self.camera_r = camera.dup().set_focus(crf).set_position(crp) self.camera_l = camera.dup().set_focus(clf).set_position(clp) return self
def main(): cam1 = Camera(0, 0, 0, 0, False, "RED2") cam2 = Camera(0, 0, 0, 0, False, "RED6") camList = [] thread1 = NetworkThread("", 8091, cam1) thread2 = NetworkThread("", 8092, cam2) thread1.start() # This actually causes the thread to run thread2.start() thread1.join() thread2.join() # This waits until the thread has completed # At this point, both threads have completed print("Done")
def __init__(self): self._robot = RobotControl(robotName=ROBOT_NAME, dof=DOF) self._world = WorldControl() self._pin_hole_left_cam = Camera( rgbImageTopic=PIN_HOLE_LEFT_CAMERA_TOPIC) self._pin_hole_right_cam = Camera( rgbImageTopic=PIN_HOLE_RIGHT_CAMERA_TOPIC) self._inspected_pin_leads_in_cameras = None self._board_pose_mm_deg = None self._robot_init_pose_mm_deg = None self._left_pin_lead_pose_init_mm_deg = None self._right_pin_lead_pose_init_mm_deg = None
def main(): """ Data Collector class """ description = "Class for data collection using a camera and a remote controlled robot car connected to USB" parser = argparse.ArgumentParser(description=description) parser.add_argument('-n', '--folder_name', default='pista', type=str, help='name of the folder that the generated collection will be saved (default=pista)') parser.add_argument('-he', '--height', default=120, type=int, help='height of the image (default=120)') parser.add_argument('-w', '--width', default=160, type=int, help='width of the image (default=160)') parser.add_argument('-cam', '--cam_device', default=0, type=int, help='ID of the recording camera (default=0)') user_args = parser.parse_args() camera = Camera(user_args.height, user_args.width, user_args.cam_device) raise_exception = False try: brick = next(USBInterface.find_bricks(debug=False)) brick.connect() except StopIteration: raise_exception = True assert raise_exception==0, "No NXT found..." dc = DataCollector(camera, brick, user_args.folder_name) dc.generate_data()
def __init__(self, engine, songName=None, libraryName=DEFAULT_LIBRARY): self.engine = engine self.time = 0.0 self.guitar = Guitar(self.engine, editorMode=True) self.controls = Player.Controls() self.camera = Camera() self.pos = 0.0 self.snapPos = 0.0 self.scrollPos = 0.0 self.scrollSpeed = 0.0 self.newNotes = None self.newNotePos = 0.0 self.song = None self.engine.loadSvgDrawing(self, "background", "editor.svg") self.modified = False self.songName = songName self.libraryName = libraryName self.heldFrets = set() self.spinnyDisabled = self.engine.config.get("game", "disable_spinny") mainMenu = [ (_("Save Song"), self.save), (_("Set Song Name"), self.setSongName), (_("Set Artist Name"), self.setArtistName), (_("Set Beats per Minute"), self.setBpm), (_("Estimate Beats per Minute"), self.estimateBpm), (_("Set A/V delay"), self.setAVDelay), (_("Set Cassette Color"), self.setCassetteColor), (_("Set Cassette Label"), self.setCassetteLabel), (_("Editing Help"), self.help), (_("Quit to Main Menu"), self.quit), ] self.menu = Menu(self.engine, mainMenu)
class TakeFotoScreen(Screen): camera = Camera() res = ImageResize() helper = Helper() resize_thread = None def ThreadCheck(self): return self.resize_thread.isAlive() def on_enter(self): app = App.get_running_app() taskshort = app.TASK_SHORT if app.TASK_SHORT else "" tasklong = app.TASK_LONG if app.TASK_LONG else "" self.camera.textlong = tasklong self.camera.textshort = taskshort self.camera.start() app.IMAGENAME = self.camera.getName() imgname = self.camera.getName() # Resize Deamon self.resize_thread = threading.Thread(name='resize_deamon', target=self.res.imgresize, args=(self.camera.getName(),)) self.resize_thread.start() app.FROMTAKEFOTO = True app.FROMTASKFOTO = True if tasklong else False self.parent.current = 'FotoScreen'
def __init__(self, parent=None): super().__init__(parent) self.interface() self.camera = Camera(Vector3(60,60,-100), Vector3(self.width(),self.height(),0), Vector3(0,0,0), 90) self.createObjects() self.determineVisibleSurface() self.keylist = []
def __init__(self): self.camera = Camera() self.grid = None self.row_spacing = None self.col_spacing = None self.pos_list = None self.pos = None
def load(self): for row, tiles in enumerate(self.level.level_data): for col, tile in enumerate(tiles): # ground = Ground(col, row, self) # self.ground_sprites.add(ground) # self.all_sprites.add(ground) if tile == 'P': self.player = Player(col, row, self) self.all_sprites.add(self.player) if tile == '1': wall = Wall(col, row, self) self.all_sprites.add(wall) self.wall_sprites.add(wall) if tile == '*': wall = Wall(col, row, self) self.all_sprites.add(wall) self.wall_sprites.add(wall) if tile == 'M': enemy = Enemy(col, row, self) self.all_sprites.add(enemy) self.camera = Camera(self.player, WINDOW_WIDTH, WINDOW_HEIGHT, self.level.width, self.level.height) self.all_sprites.add(self.player) counter = 0 total = 0
def init(self): self.faceDetector = FaceDetector() self.faceEncoder = FaceEncoder() self.camera = Camera() self.faceImageArray = None self.faceEncoding = None
def __init__(self, screen): self.screen = screen self.map = Map("map.txt") self._worldX = self.map.width self._worldY = self.map.height self.camera = Camera(self.map.width, self.map.height) self.init()
def accept_connections(self): # 'pass' = permission to enter the secret key. # 'True' = the secret key was correct, connection established. # 'False' = the secret key was incorrect. while True: while len(self.cameras) < self.camera_count: conn, addr = self.s.accept() # remove the client if it isn't a local one. if not addr[0].startswith("192.168."): print("Non-local client!") conn.close() continue # Asks the client for a password. conn.send("pass".encode("utf-8")) password = conn.recv(1024).decode("utf-8") # Checks if the password is correct. if password == self.secret_key: conn.send("True".encode("utf-8")) print(f"{addr} connected.") else: conn.send("False".encode("utf-8")) conn.close() client_camera = Camera(conn, len(self.cameras)) self.cameras.append(client_camera) # Check for disconnected clients for cl in self.cameras: if not cl.is_connected: self.cameras.remove(cl)
def __init__(self,source=0): # Selected base color # fourth one is not used self.hsv = (0,0,0,0) self.hsv2 = (0,0,0,0) self.hsv3 = (0,0,0,0) # Thresholds self.ht = 0 self.st = 180 self.vt = 200 self.ht_ = 0 self.st_ = 180 self.vt_ = 200 # Co-ords for the color selection square # self.start = (0,0) # self.end = (0,0) self.center = (0,0) # Boolean to check weather # the colors are locked or not self.locked = False # Get the camera object self.cam = Camera(source)
def add_cameras(self, device_id): if isinstance(device_id, list): for id in device_id: self.add_cameras(id) else: self.camera_list.append( Camera(self, device_id, len(self.camera_list)))
def setUp(self): self.camera = Camera(self.url) self.chessEngine = ChessEngine() self.board = 0 self.current = 0 self.previous = 0 self.CPULastMove = "0"
def __init__(self): pygame.init() self._main_game_window = pygame.display.set_mode( (Constants.GAME_WINDOW_WIDTH, Constants.GAME_WINDOW_HEIGHT)) self._customize_window() self._player = None self._map = Map() self._neutrals = [Neutral(100, 100, Textures.NEUTRAL)] self._quests = [] self._names_done_quests = [] self._enemies = self._neutrals[0].quest.condition self._camera = Camera() self._shells = [] self._things = [] self._chests = self._create_chests() self._trees = [ Tree( random.randint(-Constants.GAME_WINDOW_WIDTH, Constants.GAME_WINDOW_WIDTH), random.randint(-Constants.GAME_WINDOW_HEIGHT, Constants.GAME_WINDOW_HEIGHT), 'resources/images/trees/tree.png'), Tree( random.randint(-Constants.GAME_WINDOW_WIDTH, Constants.GAME_WINDOW_WIDTH), random.randint(-Constants.GAME_WINDOW_HEIGHT, Constants.GAME_WINDOW_HEIGHT), 'resources/images/trees/tree.png'), ]
def __init__(self, parent): fmt = QtOpenGL.QGLFormat() fmt.setVersion(3, 3) fmt.setProfile(QtOpenGL.QGLFormat.CoreProfile) fmt.setSampleBuffers(True) super().__init__(fmt, parent) timer = QTimer(parent) timer.timeout.connect(self.updateGL) timer.start(0) self.drawingElements = [] self.dt = 0.1 self.dx = 0 self.dy = 0 self.ds = 1 self.x = 0 self.y = 0 self.draw = True self.camera = Camera() self.isClick = False
def main(): detector = EyeDetector(args["shape_predictor"]) blink_consec_frames = args["frames"] camera = Camera() temp_count = 0 total_blink_count = 0 input("PRESS ANY KEY TO CONTINUE") # 무한 반복문으로 비디오의 프레임 하나씩 각각 처리 while True: frame = camera.read() left_eye_rect, right_eye_rect, probability = detector.update(frame) if probability is not None: # 눈이 떠져있을 확률이 20% 보다 낮아지면, # 눈을 감고 있는 것으로 인식하고 임시 카운트 증가 if probability < 0.2: temp_count += 1 # 눈의 크기가 설정해놓은 경계보다 클 때 (눈을 떴을 때) else: # 만약 일정 프레임 이상 눈을 감고 있었으면 눈 깜빡임 카운트 증가 if temp_count >= blink_consec_frames: total_blink_count += 1 print("***************************** Blink! " + str(total_blink_count)) ser.write(str.encode('1')) # 임시 카운트 리셋 temp_count = 0
def displayBinImagesForAllTestImages(): cam = Camera(load=True) video = VideoProcessor(cam) image_files = [ # "straight_lines1.jpg", # "straight_lines2.jpg", # "test1.jpg", # "test2.jpg" "test3.jpg", "test4.jpg", "test5.jpg", "test6.jpg" ] images = [] for imgFileName in image_files: img = cv2.imread(TEST_IMG_DIR + imgFileName) img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB) (imgSeries, Minv) = video.get_binary_warped_image(img) images.append(imgSeries) cnt = 0 f, axarr = plt.subplots(len(images), 2, figsize=(4 * 2, len(images) * 4)) for imgs in images: axarr[cnt][0].imshow(imgs[0]) axarr[cnt][0].set_title(str(image_files[cnt])) axarr[cnt][1].imshow(imgs[1]) axarr[cnt][1].set_title('Bin ') cnt += 1 plt.show()
def __init__(self): #glutInit(sys.argv) self.width, self.height = 1280, 800 pygame.init() self.screen = pygame.display.set_mode((self.width, self.height), OPENGL | DOUBLEBUF) glMatrixMode(GL_PROJECTION) glLoadIdentity() gluPerspective(65.0, self.width / float(self.height), 0.01, 1000.0) glMatrixMode(GL_MODELVIEW) glEnable(GL_DEPTH_TEST) self.camera = Camera((0.0, 100, 0), (0.0, 0, 0)) #Base vertices = np.array([[100.0, -10.0, 100.0, Conf.GRAPHX.BASE_COLOR[0],Conf.GRAPHX.BASE_COLOR[1],Conf.GRAPHX.BASE_COLOR[2]], \ [-100.0, -10.0, 100.0, Conf.GRAPHX.BASE_COLOR[0],Conf.GRAPHX.BASE_COLOR[1],Conf.GRAPHX.BASE_COLOR[2]], \ [-100.0, -10.0, -100.0,Conf.GRAPHX.BASE_COLOR[0],Conf.GRAPHX.BASE_COLOR[1],Conf.GRAPHX.BASE_COLOR[2]], \ [100.0, -10.0, -100.0, Conf.GRAPHX.BASE_COLOR[0],Conf.GRAPHX.BASE_COLOR[1],Conf.GRAPHX.BASE_COLOR[2]]], \ dtype=np.float32) self.vertexPositions = vbo.VBO(vertices) #Create the index buffer object indices = np.array([[0, 1, 2], [0, 3, 2]], dtype=np.int32) self.indexPositions = vbo.VBO(indices, target=GL_ELEMENT_ARRAY_BUFFER) self.uniform_values = {} self.uniform_locations = {}
def __init__(self, worldNum): self.obj = [] self.obj_bg = [] self.tubes = [] self.debris = [] self.mobs = [] self.whizbangs = [] self.text_objects = [] self.map = 0 self.flag = None self.mapSize = (0, 0) self.sky = 0 self.textures = {} self.worldNum = worldNum self.loadWorld_11() self.is_mob_spawned = [False, False] self.score_for_killing_mob = 100 self.score_time = 0 self.in_event = False self.tick = 0 self.time = 400 self.oPlayer = Player(x_pos=128, y_pos=351) self.oCamera = Camera(self.mapSize[0] * 32, 14) self.oEvent = Event() self.oGameUI = GameUI()
def send_help(self): print("send_help ausgeführt") # Create Imagestream Objekt and Take Picture camera = Camera() camera.stream() # Bild wird in camera.imagestream gespeichert # Telegram import telegram chat_id = private_config['telegram']['help_person_id'] #image.save(bio, 'JPEG') #bio.seek(0) print("Create BOT start") bot = telegram.Bot(token=private_config['telegram']['api-token']) print("Create BOT end") #print(bot.get_me()) print("Send message start") bot.send_message(chat_id, text=config['text']['photobox_sos']) print("Send image start") bot.send_photo(chat_id, photo=camera.imagestream) print("Send ENDE") self.ids.HelpScreenLabel.text = config['text']['help_success_text']
def populate_video_tabs(self): # try: # tmp = [cam for cam in [Camera(i) for i in camera_device_search_range] if cam.is_working()] # except: # tmp = [raspicam] # # if self.picam_packages_loaded: # raspicam = RasPiCam() # if raspicam.is_working(): # tmp.extend([raspicam]) if self.picam_packages_loaded: raspicam = RasPiCam() if raspicam.is_working(): tmp = [raspicam] # embed() else: tmp = [cam for cam in [Camera(i) for i in camera_device_search_range] if cam.is_working()] self.cameras = {camera_name_format % j: v for j, v in enumerate(tmp)} if len(self.cameras) > 0: for cam_name, cam in self.cameras.items(): self.video_tabs[cam_name] = VideoCanvas(parent=self) self.videos.addTab(self.video_tabs[cam_name], cam_name) self.video_tabs[cam_name].setLayout(QtWidgets.QHBoxLayout()) else: self.videos.addTab(QtWidgets.QWidget(), "No camera found")
def __init__(self): self.lock_ = Lock() # create a lock for this thread self.alive_ = True # create and initialise server for this processor self.server_ = VisionServer(self, V_SETT.VISION_SRV_NET_OPEN, V_SETT.VISION_SRV_PORT, V_SETT.MAX_PENDING_REQS) # obtain frame capture device obj self.cam_ = Camera(0) self.fps_ = 0 # flags that will tell wheter data can be trusted (accurate) self.trust_bal_ = self.trust_blu_ = self.trust_ylw_ = None # these hold robots' and ball's coordinates and direction self.bal_center_ = None self.blu_robot_center_ = None self.ylw_robot_center_ = None self.blu_dir_ = self.ylw_dir_ = None # these hold pitcj and goal coordinates self.l_goal_t_ = self.l_goal_b_ = self.r_goal_t_ = self.r_goal_b_ = None self.pitch_tl_ = self.pitch_bl_ = self.pitch_tr_ = self.pitch_br_ = None # create colour objects and set their threshold values self.red_color_ = ColorSpace(ColorSpace.HSV) self.red_color_.set_trsh_bounds((0, 80, 80), (10, 255, 255)) # pitch 2 self.blu_color_ = ColorSpace(ColorSpace.HSV) self.blu_color_.set_trsh_bounds((92, 132, 199), (180, 255, 255)) self.ylw_color_ = ColorSpace(ColorSpace.RGB) self.ylw_color_.set_trsh_bounds((0, 0, 0), (255, 255, 255))
def new(self): try: self.mapPath = os.path.join("../assets/", "stage1.tmx") self.map = mapLoader(self.mapPath) except: self.mapPath = os.path.join("assets/", "stage1.tmx") self.map = mapLoader(self.mapPath) self.map.makeMap() self.mapRect = self.map.terrainLayer.get_rect() self.grounds = pygame.sprite.Group() self.enemies = pygame.sprite.Group() self.bullets = pygame.sprite.Group() self.cameraCenter = (0, (-self.mapRect.height + SCREEN_SIZE[1]) * TILESCALE) self.camera = Camera(self.mapRect.width, self.mapRect.height, self.cameraCenter) for obj in self.map.tmdata.objects: if obj.name == 'ground': self.grounds.add( Ground(obj.x * TILESCALE, obj.y * TILESCALE, obj.width * TILESCALE, obj.height * TILESCALE)) elif obj.name == 'goal': self.goal = (obj.x * TILESCALE, obj.y * TILESCALE) elif obj.name == 'player': self.player = Player(obj.x * TILESCALE, obj.y * TILESCALE, self.screen) self.player.moveAhead = True elif obj.name == 'enemy1': self.enemies.add( Enemy(obj.x * TILESCALE, obj.y * TILESCALE, self.screen))
def cost_function(params,calibData): cost = 0 for i in range(0,len(calibData)): calibData_I = calibData[i] X1 = calibData_I[0] Y1 = calibData_I[1] X2 = calibData_I[2] Y2 = calibData_I[3] pos_x = calibData_I[4] pos_y = calibData_I[5] pos_z = calibData_I[6] rad_per_px1 = params[0] rad_per_px2 = params[1] cam = Camera('hacknc') cam.rad_per_px1 = rad_per_px1 cam.rad_per_px2 = rad_per_px2 result = px_2_xyz(X1,Y1,X2,Y2,cam) pos_predicted = result[0] pos_x_p = pos_predicted[0,0] pos_y_p = pos_predicted[0,1] pos_z_p = pos_predicted[0,2] #may leave out the x component since we don't know it very well during calibration cost = cost + (pos_x_p - pos_x)**2 + (pos_y_p - pos_y)**2 + 3*result[1] return cost
def __init__(self, gsm): self.gsm = gsm self.background = Background( os.path.join("res", "PlayState", "background.png")) self.camera = Camera(self) self.HUD = HUD(self.gsm) # Key handling self.leftKeyDown = False self.rightKeyDown = False self.upKeyDown = False self.spriteSheet = SpriteSheet( os.path.join("res", "PlayState", "Spritesheet.png"), 1) # Holds all the objects in the game self.allObjectList = pygame.sprite.Group() self.activeObjectList = pygame.sprite.Group() self.terrainList = pygame.sprite.Group() self.interactableList = pygame.sprite.Group() self.enemyList = pygame.sprite.Group() self.enemyAIList = pygame.sprite.Group() self.player = None self.level = currentLevel # Sets the current level self.loadLevel(self.level) # Loads the level
def init(self): self.camera = Camera(euclid.Point3(0,15, 0)) self.mainplayer_status = StatusView() self.otherplayer_status = StatusView(is_opponent=True) self.mana_controller = ManaController(self.mainplayer_status.manapool, self.otherplayer_status.manapool, self) self.x_controller = XSelector(self.mainplayer_status.manapool, self.otherplayer_status.manapool, self) self.card_selector = CardSelector(self.mainplayer_status, self.otherplayer_status, self) #self.game_status = GameStatus() self.phase_status = PhaseStatus() self.phase_bar = PhaseBar() self.phase_controller = PhaseController(self.phase_status, self) self.status_controller = StatusController(self.mainplayer_status, self.otherplayer_status, self.phase_status, self) self.selection = SelectionList() self.list_selector = SelectController(self.selection, self) self.msg_dialog = MessageDialog() self.msg_controller = MessageController(self.msg_dialog, self) self.table = Table() self.mainplay = PlayView(z=3) self.otherplay = PlayView(z=-3, is_opponent_view=True) self.play_controller = PlayController(self.mainplay, self.otherplay, self) self.damage_assignment = DamageSelector(self.mainplay, self.otherplay, self) self.distribution_assignment = DistributionSelector(self.mainplay, self.otherplay, self) self.player_hand = HandView() self.hand_controller = HandController(self.player_hand, self) self.otherplayer_hand = HandView(is_opponent=True) self.otherhand_controller = HandController(self.otherplayer_hand, self) self.stack = StackView() self.stack_controller = StackController(self.stack, self) self.zone_animator = ZoneAnimator(self) self._keep_priority = False self.finish_turn = False self.p1_stop_next = False self.p2_stop_next = False
def create_world(): #세계 생성 global cupid, target, obstaclehills, arrowlist, gagelist, life, bgm # 수정요함 global camera, backgroundbig, fire_possible_flag, cloudlist camera = Camera() backgroundbig = BackgroundBig() cupid = Cupid() target = Target() fire_possible_flag = True cloudlist = [Cloud() for i in range(5)] ### 장애물 위치 ### obstaclehills = [] obstaclehills.append(ObstacleHill(1400)) obstaclehills.append(ObstacleHill(750)) obstaclehills.append(ObstacleHill(1100)) obstaclehills.append(ObstacleHill(1700)) obstaclehills.append(ObstacleHill(3200)) obstaclehills.append(ObstacleHill(2700)) obstaclehills.append(ObstacleHill(4300)) ################## set_scrolling() arrowlist = [] gagelist = [] life = Life() bgm = BGM()
def setUpClass(cls): cls.pixels_uint8 = np.array([[1, 2], [3, 4]]).astype(np.uint8) cls.pixels_float32 = np.array([[1, 2], [3, 4]]).astype(Utils.image_data_type) cls.depth_float32 = np.array([[0.1, 0.5], [1, 2]]).astype(Utils.image_data_type) cls.se3_identity = np.identity(4, dtype=Utils.matrix_data_type) cls.intrinsic_identity = Intrinsic.Intrinsic(-1,-1,0,0) cls.camera_identity = Camera.Camera(cls.intrinsic_identity,cls.se3_identity)