from PyQt5 import QtCore, QtGui
from ..tools.utils import calculate_height, rotate, resize_image
[docs]
class ShowImage(object):
def __init__(self, Parent):
"""
Class for control the showing image on user interface.
Args:
Parent (): the main class of this application.
"""
self.parent = Parent
[docs]
def show_original_image(self, image, width):
"""
Showing the original image in label original.
Args:
image (): image want to show
width (): the width size of destination result
Returns:
"""
height = calculate_height(image, width)
# image = cv2.resize(image, (width, height), interpolation=cv2.INTER_AREA)
image = resize_image(image, width)
label_image = self.parent.ui.label_Original_Image
label_image.setMinimumSize(QtCore.QSize(width, height))
image = QtGui.QImage(image.data, image.shape[1], image.shape[0],
QtGui.QImage.Format_RGB888).rgbSwapped()
label_image.setPixmap(QtGui.QPixmap.fromImage(image))
[docs]
def show_result_image(self, image, width, angle=0):
"""
Showing the image in the label of result image.
Args:
image (): image want to show
width (): width image
angle (): the angle of the image
Returns:
"""
height = calculate_height(image, width)
# image = cv2.resize(image, (width, height), interpolation=cv2.INTER_AREA)
image = resize_image(image, width)
image = rotate(image, angle)
label_image = self.parent.ui.label_Result_Image
label_image.setMinimumSize(QtCore.QSize(width, height))
image = QtGui.QImage(image.data, image.shape[1], image.shape[0],
QtGui.QImage.Format_RGB888).rgbSwapped()
label_image.setPixmap(QtGui.QPixmap.fromImage(image))