dtl 6 months ago
parent 1ae841dd3d
commit 0610a8712d

@ -21,7 +21,7 @@ class PyQtMainEntry(QMainWindow, Ui_MainWindow):
self._timer = QtCore.QTimer(self) self._timer = QtCore.QTimer(self)
self._timer.timeout.connect(self._queryFrame) self._timer.timeout.connect(self._queryFrame)
self._timer.setInterval(30) self._timer.setInterval(10)
def btnOpenCamera_Clicked(self): def btnOpenCamera_Clicked(self):
@ -64,12 +64,33 @@ class PyQtMainEntry(QMainWindow, Ui_MainWindow):
def btnGray_Clicked(self): def btnGray_Clicked(self):
if not hasattr(self, "captured"):
return
self.cpatured = cv.cvtColor(self.captured, cv.COLOR_RGB2GRAY)
rows, columns = self.cpatured.shape
bytesPerLine = columns
QImg = QImage(self.cpatured.data, columns, rows, bytesPerLine, QImage.Format_Indexed8)
self.labelResult.setPixmap(QPixmap.fromImage(QImg).scaled(
self.labelResult.size(), Qt.KeepAspectRatio, Qt.SmoothTransformation))
def btnThreshold_Clicked(self): def btnThreshold_Clicked(self):
if not hasattr(self, "captured"): if not hasattr(self, "captured"):
return return
_, self.cpatured = cv.threshold(
self.cpatured, 0, 255, cv.THRESH_BINARY + cv.THRESH_OTSU)
rows, columns = self.cpatured.shape
bytesPerLine = columns
QImg = QImage(self.cpatured.data, columns, rows, bytesPerLine, QImage.Format_Indexed8)
self.labelResult.setPixmap(QPixmap.fromImage(QImg).scaled(
self.labelResult.size(), Qt.KeepAspectRatio, Qt.SmoothTransformation))
@QtCore.pyqtSlot() @QtCore.pyqtSlot()
def _queryFrame(self): def _queryFrame(self):
@ -89,7 +110,14 @@ class PyQtMainEntry(QMainWindow, Ui_MainWindow):
if not hasattr(self, "captured"): if not hasattr(self, "captured"):
return return
self.cpatured = cv.fastNlMeansDenoising(self.cpatured, None, 10, 7, 21)
rows, columns = self.cpatured.shape
bytesPerLine = columns
QImg = QImage(self.cpatured.data, columns, rows, bytesPerLine, QImage.Format_Indexed8)
self.labelResult.setPixmap(QPixmap.fromImage(QImg).scaled(
self.labelResult.size(), Qt.KeepAspectRatio, Qt.SmoothTransformation))
if __name__ == "__main__": if __name__ == "__main__":
app = QtWidgets.QApplication(sys.argv) app = QtWidgets.QApplication(sys.argv)

Loading…
Cancel
Save