class Acces: def __init__(self, parking): self.camera = Camera() self.tel_entre = self.tel_sortie = Teleporteur() self.mon_panneau = Panneau_Affichage() self.ma_borne = Borne_Ticket(self) self.mon_parking = parking def actionner_camera(self, client): voiture = client.ma_voiture hauteur = self.camera.capturer_hauteur(voiture) longeur = self.camera.capturer_longueur(voiture) largeur = self.camera.capturer_largeur(voiture) immatr = self.camera.capturer_immatr() return Voiture(immatr, hauteur, longeur, largeur, client) def actionner_panneau(self): return self.mon_parking.afficher_nb_place_disponible(self.mon_parking) def lancer_procedure_entre(self, client): voiture = self.actionner_camera(client) place = self.mon_parking.rechercherPlace(voiture) est_garer = True if place != None: self.tel_entre.teleporter_voiture(voiture, place, self.mon_parking) elif client.est_super_abonne : place = self.tel_entre.teleporter_voiture_super_abonne(voiture, self.mon_parking) else : est_garer = False return place
def get_cam(self,cam): if str(cam) not in cameras: config_file = Path('cameras.json') try: if config_file.is_file(): print(config_file) with open('cameras.json', 'r') as f: data = json.load(f) if str(cam) in data: value = data[str(cam)] print("creating camera {} {}".format(cam,value['index'])) cameras[str(cam)] = Camera(str(cam),config=value,type=CameraType[value['type']]) except: print("unable to load cameras from camera.json") if str(cam) not in cameras: try: cameras[str(cam)] = Camera(cam,self.data["yres"],self.data["xres"]) except FileNotFoundError: logging.debug("instance not found {}".format(str(cam))) if settings.data['SPINNAKER']: try: cameras[str(cam)] = Camera(cam,self.data["yres"],self.data["xres"],type=CameraType.pgrey) except: logging.debug(traceback.format_exc()) if not str(cam) in cameras: return None return cameras[str(cam)]
def test_init_pgcam(self): settings.pgsystem = PySpin.System.GetInstance() cam = Camera(cfg.pgcamera_id,cfg.camera_yres,cfg.camera_xres,type=CameraType.pgrey) self.assertIsNotNone(cam.type, CameraType.pgrey) cam.release() if settings.pgsystem is not None: settings.pgsystem.ReleaseInstance() del settings.pgsystem settings.pgsystem = None
def add_camera(camera, autoconnect=False, loop_mode=True): host = camera[0] port = camera[1] user = camera[2] passwd = camera[3] new_camera = Camera(host, port, user, passwd, autoconnect, loop_mode) new_camera.set_name('camera' + str(CamController.__cam_count + 1)) CamController.__cams[new_camera.get_host()] = new_camera CamController.__cam_count += 1
def test_serialize(self): cam = Camera.from_json(self.obj) cam_serialized = cam.serialize() assert_equal(cam_serialized, { 'camera_id': '2', 'description': 'camera 2' })
def test_read(self): for type in CameraType: if type == CameraType.pgrey: index = cfg.pgcamera_id else: index = cfg.usbcamera_id settings.pgsystem = PySpin.System.GetInstance() cam = Camera(index,cfg.camera_yres,cfg.camera_xres,type=type) frame,_ = cam.getFrame() height, width = frame.shape[:2] self.assertEqual(height,cfg.camera_yres) self.assertEqual(width,cfg.camera_xres) cam.release() if settings.pgsystem is not None: settings.pgsystem.ReleaseInstance() del settings.pgsystem settings.pgsystem = None
def __init__(self, width, height): #Iniciar OpenGL init() reshape(width, height) #crear Pokemones self.asda = bronzor.Bronzor() #self.bronzor = 1 self.pokemones = [ self.asda] self.camera = Camera() self.vista = vista.Vista(camera= self.camera, pokemones=self.pokemones) #self.vista.dibujar() self.show_axes = True self.polygon = True self.color = "b" self.run = True
class TestCamera(TestCase): obj = ['2', 'camera 2'] cam = Camera(1, 'camera 1') def test_get_id(self): id = self.cam.get_id() assert_equal(str(id), '1') def test_get_description(self): description = self.cam.get_description() assert_equal(description, 'camera 1') def test_serialize(self): cam = Camera.from_json(self.obj) cam_serialized = cam.serialize() assert_equal(cam_serialized, { 'camera_id': '2', 'description': 'camera 2' })
def test_change_res(self): for type in CameraType: if type == CameraType.pgrey: index = cfg.pgcamera_id else: index = cfg.usbcamera_id settings.pgsystem = PySpin.System.GetInstance() cam = Camera(index,cfg.camera_yres,cfg.camera_xres,type=type) cam.setDimensions(cfg.camera_nxres,cfg.camera_nyres) self.assertEqual(cam.h,cfg.camera_nyres) self.assertEqual(cam.w,cfg.camera_nxres) cam.release() if settings.pgsystem is not None: settings.pgsystem.ReleaseInstance() del settings.pgsystem settings.pgsystem = None
Edge(vertex2, vertex1), Edge(vertex2, vertex3), Edge(vertex2, vertex7), Edge(vertex6, vertex3), Edge(vertex6, vertex4), Edge(vertex6, vertex7), Edge(vertex5, vertex1), Edge(vertex5, vertex4), Edge(vertex5, vertex7), Edge(Vertex(0, 0, 0), Vertex(-2, 0, 0)), Edge(Vertex(0, 0, 0), Vertex(0, 2, 0)), Edge(Vertex(0, 0, 0), Vertex(0, 0, -2)), ) cube = Cube(edges) camera = Camera() def resize(width, height): glViewport(0, 0, width, height) glMatrixMode(GL_PROJECTION) glLoadIdentity() gluPerspective(40.0, float(width / height), 0.1, 50.0) glMatrixMode(GL_MODELVIEW) glLoadIdentity() def main(): global but_id pygame.init() screen = pygame.display.set_mode(SCREEN_SIZE,
pass print("Lanzando camara", mp.current_process().name) vc = VideoCapture(camera) cams = [0, 'rtsp://*****:*****@192.168.1.35:554/11'] if __name__ == '__main__': #Cargar archivo de configuración cams = [] with open('./resources/camConfig.json') as f: camConfig = json.load(f) for d in camConfig: pass cams.append(Camera(d)) #Multiprocesamiento por camara mp.set_start_method('spawn') procs = [] for x in cams: pass p = mp.Process(name=x._name, target=videoStreaming, args=(x, )) p.start() procs.append(p) for y in procs: pass y.join() while True:
def camera_save_description(camera_id, description): c = Camera(camera_id, description) if db.CameraDB.save_description(c): return jsonify({'message': 'success'}) else: return jsonify({'message': 'failed to save description'})
def setup_display(self, size: (int, int), power: int): width, height = size self.__display = pygame.display.set_mode( (width * power, height * power)) self.__camera = Camera(size, power)
def test_init_usb_am(self): cam = Camera(cfg.usbcamera_id,cfg.camera_yres,cfg.camera_xres) self.assertIsNotNone(cam.type, CameraType.usb) cam.release()
class Controller: def __init__(self, width, height): #Iniciar OpenGL init() reshape(width, height) #crear Pokemones self.asda = bronzor.Bronzor() #self.bronzor = 1 self.pokemones = [ self.asda] self.camera = Camera() self.vista = vista.Vista(camera= self.camera, pokemones=self.pokemones) #self.vista.dibujar() self.show_axes = True self.polygon = True self.color = "b" self.run = True def update(self): #ejes: rojo x # pressed = pygame.key.get_pressed() for event in pygame.event.get(): if event.type == QUIT: # cerrar ventana self.run = False if pressed[K_UP]: self.camera.mover(Vector(0,0,1)) if pressed[K_DOWN]: self.camera.mover(Vector(0,0,-1)) if pressed[K_RIGHT]: self.camera.mover(Vector(0,1,0)) if pressed[K_LEFT]: self.camera.mover(Vector(0,-1,0)) if pressed[K_w]: if pressed[K_LSHIFT]: self.camera.mover(Vector(5,0,0)) else: self.camera.mover(Vector(2,0,0)) if pressed[K_s]: if pressed[K_LSHIFT]: self.camera.mover(Vector(-5,0,0)) else: self.camera.mover(Vector(-2,0,0)) if pressed[K_d]: self.camera.rotar(-1) if pressed[K_a]: self.camera.rotar(1) if pressed[K_1]: self.show_axes = not self.show_axes if pressed[K_2]: self.polygon = not self.polygon if pressed[K_3]: if self.color == "n": glClearColor(1.0, 1.0, 1.0, 1.0) self.color = "b" else : glClearColor(0.0, 0.0, 0.0, 1.0) self.color = "n" if pressed[K_ESCAPE]: run = False self.vista.dibujar(self.show_axes, self.polygon) return self.run
def __init__(self, parking): self.camera = Camera() self.tel_entre = self.tel_sortie = Teleporteur() self.mon_panneau = Panneau_Affichage() self.ma_borne = Borne_Ticket(self) self.mon_parking = parking
class GameSystem(): @property def timer(self) -> int: return self.__timer @property def speed(self) -> int: return self.__speed @property def display(self) -> pygame.display: return self.__display def __init__(self): super().__init__() self.__timer = -1 self.__speed = 1 self.__display: pygame.display = None self.__sound_manager = SoundManager() self.__camera: Camera = None pygame.init() self.__clock = pygame.time.Clock() def get_screen_size(self) -> (int, int): return self.__camera.screen.get_size() def reset_camera(self): self.__camera.reset() def setup_display(self, size: (int, int), power: int): width, height = size self.__display = pygame.display.set_mode( (width * power, height * power)) self.__camera = Camera(size, power) def set_caption(self, text: str): pygame.display.set_caption(text) def add_speed(self): self.__speed += 1 if DebugManager.is_debug: if self.__speed > 9: self.__speed = 1 elif self.__speed > 4: self.__speed = 1 def reset_timer(self): self.__timer = -1 def progress(self): self.__timer += 1 def update_display(self): self.__camera.draw() surface = self.__display pygame.transform.scale(self.__camera.screen, surface.get_size(), surface) pygame.display.update() self.__clock.tick((self.__speed - 1) * 2 + 8) def quit(self): pygame.quit() def play_music(self, file_path: str): self.__sound_manager.play_music(file_path) def play_se(self, file_path: str): self.__sound_manager.play_se(file_path) def stop_music(self): self.__sound_manager.stop_music() def add_draw_object(self, draw_object: DrawObject): self.__camera.add_draw_object(draw_object) def fill_display(self, color=Color.BLACK): self.__camera.fill(color) def add_camera_position(self, position: (int, int)): x, y = position self.__camera.x += x self.__camera.y += y def set_camera_position(self, position: (int, int)): x, y = position self.__camera.x = x self.__camera.y = y
def __create_objects(query): return_list = [] for camera in [i for i in query.cursor.fetchall()]: return_list.append(Camera.from_json(camera)) return return_list