Skip to content

Commit

Permalink
imports enhanced
Browse files Browse the repository at this point in the history
  • Loading branch information
ArthurDelannoyazerty committed Oct 15, 2023
1 parent 8719596 commit d7eb8dd
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 17 deletions.
19 changes: 10 additions & 9 deletions src/main.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import sys
from PySide6.QtWidgets import QApplication, QCheckBox, QMainWindow, QRadioButton, QVBoxLayout, QHBoxLayout, QLabel, QFrame, QPushButton, QFileDialog, QWidget, QScrollArea
from PySide6.QtGui import Qt
from PySide6.QtCore import Qt, QSize, QTimer
import cv2 as cv
import numpy as np

from cv2 import cvtColor, imdecode, imencode, COLOR_BGR2RGB, IMREAD_UNCHANGED
from numpy import fromfile, uint8
from sys import argv, exit

from transformermanager import TransformerManager
from transformer import Transformer
Expand Down Expand Up @@ -195,8 +196,8 @@ def open_image(self):

if str_path:
self.img_path = str_path
img_array = cv.imdecode(np.fromfile(str_path, dtype=np.uint8), cv.IMREAD_UNCHANGED)
img_array = cv.cvtColor(img_array, cv.COLOR_BGR2RGB)
img_array = imdecode(fromfile(str_path, dtype=uint8), IMREAD_UNCHANGED)
img_array = cvtColor(img_array, COLOR_BGR2RGB)
return img_array

def open_first_image(self):
Expand Down Expand Up @@ -321,8 +322,8 @@ def action_download_current_image(self):
if file_dialog.exec():
file_path = file_dialog.selectedFiles()[0]
try:
array_to_save = cv.cvtColor(self.pipeline[self.index_current_img].img_array, cv.COLOR_BGR2RGB)
_, im_buf_arr = cv.imencode(".png", array_to_save)
array_to_save = cvtColor(self.pipeline[self.index_current_img].img_array, COLOR_BGR2RGB)
_, im_buf_arr = imencode(".png", array_to_save)
im_buf_arr.tofile(file_path)
print("Image saved successfully.")
except Exception as e:
Expand Down Expand Up @@ -463,7 +464,7 @@ def update_transformation_parameters_frame(self):


if __name__ == '__main__':
app = QApplication(sys.argv)
app = QApplication(argv)
window = MainWindow()
window.show()
sys.exit(app.exec())
exit(app.exec())
2 changes: 0 additions & 2 deletions src/menuwithtext.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
from PySide6.QtWidgets import QComboBox, QLabel, QFrame, QVBoxLayout
from PySide6.QtCore import Qt
from stepslider import StepSlider

MAXIMUM_HEIGHT = 65

Expand Down
6 changes: 3 additions & 3 deletions src/pipelineitem.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from PySide6.QtGui import QPixmap, QImage, qRgb
import numpy as np
from numpy import uint8, require

class PipelineItem():
"""Object that contains the image in an array and the corresponding transformation item"""
Expand All @@ -20,8 +20,8 @@ def to_q_image(self, im, copy=False):
if im is None:
return QImage()

if im.dtype == np.uint8:
im = np.require(im, np.uint8, 'C')
if im.dtype == uint8:
im = require(im, uint8, 'C')
if len(im.shape) == 2:
qim = QImage(im.data, im.shape[1], im.shape[0], im.strides[0], QImage.Format_Indexed8)
qim.setColorTable(gray_color_table)
Expand Down
3 changes: 1 addition & 2 deletions src/sliderwithtext.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from PySide6.QtWidgets import QSlider, QLabel, QFrame, QVBoxLayout
from PySide6.QtCore import Qt
from PySide6.QtWidgets import QLabel, QFrame, QVBoxLayout
from stepslider import StepSlider

MAXIMUM_HEIGHT = 65
Expand Down
1 change: 0 additions & 1 deletion src/transformermanager.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from pipelineitem import PipelineItem
from transformationitem import TransformationItem
from PySide6.QtWidgets import QApplication, QMessageBox


class TransformerManager():
Expand Down

0 comments on commit d7eb8dd

Please sign in to comment.