class Ui_MainWindow(object): def setupUi(self, MainWindow): MainWindow.setObjectName("MainWindow") MainWindow.resize(496, 286) self.centralwidget = QtWidgets.QWidget(MainWindow) self.centralwidget.setObjectName("centralwidget") self.verticalLayout = QtWidgets.QVBoxLayout(self.centralwidget) self.verticalLayout.setObjectName("verticalLayout") self.sw_video = QtWidgets.QStackedWidget(self.centralwidget) self.sw_video.setObjectName("sw_video") self.w_video = QtWidgets.QWidget() self.w_video.setObjectName("w_video") self.horizontalLayout_2 = QtWidgets.QHBoxLayout(self.w_video) self.horizontalLayout_2.setObjectName("horizontalLayout_2") self.v_video = Video(self.w_video) self.v_video.setObjectName("v_video") self.horizontalLayout_2.addWidget(self.v_video) self.sw_video.addWidget(self.w_video) self.page_2 = QtWidgets.QWidget() self.page_2.setObjectName("page_2") self.sw_video.addWidget(self.page_2) self.verticalLayout.addWidget(self.sw_video) self.horizontalLayout = QtWidgets.QHBoxLayout() self.horizontalLayout.setObjectName("horizontalLayout") spacerItem = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum) self.horizontalLayout.addItem(spacerItem) self.pb_start = QtWidgets.QPushButton(self.centralwidget) self.pb_start.setObjectName("pb_start") self.horizontalLayout.addWidget(self.pb_start) spacerItem1 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum) self.horizontalLayout.addItem(spacerItem1) self.verticalLayout.addLayout(self.horizontalLayout) MainWindow.setCentralWidget(self.centralwidget) self.menubar = QtWidgets.QMenuBar(MainWindow) self.menubar.setGeometry(QtCore.QRect(0, 0, 496, 23)) self.menubar.setObjectName("menubar") MainWindow.setMenuBar(self.menubar) self.statusbar = QtWidgets.QStatusBar(MainWindow) self.statusbar.setObjectName("statusbar") MainWindow.setStatusBar(self.statusbar) self.retranslateUi(MainWindow) QtCore.QMetaObject.connectSlotsByName(MainWindow) def retranslateUi(self, MainWindow): _translate = QtCore.QCoreApplication.translate MainWindow.setWindowTitle(_translate("MainWindow", "MainWindow")) self.v_video.setText(_translate("MainWindow", "TextLabel")) self.pb_start.setText(_translate("MainWindow", "PushButton"))
def main(argv): try: # read YAML configuration _loader = ConfigLoader(Level.INFO) filename = 'config.yaml' _config = _loader.configure(filename) _lux = Lux(Level.INFO) _matrix11x7_stbd_available = True _video = Video(_config, _lux, _matrix11x7_stbd_available, Level.INFO) _video.start() while True: time.sleep(1.0) _video.stop() except KeyboardInterrupt: print(Fore.CYAN + Style.BRIGHT + 'caught Ctrl-C; exiting...') if _video is not None: _video.stop() except Exception: print(Fore.RED + Style.BRIGHT + 'error starting ros: {}'.format(traceback.format_exc()) + Style.RESET_ALL)
def run(youtube_src): Video.connect() youtube_id = __parse_youtube_src(youtube_src) video = get_video(youtube_src) if video: return video.attributes() else: add_new_video.delay(youtube_id) return { 'delayed': 'true' } Video.disconnect()
def main(): main_window_name = 'main_window_name' selecting = False initial_x = -1 initial_y = -1 def crop_cb(event, x, y, flag, params): global initial_x, initial_y, selecting if event == cv.EVENT_LBUTTONDOWN: selecting = True initial_x, initial_y = x, y elif (event == cv.EVENT_MOUSEMOVE and selecting == True): print((initial_x, initial_y, x, y)) elif event == cv.EVENT_LBUTTONUP: selecting = False print((initial_x, initial_y, x, y)) cv.namedWindow(main_window_name) cv.setMouseCallback(main_window_name, crop_cb) with Video(path='./test_assets/long_run.mov', step=1000) as video: for _, frame in video.play(): cv.imshow(main_window_name, frame) key = cv.waitKey(10000) elif key == ord('q'): break
def main(argv): _video = None try: # read YAML configuration _loader = ConfigLoader(Level.INFO) _config = _loader.configure('config.yaml') _video = Video(_config, Level.INFO) _video.start() while True: time.sleep(1.0) except KeyboardInterrupt: print(Fore.CYAN + Style.BRIGHT + 'caught Ctrl-C; exiting...') except Exception: print(Fore.RED + Style.BRIGHT + 'error starting ros: {}'.format(traceback.format_exc()) + Style.RESET_ALL) finally: if _video is not None: _video.stop()
def add_new_video(youtube_id): Video.connect() # # iterate all the workers and all the running jobs # and stop the ones that already running # def find_duplicated_job(): run_count = 0 workers = app.control.inspect() active = workers.active() for worker, jobs in active.iteritems(): for job in jobs: # args is a string tuple =\. need to get the id match = re.match(r'\(u\'(.{11})\',\)', job['args']) if match and match.group(1) == youtube_id: run_count += 1 return run_count > 1 if find_duplicated_job(): print "Already running " return dl = Downloader() tr = TrumpRecognizer() video = Video() try: (path_to_wave, thumbnail, title) = dl.start(youtube_id) except VideoTooLong as e: video.set(youtube_id=youtube_id, state="too_long") video.save() return except DownlaodError as e: video.set(youtube_id=youtube_id, state="download_error") return # Video might already exist if multiple jobs are in the queue if video.fetch(youtube_id): return (rate, predictions) = tr.recognize(path_to_wave) video.set( youtube_id = youtube_id, thumbnail = thumbnail, title = title, rate = rate, predictions = predictions ) video.save() Video.disconnect()
def get_video(youtube_src): youtube_id = __parse_youtube_src(youtube_src) video = Video() if video.fetch(youtube_id): return video
def popular(): Video.connect() video = Video() popular = video.last() video.disconnect() return popular
def __epoch_features(self, epoch_number, image_processor): video = Video(self.__epoch_video_path(epoch_number)) images = video.images(image_processor) video.close() return images
def add_new_video(youtube_id): Video.connect() # # iterate all the workers and all the running jobs # and stop the ones that already running # def find_duplicated_job(): run_count = 0 workers = app.control.inspect() active = workers.active() for worker, jobs in active.iteritems(): for job in jobs: # args is a string tuple =\. need to get the id match = re.match(r'\(u\'(.{11})\',\)', job['args']) if match and match.group(1) == youtube_id: run_count += 1 return run_count > 1 if find_duplicated_job(): print "Already running " return dl = Downloader() tr = TrumpRecognizer() video = Video() try: (path_to_wave, thumbnail, title) = dl.start(youtube_id) except VideoTooLong as e: video.set(youtube_id=youtube_id, state="too_long") video.save() return except DownlaodError as e: video.set(youtube_id=youtube_id, state="download_error") return # Video might already exist if multiple jobs are in the queue if video.fetch(youtube_id): return (rate, predictions) = tr.recognize(path_to_wave) video.set(youtube_id=youtube_id, thumbnail=thumbnail, title=title, rate=rate, predictions=predictions) video.save() Video.disconnect()