Skip to content

Commit

Permalink
fixing bugs in PyQt6, many bugs in colors, video navigation and scrol…
Browse files Browse the repository at this point in the history
…ling still exist
  • Loading branch information
0ssamaak0 committed Jul 16, 2023
1 parent 51b10df commit 7a03a59
Show file tree
Hide file tree
Showing 31 changed files with 260 additions and 269 deletions.
8 changes: 4 additions & 4 deletions DLTA_AI_app/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ def main():
app.setWindowIcon(newIcon("icon"))

# create and show splash screen
# splash_pix = QtGui.QPixmap('labelme/icons/splash_screen.png')
# splash = QtWidgets.QSplashScreen(splash_pix)
# splash.show()
splash_pix = QtGui.QPixmap('labelme/icons/splash_screen.png')
splash = QtWidgets.QSplashScreen(splash_pix)
splash.show()

qss = """
QMenuBar::item {
Expand Down Expand Up @@ -60,7 +60,7 @@ def main():
# create main window
from labelme.app import MainWindow
win = MainWindow()
# splash.finish(win)
splash.finish(win)
win.show()

# close splash screen
Expand Down
210 changes: 103 additions & 107 deletions DLTA_AI_app/labelme/app.py

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion DLTA_AI_app/labelme/intelligence.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from labelme.label_file import LabelFile
from labelme import PY2
from PyQt6.QtCore import QThread
from PyQt6.QtCore import pyqtBoundSignal as pyqtSignal
from PyQt6.QtCore import pyqtSignal as pyqtSignal
from PyQt6 import QtGui
from PyQt6 import QtWidgets
import os
Expand Down
2 changes: 1 addition & 1 deletion DLTA_AI_app/labelme/utils/export.py
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@ def __init__(self, default_file_name, default_format):
super().__init__()

# Set the mode to save a file
self.setAcceptMode(QFileDialog.AcceptSave)
self.setAcceptMode(QFileDialog.AcceptMode.AcceptSave)

# Set the default file name
self.selectFile(default_file_name)
Expand Down
9 changes: 5 additions & 4 deletions DLTA_AI_app/labelme/utils/helpers/mathOps.py
Original file line number Diff line number Diff line change
Expand Up @@ -550,14 +550,15 @@ def convert_QT_to_cv(incomingImage):
Returns:
arr: a cv image MAT format
"""

incomingImage = incomingImage.convertToFormat(4)
from PyQt5.QtGui import QImage as QImg5

# incomingImage = incomingImage.convertToFormat(QtGui.QImage.Format.Format_RGBA8888)

width = incomingImage.width()
height = incomingImage.height()

ptr = incomingImage.bits()
ptr.setsize(incomingImage.byteCount())
ptr.setsize(incomingImage.sizeInBytes())
arr = np.array(ptr).reshape(height, width, 4) # Copies the data
return arr

Expand All @@ -578,7 +579,7 @@ def convert_cv_to_qt(cv_img):
h, w, ch = rgb_image.shape
bytes_per_line = ch * w
convert_to_Qt_format = QtGui.QImage(
rgb_image.data, w, h, bytes_per_line, QtGui.QImage.Format_RGB888)
rgb_image.data, w, h, bytes_per_line, QtGui.QImage.Format.Format_RGB888)
return convert_to_Qt_format

def SAM_rects_to_boxes(rects):
Expand Down
6 changes: 3 additions & 3 deletions DLTA_AI_app/labelme/utils/model_explorer.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def __init__(self, main_window=None, mute=None, notification=None):
self.mute = mute
self.notification = notification
self.setWindowTitle("Model Explorer")
self.setWindowFlags(self.windowFlags() & ~QtCore.Qt.WindowContextHelpButtonHint)
self.setWindowFlags(self.windowFlags() & ~QtCore.Qt.WindowType.WindowContextHelpButtonHint)


# Define the columns of the table
Expand Down Expand Up @@ -150,7 +150,7 @@ def populate_table(self):
col_count = 0
for key in self.cols_labels:
item = QTableWidgetItem(f"{model[key]}")
item.setTextAlignment(QtCore.Qt.AlignCenter)
item.setTextAlignment(QtCore.Qt.AlignmentFlag.AlignCenter)
self.table.setItem(row_count, col_count, item)
col_count += 1

Expand All @@ -171,7 +171,7 @@ def populate_table(self):
# make the text color dark green
available_item.setForeground(QtCore.Qt.darkGreen)
self.table.setItem(row_count, 9, available_item)
available_item.setTextAlignment(QtCore.Qt.AlignCenter)
available_item.setTextAlignment(QtCore.Qt.AlignmentFlag.AlignCenter)
else:
available_item = QPushButton("Requires Download")
available_item.clicked.connect(
Expand Down
2 changes: 1 addition & 1 deletion DLTA_AI_app/labelme/utils/qt.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def newAction(
checked=False,
):
"""Create a new action and assign callbacks, shortcuts, etc."""
a = QtWidgets.QAction(text, parent)
a = QtGui.QAction(text, parent)
if icon is not None:
a.setIconText(text.replace(" ", "\n"))
a.setIcon(newIcon(icon))
Expand Down
20 changes: 10 additions & 10 deletions DLTA_AI_app/labelme/utils/vid_to_frames.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def __init__(self, mute = None, notification = None):
self.setMinimumSize(500, 300)

self.setWindowTitle("Open Video as Frames")
self.setWindowFlags(self.windowFlags() & ~Qt.WindowContextHelpButtonHint)
self.setWindowFlags(self.windowFlags() & ~Qt.WindowType.WindowContextHelpButtonHint)


self.sampling_max = 100
Expand Down Expand Up @@ -47,12 +47,12 @@ def __init__(self, mute = None, notification = None):
self.sampling_slider.valueChanged.connect(self.update_sampling_rate)
self.sampling_edit = QLineEdit(str(self.sampling_slider.value()))
self.sampling_edit.setFont(QFont('', 5))
self.sampling_edit.setAlignment(Qt.AlignCenter)
self.sampling_edit.setAlignment(Qt.AlignmentFlag.AlignCenter)
self.sampling_edit.setEnabled(False)
self.sampling_edit.textChanged.connect(self.update_sampling_slider)
self.sampling_time_label = QLabel("hh:mm:ss")
self.sampling_time_label.setFont(font)
self.sampling_time_label.setAlignment(Qt.AlignRight)
self.sampling_time_label.setAlignment(Qt.AlignmentFlag.AlignRight)

self.start_label = QLabel("Start frame:")
self.start_slider = QSlider()
Expand All @@ -63,12 +63,12 @@ def __init__(self, mute = None, notification = None):
self.start_slider.valueChanged.connect(self.update_start_frame)
self.start_edit = QLineEdit(str(self.start_slider.value()))
self.start_edit.setFont(QFont('', 5))
self.start_edit.setAlignment(Qt.AlignCenter)
self.start_edit.setAlignment(Qt.AlignmentFlag.AlignCenter)
self.start_edit.setEnabled(False)
self.start_edit.textChanged.connect(self.update_start_slider)
self.start_time_label = QLabel("hh:mm:ss")
self.start_time_label.setFont(font)
self.start_time_label.setAlignment(Qt.AlignRight)
self.start_time_label.setAlignment(Qt.AlignmentFlag.AlignRight)

self.end_label = QLabel("End frame:")
self.end_slider = QSlider()
Expand All @@ -79,12 +79,12 @@ def __init__(self, mute = None, notification = None):
self.end_slider.valueChanged.connect(self.update_end_frame)
self.end_edit = QLineEdit(str(self.end_slider.value()))
self.end_edit.setFont(QFont('', 5))
self.end_edit.setAlignment(Qt.AlignCenter)
self.end_edit.setAlignment(Qt.AlignmentFlag.AlignCenter)
self.end_edit.setEnabled(False)
self.end_edit.textChanged.connect(self.update_end_slider)
self.end_time_label = QLabel("hh:mm:ss")
self.end_time_label.setFont(font)
self.end_time_label.setAlignment(Qt.AlignRight)
self.end_time_label.setAlignment(Qt.AlignmentFlag.AlignRight)

self.extract_button = QPushButton("Extract Frames")
self.extract_button.clicked.connect(self.extract_frames)
Expand Down Expand Up @@ -121,8 +121,8 @@ def __init__(self, mute = None, notification = None):

start_layout = QHBoxLayout()
inner_start_layout = QVBoxLayout()
inner_start_layout.addWidget(self.start_label, alignment=Qt.AlignLeft)
inner_start_layout.addWidget(self.start_time_label, alignment=Qt.AlignLeft)
inner_start_layout.addWidget(self.start_label, alignment=Qt.AlignmentFlag.AlignLeft)
inner_start_layout.addWidget(self.start_time_label, alignment=Qt.AlignmentFlag.AlignLeft)
start_layout.addLayout(inner_start_layout)
inner_start_layout = QVBoxLayout()
inner_start_layout.addWidget(self.start_edit)
Expand Down Expand Up @@ -380,4 +380,4 @@ def vid_to_frames(self, vid_path, sampling_rate, start_frame, end_frame):
# qdarktheme.setup_theme()
# window = VideoFrameExtractor()
# window.show()
# sys.exit(app.exec_())
# sys.exit(app.exec())
4 changes: 2 additions & 2 deletions DLTA_AI_app/labelme/widgets/ClassesWidget.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def getValue(self):
def setValue(self, value):
self.class_name = value

def exec_(self):
super(Classeswidget, self).exec_()
def exec(self):
super(Classeswidget, self).exec()
return self.class_name

12 changes: 6 additions & 6 deletions DLTA_AI_app/labelme/widgets/MsgBox.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,19 @@ def OKmsgBox(title, text, type = "info", turnResult = False):

msgBox = QtWidgets.QMessageBox()
if type == "info":
msgBox.setIcon(QtWidgets.QMessageBox.Information)
msgBox.setIcon(QtWidgets.QMessageBox.Icon.Information)
elif type == "warning":
msgBox.setIcon(QtWidgets.QMessageBox.Warning)
elif type == "critical":
msgBox.setIcon(QtWidgets.QMessageBox.Critical)
msgBox.setIcon(QtWidgets.QMessageBox.Icon.Critical)
msgBox.setText(text)
msgBox.setWindowTitle(title)
if turnResult:
msgBox.setStandardButtons(QtWidgets.QMessageBox.Ok | QtWidgets.QMessageBox.Cancel)
msgBox.setDefaultButton(QtWidgets.QMessageBox.Ok)
msgBox.setStandardButtons(QtWidgets.QMessageBox.StandardButton.Ok | QtWidgets.QMessageBox.Cancel)
msgBox.setDefaultButton(QtWidgets.QMessageBox.StandardButton.Ok)
else:
msgBox.setStandardButtons(QtWidgets.QMessageBox.Ok)
msgBox.exec_()
msgBox.setStandardButtons(QtWidgets.QMessageBox.StandardButton.Ok)
msgBox.exec()
return msgBox.result()


Expand Down
2 changes: 1 addition & 1 deletion DLTA_AI_app/labelme/widgets/brightness_contrast_dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def onNewValue(self, value):
self.callback(qimage)

def _create_slider(self):
slider = QtWidgets.QSlider(Qt.Horizontal)
slider = QtWidgets.QSlider(Qt.Orientation.Horizontal)
slider.setRange(0, 150)
slider.setValue(50)
slider.valueChanged.connect(self.onNewValue)
Expand Down
Loading

0 comments on commit 7a03a59

Please sign in to comment.