def __init__(self): super().__init__() self._zoom = 0 self._scale = 1 self._empty = True self._imageRect = None self._macosScrollKey = False self._scene = QtWidgets.QGraphicsScene(self) self._container = ImageView.createContainer( ) # Permits rotation mechanics self._pixmapItem = QtWidgets.QGraphicsPixmapItem( parent=self._container) # The pixmap form of the image data self._scene.addItem(self._container) self.setMinimumSize(600, 400) # What does this do? self.setScene(self._scene) self.setTransformationAnchor(QtWidgets.QGraphicsView.AnchorUnderMouse) self.setResizeAnchor(QtWidgets.QGraphicsView.AnchorUnderMouse) self.setFrameShape(QtWidgets.QFrame.NoFrame) self.addShortcuts()
def __init__(self): super(FrameViewer, self).__init__() self._empty = True # Initialize a flag which indicates when an image is being loaded. self.image_loading_busy = False # Initialize the photo object. No image is loaded yet. self._photo = QtWidgets.QGraphicsPixmapItem() self.viewrect = self.viewport().rect() self.setTransformationAnchor(QtWidgets.QGraphicsView.AnchorUnderMouse) self.setResizeAnchor(QtWidgets.QGraphicsView.AnchorUnderMouse) self.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff) self.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff) self.setBackgroundBrush(QtGui.QBrush(QtGui.QColor(30, 30, 30))) self.setFrameShape(QtWidgets.QFrame.NoFrame) self.setDragMode(QtWidgets.QGraphicsView.ScrollHandDrag) self.drag_mode = True # Set the focus on the viewer. self.setFocus()
def btnAnalysis(self): self.writeLog1("Analysis Image") img = self.image print(img) img_cutline = img height, width, channels = img.shape self.Xcutlines = [width] self.Ycutlines = [height] print("TESTED") print(height) Columns = 3 Rows = 2 for i in range(1, Columns): for j in range(1, Rows): print('Count Down', i, j) x = int(width * i / Columns) y = int(height * j / Rows) self.Xcutlines.append(x) self.Ycutlines.append(y) img_cutline[:, (x - 5):(x + 5), 0:2] = 0 img_cutline[(y - 5):(y + 5), :, 0:2] = 0 print("Lines", x, y) finalname = 'textile_array_line.png' cv2.imwrite(finalname, img_cutline) scene = QtWidgets.QGraphicsScene(self) pixmap = QPixmap(finalname) item = QtWidgets.QGraphicsPixmapItem(pixmap) scene.addItem(item) self.Ycutlines = list(set(self.Ycutlines)) self.Xcutlines = list(set(self.Xcutlines)) self.Xcutlines.sort() self.Ycutlines.sort() self.graphicsView.setScene(scene)
def __init__(self): #usual parameters to make sure the image can be zoom-in and out and is #possible to move around the zoomed-in view super(ImageViewer, self).__init__() self._zoom = 0 self._scene = QtWidgets.QGraphicsScene(self) self._photo = QtWidgets.QGraphicsPixmapItem() self._scene.addItem(self._photo) self.setScene(self._scene) self.setTransformationAnchor(QtWidgets.QGraphicsView.AnchorUnderMouse) self.setResizeAnchor(QtWidgets.QGraphicsView.AnchorUnderMouse) self.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff) self.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff) self.setBackgroundBrush(QtGui.QBrush(QtGui.QColor(100, 100, 100))) self.setFrameShape(QtWidgets.QFrame.NoFrame) self.setDragMode(QtWidgets.QGraphicsView.RubberBandDrag) self.setMouseTracking(True) #this is used to show the dots and update the dots in image self._shape = None self._lefteye = None self._righteye = None self._opencvimage = None self._boundingbox = None self._PointToModify = None self._points = None self._landmark_size = None #this variable is used to verify is a landmark will be relocated self._IsPointLifted = False #this variable is used to verify if the user wants to drag the eyes to a different location self._IsDragEyes = False #and what eye is the person trying to move self._IsDragLeft = False self._IsDragRight = False self._BothEyesTogether = False
def LDALoad(self): # 图片导入 city = self.comboBoxCItyList.currentText() filepath = 'Data/DataProcessing/' + city + '/' pngPerplex = QtGui.QPixmap(filepath + 'LDATrainResult/PerplexityTrend.png') pngPerplex = pngPerplex.scaled(400, 300) scenePerplex = QtWidgets.QGraphicsScene() scenePerplex.addItem(QtWidgets.QGraphicsPixmapItem(pngPerplex)) self.graphicsViewLDAPerplexity.setScene(scenePerplex) # 主题关键词导入 TopicWord = function.ReadTable(filepath + 'LDATrainResult/TopicWords.txt') self.tableWidgetTopicWord.setColumnCount(2) self.tableWidgetTopicWord.setRowCount(len(TopicWord)) horizontalHeader = ["Topic #", "KeyWords"] self.tableWidgetTopicWord.setHorizontalHeaderLabels(horizontalHeader) self.tableWidgetTopicWord.setColumnWidth(0, 70) self.tableWidgetTopicWord.setColumnWidth(1, 300) Rowindex = 0 for i in TopicWord: self.tableWidgetTopicWord.setItem(Rowindex, 0, QtWidgets.QTableWidgetItem(i)) self.tableWidgetTopicWord.setItem(Rowindex, 1, QtWidgets.QTableWidgetItem(TopicWord[i])) Rowindex += 1 # 文档主题概率矩阵的导入 DocTopic = function.ReadTable(filepath + 'LDATrainResult/DocTopicDist.txt') self.tableWidgetDocTopic.setColumnCount(2) self.tableWidgetDocTopic.setRowCount(len(DocTopic)) horizontalHeader = ["Document #", " Probability"] self.tableWidgetDocTopic.setHorizontalHeaderLabels(horizontalHeader) self.tableWidgetDocTopic.setColumnWidth(0, 70) self.tableWidgetDocTopic.setColumnWidth(1, 300) Rowindex = 0 for i in DocTopic: self.tableWidgetDocTopic.setItem(Rowindex, 0, QtWidgets.QTableWidgetItem(i)) self.tableWidgetDocTopic.setItem(Rowindex, 1, QtWidgets.QTableWidgetItem(DocTopic[i])) Rowindex += 1 QtWidgets.QMessageBox.about(self.centralwidget, str("LDA"), "LDA Load Success!")
def __init__(self, x, y, square_size, character, gui): super().__init__() self.character = character self.gui = gui # To be able to use log printing #Backgound color basen on faction self.rectangle_background = QtWidgets.QGraphicsRectItem( x - 3, y - 3, square_size + 6, square_size + 6) if self.character.is_controllable(): brush = QtGui.QBrush(QtGui.QColor(25, 50, 200)) # Blue = player else: brush = QtGui.QBrush(QtGui.QColor(200, 25, 25)) # Red = enemy self.rectangle_background.setBrush(brush) self.addToGroup(self.rectangle_background) #Get character icon path = "characters/{}/iconSE.png".format(character.get_name().lower()) pixmap = QtGui.QPixmap(path) self.char_icon = QtWidgets.QGraphicsPixmapItem(pixmap) self.char_icon.setPos(x, y) icon_size = pixmap.width() #Assuming all icon are square factor = square_size / icon_size self.char_icon.setScale(factor) self.addToGroup(self.char_icon) #Add hp text self.text_item = QtWidgets.QGraphicsTextItem() self.update_stats() self.text_item.setPos(x, y + square_size - 24) self.text_item.setDefaultTextColor(QtGui.QColor(255, 255, 255)) font = QtGui.QFont() font.setPixelSize(16) font.setBold(True) self.text_item.setFont(font) self.addToGroup(self.text_item)