def _updateDownloadInfo(self, currSpeed, received, total): ''' @param: currSpeed double @param: received qint64 @param: total qint64 ''' if self.DEBUG: print('DEBUG: %s::_updateDownloadInfo %s %s %s' % (self.__class__.__name__, currSpeed, received, total)) # QString QString QString QString # | m_remTime | |m_currSize| |m_fileSize| |m_speed| # Remaining 26 minutes - 339MB of 693 MB (350kB/s) if currSpeed == 0: currSpeed = 1 estimatedTime = ((total - received) / 1024) / (currSpeed / 1024) speed = self.currentSpeedToString(currSpeed) # We have QString speed now time = QTime(0, 0, 0) time = time.addSecs(estimatedTime) remTime = self.remaingTimeToString(time) self._remTime = time currSize = gVar.appTools.fileSizeToString(received) fileSize = gVar.appTools.fileSizeToString(total) if fileSize == _('Unkown size'): self._ui.downloadInfo.setText( _('%s - unkown size (%s)') % (currSize, speed)) else: self._ui.downloadInfo.setText( _('Remaining %s - %s of %s (%s)') % (remTime, currSize, fileSize, speed))
def widget(self) -> QWidget: if not self._widget: self._widget = uic.loadUi( self.context.get_resource("ui/lifelong_learning.ui")) self.le_code = self._widget.findChild(QLineEdit, "leCode") self.le_title = self._widget.findChild(QLineEdit, "leTitle") self.le_location = self._widget.findChild(QLineEdit, "leLocation") self.de_day = self._widget.findChild(QDateEdit, "deDay") now = datetime.now() self.de_day.setDate(now) self.te_beginning = self._widget.findChild(QTimeEdit, "teBeginning") self.te_beginning.setTime(QTime(now.hour, now.minute)) self.te_ending = self._widget.findChild(QTimeEdit, "teEnding") now += timedelta(seconds=3600) self.te_ending.setTime(QTime(now.hour, now.minute)) self.le_credits = self._widget.findChild(QLineEdit, "leCredits") self.le_notes = self._widget.findChild(QLineEdit, "leNotes") self.pb_close = self._widget.findChild(QPushButton, "pbClose") self.pb_close.clicked.connect(self.pb_close_clicked) self.pb_schedule = self._widget.findChild(QPushButton, "pbSchedule") self.pb_schedule.clicked.connect(self.pb_schedule_clicked) self.signal_success.connect(self.success) self.signal_failure.connect(self.failure) return self._widget
def run(self): time = QTime() hora = time.currentTime().toString() self.startTelaDeLog.emit(hora + " - Inicialização do Sistema") while True: hora = time.currentTime().toString() self.horarioEmTempoReal.emit(hora)
def getNome(self): msg, ok = QInputDialog.getText(self, 'Bem Vindo!', 'Olá, qual é seu nome?') if ok: script = ( "Meu nome é Judite, e eu irei lhe auxiliar em sua viagem analisando seu estado físico e mental" + "para evitar qualquer desatenção durante o percurso...") if (self.horario.currentTime() > QTime(5, 59) and self.horario.currentTime() < QTime(12, 0)): tts = gTTS(text='Olá, bom dia ' + msg + "." + script, lang='pt') tts.save("Mensagens Faladas\\boas-vindas.mp3") return msg elif (self.horario.currentTime() > QTime(11, 59) and self.horario.currentTime() < QTime(18, 0)): tts = gTTS(text='Olá, boa tarde ' + msg + "." + script, lang='pt') tts.save("Mensagens Faladas\\boas-vindas.mp3") return msg else: tts = gTTS(text='Olá, boa noite ' + msg + "." + script, lang='pt') tts.save("Mensagens Faladas\\boas-vindas.mp3") return msg
def remaingTimeToString(cls, time): ''' @param: time QTime ''' if time < QTime(0, 0, 10): return _('few seconds') elif time < QTime(0, 1): return _('%s seconds') % time.second() elif time < QTime(1, 0): return _('%s minutes') % time.minute() else: return _('%s hours') % time.hour()
def button_clicked(): dw = self.dialog_widget periodicity = QTime(0, 0).secsTo(dw.periodicity_edit.time()) font_family = dw.font_family_edit.text() font_size = dw.font_size_edit.value() message = dw.alert_message_edit.text() if font_family == '': font_family = None if font_size <= 0: font_size = None if message == '': message = "Untitled simple alert" notification = Notification(message, font_family=font_family, font_size=font_size, color_hex=dw.color_edit.hex_color, sound=dw.sound_edit.sound_name) trigger_time = dw.date_time_edit.dateTime().toTime_t() try: self.app.alert_collection.edit(id_alert, notification=notification, trigger_time=trigger_time, periodicity=periodicity) except KeyError: logging.info("The alert to edit doesn't exist anymore") dw.close()
def pd_timestamp_to_q_datetime(pd_timestamp: datetime): if pd_timestamp is None or pd.isna(pd_timestamp): return QDateTime() return QDateTime( QDate(pd_timestamp.year, pd_timestamp.month, pd_timestamp.day), QTime(pd_timestamp.hour, pd_timestamp.minute, pd_timestamp.second, pd_timestamp.microsecond / 1000))
def loadArtifactOrder(self,event,xml_file=None): if not xml_file: fileName = QFileDialog.getOpenFileName(self, "Open Bookmark File", os.path.join(QtCore.QDir.currentPath(),self.XML_Read.getValue(['Paths','ArtifactOrderSettingsDefault'])), "XBEL Files (*.xbel *.xml)") else: fileName = xml_file if type(fileName)==str: xmlReader = XML_Read(fileName) if not xml_file: self.currentXMLfilepath = fileName else: xmlReader = XML_Read(fileName[0]) if not xml_file: self.currentXMLfilepath = fileName[0] orders = list(zip(*xmlReader.getChildren(['Order'])))[0] self.emptyLayout(self.verticalLayout) for _type in orders: self.verticalLayout.addWidget((DragQLabel(self.XML_Read.getValue(['ArtefactCategories',_type,'Text']),xml_text=_type,parent=self.verticalLayout))) pause_minute = xmlReader.getValue(['PauseInBetweenTrials','Minute']) pause_second = xmlReader.getValue(['PauseInBetweenTrials','Second']) self.timeEditInBetweenTrials.setTime(QTime(0,int(pause_minute),int(pause_second),0)) self.sbAmountTrials.setValue(int(xmlReader.getValue(['AmountOfTrials'])))
def button_clicked(): dw = self.dialog_widget periodicity = QTime(0, 0).secsTo(dw.periodicity_edit.time()) font_family = dw.font_family_edit.text() font_size = dw.font_size_edit.value() message = dw.alert_message_edit.text() if periodicity == 0: periodicity = None if font_family == '': font_family = None if font_size <= 0: font_size = None if message == '': message = "Untitled simple alert" notification = Notification(message, font_family=font_family, font_size=font_size, color_hex=dw.color_edit.hex_color, sound=dw.sound_edit.sound_name) new_alert = SimpleAlert(dw.date_time_edit.dateTime().toTime_t(), notification, periodicity=periodicity) self.app.alert_collection.add(new_alert) dw.close()
def updateClock(self): # What time is it ? cur = QTime.currentTime() self.from_time_updater = True self.ui.timeEdit.setTime(cur) self.from_time_updater = False
def updateClock(self): # What time is it ? cur = QTime.currentTime() self.from_time_updater = True self.ui.timeEdit.setTime(cur) self.from_time_updater = False
def duration_to_seconds(self): """ Return "duration" QTimeEdit value in seconds :return: "duration" in seconds :rtype: int """ return QTime(0, 0).secsTo(self.duration.time())
def __init__(self, type_, parent=None): self._type = type_ self._parent = None # BookmarkItem self._children = [] # QList<BookmarkItem> self._url = QUrl() self._title = '' self._description = '' self._keyword = '' self._icon = QIcon() self._iconTime = QTime() self._visitCount = 0 self._expanded = False self._sidebarExpanded = False if parent: parent.addChild(self) assert (self._parent == parent)
def show_clock(self): self.clock_label.setVisible(True) self.clock_label.setText(QTime(22, 33, 33).toString(Qt.SystemLocaleShortDate)) self.clock_timer.start(1000) self.clock_label.setStyleSheet(self.info_label_style%( 'rgba(0, 0, 0, 0)', self.view.document.colors()[1])) self.clock_label.resize(self.clock_label.sizeHint()) self.update_clock()
def __init__(self, item, downloadItem, path, fileName, openFile, manager): ''' @param: item QListWidgetItem @param: downloadItem QWebEngineDownloadItem @param: path QString @param: fileName QString @param: openFile bool @param: manager DownloadManager ''' super().__init__() self._ui = uic.loadUi('mc/downloads/DownloadItem.ui', self) self._item = item # QListWidgetItem self._download = downloadItem # QWebEngineDownloadItem self._path = path self._fileName = fileName self._downTimer = QTime() self._remTime = QTime() self._downUrl = downloadItem.url() self._openFile = openFile self._downloading = False self._downloadStopped = False self._currSpeed = 0.0 self._received = downloadItem.receivedBytes() self._total = downloadItem.totalBytes() if self.DEBUG: print( 'DEBUG: %s::__init__ %s %s %s %s' % (self.__class__.__name__, item, downloadItem, path, fileName)) self.setMaximumWidth(525) self._ui.button.setPixmap( QIcon.fromTheme('process-stop').pixmap(20, 20)) self._ui.fileName.setText(self._fileName) self._ui.downloadInfo.setText(_('Remaining time unavailable')) self.setContextMenuPolicy(Qt.CustomContextMenu) self.customContextMenuRequested.connect( self._customContextMenuRequested) self._ui.button.clicked.connect(self._stop) manager.resized.connect(self._parentResized)
def initialize(self, typ=None, val=None): if typ is None: typ = 'day/time' val = (-1, 6, 0) if typ == 'day/time': val = convert_day_time_schedule(val) days_of_week, hour, minute = val for i, d in enumerate(self.days): d.setChecked(i in days_of_week) self.time.setTime(QTime(hour, minute))
def _init(self): from .History import History minTs = HistoryDbModel.select(peewee.fn.Min( HistoryDbModel.date)).scalar() if minTs <= 0: return today = QDate.currentDate() week = today.addDays(1 - today.dayOfWeek()) month = QDate(today.year(), today.month(), 1) currentTs = QDateTime.currentMSecsSinceEpoch() ts = currentTs while ts > minTs: tsDate = QDateTime.fromMSecsSinceEpoch(ts).date() endTs = 0 itemName = '' if tsDate == today: endTs = QDateTime(today).toMSecsSinceEpoch() itemName = _('Today') elif tsDate >= week: endTs = QDateTime(week).toMSecsSinceEpoch() itemName = _('This Week') elif tsDate.month() == month.month() and tsDate.year( ) == month.year(): endTs = QDateTime(month).toMSecsSinceEpoch() itemName = _('This Month') else: startDate = QDate(tsDate.year(), tsDate.month(), tsDate.daysInMonth()) endDate = QDate(startDate.year(), startDate.month(), 1) ts = QDateTime(startDate, QTime(23, 59, 59)).toMSecsSinceEpoch() endTs = QDateTime(endDate).toMSecsSinceEpoch() itemName = '%s %s' % (tsDate.year(), History.titleCaseLocalizedMonth( tsDate.month())) dbobj = HistoryDbModel.select().where( HistoryDbModel.date.between(endTs, ts)).first() if dbobj: item = HistoryItem(self._rootItem) item.setStartTimestamp(ts == currentTs and -1 or ts) item.setEndTimestamp(endTs) item.title = itemName item.canFetchMore = True if ts == currentTs: self._todayItem = item ts = endTs - 1
def timerEvent(self, event): ''' @param: event QTimerEvent ''' remTimes = [] # QVector<QTime> progresses = [] # QVector<int> speeds = [] # QVector<double> if event.timerId() == self._timer.timerId(): if not self._ui.list.count(): self._ui.speedLabel.clear() self.setWindowTitle(_('Download Manager')) if const.OS_WIN: self.taskbarButton().progress().hide() return for idx in range(self._ui.list.count()): downItem = self._ui.list.itemWidget(self._ui.list.item(idx)) if not isinstance(downItem, DownloadItem) or downItem.isCancelled() \ or not downItem.isDownloading(): continue progresses.append(downItem.progress()) remTimes.append(downItem.remainingTime()) speeds.append(downItem.currentSpeed()) if not remTimes: return remaining = QTime() for time in remTimes: if time > remaining: remaining = time progress = 0 for prog in progresses: progress += prog progress = int(progress / len(progresses) * 100) / 100 speed = sum(speeds) if not const.OS_WIN: self._ui.speedLabel.setText( _('%s%% of %s files (%s) %s remaining') % (progress, len(progresses), DownloadItem.currentSpeedToString(speed), DownloadItem.remainingTimeToString(remaining))) else: self.setWindowTitle(_('%s%% - Download Manager') % progress) if const.OS_WIN: self.taskbarButton().progress().show() self.taskbarButton().progress().setValue(progress) super().timerEvent(event)
def show_time(self): # 更新时间 time_now = QTime.currentTime() time_text = time_now.toString(Qt.DefaultLocaleLongDate) # 冒号闪烁 if self.__ShowColon: self.__ShowColon = False else: time_text = time_text.replace(':', ' ') self.__ShowColon = True self.display(time_text)
def showTime(self): # 更新时间的显示 time = QTime.currentTime() # 获取当前时间 time_text = time.toString(Qt.DefaultLocaleLongDate) # 获取HH:MM:SS格式的时间 # 冒号闪烁 if self.__ShowColon == True: self.__ShowColon = False else: time_text = time_text.replace(':', ' ') self.__ShowColon = True self.display(time_text) # 显示时间
def showTime(self): #更新时间的显示 time = QTime.currentTime() #获取当前时间 time_text = time.toString( Qt.DefaultLocaleLongDate ) #获取HH:MM:SS格式的时间,在中国获取后是这个格式,其他国家我不知道,如果有土豪愿意送我去外国旅行的话我就可以试一试 #冒号闪烁 if self.__ShowColon == True: self.__ShowColon = False else: time_text = time_text.replace(':', ' ') self.__ShowColon = True self.display(time_text) #显示时间
def in_timer(self, action_time, action_type): try: while True: now = QTime.currentTime().toString() if now == action_time: print(123) os.system(action_type) raise StopIteration break elif self.action_time_thread_kill is True: print("Stop") self.restore() break except StopIteration: self.restore()
def setupUi(self, my_win): super().setupUi(my_win) self.sub_menu_inicio.aboutToShow.connect(self.volver_incio) self.sub_menu_registro.triggered.connect(self.mostrar_registrar_cancion) self.sub_meni_listado_canciones.triggered.connect(self.mostrar_listado_canciones) self.sub_menu_tabla_Canciones.triggered.connect(self.mostrar_tabla_canciones) self.sub_menu_registro_usuario.triggered.connect(self.registrar_usuario) #incluir fecha date = QDate.currentDate() date = str(date.toPyDate()) self.txt_fecha.setText(date) #incluir hora hora = QTime.currentTime() hora_txt = hora.toString("hh:mm") self.lcdNumber.display(hora_txt)
def __init__(self, call_type, path, parent=None): super(VideoInfoDialog, self).__init__(parent) self.call_type = call_type self.path = path self.ui = Ui_VideoInfoDialog() self.db = Video() self.ui.setupUi(self) self.ui.pathLineEdit.setEnabled(False) if self.call_type == "add": self.ui.okButton.setEnabled(False) elif self.call_type == "edit": video_info = self.db.select_video_info_by_path(self.path)[0] name = Video.get_video_info_name(video_info) start_str = Video.get_video_info_start(video_info) end_str = Video.get_video_info_end(video_info) self.ui.pathSelectButton.setEnabled(False) self.ui.pathLineEdit.setText(self.path) self.ui.nameLineEdit.setText(name) start = QTime() start.setHMS(int(start_str.split(":")[0]), int(start_str.split(":")[1]), int(start_str.split(":")[2])) end = QTime() end.setHMS(int(end_str.split(":")[0]), int(end_str.split(":")[1]), int(end_str.split(":")[2])) self.ui.startTimeEdit.setTime(start) self.ui.endTimeEdit.setTime(end) self.ui.okButton.setEnabled(True) else: pass self.ui.okButton.clicked.connect(self.confirm) self.ui.pathSelectButton.clicked.connect(self.select_file) self.ui.cancelButton.clicked.connect(self.close)
#coding:utf-8
def update_clock(self): self.clock_label.setText(QTime.currentTime().toString(Qt.SystemLocaleShortDate))
def update_clock(self): self.clock_label.setText(QTime.currentTime().toString(Qt.SystemLocaleShortDate))
def __init__(self): super().__init__() self.setupUi(self) self.video_path = '2019-05-06-10-45-16-tv_30_tnf.avi' self.video_capturer = cv2.VideoCapture(self.video_path) self.video_status = 'Video is not playing' self.width = int(self.video_capturer.get(cv2.CAP_PROP_FRAME_WIDTH)) self.height = int(self.video_capturer.get(cv2.CAP_PROP_FRAME_HEIGHT)) self.out = cv2.VideoWriter(self.video_path[:-4] + '_label.avi', cv2.VideoWriter_fourcc(*'XVID'), 25.0, (self.width, self.height)) self.video_frame = None self.video_src = 'camera' self.proc_image_width = 960 self.proc_image_height = 540 self.proc_qimage = QImage() self.proc_qpixmap = QPixmap() self.tmr = QTimer(self) self.tmr.setInterval(40) self.tmr.timeout.connect(self.timeout_slot) self.tmr.start() self.time = QTime() self.time.start() self.fps_period = None self.last_timestamp = self.time.elapsed() self.enable_detector = False self.enable_detector_yolo = False self.enable_playing = False self.enable_record = False self.cnn_model_path = 'output_models/frozen_inference_graph.pb' self.cfg_yolo_path = 'output_modelsgoit/yolov2.cfg' self.weights_yolo_path = 'output_models/yolov2_last.weights' self.ssd = None self.yolo = None self.camera_id = 0 self.camera_capturer = cv2.VideoCapture(self.camera_id) self.camera_status = 'Stream is non active' self.camera_frame = None self.setWindowTitle('SKL CNN Classifier') self.checkBox_enable_detection.toggled.connect( self.checkbox_enable_detection_toggled) self.checkBox_enable_playing.toggled.connect( self.checkbox_enable_playing_toggled) self.checkBox_enable_camera.toggled.connect( self.checkbox_enable_camera_toggled) self.checkBox_enable_detection_yolo.toggled.connect( self.checkBox_enable_detection_yolo_toggled) self.checkBox_enable_record.toggled.connect( self.checkBox_enable_record_toggled) self.lineEdit_path_video.editingFinished.connect( self.lineedit_path_video_editing_finished) self.lineEdit_path_graph.editingFinished.connect( self.lineedit_path_graph_editing_finished) self.lineEdit_path_cfg_yolo.editingFinished.connect( self.lineedit_path_cfg_yolo_editing_finished) self.lineEdit_path_weight_yolo.editingFinished.connect( self.lineedit_path_weight_yolo_editing_finished) self.pushButton_load_video.clicked.connect( self.pushbutton_load_video_clicked) self.pushButton_load_graph.clicked.connect( self.pushbutton_load_graph_clicked) self.pushButton_load_cdg_yolo.clicked.connect( self.pushButton_load_cdg_yolo_clicked) self.pushButton_load_weights_yolo.clicked.connect( self.pushButton_load_weights_yolo_clicked) self.lineEdit_path_video.setText(self.video_path) self.lineEdit_path_graph.setText(self.cnn_model_path) self.lineEdit_path_cfg_yolo.setText(self.cfg_yolo_path) self.lineEdit_path_weight_yolo.setText(self.weights_yolo_path) self.checkBox_enable_camera.setChecked(True) pass
class guiApp(QtWidgets.QMainWindow, mainwindow.Ui_MainWindow): def __init__(self): super().__init__() self.setupUi(self) self.video_path = '2019-05-06-10-45-16-tv_30_tnf.avi' self.video_capturer = cv2.VideoCapture(self.video_path) self.video_status = 'Video is not playing' self.width = int(self.video_capturer.get(cv2.CAP_PROP_FRAME_WIDTH)) self.height = int(self.video_capturer.get(cv2.CAP_PROP_FRAME_HEIGHT)) self.out = cv2.VideoWriter(self.video_path[:-4] + '_label.avi', cv2.VideoWriter_fourcc(*'XVID'), 25.0, (self.width, self.height)) self.video_frame = None self.video_src = 'camera' self.proc_image_width = 960 self.proc_image_height = 540 self.proc_qimage = QImage() self.proc_qpixmap = QPixmap() self.tmr = QTimer(self) self.tmr.setInterval(40) self.tmr.timeout.connect(self.timeout_slot) self.tmr.start() self.time = QTime() self.time.start() self.fps_period = None self.last_timestamp = self.time.elapsed() self.enable_detector = False self.enable_detector_yolo = False self.enable_playing = False self.enable_record = False self.cnn_model_path = 'output_models/frozen_inference_graph.pb' self.cfg_yolo_path = 'output_modelsgoit/yolov2.cfg' self.weights_yolo_path = 'output_models/yolov2_last.weights' self.ssd = None self.yolo = None self.camera_id = 0 self.camera_capturer = cv2.VideoCapture(self.camera_id) self.camera_status = 'Stream is non active' self.camera_frame = None self.setWindowTitle('SKL CNN Classifier') self.checkBox_enable_detection.toggled.connect( self.checkbox_enable_detection_toggled) self.checkBox_enable_playing.toggled.connect( self.checkbox_enable_playing_toggled) self.checkBox_enable_camera.toggled.connect( self.checkbox_enable_camera_toggled) self.checkBox_enable_detection_yolo.toggled.connect( self.checkBox_enable_detection_yolo_toggled) self.checkBox_enable_record.toggled.connect( self.checkBox_enable_record_toggled) self.lineEdit_path_video.editingFinished.connect( self.lineedit_path_video_editing_finished) self.lineEdit_path_graph.editingFinished.connect( self.lineedit_path_graph_editing_finished) self.lineEdit_path_cfg_yolo.editingFinished.connect( self.lineedit_path_cfg_yolo_editing_finished) self.lineEdit_path_weight_yolo.editingFinished.connect( self.lineedit_path_weight_yolo_editing_finished) self.pushButton_load_video.clicked.connect( self.pushbutton_load_video_clicked) self.pushButton_load_graph.clicked.connect( self.pushbutton_load_graph_clicked) self.pushButton_load_cdg_yolo.clicked.connect( self.pushButton_load_cdg_yolo_clicked) self.pushButton_load_weights_yolo.clicked.connect( self.pushButton_load_weights_yolo_clicked) self.lineEdit_path_video.setText(self.video_path) self.lineEdit_path_graph.setText(self.cnn_model_path) self.lineEdit_path_cfg_yolo.setText(self.cfg_yolo_path) self.lineEdit_path_weight_yolo.setText(self.weights_yolo_path) self.checkBox_enable_camera.setChecked(True) pass def timeout_slot(self): if self.video_src == 'camera': self.refresh_camera_frame() self.proc_frame = self.camera_frame if self.video_src == 'video': self.refresh_video_frame() self.proc_frame = self.video_frame if self.proc_frame is not None: if self.enable_detector: cropimg = self.proc_frame[ 0:self.proc_frame.shape[0], int((self.proc_frame.shape[1] - self.proc_frame.shape[0]) / 2):int((self.proc_frame.shape[1] + self.proc_frame.shape[0]) / 2), :] ssd_image = self.ssd.forwardpass(cropimg) self.proc_frame[0:self.proc_frame.shape[0], int((self.proc_frame.shape[1] - self.proc_frame.shape[0]) / 2):int((self.proc_frame.shape[1] + self.proc_frame.shape[0]) / 2), :] = ssd_image cv2.rectangle(self.proc_frame, (int( (self.proc_frame.shape[1] - self.proc_frame.shape[0]) / 2), 0), (int( (self.proc_frame.shape[1] + self.proc_frame.shape[0]) / 2), self.proc_frame.shape[0]), (255, 0, 0), 2) elif self.enable_detector_yolo: cropimg = self.proc_frame[ 0:self.proc_frame.shape[0], int((self.proc_frame.shape[1] - self.proc_frame.shape[0]) / 2):int((self.proc_frame.shape[1] + self.proc_frame.shape[0]) / 2), :] yolo_image = self.yolo.detect_by_yolo(cropimg) self.proc_frame[0:self.proc_frame.shape[0], int((self.proc_frame.shape[1] - self.proc_frame.shape[0]) / 2):int((self.proc_frame.shape[1] + self.proc_frame.shape[0]) / 2), :] = yolo_image cv2.rectangle(self.proc_frame, (int( (self.proc_frame.shape[1] - self.proc_frame.shape[0]) / 2), 0), (int( (self.proc_frame.shape[1] + self.proc_frame.shape[0]) / 2), self.proc_frame.shape[0]), (255, 0, 0), 2) if self.enable_record: self.out.write(cv2.cvtColor(self.proc_frame, cv2.COLOR_RGB2BGR)) self.proc_frame = cv2.resize( self.proc_frame, (self.proc_image_width, self.proc_image_height), interpolation=cv2.INTER_CUBIC) self.proc_qimage = convert_ndarray_to_qimg(self.proc_frame) self.proc_qpixmap = QPixmap.fromImage(self.proc_qimage) if self.proc_qpixmap is not None: self.label_image.setPixmap(self.proc_qpixmap) cur_time = self.time.elapsed() self.fps_period = cur_time - self.last_timestamp self.last_timestamp = cur_time self.label_processing_time.setText(str(self.fps_period)) self.label_fps.setText(str(int(1000.0 / self.fps_period))) pass def refresh_camera_frame(self): ret, self.camera_frame = self.camera_capturer.read() if self.camera_frame is not None: self.camera_frame = cv2.cvtColor(self.camera_frame, cv2.COLOR_BGR2RGB) self.camera_status = 'Capturing in progress' else: self.camera_status = 'Error' pass def refresh_camera_stream(self): self.camera_capturer.release() self.camera_capturer = cv2.VideoCapture(self.camera_id) pass def refresh_video_frame(self): ret, self.video_frame = self.video_capturer.read() if self.video_frame is not None: self.video_frame = cv2.cvtColor(self.video_frame, cv2.COLOR_BGR2RGB) self.video_status = 'Playing in progress' else: self.video_status = 'Error' self.label_video_status.setText(self.video_status) pass def refresh_video_stream(self): self.video_capturer.release() self.video_capturer = cv2.VideoCapture(self.video_path) def lineedit_path_video_editing_finished(self): self.video_path = self.lineEdit_path_video.text() self.width = int(self.video_capturer.get(cv2.CAP_PROP_FRAME_WIDTH)) self.height = int(self.video_capturer.get(cv2.CAP_PROP_FRAME_HEIGHT)) self.out = cv2.VideoWriter(self.video_path[:-4] + '_label.avi', cv2.VideoWriter_fourcc(*'XVID'), 25.0, (self.width, self.height)) self.refresh_video_stream() pass def lineedit_path_graph_editing_finished(self): self.cnn_model_path = self.lineEdit_path_graph.text() pass def lineedit_path_cfg_yolo_editing_finished(self): self.cfg_yolo_path = self.lineEdit_path_cfg_yolo.text() pass def lineedit_path_weight_yolo_editing_finished(self): self.weights_yolo_path = self.lineEdit_path_weight_yolo.text() pass def checkbox_enable_detection_toggled(self, checked): if self.ssd is not tf_classifier: self.ssd = tf_classifier() self.ssd.select_path_to_model(self.cnn_model_path) self.enable_detector = checked pass def checkBox_enable_detection_yolo_toggled(self, checked): if self.yolo is not df_classifier: self.yolo = df_classifier() self.yolo.select_path_to_model(self.cfg_yolo_path, self.weights_yolo_path) self.enable_detector_yolo = checked pass def checkbox_enable_camera_toggled(self, checked): if checked: self.video_src = 'camera' else: self.video_src = 'none' self.switch_video_src(self.video_src) pass def checkbox_enable_playing_toggled(self, checked): if checked: self.video_src = 'video' else: self.video_src = 'none' self.switch_video_src(self.video_src) pass def checkBox_enable_record_toggled(self, checked): self.enable_record = checked pass def switch_video_src(self, new_src): if new_src == 'camera': self.checkBox_enable_playing.setChecked(False) self.checkBox_enable_camera.setChecked(True) elif new_src == 'video': self.checkBox_enable_playing.setChecked(True) self.checkBox_enable_camera.setChecked(False) else: self.checkBox_enable_playing.setChecked(False) self.checkBox_enable_camera.setChecked(False) pass def pushbutton_load_video_clicked(self): fname = QFileDialog.getOpenFileName(self, 'Select video', '')[0] self.lineEdit_path_video.setText(fname) self.video_path = self.lineEdit_path_video.text() self.refresh_video_stream() pass def pushbutton_load_graph_clicked(self): fname = QFileDialog.getOpenFileName(self, 'Select graph SSD', '')[0] self.lineEdit_path_graph.setText(fname) pass def pushButton_load_cdg_yolo_clicked(self): fname = QFileDialog.getOpenFileName(self, 'Select cfg Yolo', '')[0] self.lineEdit_path_cfg_yolo.setText(fname) pass def pushButton_load_weights_yolo_clicked(self): fname = QFileDialog.getOpenFileName(self, 'Select weights Yolo', '')[0] self.lineEdit_path_weight_yolo.setText(fname) pass
def download(self, downloadItem): # noqa C901 ''' @param: downloadItem QWebEngineDownloadItem ''' downloadTimer = QTime() downloadTimer.start() self.closeDownloadTab(downloadItem) downloadPath = '' openFile = False fileName = basename(downloadItem.path()) forceAsk = downloadItem.savePageFormat() != QWebEngineDownloadItem.UnknownSaveFormat \ or downloadItem.type() == QWebEngineDownloadItem.UserRequested if self._useExternalManager: self.startExternalManager(downloadItem.url()) elif forceAsk or not self._downloadPath: (Unknown, Open, Save, ExternalManager, SavePage) = range(5) result = Unknown if downloadItem.savePageFormat( ) != QWebEngineDownloadItem.UnknownSaveFormat: # Save Page Requested result = SavePage elif downloadItem.type() == QWebEngineDownloadItem.UserRequested: # Save x as... requested result = Save else: # Ask what to do optionsDialog = DownloadOptionsDialog(fileName, downloadItem, gVar.app.activeWindow()) optionsDialog.showExternalManagerOption( self._useExternalManager) optionsDialog.setLastDownloadOption(self._lastDownloadOption) result = optionsDialog.exec_() if result == Open: openFile = True downloadPath = gVar.appTools.ensureUniqueFilename( pathjoin(DataPaths.path(DataPaths.Temp), fileName)) self._lastDownloadOption = self.OpenFile elif result == Save: downloadPath, selectedFitler = QFileDialog.getSaveFileName( gVar.app.activeWindow(), _('Save file as...'), pathjoin(self._lastDownloadPath, fileName)) if downloadPath: self._lastDownloadPath = QFileInfo( downloadPath).absolutePath() Settings().setValue('DownloadManager/lastDownloadPath', self._lastDownloadPath) self._lastDownloadOption = self.SaveFile elif result == SavePage: mhtml = _('MIME HTML Archive (*.mhtml)') htmlSingle = _('HTML Page, single (*.html)') htmlComplete = _('HTML Page, complete (*.html)') filter_ = '%s;;%s;;%s' % (mhtml, htmlSingle, htmlComplete) selectedFilter = '' downloadPath, selectedFilter = QFileDialog.getSaveFileName( gVar.app.activeWindow(), _('Save page as...'), pathjoin(self._lastDownloadPath, fileName), filter_, selectedFilter) if downloadPath: self._lastDownloadPath = QFileInfo( downloadPath).absolutePath() Settings().setValue('DownloadManager/lastDownloadPath', self._lastDownloadPath) self._lastDownloadOption = self.SaveFile format_ = QWebEngineDownloadItem.UnknownSaveFormat if selectedFilter == mhtml: format_ = QWebEngineDownloadItem.MimeHtmlSaveFormat elif selectedFilter == htmlSingle: format_ = QWebEngineDownloadItem.SingleHtmlSaveFormat elif selectedFilter == htmlComplete: format_ = QWebEngineDownloadItem.CompleteHtmlSaveFormat if format_ == QWebEngineDownloadItem.UnknownSaveFormat: downloadItem.setSavePageFormat(format_) elif result == ExternalManager: self.startExternalManager(downloadItem.url()) downloadItem.cancel() else: downloadItem.cancel() else: downloadPath = gVar.appTools.ensureUniqueFilename( pathjoin(self._downloadPath, fileName)) if not downloadPath: downloadItem.cancel() return # Set download path ad accept downloadItem.setPath(downloadPath) downloadItem.accept() # Create download item listItem = QListWidgetItem(self._ui.list) downItem = DownloadItem(listItem, downloadItem, QFileInfo(downloadPath).absolutePath(), basename(downloadPath), openFile, self) downItem.setDownTimer(downloadTimer) downItem.startDownloading() downItem.deleteItem.connect(self._deleteItem) downItem.downloadFinished.connect(self._downloadFinished) self._ui.list.setItemWidget(listItem, downItem) listItem.setSizeHint(downItem.sizeHint()) downItem.show() self._activeDownloadsCount += 1 self.downloadsCountChanged.emit()
def _handle_date_changed_from_calendar(self, value): self.value = QDateTime(value, QTime(0, 0))
def initialize(self, typ=None, val=None): if val is None: val = ((1,), 6, 0) days_of_month, hour, minute = val self.days.setText(', '.join(map(str, map(int, days_of_month)))) self.time.setTime(QTime(hour, minute))