可以读取文件里所有的图像,显示,评分并进行统计
源码如下:
# -*- coding: utf-8 -*-
# Form implementation generated from reading ui file 'Test.ui'
#
# Created by: PyQt5 UI code generator 5.9.2
#
# WARNING! All changes made in this file will be lost!
from PyQt5 import QtCore, QtGui, QtWidgets
from PyQt5.QtWidgets import QGraphicsScene, QGraphicsPixmapItem,QGraphicsView
from PyQt5.QtGui import QPixmap, QImage
import os
import cv2
import sys
class Ui_Form(object):
def setupUi(self, Form):
Form.setObjectName("Form")
Form.resize(1677, 1013)
self.ImgView_1 = QtWidgets.QGraphicsView(Form)
self.ImgView_1.setGeometry(QtCore.QRect(10, 10, 400, 600))
self.ImgView_1.setMinimumSize(QtCore.QSize(400, 600))
self.ImgView_1.setMaximumSize(QtCore.QSize(400, 600))
self.ImgView_1.setObjectName("ImgView_1")
self.ImgView_2 = QtWidgets.QGraphicsView(Form)
self.ImgView_2.setGeometry(QtCore.QRect(420, 10, 400, 600))
self.ImgView_2.setMinimumSize(QtCore.QSize(400, 600))
self.ImgView_2.setMaximumSize(QtCore.QSize(400, 600))
self.ImgView_2.setObjectName("ImgView_2")
self.ImgView_3 = QtWidgets.QGraphicsView(Form)
self.ImgView_3.setGeometry(QtCore.QRect(830, 10, 400, 600))
self.ImgView_3.setMinimumSize(QtCore.QSize(400, 600))
self.ImgView_3.setMaximumSize(QtCore.QSize(400, 600))
self.ImgView_3.setObjectName("ImgView_3")
self.lineEdit_1 = QtWidgets.QLineEdit(Form)
self.lineEdit_1.setGeometry(QtCore.QRect(1240, 10, 370, 20))
self.lineEdit_1.setMinimumSize(QtCore.QSize(370, 20))
self.lineEdit_1.setMaximumSize(QtCore.QSize(370, 20))
self.lineEdit_1.setObjectName("lineEdit_1")
self.lineEdit_2 = QtWidgets.QLineEdit(Form)
self.lineEdit_2.setGeometry(QtCore.QRect(1240, 40, 370, 20))
self.lineEdit_2.setMinimumSize(QtCore.QSize(370, 20))
self.lineEdit_2.setMaximumSize(QtCore.QSize(370, 20))
self.lineEdit_2.setObjectName("lineEdit_2")
self.lineEdit_3 = QtWidgets.QLineEdit(Form)
self.lineEdit_3.setGeometry(QtCore.QRect(1240, 70, 370, 20))
self.lineEdit_3.setMinimumSize(QtCore.QSize(370, 20))
self.lineEdit_3.setMaximumSize(QtCore.QSize(370, 20))
self.lineEdit_3.setObjectName("lineEdit_3")
self.lineEdit_4 = QtWidgets.QLineEdit(Form)
self.lineEdit_4.setGeometry(QtCore.QRect(1240, 100, 370, 20))
self.lineEdit_4.setMinimumSize(QtCore.QSize(370, 20))
self.lineEdit_4.setMaximumSize(QtCore.QSize(370, 20))
self.lineEdit_4.setObjectName("lineEdit_4")
self.labelPath_1 = QtWidgets.QLabel(Form)
self.labelPath_1.setGeometry(QtCore.QRect(1620, 10, 50, 20))
self.labelPath_1.setMinimumSize(QtCore.QSize(50, 20))
self.labelPath_1.setMaximumSize(QtCore.QSize(50, 20))
font = QtGui.QFont()
font.setFamily("Times New Roman")
font.setPointSize(11)
font.setBold(True)
font.setWeight(75)
self.labelPath_1.setFont(font)
self.labelPath_1.setObjectName("labelPath_1")
self.labelPath_2 = QtWidgets.QLabel(Form)
self.labelPath_2.setGeometry(QtCore.QRect(1620, 40, 50, 20))
self.labelPath_2.setMinimumSize(QtCore.QSize(50, 20))
self.labelPath_2.setMaximumSize(QtCore.QSize(50, 20))
font = QtGui.QFont()
font.setFamily("Times New Roman")
font.setPointSize(11)
font.setBold(True)
font.setWeight(75)
self.labelPath_2.setFont(font)
self.labelPath_2.setObjectName("labelPath_2")
self.labelPath_3 = QtWidgets.QLabel(Form)
self.labelPath_3.setGeometry(QtCore.QRect(1620, 70, 50, 20))
self.labelPath_3.setMinimumSize(QtCore.QSize(50, 20))
self.labelPath_3.setMaximumSize(QtCore.QSize(50, 20))
font = QtGui.QFont()
font.setFamily("Times New Roman")
font.setPointSize(11)
font.setBold(True)
font.setWeight(75)
self.labelPath_3.setFont(font)
self.labelPath_3.setObjectName("labelPath_3")
self.labelPath_4 = QtWidgets.QLabel(Form)
self.labelPath_4.setGeometry(QtCore.QRect(1620, 100, 50, 20))
self.labelPath_4.setMinimumSize(QtCore.QSize(50, 20))
self.labelPath_4.setMaximumSize(QtCore.QSize(50, 20))
font = QtGui.QFont()
font.setFamily("Times New Roman")
font.setPointSize(11)
font.setBold(True)
font.setWeight(75)
self.labelPath_4.setFont(font)
self.labelPath_4.setObjectName("labelPath_4")
self.View_4 = QtWidgets.QGraphicsView(Form)
self.View_4.setGeometry(QtCore.QRect(1240, 130, 420, 480))
self.View_4.setMinimumSize(QtCore.QSize(420, 480))
self.View_4.setMaximumSize(QtCore.QSize(420, 480))
self.View_4.setObjectName("View_4")
self.LoadButton = QtWidgets.QPushButton(Form)
self.LoadButton.setGeometry(QtCore.QRect(1270, 630, 75, 30))
self.LoadButton.setMinimumSize(QtCore.QSize(75, 30))
self.LoadButton.setMaximumSize(QtCore.QSize(75, 30))
font = QtGui.QFont()
font.setFamily("Times New Roman")
font.setPointSize(12)
font.setBold(True)
font.setWeight(75)
self.LoadButton.setFont(font)
self.LoadButton.setObjectName("LoadButton")
self.ResetButton = QtWidgets.QPushButton(Form)
self.ResetButton.setGeometry(QtCore.QRect(1380, 630, 75, 30))
self.ResetButton.setMinimumSize(QtCore.QSize(75, 30))
self.ResetButton.setMaximumSize(QtCore.QSize(75, 30))
font = QtGui.QFont()
font.setFamily("Times New Roman")
font.setPointSize(12)
font.setBold(True)
font.setWeight(75)
self.ResetButton.setFont(font)
self.ResetButton.setObjectName("ResetButton")
self.NextButton = QtWidgets.QPushButton(Form)
self.NextButton.setGeometry(QtCore.QRect(1480, 630, 75, 30))
self.NextButton.setMinimumSize(QtCore.QSize(75, 30))
self.NextButton.setMaximumSize(QtCore.QSize(75, 30))
font = QtGui.QFont()
font.setFamily("Times New Roman")
font.setPointSize(12)
font.setBold(True)
font.setWeight(75)
self.NextButton.setFont(font)
self.NextButton.setObjectName("StartButton")
self.textBrowser = QtWidgets.QTextBrowser(Form)
self.textBrowser.setGeometry(QtCore.QRect(20, 770, 1200, 230))
self.textBrowser.setMinimumSize(QtCore.QSize(1200, 230))
self.textBrowser.setMaximumSize(QtCore.QSize(1200, 230))
self.textBrowser.setObjectName("textBrowser")
self.check_bad_1 = QtWidgets.QCheckBox(Form)
self.check_bad_1.setGeometry(QtCore.QRect(140, 620, 80, 30))
self.check_bad_1.setMinimumSize(QtCore.QSize(80, 30))
self.check_bad_1.setMaximumSize(QtCore.QSize(80, 30))
font = QtGui.QFont()
font.setFamily("Times New Roman")
font.setPointSize(12)
font.setBold(True)
font.setWeight(75)
self.check_bad_1.setFont(font)
self.check_bad_1.setObjectName("check_bad_1")
self.check_bad_2 = QtWidgets.QCheckBox(Form)
self.check_bad_2.setGeometry(QtCore.QRect(610, 620, 80, 30))
self.check_bad_2.setMinimumSize(QtCore.QSize(80, 30))
self.check_bad_2.setMaximumSize(QtCore.QSize(80, 30))
font = QtGui.QFont()
font.setFamily("Times New Roman")
font.setPointSize(12)
font.setBold(True)
font.setWeight(75)
self.check_bad_2.setFont(font)
self.check_bad_2.setObjectName("check_bad_2")
self.check_bad_3 = QtWidgets.QCheckBox(Form)
self.check_bad_3.setGeometry(QtCore.QRect(1010, 620, 80, 30))
self.check_bad_3.setMinimumSize(QtCore.QSize(80, 30))
self.check_bad_3.setMaximumSize(QtCore.QSize(80, 30))
font = QtGui.QFont()
font.setFamily("Times New Roman")
font.setPointSize(12)
font.setBold(True)
font.setWeight(75)
self.check_bad_3.setFont(font)
self.check_bad_3.setObjectName("check_bad_3")
self.check_medium_1 = QtWidgets.QCheckBox(Form)
self.check_medium_1.setGeometry(QtCore.QRect(140, 650, 80, 30))
self.check_medium_1.setMinimumSize(QtCore.QSize(80, 30))
self.check_medium_1.setMaximumSize(QtCore.QSize(80, 30))
font = QtGui.QFont()
font.setFamily("Times New Roman")
font.setPointSize(12)
font.setBold(True)
font.setWeight(75)
self.check_medium_1.setFont(font)
self.check_medium_1.setObjectName("check_medium_1")
self.check_medium_2 = QtWidgets.QCheckBox(Form)
self.check_medium_2.setGeometry(QtCore.QRect(610, 650, 80, 30))
self.check_medium_2.setMinimumSize(QtCore.QSize(80, 30))
self.check_medium_2.setMaximumSize(QtCore.QSize(80, 30))
font = QtGui.QFont()
font.setFamily("Times New Roman")
font.setPointSize(12)
font.setBold(True)
font.setWeight(75)
self.check_medium_2.setFont(font)
self.check_medium_2.setObjectName("check_medium_2")
self.check_medium_3 = QtWidgets.QCheckBox(Form)
self.check_medium_3.setGeometry(QtCore.QRect(1010, 650, 80, 30))
self.check_medium_3.setMinimumSize(QtCore.QSize(80, 30))
self.check_medium_3.setMaximumSize(QtCore.QSize(80, 30))
font = QtGui.QFont()
font.setFamily("Times New Roman")
font.setPointSize(12)
font.setBold(True)
font.setWeight(75)
self.check_medium_3.setFont(font)
self.check_medium_3.setObjectName("check_medium_3")
self.check_good_1 = QtWidgets.QCheckBox(Form)
self.check_good_1.setGeometry(QtCore.QRect(140, 680, 80, 30))
self.check_good_1.setMinimumSize(QtCore.QSize(80, 30))
self.check_good_1.setMaximumSize(QtCore.QSize(80, 30))
font = QtGui.QFont()
font.setFamily("Times New Roman")
font.setPointSize(12)
font.setBold(True)
font.setWeight(75)
self.check_good_1.setFont(font)
self.check_good_1.setObjectName("check_good_1")
self.check_good_2 = QtWidgets.QCheckBox(Form)
self.check_good_2.setGeometry(QtCore.QRect(610, 680, 80, 30))
self.check_good_2.setMinimumSize(QtCore.QSize(80, 30))
self.check_good_2.setMaximumSize(QtCore.QSize(80, 30))
font = QtGui.QFont()
font.setFamily("Times New Roman")
font.setPointSize(12)
font.setBold(True)
font.setWeight(75)
self.check_good_2.setFont(font)
self.check_good_2.setObjectName("check_good_2")
self.check_good_3 = QtWidgets.QCheckBox(Form)
self.check_good_3.setGeometry(QtCore.QRect(1010, 680, 80, 30))
self.check_good_3.setMinimumSize(QtCore.QSize(80, 30))
self.check_good_3.setMaximumSize(QtCore.QSize(80, 30))
font = QtGui.QFont()
font.setFamily("Times New Roman")
font.setPointSize(12)
font.setBold(True)
font.setWeight(75)
self.check_good_3.setFont(font)
self.check_good_3.setObjectName("check_good_3")
self.ComtButton = QtWidgets.QPushButton(Form)
self.ComtButton.setGeometry(QtCore.QRect(1570, 630, 75, 30))
self.ComtButton.setMinimumSize(QtCore.QSize(75, 30))
self.ComtButton.setMaximumSize(QtCore.QSize(75, 30))
font = QtGui.QFont()
font.setFamily("Times New Roman")
font.setPointSize(12)
font.setBold(True)
font.setWeight(75)
self.ComtButton.setFont(font)
self.ComtButton.setObjectName("ComtButton")
self.retranslateUi(Form)
self.ResetButton.setEnabled(False)
self.NextButton.setEnabled(False)
self.ComtButton.setEnabled(False)
self.path1=None
self.path2=None
self.path3=None
self.path4=None
self.ImgList1=[]
self.ImgList2=[]
self.ImgList3=[]
self.ImgList4=[]
self.curIndex=0
self.TotalNums=0
self.Img1_bad=0
self.Img2_bad=0
self.Img3_bad=0
self.Img1_medium=0
self.Img2_medium=0
self.Img3_medium=0
self.Img1_good=0
self.Img2_good=0
self.Img3_good=0
self.Img1_flag=0
self.Img2_flag=0
self.Img3_flag=0
self.LoadButton.clicked.connect(self.LoadImg_Rec)
self.ResetButton.clicked.connect(self.ResetBn_Rec)
self.ComtButton.clicked.connect(self.ComBn_Rec)
self.NextButton.clicked.connect(self.NextBn_Rec)
self.check_bad_1.stateChanged.connect(lambda: self.GetOption(self.check_bad_1))
self.check_bad_2.stateChanged.connect(lambda: self.GetOption(self.check_bad_2))
self.check_bad_3.stateChanged.connect(lambda: self.GetOption(self.check_bad_3))
self.check_medium_1.stateChanged.connect(lambda: self.GetOption(self.check_medium_1))
self.check_medium_2.stateChanged.connect(lambda: self.GetOption(self.check_medium_2))
self.check_medium_3.stateChanged.connect(lambda: self.GetOption(self.check_medium_3))
self.check_good_1.stateChanged.connect(lambda: self.GetOption(self.check_good_1))
self.check_good_2.stateChanged.connect(lambda: self.GetOption(self.check_good_2))
self.check_good_3.stateChanged.connect(lambda: self.GetOption(self.check_good_3))
QtCore.QMetaObject.connectSlotsByName(Form)
def retranslateUi(self, Form):
_translate = QtCore.QCoreApplication.translate
Form.setWindowTitle(_translate("Form", "Form"))
self.labelPath_1.setText(_translate("Form", "path_1"))
self.labelPath_2.setText(_translate("Form", "path_2"))
self.labelPath_3.setText(_translate("Form", "path_3"))
self.labelPath_4.setText(_translate("Form", "path_4"))
self.LoadButton.setText(_translate("Form", "Load"))
self.ResetButton.setText(_translate("Form", "Reset"))
self.NextButton.setText(_translate("Form", "Next"))
self.check_bad_1.setText(_translate("Form", "bad"))
self.check_bad_2.setText(_translate("Form", "bad"))
self.check_bad_3.setText(_translate("Form", "bad"))
self.check_medium_1.setText(_translate("Form", "medium"))
self.check_medium_2.setText(_translate("Form", "medium"))
self.check_medium_3.setText(_translate("Form", "medium"))
self.check_good_1.setText(_translate("Form", "good"))
self.check_good_2.setText(_translate("Form", "good"))
self.check_good_3.setText(_translate("Form", "good"))
self.ComtButton.setText(_translate("Form", "confirm"))
####################################################################
def ResetBn_Rec(self):
self.ResetButton.setEnabled(False)
self.NextButton.setEnabled(False)
self.ComtButton.setEnabled(False)
self.LoadButton.setEnabled(True)
self.ImgList1=[]
self.ImgList2=[]
self.ImgList3=[]
self.ImgList4=[]
self.path1=None
self.path2=None
self.path3=None
self.path4=None
self.curIndex=0
self.TotalNums=0
self.Img1_bad=0
self.Img2_bad=0
self.Img3_bad=0
self.Img1_medium=0
self.Img2_medium=0
self.Img3_medium=0
self.Img1_good=0
self.Img2_good=0
self.Img3_good=0
self.Img1_flag=0
self.Img2_flag=0
self.Img3_flag=0
showStr="reset succed..."
self.textBrowser.append(showStr)
self.cursor=self.textBrowser.textCursor()
self.textBrowser.moveCursor(self.cursor.End)
QtWidgets.QApplication.processEvents()
def LoadImg_Rec(self):
self.path1=self.lineEdit_1.text()
self.path2=self.lineEdit_2.text()
self.path3=self.lineEdit_3.text()
self.path4=self.lineEdit_4.text()
for i in range(0,4):
if i==0:
k1,self.ImgList1=self.Read(i)
showStr="total "+str(k1)+" images are loaded"
self.textBrowser.append(showStr)
self.cursor=self.textBrowser.textCursor()
self.textBrowser.moveCursor(self.cursor.End)
QtWidgets.QApplication.processEvents()
elif i==1:
k2,self.ImgList2=self.Read(i)
showStr="total "+str(k2)+" images are loaded"
self.textBrowser.append(showStr)
self.cursor=self.textBrowser.textCursor()
self.textBrowser.moveCursor(self.cursor.End)
QtWidgets.QApplication.processEvents()
elif i==2:
k3,self.ImgList3=self.Read(i)
showStr="total "+str(k3)+" images are loaded"
self.textBrowser.append(showStr)
self.cursor=self.textBrowser.textCursor()
self.textBrowser.moveCursor(self.cursor.End)
QtWidgets.QApplication.processEvents()
elif i==3:
k4,self.ImgList4=self.Read(i)
showStr="total "+str(k4)+" images are loaded"
self.textBrowser.append(showStr)
self.cursor=self.textBrowser.textCursor()
self.textBrowser.moveCursor(self.cursor.End)
QtWidgets.QApplication.processEvents()
if k1==k2 and k2==k3 and k3==k4:
self.ResetButton.setEnabled(True)
self.NextButton.setText("Start")
self.NextButton.setEnabled(True)
self.LoadButton.setEnabled(False)
self.ComtButton.setEnabled(True)
self.TotalNums=k1
else:
showStr="images load error!"
self.textBrowser.append(showStr)
self.cursor=self.textBrowser.textCursor()
self.textBrowser.moveCursor(self.cursor.End)
QtWidgets.QApplication.processEvents()
def NextBn_Rec(self):
if self.curIndex>=self.TotalNums:
self.ResetButton.setEnabled(False)
self.NextButton.setText("Start")
self.NextButton.setEnabled(False)
self.LoadButton.setEnabled(True)
showStr="end."+str(self.Img1_bad)+" "+str(self.Img1_medium)+" "+str(self.Img1_good)+" "+str(self.Img2_bad)+" "+str(self.Img2_medium)+" "+str(self.Img2_good)+" "+str(self.Img2_bad)+" "+str(self.Img3_medium)+" "+str(self.Img3_good)
self.textBrowser.append(showStr)
self.cursor=self.textBrowser.textCursor()
self.textBrowser.moveCursor(self.cursor.End)
QtWidgets.QApplication.processEvents()
else:
self.NextButton.setText("Next")
#QtWidgets.QApplication.processEvents()
self.zoomscale=1
Img1=self.ImgList1[self.curIndex]
Img2=self.ImgList2[self.curIndex]
Img3=self.ImgList3[self.curIndex]
Img4=self.ImgList4[self.curIndex]
height1,width1,bytePerComponent1=Img1.shape
bytesPerLine1 = 3 * width1
cv2.cvtColor(Img1, cv2.COLOR_BGR2RGB, Img1)
frame1 = QImage(Img1.data, width1, height1,bytesPerLine1, QImage.Format_RGB888)
height2,width2,bytePerComponent2=Img2.shape
bytesPerLine2 = 3 * width2
cv2.cvtColor(Img2, cv2.COLOR_BGR2RGB, Img2)
frame2 = QImage(Img2.data, width2, height2,bytesPerLine2, QImage.Format_RGB888)
height3,width3,bytePerComponent3=Img3.shape
bytesPerLine3 = 3 * width3
cv2.cvtColor(Img3, cv2.COLOR_BGR2RGB, Img3)
frame3 = QImage(Img3.data, width3, height3,bytesPerLine3, QImage.Format_RGB888)
height4,width4,bytePerComponent4=Img4.shape
bytesPerLine4 = 3 * width4
cv2.cvtColor(Img4, cv2.COLOR_BGR2RGB, Img4)
frame4 = QImage(Img4.data, width4, height4,bytesPerLine4, QImage.Format_RGB888)
pix1 = QPixmap.fromImage(frame1)
pix2 = QPixmap.fromImage(frame2)
pix3 = QPixmap.fromImage(frame3)
pix4 = QPixmap.fromImage(frame4)
self.item1=QGraphicsPixmapItem(pix1)
self.item2=QGraphicsPixmapItem(pix2)
self.item3=QGraphicsPixmapItem(pix3)
self.item4=QGraphicsPixmapItem(pix4)
self.scene1=QGraphicsScene()
self.scene2=QGraphicsScene()
self.scene3=QGraphicsScene()
self.scene4=QGraphicsScene()
self.scene1.addItem(self.item1)
self.scene2.addItem(self.item2)
self.scene3.addItem(self.item3)
self.scene4.addItem(self.item4)
self.ImgView_1.setScene(self.scene1)
self.ImgView_2.setScene(self.scene2)
self.ImgView_3.setScene(self.scene3)
self.View_4.setScene(self.scene4)
showStr="the "+str(self.curIndex)+" image..."
self.textBrowser.append(showStr)
self.cursor=self.textBrowser.textCursor()
self.textBrowser.moveCursor(self.cursor.End)
QtWidgets.QApplication.processEvents()
#self.curIndex+=1
self.Img1_flag=0
self.Img2_flag=0
self.Img3_flag=0
self.check_bad_1.setChecked(False)
self.check_bad_2.setChecked(False)
self.check_bad_3.setChecked(False)
self.check_medium_1.setChecked(False)
self.check_medium_2.setChecked(False)
self.check_medium_3.setChecked(False)
self.check_good_1.setChecked(False)
self.check_good_2.setChecked(False)
self.check_good_3.setChecked(False)
def ComBn_Rec(self):
print(self.Img1_flag,self.Img2_flag,self.Img3_flag)
if (self.Img1_flag+self.Img2_flag+self.Img3_flag)!=3:
showStr="please chose the fit option..."
self.textBrowser.append(showStr)
self.cursor=self.textBrowser.textCursor()
self.textBrowser.moveCursor(self.cursor.End)
QtWidgets.QApplication.processEvents()
self.Img1_flag=0
self.Img2_flag=0
self.Img3_flag=0
self.check_bad_1.setChecked(False)
self.check_bad_2.setChecked(False)
self.check_bad_3.setChecked(False)
self.check_medium_1.setChecked(False)
self.check_medium_2.setChecked(False)
self.check_medium_3.setChecked(False)
self.check_good_1.setChecked(False)
self.check_good_2.setChecked(False)
self.check_good_3.setChecked(False)
else:
showSub1=None
showSub2=None
showSub3=None
if self.check_bad_1.isChecked():
self.Img1_bad+=1
showSub1="1th bad"#+str(self.Img1_bad)
if self.check_bad_2.isChecked():
self.Img2_bad+=1
showSub2="2th bad"#+str(self.Img2_bad)
if self.check_bad_3.isChecked():
self.Img3_bad+=1
showSub3="3th bad"#+str(self.Img3_bad)
if self.check_medium_1.isChecked():
self.Img1_medium+=1
showSub1="1th medium"#+str(self.Img1_medium)
if self.check_medium_2.isChecked():
self.Img2_medium+=1
showSub2="2th medium"#+str(self.Img2_medium)
if self.check_medium_3.isChecked():
self.Img3_medium+=1
showSub3="3th medium"#+str(self.Img3_medium)
if self.check_good_1.isChecked():
self.Img1_good+=1
showSub1="1th good"#+str(self.Img1_good)
if self.check_good_2.isChecked():
self.Img2_good+=1
showSub2="2th good"#+str(self.Img2_good)
if self.check_good_3.isChecked():
self.Img3_good+=1
showSub3="3th good"#+str(self.Img3_good)
self.curIndex+=1
showStr=showSub1+" "+showSub2+" "+showSub3
self.textBrowser.append(showStr)
self.cursor=self.textBrowser.textCursor()
self.textBrowser.moveCursor(self.cursor.End)
QtWidgets.QApplication.processEvents()
def GetOption(self,btn):
if btn.text()=="bad":
if self.check_bad_1.isChecked():
self.Img1_flag=1
elif self.check_bad_2.isChecked():
self.Img2_flag=1
elif self.check_bad_3.isChecked():
self.Img3_flag=1
elif btn.text()=="medium":
if self.check_medium_1.isChecked():
self.Img1_flag=1
elif self.check_medium_2.isChecked():
self.Img2_flag=1
elif self.check_medium_3.isChecked():
self.Img3_flag=1
elif btn.text()=="good":
if self.check_good_1.isChecked():
self.Img1_flag=1
elif self.check_good_2.isChecked():
self.Img2_flag=1
elif self.check_good_3.isChecked():
self.Img3_flag=1
#################################################################
def Read(self,index):
nameList=[]
ImgList=[]
filepath=None
if index==0:
nameList=os.listdir(self.path1)
filepath=self.path1
elif index==1:
nameList=os.listdir(self.path2)
filepath=self.path2
elif index==2:
nameList=os.listdir(self.path3)
filepath=self.path3
elif index==3:
nameList=os.listdir(self.path4)
filepath=self.path4
k=0
for name in nameList:
imgpath=os.path.join(filepath,name)
Img=cv2.imread(imgpath)
if Img is not None:
ImgList.append(Img)
k+=1
self.curIndex=0
return k,ImgList
# # ##############################
if __name__=="__main__":
app = QtWidgets.QApplication(sys.argv)
form = QtWidgets.QWidget()
windows = Ui_Form()
windows.setupUi(form)
form.show()
sys.exit(app.exec_())
运行页面如下:
原文链接:https://blog.csdn.net/cxn511/article/details/106692062