def start_game(game_data): char_data = game_data["CHAR"] map_data = game_data["LOC"] flags = game_data["FLAGS"] cam = Camera(screen_size=screen_size, roster=char_data, flags=flags) cam.load_map(map_name=map_data["MAP"], goto=map_data["POSITION"]) return cam
def __init__(self, argv): QtGui.QMainWindow.__init__(self) self.MainWindow = Ui_MainWindow self.ui = Ui_MainWindow self.MainWindow.__init__(self.window) self.setupUi(self) self.show() self.logger = Logger(self.logPanel) self.device = EthernetDevice(self.logger) self.device.disconState = QtGui.QPixmap( _fromUtf8('../res/disconnected')) self.device.conState = QtGui.QPixmap(_fromUtf8('../res/connected')) self.device.currentState = 0 self.device.power = 0 self.device.direction = 0 self.addWidgets() self.updater = DataUpdateThread(self) # create a thread self.updater.trigger.connect( self.updateState) # connect to it's signal self.updater.start() self.cam = Camera(self)
def ch7(): # Step 1 floor = Sphere() floor.transform = Matrix.scaling(10, 0.01, 10) floor.material = Material() floor.material.color = Color(1, 0.9, 0.9) floor.material.specular = 0 # Step 2 left_wall = Sphere() left_wall.transform = Matrix.translation(0, 0, 5) * Matrix.rotation_y(-45) * \ Matrix.rotation_x(90) * Matrix.scaling(10, 0.01, 10) left_wall.material = floor.material # Step 3 right_wall = Sphere() right_wall.transform = Matrix.translation(0, 0, 5) * Matrix.rotation_y(45) * \ Matrix.rotation_x(90) * Matrix.scaling(10, 0.01, 10) right_wall.material = floor.material # Step 4 middle = Sphere() middle.transform = Matrix.translation(-0.5, 1, 0.5) middle.material = Material() middle.material.color = Color(0.1, 1, 0.5) middle.material.diffuse = 0.7 middle.material.specular = 0.3 # Step 5 right = Sphere() right.transform = Matrix.translation(1.5, 0.5, -0.5) * Matrix.scaling( 0.5, 0.5, 0.5) right.material = Material() right.material.color = Color(0.5, 1, 0.1) right.material.diffuse = 0.7 right.material.specular = 0.3 # Step 6 left = Sphere() left.transform = Matrix.translation(-1.5, 0.33, -0.75) * Matrix.scaling( 0.33, 0.33, 0.33) left.material = Material() left.material.color = Color(1, 0.8, 0.1) left.material.diffuse = 0.7 left.material.specular = 0.3 world = World() world.light = PointLight(point(-10, 10, -10), Color(1, 1, 1)) world.objects.extend([floor, left_wall, right_wall, middle, right, left]) camera = Camera(100, 50, 60) # camera = Camera(500, 250, 60) camera.transform = view_transform(point(0, 1.5, -5), point(0, 1, 0), vector(0, 1, 0)) canvas = camera.render(world) with open('ch8.ppm', 'w') as fp: fp.write(canvas.to_ppm())
def ch14(): world = World() world.light = PointLight(point(-10, 10, -10), Color(1, 1, 1)) hex = hexagon() world.objects.append(hex) camera = Camera(100, 50, 60) camera.transform = view_transform(point(0, 2, -1), point(0, 0, 0), vector(0, 1, 0)) canvas = camera.render(world) with open('ch14.ppm', 'w') as fp: fp.write(canvas.to_ppm())
def ch9(): # Step 1 floor = Plane() floor.transform = Matrix.scaling(10, 0.01, 10) floor.material = Material() floor.material.color = Color(1, 0.9, 0.9) floor.material.specular = 0 floor.material.pattern = StripePattern(Color(1, 0, 0), Color(0, 0, 1)) # Middle biggest sphere middle = Sphere() middle.transform = Matrix.translation(-0.5, 1, 0.5) middle.material = Material() middle.material.color = Color(0.1, 1, 0.5) middle.material.diffuse = 0.7 middle.material.specular = 0.3 middle.material.pattern = RingPattern(Color(1, 0, 1), Color(1, 1, 1)) middle.material.pattern.transform = Matrix.scaling(0.25, 0.5, 0.25) # Smaller right sphere right = Sphere() right.transform = Matrix.translation(1.5, 0.5, -0.5) * Matrix.scaling(0.5, 0.5, 0.5) right.material = Material() right.material.color = Color(0.5, 1, 0.1) right.material.diffuse = 0.7 right.material.specular = 0.3 right.material.reflective = 1.0 # Left yellow sphere left = Sphere() left.transform = Matrix.translation(-1.5, 0.33, -0.75) * Matrix.scaling(0.33, 0.33, 0.33) left.material = Material() left.material.color = Color(1, 0.8, 0.1) left.material.diffuse = 0.7 left.material.specular = 0.3 world = World() world.light = PointLight(point(-10, 10, -10), Color(1, 1, 1)) world.objects.extend([floor, middle, right, left]) camera = Camera(100, 50, 60) # camera = Camera(500, 250, 60) camera.transform = view_transform(point(0, 1.5, -5), point(0, 1, 0), vector(0, 1, 0)) canvas = camera.render(world) with open('ch9.ppm', 'w') as fp: fp.write(canvas.to_ppm())
def generateNeighbour(self, camera_move_method): # deep copy cameras cameras = [copy.copy(c) for c in self.cameras] transformation = self.randomlyChooseTransformationMethod(cameras) # perform transformation if transformation == 'insert': new_camera = Camera(self.problem, self.getRandomFreePointFromRoom()) cameras.append(new_camera) elif transformation == 'remove': cameras.remove(random.choice(self.cameras)) elif transformation == 'move': to_modify = random.choice(self.cameras) if camera_move_method == 'local': to_modify.move() elif camera_move_method == 'random': to_modify.move(self.getRandomFreePointFromRoom()) else: raise RuntimeError("Wrong move camera method!") else: raise RuntimeError("Wrong transformation method!") return State(self.problem, cameras)
def generateCameras(self): cameras = [] for _ in range(self.problem.min_number_of_cams): cameras.append( Camera(self.problem, self.getRandomFreePointFromRoom())) return cameras
def __init__(self, argv): QtGui.QMainWindow.__init__(self) self.MainWindow=Ui_MainWindow self.ui=Ui_MainWindow self.MainWindow.__init__(self.window) self.setupUi(self) self.show() self.logger = Logger(self.logPanel) self.device = EthernetDevice(self.logger) self.device.disconState = QtGui.QPixmap(_fromUtf8('../res/disconnected')) self.device.conState = QtGui.QPixmap(_fromUtf8('../res/connected')) self.device.currentState = 0 self.device.power=0 self.device.direction=0 self.addWidgets() self.updater = DataUpdateThread(self) # create a thread self.updater.trigger.connect(self.updateState) # connect to it's signal self.updater.start() self.cam = Camera(self)
def __init__(self): logging.info("Starting Spaceship") self.q_mode_camera = Queue.Queue() self.q_com_device_in = Queue.Queue() self.q_com_device_out = Queue.Queue() GPIO.setmode(GPIO.BOARD) # init pin 7 for camera PWM GPIO.setup(7, GPIO.OUT) # Init pin 11 for diode GPIO.setup(11, GPIO.OUT) # Init pin 13 for relay for power to servo GPIO.setup(13, GPIO.OUT) self.mode = "" self.online = False self.camera = Camera(self.q_mode_camera) self.com_device = ComDevice(self.q_com_device_in, self.q_com_device_out) self.running = True
class Spaceship: def __init__(self): logging.info("Starting Spaceship") self.q_mode_camera = Queue.Queue() self.q_com_device_in = Queue.Queue() self.q_com_device_out = Queue.Queue() GPIO.setmode(GPIO.BOARD) # init pin 7 for camera PWM GPIO.setup(7, GPIO.OUT) # Init pin 11 for diode GPIO.setup(11, GPIO.OUT) # Init pin 13 for relay for power to servo GPIO.setup(13, GPIO.OUT) self.mode = "" self.online = False self.camera = Camera(self.q_mode_camera) self.com_device = ComDevice(self.q_com_device_in, self.q_com_device_out) self.running = True # Main loop def run(self): logging.info('Started') self.com_device.start() self.camera.start() try: while self.running: self.check_queue() self.blink_diode() time.sleep(2) except KeyboardInterrupt: self.shutdown() finally: pass GPIO.cleanup() logging.info('Finished') def set_mode(self, mode): logging.info("Setting mode "+mode) self.q_mode_camera.put(mode) self.q_com_device_in.put(mode) self.mode = mode def shutdown(self): print("Shutting down...") self.running = False self.set_mode("EXIT") logging.info("All shut down") logging.info("Shutdown Spaceship") def check_queue(self): try: msg = self.q_com_device_out.get_nowait().upper() if msg == "MODE 1" \ or msg == "MODE 2" \ or msg == "MODE 3" \ or msg == "START": self.set_mode(msg) elif msg == "EXIT": self.shutdown() elif msg == "ONLINE": self.online = True elif msg == "OFFLINE": self.online = False except Queue.Empty: None finally: pass def blink_diode(self): if self.mode == "": GPIO.output(11, GPIO.HIGH) time.sleep(0.5) GPIO.output(11, GPIO.LOW) time.sleep(0.5) self.blink_online_status() elif self.mode == "MODE 1": self.blink() time.sleep(0.5) self.blink_online_status() elif self.mode == "MODE 2": self.blink() self.blink() time.sleep(0.5) self.blink_online_status() elif self.mode == "MODE 3": self.blink() self.blink() self.blink() time.sleep(0.5) self.blink_online_status() def blink_online_status(self): if self.online: GPIO.output(11, GPIO.HIGH) time.sleep(0.5) GPIO.output(11, GPIO.LOW) else: time.sleep(0.5) @staticmethod def blink(): GPIO.output(11, GPIO.HIGH) time.sleep(0.1) GPIO.output(11, GPIO.LOW) time.sleep(0.1)
def step_impl(context): context.c = Camera(context.hsize, context.vsize, context.field_of_view)
def step_impl(context, width, height, degrees): context.c = Camera(width, height, degrees)
def parse(self): args = sys.argv for i in range(len(args)): if args[i] == "-h": self.help() elif args[i] == "-t": camera = Camera() checkboard = (6, 9) winSize = (5, 5) print(args) camera.Calibration(args[i + 1], checkboard, winSize) camera.save() elif args[i] == "-i": if not args[i + 1]: raise Exception( "need path after -i type -h for more information") camera = Camera() camera.load() img = cv2.imread(args[i + 1]) camera.imgCamToWorld(img)
class ControlApp(QtGui.QMainWindow, Ui_MainWindow): #def values camDirectionAngle = 0 keylist = [] cam = None updater = None def __init__(self, argv): QtGui.QMainWindow.__init__(self) self.MainWindow = Ui_MainWindow self.ui = Ui_MainWindow self.MainWindow.__init__(self.window) self.setupUi(self) self.show() self.logger = Logger(self.logPanel) self.device = EthernetDevice(self.logger) self.device.disconState = QtGui.QPixmap( _fromUtf8('../res/disconnected')) self.device.conState = QtGui.QPixmap(_fromUtf8('../res/connected')) self.device.currentState = 0 self.device.power = 0 self.device.direction = 0 self.addWidgets() self.updater = DataUpdateThread(self) # create a thread self.updater.trigger.connect( self.updateState) # connect to it's signal self.updater.start() self.cam = Camera(self) def addWidgets(self): """ В этом методе мы добавляем виджеты и wприсоединяем обработчики сигналов. Обработчик сигнала для виджета так же называется "слотом" """ #camview setup #path="C:\\Users\\SCB\\Downloads\\test.avi" path = QtCore.QUrl("rtsp://192.168.2.100:7070/") media = Phonon.MediaSource(path) self.videoPlayer.load(media) self.videoPlayer.play() #set maps properties url = "res.gmap.html" page = QtCore.QUrl("../res/gmap.html") self.mapView.load(page) #thumper pic myPixmap = QtGui.QPixmap(_fromUtf8('../res/thumper_top.jpg')) self.thumperImage.setPixmap(myPixmap) self.thumperImage.setScaledContents(True) #camDirection myPixmap = QtGui.QPixmap(_fromUtf8('../res/cam.png')) myPixmap = myPixmap.transformed(QtGui.QTransform().rotate( self.camDirectionAngle)) self.camDirection.setPixmap(myPixmap) self.camDirection.setScaledContents(True) #logger self.actionSaveLog.triggered.connect(self.saveLog) self.actionSaveLog.setShortcut('Ctrl+S') #define menu actions self.actionExit.triggered.connect(self.exitApp) self.actionExit.setShortcut('Ctrl+Q') #device state #self.connectStateIndicator.connect(self.connectStateIndicator, QtCore.SIGNAL("") self.connectStateIndicator.setPixmap(self.device.disconState) self.connectStateIndicator.setScaledContents(True) self.actionConnect.triggered.connect(self.changeConnectionState) self.actionConnect.setShortcut('F5') self.resetTelemetry() #get state self.actionBattery.triggered.connect(self.addMarkerWithLabel) #init direction level (altitude direction indicator) #init battery state #self.actionBattery.setShortcut('R') def keyPressEvent(self, event): if event.key() not in self.keylist: self.keylist.append(event.key()) self.processmultikeys(self.keylist) def keyReleaseEvent(self, event): if event.key() in self.keylist: if not event.isAutoRepeat(): self.keylist.remove(event.key()) self.processmultikeys(self.keylist) def processmultikeys(self, keyspressed): #TODO send eth control print(self.keylist) Key_G = QtCore.Qt.Key_G in self.keylist Key_J = QtCore.Qt.Key_J in self.keylist Key_Y = QtCore.Qt.Key_Y in self.keylist Key_H = QtCore.Qt.Key_H in self.keylist Key_Q = QtCore.Qt.Key_Q in self.keylist Key_E = QtCore.Qt.Key_E in self.keylist Key_R = QtCore.Qt.Key_R in self.keylist Key_W = QtCore.Qt.Key_W in self.keylist Key_S = QtCore.Qt.Key_S in self.keylist self.device.power = 0 + Key_W - Key_S Key_A = QtCore.Qt.Key_A in self.keylist Key_D = QtCore.Qt.Key_D in self.keylist Key_I = QtCore.Qt.Key_I in self.keylist self.device.direction = 0 + Key_A - Key_D Key_SPACE = QtCore.Qt.Key_Space in self.keylist if (self.device.isConnected()): self.device.movePD(1 + Key_W - Key_S, 1 + Key_A - Key_D) print("ololololololo" + str(Key_W) + "|" + str(QtCore.Qt.Key_W)) self.cam.zdirection = 0 + Key_Q - Key_E self.cam.hdirection = 0 + Key_G - Key_J self.cam.vdirection = 0 + Key_Y - Key_H if (Key_I): self.cam.moveReset() else: if (Key_R): self.cam.home() else: self.cam.move() def closeEvent(self, event): # do stuff self.updater.stop() self.updater.wait() self.device.destroy() print("Goodby, World!") sys.exit() def exitApp(self): self.updater.stop() self.updater.wait() self.device.destroy() print("Goodby, World!") sys.exit() def saveLog(self): self.logger.save() def updateState(self): BatteryState = self.device.getBatteryState() self.leftBatteryState.setValue(int(BatteryState[0])) self.rightBatteryState.setValue(int(BatteryState[1])) self.obstacleLeftTop.setValue(10) self.obstacleRightTop.setValue(10) self.obstacleTop.setValue(10) self.obstacleBottom.setValue(10) #if BatteryState[0] <= 7000: # self.logger.append("Low left battery level") #if BatteryState[1] <= 7000: # self.logger.append("Low right battery level") def addMarkerWithLabel(self): doc = self.mapView.page().mainFrame().documentElement() #user = doc.findFirst("div[id=map_canvas]") #user.evaluateJavaScript("panTo(new google.maps.LatLng(51.98646, 81.90669));") def resetTelemetry(self): self.obstacleLeftTop.setValue(0) self.obstacleRightTop.setValue(0) self.obstacleTop.setValue(0) self.obstacleBottom.setValue(0) def changeConnectionState(self): if (self.device.isConnected()): self.device.disconnect() self.connectStateIndicator.setPixmap(self.device.disconState) self.actionConnect.setText("Connect") self.actionConnect.setShortcut('F5') self.device.currentState = 0 self.resetTelemetry() else: if self.device.connect() == 0: self.connectStateIndicator.setPixmap(self.device.conState) self.actionConnect.setText("Disconnect") self.actionConnect.setShortcut('Ctrl+D') self.device.currentState = 1
class ControlApp(QtGui.QMainWindow, Ui_MainWindow): #def values camDirectionAngle=0 keylist = [] cam = None updater = None def __init__(self, argv): QtGui.QMainWindow.__init__(self) self.MainWindow=Ui_MainWindow self.ui=Ui_MainWindow self.MainWindow.__init__(self.window) self.setupUi(self) self.show() self.logger = Logger(self.logPanel) self.device = EthernetDevice(self.logger) self.device.disconState = QtGui.QPixmap(_fromUtf8('../res/disconnected')) self.device.conState = QtGui.QPixmap(_fromUtf8('../res/connected')) self.device.currentState = 0 self.device.power=0 self.device.direction=0 self.addWidgets() self.updater = DataUpdateThread(self) # create a thread self.updater.trigger.connect(self.updateState) # connect to it's signal self.updater.start() self.cam = Camera(self) def addWidgets(self): """ В этом методе мы добавляем виджеты и wприсоединяем обработчики сигналов. Обработчик сигнала для виджета так же называется "слотом" """ #camview setup #path="C:\\Users\\SCB\\Downloads\\test.avi" path=QtCore.QUrl("rtsp://192.168.2.100:7070/") media = Phonon.MediaSource(path) self.videoPlayer.load(media) self.videoPlayer.play() #set maps properties url = "res.gmap.html" page = QtCore.QUrl("../res/gmap.html") self.mapView.load(page) #thumper pic myPixmap = QtGui.QPixmap(_fromUtf8('../res/thumper_top.jpg')) self.thumperImage.setPixmap(myPixmap) self.thumperImage.setScaledContents(True) #camDirection myPixmap = QtGui.QPixmap(_fromUtf8('../res/cam.png')) myPixmap = myPixmap.transformed(QtGui.QTransform().rotate(self.camDirectionAngle)) self.camDirection.setPixmap(myPixmap) self.camDirection.setScaledContents(True) #logger self.actionSaveLog.triggered.connect(self.saveLog) self.actionSaveLog.setShortcut('Ctrl+S') #define menu actions self.actionExit.triggered.connect(self.exitApp) self.actionExit.setShortcut('Ctrl+Q') #device state #self.connectStateIndicator.connect(self.connectStateIndicator, QtCore.SIGNAL("") self.connectStateIndicator.setPixmap(self.device.disconState) self.connectStateIndicator.setScaledContents(True) self.actionConnect.triggered.connect(self.changeConnectionState) self.actionConnect.setShortcut('F5') self.resetTelemetry() #get state self.actionBattery.triggered.connect(self.addMarkerWithLabel) #init direction level (altitude direction indicator) #init battery state #self.actionBattery.setShortcut('R') def keyPressEvent(self, event): if event.key() not in self.keylist: self.keylist.append(event.key()) self.processmultikeys(self.keylist) def keyReleaseEvent(self, event): if event.key() in self.keylist: if not event.isAutoRepeat(): self.keylist.remove(event.key()) self.processmultikeys(self.keylist) def processmultikeys(self, keyspressed): #TODO send eth control print(self.keylist) Key_G = QtCore.Qt.Key_G in self.keylist Key_J = QtCore.Qt.Key_J in self.keylist Key_Y = QtCore.Qt.Key_Y in self.keylist Key_H = QtCore.Qt.Key_H in self.keylist Key_Q = QtCore.Qt.Key_Q in self.keylist Key_E = QtCore.Qt.Key_E in self.keylist Key_R = QtCore.Qt.Key_R in self.keylist Key_W = QtCore.Qt.Key_W in self.keylist Key_S = QtCore.Qt.Key_S in self.keylist self.device.power = 0 + Key_W - Key_S Key_A = QtCore.Qt.Key_A in self.keylist Key_D = QtCore.Qt.Key_D in self.keylist Key_I = QtCore.Qt.Key_I in self.keylist self.device.direction = 0 + Key_A - Key_D Key_SPACE = QtCore.Qt.Key_Space in self.keylist if(self.device.isConnected()): self.device.movePD(1 + Key_W - Key_S, 1 + Key_A - Key_D) print("ololololololo"+str(Key_W) +"|"+ str(QtCore.Qt.Key_W)) self.cam.zdirection = 0 + Key_Q - Key_E self.cam.hdirection = 0 + Key_G - Key_J self.cam.vdirection = 0 + Key_Y - Key_H if(Key_I): self.cam.moveReset(); else: if(Key_R): self.cam.home(); else: self.cam.move(); def closeEvent(self, event): # do stuff self.updater.stop() self.updater.wait() self.device.destroy() print("Goodby, World!") sys.exit() def exitApp(self): self.updater.stop() self.updater.wait() self.device.destroy() print("Goodby, World!") sys.exit() def saveLog(self): self.logger.save() def updateState(self): BatteryState = self.device.getBatteryState() self.leftBatteryState.setValue(int(BatteryState[0])) self.rightBatteryState.setValue(int(BatteryState[1])) self.obstacleLeftTop.setValue(10) self.obstacleRightTop.setValue(10) self.obstacleTop.setValue(10) self.obstacleBottom.setValue(10) #if BatteryState[0] <= 7000: # self.logger.append("Low left battery level") #if BatteryState[1] <= 7000: # self.logger.append("Low right battery level") def addMarkerWithLabel(self): doc = self.mapView.page().mainFrame().documentElement() #user = doc.findFirst("div[id=map_canvas]") #user.evaluateJavaScript("panTo(new google.maps.LatLng(51.98646, 81.90669));") def resetTelemetry(self): self.obstacleLeftTop.setValue(0) self.obstacleRightTop.setValue(0) self.obstacleTop.setValue(0) self.obstacleBottom.setValue(0) def changeConnectionState(self): if(self.device.isConnected()): self.device.disconnect() self.connectStateIndicator.setPixmap(self.device.disconState) self.actionConnect.setText("Connect") self.actionConnect.setShortcut('F5') self.device.currentState = 0 self.resetTelemetry() else: if self.device.connect() == 0: self.connectStateIndicator.setPixmap(self.device.conState) self.actionConnect.setText("Disconnect") self.actionConnect.setShortcut('Ctrl+D')
def detection_pipeline(log, args=None): """ Detection main function :param log: :param args: :return: """ config = Config(log) img_archive_dir = config.img_archive_dir if not os.path.exists(img_archive_dir): os.makedirs(img_archive_dir) father_dir = os.path.abspath(os.path.dirname(os.path.dirname(__file__))) '''would need a starting time for video''' config.st = datetime.datetime.now() if config.socket_enable: config.start_status_report_timer() if config.reupload_enbale: config.re_upload_cache() config.start_log_upload_timer() # Initialize for each camera if args[1] in ['use_onboard_camera', 'use_local_rtsp']: camera = Camera(log, args[1], local=False, cfg_path=father_dir + '/camera_info.txt') elif args[1] == 'use_captured_video': camera = Camera(log, args[1], local=True, cfg_path=father_dir + '/camera_info.txt') else: log.logger.error('Unrecognized execution mode argument {}'.format(args[1])) exit() dnn_model = DnnModel(log, config) for cam_id in camera.info: motion_roi = camera.info[cam_id]['coord']['bounding_rect'] cov_roi, spot_roi1, spot_roi2 = camera.info[cam_id]['coord']['roi_rects'] parking_ids = camera.info[cam_id]['parking_ids'] transformation_matrix = camera.info[cam_id]['transformation_matrix'] # convert to (left, top, right, bottom), may change in yaml file later. motion_roi = [motion_roi[0], motion_roi[1], motion_roi[0] + motion_roi[2], motion_roi[1] + motion_roi[3]] cov_roi = [cov_roi[0], cov_roi[1], cov_roi[0] + cov_roi[2], cov_roi[1] + cov_roi[3]] spot_roi1 = [spot_roi1[0], spot_roi1[1], spot_roi1[0] + spot_roi1[2], spot_roi1[1] + spot_roi1[3]] spot_roi2 = [spot_roi2[0], spot_roi2[1], spot_roi2[0] + spot_roi2[2], spot_roi2[1] + spot_roi2[3]] # trace_roi are used for backtrace trace_roi = [cov_roi[0] * 2 - cov_roi[2], cov_roi[1], cov_roi[0], cov_roi[3]] # set parameters for different cameras if int(cam_id) == 1: distance_thres = [-0.2, 0.9] elif int(cam_id) == 2: distance_thres = [-0.3, 0.9] elif int(cam_id) == 3: distance_thres = [-0.3, 0.9] else: distance_thres = [-0.3, 0.9] parking_spot = ParkingSpot(log, config, cov_roi, spot_roi1, spot_roi2, parking_ids, trace_roi, distance_thres, camera.info[cam_id]['initial_state']) logic = B_logic(log, 8) motion = Motion(log, motion_roi, dnn_model, parking_spot, logic, transformation_matrix) camera.info[cam_id]['ParkingSpot'] = motion if args[1] == 'use_onboard_camera' or args[1] == 'use_local_rtsp': camera.capture_pic_multithread() while config.cap_on is True: # camera robin-round for cam_id in camera.info: motion = camera.info[cam_id]['ParkingSpot'] parking_draw = camera.info[cam_id]['parking_draw'] # Read frame-by-frame if args[1] == 'use_onboard_camera' or args[1] == 'use_local_rtsp': ret, video_cur_frame, video_cur_time, video_cur_cnt = camera.get_frame_from_queue(cam_id) else: cap = camera.info[cam_id]['video_cap'] if cap is None: continue # Current position of the video file in seconds, indicate current time video_cur_time = cap.get(cv2.CAP_PROP_POS_MSEC) / 1000.0 # Index of the frame to be decoded/captured next video_cur_cnt = cap.get(cv2.CAP_PROP_POS_FRAMES) ret, video_cur_frame = cap.read() if ret is False: log.logger.info('Video Analysis Finished!') config.cap_on = False break elif ret is None: continue '''run each ParkingSpot''' frame_info = {'cur_frame': video_cur_frame, 'cur_time': video_cur_time, 'cur_cnt': video_cur_cnt} if video_cur_cnt % motion.read_step == 0: # frame_for_display is returned for debug, need to change later frame_for_display = detection_flow(log, motion, dnn_model, frame_info) # the rest is added only for debug show_camera(motion, frame_for_display, parking_draw) camera.release_video_cap() config.stop_status_report_timer() config.ftp_upload_enable = False