def get_cameras(self) -> List[Camera]: cameras = [] for data in self.__cameras.all(): cam = Camera(data['name'], data['url']) cam.id = data['id'] cameras.append(cam) return cameras
async def addCamera(request): params = await request.json() cam = Camera(params['name'], params['url']) id = db.insert_camera(cam) cam.id = id db.update_camera(id, cam) asyncio.create_task(frameserver.capture(cam)) return web.Response(status=201, text=json.dumps({'id': id}))
def consult_by(self, condition, camera): sql = '' if condition == 'id': sql = "SELECT * FROM camera WHERE id={}".format(camera.id) elif condition == 'name': sql = "SELECT * FROM camera WHERE station_id LIKE '%{}%';".format( camera.station_id) result = self.db.consult(sql) if result is None: return None for c in result: camera = Camera(camera_id=c[0], station_id=c[1], show_image=c[2], resize_image=c[3], width=c[4], height=c[5], fps=c[6]) return camera
def consult(self): cameras = list() sql = 'SELECT * FROM camera' result = self.db.consult(sql) if result is None: return None for c in result: cameras.append( Camera(camera_id=c[0], station_id=c[1], show_image=c[2], resize_image=c[3], width=c[4], height=c[5], fps=c[6])) return cameras
def update_camera(): configs = read_config() if request.method == "POST": data = request.form camera = Camera(camera_id=data["id"], station_id=data["station_id"], show_image=data["show_image"], resize_image=data["resize_image"], width=data["width"], height=data["height"], fps=data["fps"]) cameraController.update(camera) configs = read_config() flash("changes saved successfully :)") return render_template('camera.html', configs=configs) return render_template('camera.html', configs=configs)
f1 = Floor(1) p1 = Person("Иванов Иван Иванович", 1234) print(p1) print("\n") r1 = Room(101) r1.add_equipment(q1) f1.add_room_on_floor(r1) print(f1) print("\n") s1 = Section(11) c1 = Camera(12, "C:\\Users") s1.add_camera(c1) s1.add_floor(f1) r2 = Room(201) s1.add_roomnoonfloor(r2) print(s1) print("\n") c1.set_section(s1) print(c1) print("\n") event1 = Event(c1, p1)
from flask import Flask import controllers.config as config from models.camera import Camera app = Flask(__name__) #CameraConfigStatus = CameraConfig() camera_module = Camera() instance = config.CameraConfig.get_instance() @app.route("/") def index(): return 'Camera server is up, the devoly trinity was here' @app.route("/start_camera") def start_camera(): try: #config.CameraConfig.set_status("ENABLED") camera_module.set_camera_state("ENABLED") camera_module.start_camera_thread() response = {"response": "ENABLED"} except: #config.CameraConfig.set_status("DISABLED") camera_module.set_camera_state("DISABLED") response = {"response": "ERROR"} return response
def _calibration_camera(**kwargs): return Camera.from_calibration_config(**kwargs)
def get_camera(self, id: int) -> Camera: data = self.__cameras.get(doc_id=id) cam = Camera(data['name'], data['url']) cam.id = id return cam
from flask import Flask, render_template, request, Response, redirect, url_for, session, Blueprint, send_from_directory from models.camera import Camera from pathlib import Path import os import cv2 from models.uplaod import Upload from random import randint from werkzeug.utils import secure_filename camera_route = Blueprint('camera_route', __name__) camera = Camera() root = os.path.dirname(os.path.abspath(__file__)) @camera_route.after_request def add_header(capture): capture.headers["Cache-Control"] = "no-cache, no-store, must-revalidate" capture.headers["Pragma"] = "no-cache" capture.headers["Expires"] = "0" capture.headers["Cache-Control"] = "public, max-age=0" return capture @camera_route.route("/camera_normal") def camera_normal(): camera.camera_normal() return redirect(url_for('camera_route.stream_page')) @camera_route.route("/camera_gray") def camera_gray():
def get_camera(self, camera_id): camera_data = self.db.get_camera(camera_id) if not camera_data: return None return Camera(**camera_data)
def create_camera(self, location, camera_id): camera = Camera(location=location, camera_id=camera_id) return self.db.put_camera(camera)
def main(): white_diffuse = BSDF(BSDFType.Diffuse, np.array([1, 1, 1])) red_diffuse = BSDF(BSDFType.Diffuse, np.array([1, 0, 0])) blue_diffuse = BSDF(BSDFType.Diffuse, np.array([0, 0, 1])) light = BSDF(BSDFType.Light, np.array([2, 2, 2])) size = 1.0 left = size right = -size top = size bottom = -size front = size - 2 back = -size - 2 # left nl = np.array([-1, 0, 0]) tl0 = Triangle([ Vertex(np.array([left, bottom, back]), nl, np.array([0, 0])), Vertex(np.array([left, bottom, front]), nl, np.array([0, 0])), Vertex(np.array([left, top, front]), nl, np.array([0, 0])), ], red_diffuse) tl1 = Triangle([ Vertex(np.array([left, top, front]), nl, np.array([0, 0])), Vertex(np.array([left, top, back]), nl, np.array([0, 0])), Vertex(np.array([left, bottom, back]), nl, np.array([0, 0])), ], red_diffuse) # right nr = np.array([1, 0, 0]) tr0 = Triangle([ Vertex(np.array([right, bottom, front]), nr, np.array([0, 0])), Vertex(np.array([right, bottom, back]), nr, np.array([0, 0])), Vertex(np.array([right, top, back]), nr, np.array([0, 0])), ], blue_diffuse) tr1 = Triangle([ Vertex(np.array([right, top, back]), nr, np.array([0, 0])), Vertex(np.array([right, top, front]), nr, np.array([0, 0])), Vertex(np.array([right, bottom, front]), nr, np.array([0, 0])), ], blue_diffuse) # top nt = np.array([0, -1, 0]) tt0 = Triangle([ Vertex(np.array([left, top, front]), nt, np.array([0, 0])), Vertex(np.array([right, top, front]), nt, np.array([0, 0])), Vertex(np.array([right, top, back]), nt, np.array([0, 0])), ], white_diffuse) tt1 = Triangle([ Vertex(np.array([right, top, back]), nt, np.array([0, 0])), Vertex(np.array([left, top, back]), nt, np.array([0, 0])), Vertex(np.array([left, top, front]), nt, np.array([0, 0])), ], white_diffuse) # bottom nb_ = np.array([0, 1, 0]) tb_0 = Triangle([ Vertex(np.array([left, bottom, front]), nb_, np.array([0, 0])), Vertex(np.array([right, bottom, front]), nb_, np.array([0, 0])), Vertex(np.array([right, bottom, back]), nb_, np.array([0, 0])), ], white_diffuse) tb_1 = Triangle([ Vertex(np.array([right, bottom, back]), nb_, np.array([0, 0])), Vertex(np.array([left, bottom, back]), nb_, np.array([0, 0])), Vertex(np.array([left, bottom, front]), nb_, np.array([0, 0])), ], white_diffuse) # back nb = np.array([0, 0, 1]) tb0 = Triangle([ Vertex(np.array([left, bottom, back]), nb, np.array([0, 0])), Vertex(np.array([right, bottom, back]), nb, np.array([0, 0])), Vertex(np.array([right, top, back]), nb, np.array([0, 0])), ], white_diffuse) tb1 = Triangle([ Vertex(np.array([right, top, back]), nb, np.array([0, 0])), Vertex(np.array([left, top, back]), nb, np.array([0, 0])), Vertex(np.array([left, bottom, back]), nb, np.array([0, 0])), ], white_diffuse) # light l0 = Triangle([ Vertex(np.array([left, top - 0.01, back]), nt, np.array([0, 0])), Vertex(np.array([right, top - 0.01, back]), nt, np.array([0, 0])), Vertex(np.array([0, top - 0.01, front]), nt, np.array([0, 0])), ], light) scene = Scene([tl0, tl1, tr0, tr1, tt0, tt1, tb_0, tb_1, tb0, tb1, l0], [l0]) world_matrix = np.array([[1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]]) camera = Camera(pi / 2, Film(400, 400), world_matrix) camera.look_at(np.array([0, 0, 10]), np.array([0, 0, 0]), np.array([-1, 0, 0])) render_options = RenderOptions(400, 400, 2, 2, 1, 1, 2, 2.2, 0) renderer = Renderer(render_options, camera, scene) renderer.render() print('Rendering completed.') print(datetime.now())
def __init__(self, camera: Camera = None, person: Person = None) -> None: self.date = datetime.today() self.camera = camera self.person = person self.record = camera.get_locrecord()
import socket import time from pysabertooth import Sabertooth from models.robot import Robot from models.camera import Camera from multiprocessing import Process PORT = "/dev/serial/by-id/usb-FTDI_FT232R_USB_UART_A105QI4I-if00-port0" saber = Sabertooth(PORT, baudrate=9600, address=128, timeout=0.1) robot = Robot(saber) camera = Camera('test_1', "./data/") client_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) client_socket.connect(("192.168.0.9", 8000)) button_delay = 0.2 try: while True: from_server = client_socket.recv(4096) char = from_server.decode("utf-8") if char == "p": print("Stoping robot") robot.stop() time.sleep(1) camera.done() exit(0) if char == "c": robot.stop() time.sleep(button_delay)