|
|
@ -1,10 +1,11 @@ |
|
|
|
import sys |
|
|
|
import cv2 |
|
|
|
import threading |
|
|
|
|
|
|
|
from core import Video, Mark |
|
|
|
|
|
|
|
from PySide6.QtCore import (QCoreApplication, QDate, QDateTime, QLocale, |
|
|
|
QMetaObject, QObject, QPoint, QRect, |
|
|
|
QMetaObject, QObject, QPoint, QRect, QTimer, |
|
|
|
QSize, QTime, QUrl, Qt) |
|
|
|
from PySide6.QtGui import (QAction, QBrush, QColor, QConicalGradient, |
|
|
|
QCursor, QFont, QFontDatabase, QGradient, |
|
|
@ -28,6 +29,10 @@ class Ui_MainWindow(object): |
|
|
|
self.pushButton_2.setObjectName(u"pushButton_2") |
|
|
|
self.graphicsView = QGraphicsView(self.centralwidget) |
|
|
|
self.graphicsView.setObjectName(u"graphicsView") |
|
|
|
self.graphicsView_2 = QGraphicsView(self.centralwidget) |
|
|
|
self.graphicsView_2.setObjectName(u"graphicsView_2") |
|
|
|
self.graphicsView_3 = QGraphicsView(self.centralwidget) |
|
|
|
self.graphicsView_3.setObjectName(u"graphicsView_3") |
|
|
|
self.textBrowser = QTextBrowser(self.centralwidget) |
|
|
|
self.textBrowser.setObjectName(u"textBrowser") |
|
|
|
self.pushButton_3 = QPushButton(self.centralwidget) |
|
|
@ -50,12 +55,14 @@ class Ui_MainWindow(object): |
|
|
|
w = w+10 |
|
|
|
h = h+10 |
|
|
|
w_button = 80 |
|
|
|
self.resize(w+w_button*2+30, h+100) |
|
|
|
self.resize(2*w+10, h*2+50) |
|
|
|
self.graphicsView.setGeometry(QRect(0, 0, w, h)) |
|
|
|
self.textBrowser.setGeometry(QRect(w+10, 30, w_button*2+10, 200)) |
|
|
|
self.pushButton.setGeometry(QRect(w+10, 240, w_button*2+10, 50)) |
|
|
|
self.pushButton_2.setGeometry(QRect(w+10, 300, w_button, 50)) |
|
|
|
self.pushButton_3.setGeometry(QRect(w+10+w_button+10, 300, w_button, 50)) |
|
|
|
self.graphicsView_2.setGeometry(QRect(w+10, 0, w, h)) |
|
|
|
self.graphicsView_3.setGeometry(QRect(0, h+10, w, h)) |
|
|
|
self.textBrowser.setGeometry(QRect(w+10, h+10+30, w_button*2+10, 200)) |
|
|
|
self.pushButton.setGeometry(QRect(w+10, h+10+240, w_button*2+10, 50)) |
|
|
|
self.pushButton_2.setGeometry(QRect(w+10, h+10+300, w_button, 50)) |
|
|
|
self.pushButton_3.setGeometry(QRect(w+10+w_button+10, h+10+300, w_button, 50)) |
|
|
|
# self.pushButton_4.setGeometry(QRect(w+10+w_button+10, 560, w_button, 40)) |
|
|
|
# self.comboBox.setGeometry(QRect(w+10+w_button+10, 530, w_button, 30)) |
|
|
|
|
|
|
@ -70,6 +77,9 @@ class Ui_MainWindow(object): |
|
|
|
# ui逻辑控制 |
|
|
|
class MainWindow(QMainWindow, Ui_MainWindow): |
|
|
|
def __init__(self): |
|
|
|
self.timer_interval = 1000 |
|
|
|
self.max_width = 460 |
|
|
|
|
|
|
|
super(MainWindow, self).__init__() |
|
|
|
self.setupUi(self) |
|
|
|
|
|
|
@ -80,21 +90,28 @@ class MainWindow(QMainWindow, Ui_MainWindow): |
|
|
|
|
|
|
|
# self.comboBox.currentIndexChanged.connect(self.name_reset) |
|
|
|
|
|
|
|
self.video = Video() |
|
|
|
self.timer = QTimer() |
|
|
|
|
|
|
|
self.timer.timeout.connect(self.timer_act) |
|
|
|
|
|
|
|
self.scene = QGraphicsScene() |
|
|
|
self.graphicsView.setScene(self.scene) |
|
|
|
self.graphicsView.show() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
self.txt = "" |
|
|
|
|
|
|
|
|
|
|
|
def show_video(self): |
|
|
|
img = self.video.read() # 读入opencv视频流 |
|
|
|
def show_video(self, img = None): |
|
|
|
if img is None: |
|
|
|
img = self.video.read() # 读入opencv视频流 |
|
|
|
y, x = img.shape[:-1] |
|
|
|
#视频帧如果过大需要在此进行缩放,如 |
|
|
|
max_width = 1000 |
|
|
|
if x > max_width: |
|
|
|
mult = max_width/x |
|
|
|
|
|
|
|
if x > self.max_width: |
|
|
|
mult = self.max_width/x |
|
|
|
img = cv2.resize(img, (0, 0), fx=mult, fy=mult, interpolation=cv2.INTER_NEAREST) |
|
|
|
y, x = img.shape[:-1] |
|
|
|
|
|
|
@ -115,11 +132,16 @@ class MainWindow(QMainWindow, Ui_MainWindow): |
|
|
|
|
|
|
|
def start(self): |
|
|
|
## 调用start函数 |
|
|
|
self.load_video() |
|
|
|
self.timer.start(self.timer_interval) |
|
|
|
self.show_text("started\n") |
|
|
|
|
|
|
|
|
|
|
|
def test(self): |
|
|
|
print("test func run") |
|
|
|
|
|
|
|
def pause(self): |
|
|
|
## 调用pause函数 |
|
|
|
self.timer.stop() |
|
|
|
self.show_text("paused\n") |
|
|
|
|
|
|
|
def load_video(self): |
|
|
@ -135,6 +157,9 @@ class MainWindow(QMainWindow, Ui_MainWindow): |
|
|
|
return |
|
|
|
self.show_text("loaded model "+fname+"\n") |
|
|
|
|
|
|
|
def timer_act(self): |
|
|
|
self.show_video() |
|
|
|
|
|
|
|
# def name_reset(self): |
|
|
|
# name = self.comboBox.currentText() |
|
|
|
# self.mark.change_name(name) |
|
|
|