Я хочу отобразить мое обрезанное изображение (с переменной «roi_color») в метке Qt с кодом «self.displayImage (2)» и изменило «self» на «roi_color», но мое приложение остановилосьработает вместо
def haarClicked(self):
gray = cv2.cvtColor(self.image, cv2.COLOR_BGR2GRAY)
faces = face_cascade.detectMultiScale(gray, 1.25, 2)
for (x, y, w, h) in faces:
cv2.rectangle(self.image, (x, y), (x+w, y+h), (255, 0, 0), 2)
roi_gray = gray[y:y + h, x:x + w]
roi_color = self.image[y:y + h, x:x + w]
#cv2.imshow("cropped", roi_color)
self.image = self.image[y:y + h, x:x + w]
self.displayImage(2)
def displayImage(self, windows=1):
qformat=QImage.Format_Indexed8
if len(self.image.shape)==3:
if(self.image.shape[2])==4:
qformat=QImage.Format_RGBA8888
else:
qformat=QImage.Format_RGB888
img=QImage(self.image,self.image.shape[1],self.image.shape[0],self.image.strides[0],qformat)
img=img.rgbSwapped()
if windows==1:
self.imgLabel.setPixmap(QPixmap.fromImage(img))
self.imgLabel.setAlignment(QtCore.Qt.AlignHCenter|QtCore.Qt.AlignVCenter)
self.imgLabel.setScaledContents(True)
if windows==2:
self.haarLabel.setPixmap(QPixmap.fromImage(img))
self.haarLabel.setAlignment(QtCore.Qt.AlignHCenter|QtCore.Qt.AlignVCenter)
self.haarLabel.setScaledContents(True)