def __init__(self, parent, expected_memory): self.log = logs.logger.add_module("Threading") QThread.__init__(self, parent) self.cam = Camera(expected_memory) self.cmd_fifo = queue.Queue() self.available_space = self.cam.get_available_space() self.filename = ""
def main(): ''' Main loop that initializes camera and other ''' args = parse_args() config = Config() #Start Camera async class cam = Camera(args) cam.start() #Start io writing queue write_queue = WriteQueue() write_queue.start() if config.Inference.mode == 'detect': print('Running detection') detector = OpenVinoDetectorAsync(config.Inference) else: detector = OpenVinoClassifierAsync(config.Inference) while True: _,frame = cam.read() start_time = time.time() infer_frame = deepcopy(frame) detections = detector.run(infer_frame) timestamp = datetime.now(tz=timezone.utc).strftime('%Y-%m-%d-%H-%M-%S-%f') path = 'tmp/' + timestamp + '.jpg' if detections: ''' Need to fix the bounding box locations for detection in detections: xmin = detection.position.xmin ymin = detection.position.ymin xmax = detection.position.xmax ymax = detection.position.ymax cv2.rectangle(frame, (int(xmin), int(ymin)), (int(xmax), int(ymax)), detection.color, 2) ''' cv2.putText(frame,'HUMAN',(10,400), cv2.FONT_HERSHEY_SIMPLEX, 4,(25,25,255),2,cv2.LINE_AA) cv2.imshow('frame', frame) cv2.imwrite(path, frame) #This has to RTT upload_frame(path, config) else: #add to upload queue write_queue.enqueue(path, frame) end_time = time.time() print("[LOGS] ---PIPELINE TIME--- **{}**".format(end_time-start_time)) if cv2.waitKey(1) & 0xFF == ord('q'): break cam.stop() write_queue.stop() cv2.destroyAllWindows()
def start_cam_service(): global cam if not cam: cam = Camera(800, 600) if cam and (not cam.operating): try: _thread.start_new_thread(cam.start, (get_yolo_result, )) # _thread.start_new_thread(hello, (1234, )) return jsonify({'success': True, 'operating': True}) except: print("Error: start thread error ") return jsonify({'success': False, 'error': 'START_THREAD_ERROR'}) else: return jsonify({'success': True, 'operating': True})
def __init__(self, mrz_port="/dev/ttyACM0"): with timer.time(f'load-total'): self.card_reader = CardReader() self.card_reader.set_mrz_port(mrz_port) with timer.time(f'load-mtcnn'): self.mtcnn = MTCNN() self.mtcnn.init(480, 640) with timer.time(f'load-facenet'): self.face_embedder = FaceEmbedder() self.camera = Camera() # self.camera_face = None self.camera_emb = None self.reader_face = None self.reader_emb = None
def cam_update_img(): global cam if not cam: cam = Camera(800, 600) try: cam.start_once(get_yolo_result) # _thread.start_new_thread(hello, (1234, )) return jsonify({ 'success': True, }) except: print("Error: start thread error ") return jsonify({ 'success': False, })
from m2 import M2 from wow import WoW from cam import Camera from objects import GameObject # TODO: RENDER in argv # RENDER = False RENDER = True GODI_PATH = 'Y:\\dbc\\GameObjectDisplayInfo.dbc' CMD_PATH = 'Y:\\dbc\\CreatureModelData.dbc' MODELS_PREFIX = 'Y:\\model.mpq' w = WoW(godi_path=GODI_PATH, cmd_path=CMD_PATH) cam = Camera(w) it = [] it += list(w.gen_game_objects()) it += list(w.gen_players()) print(' Snapshoting screen...') with mss.mss() as sct: monitor = sct.monitors[1] img = sct.grab(monitor) img = np.asarray(img)[:, :, [2, 1, 0]] print(' Snapshoted!', img.shape) plt.close('all') fig = plt.figure() ax = fig.add_subplot(111)
cam.rot +=1 mv = Vector() if kbd.a: mv.y -= 1 if kbd.d: mv.y += 1 if kbd.w: mv.x += 1 if kbd.s: mv.x -= 1 if kbd.up: cam.rays +=1 if kbd.down: cam.rays -=1 cam.move(mv) cam.colides(lines) lines.append(Line(Vector(300,100),Vector(300,200),True,wallImg)) cam = Camera() kbd = Keyboard() physloop = simplegui.create_timer(1000/60,pysloop) frame = simplegui.create_frame("Points", Camera.WIDTH , Camera.HEIGHT,0) frame.set_draw_handler(draw) frame.set_canvas_background("White") frame.set_keydown_handler(kbd.keyDown) frame.set_keyup_handler(kbd.keyUp) # pos the frame animation frame.set_mouseclick_handler(mouse) physloop.start() frame.start()
def initCamera(self): self.cam = Camera() self.cam.setTreshold(self._treshold)
def setupApp(self): self.current_user['username'] = self.login.username_lineedit.text() print(self.current_user['uid']) self.startNetFinder() self.show() def startNetFinder(self): self.thread_finder = QThread() self.online_finder = NetFinder(self.current_user) self.online_finder.moveToThread(self.thread_finder) self.thread_finder.started.connect(self.online_finder.run) self.online_finder.new_client.connect(self.online_dialog.addOnlineUser) self.thread_finder.start() if __name__ == '__main__': camera = Camera(0) app = QApplication([]) # start_window = UI_Window(camera) start_window = NetCrawler() # apply_stylesheet(app, theme='dark_teal.xml') # start_window.show() app.exit(app.exec_())
from evaluate_gpu import get_nearest_neighbors from evaluate_rerank import get_nearest_neighbors_rerank import scipy.io import torch from flask import Flask, jsonify, request from flask_cors import CORS from detect import get_model, get_bbox_of_image, arg_parse from cam import Camera import _thread import os import numpy as np app = Flask(__name__) CORS(app) cam = Camera(800, 600) import os model_pcb = None model_dense = None model_yolo = None result_pcb = scipy.io.loadmat('reid/pytorch_result_PCB.mat') gf_pcb = torch.FloatTensor(result_pcb['gallery_f']) gf_pcb = gf_pcb.cuda() gc_pcb = result_pcb['gallery_cam'][0] gl_pcb = result_pcb['gallery_label'][0] gp_pcb = result_pcb['gallery_path'][..., 0] # g_g_dist = np.dot(gf_pcb, np.transpose(gf_pcb))
def __init__(self): self.camera = Camera() with timer.time(f'load'): self.mtcnn = MTCNN() self.mtcnn.init(480,640)
from base64 import b64decode from fastapi import FastAPI from fastapi.responses import StreamingResponse from tortoise.contrib.fastapi import register_tortoise from authentication import router, check_token, credentials_exception from cam import Camera camera = Camera() app = FastAPI() app.include_router(router) def stream_video(): while True: frame = camera.get_frame() yield (b'--frame\r\n' b'Content-Type: image/jpeg\r\n\r\n' + frame + b'\r\n') @app.get('/mstreamj.mjpg') async def main(t: bytes): token = b64decode(t).decode('utf-8') print(token) if await check_token(token): return StreamingResponse( stream_video(), media_type='multipart/x-mixed-replace; boundary=frame') raise credentials_exception
def __init__(self): # Initalize the camera and motorController for use in the gradient descent self.cam = Camera() self.controller = MotorController()
from temperature import Temperature from light import Light from cam import Camera import time import RPi.GPIO as GPIO if __name__ == "__main__": GPIO.setmode(GPIO.BCM) camera = Camera("pub_monitor_thread") camera.start() while True: # get and pub temperature temperature = Temperature() temperature.pub_temperature() # get and pub light light = Light(17, 0) light.pub_light() time.sleep(1)