imgpath = "result.jpg"img = cv2.imread(imgpath) # 讀取圖像img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB) # 轉換圖像通道x = img.shape[1] # 獲取圖像大小y = img.shape[0]self.zoomscale = 1 # 圖片放縮尺度frame = QImage(img, x, y, x * 3, QImage.Format_RGB888)pix = QPixmap.fromImage(frame)self.item = QGraphicsPixmapItem(pix) # 創建像素圖元self.item.setScale(self.zoomscale)self.scene = QGraphicsScene() # 創建場景self.scene.addItem(self.item)self.graphicsView.setScene(self.scene) # 將場景添加至視圖