示例#1
0
class Example(QMainWindow):
    def __init__(self):
        super().__init__()

        self.initUI()

    def initUI(self):

        self.setGeometry(300, 300, 300, 200)
        self.setWindowTitle('Camera')
        self.show()

        self.camera = Camera(1)
        self.camera.initialize()

        self.central_widget = QWidget()
        self.layout = QVBoxLayout(self.central_widget)

        #define data capture button
        self.button_frame = QPushButton('Capture', self.central_widget)
        self.button_frame.clicked.connect(self.update_image)
        self.layout.addWidget(self.button_frame)

        #define image view widget
        self.image_view = ImageView()
        self.layout.addWidget(self.image_view)

        #add central widget
        self.setCentralWidget(self.central_widget)

    def update_image(self):
        frame = self.camera.get_frame()
        self.image_view.setImage(frame.T)
        print('Maximum in frame: {}, Minimum in frame: {}'.format(
            np.max(frame), np.min(frame)))
示例#2
0
from PyQt5.QtWidgets import QApplication

from models import Camera
from Spectrometer import Spectrometer
from views import StartWindow

camera = Camera(0)
camera.initialize()

spectrometer = Spectrometer()
spectrometer.connect()

app = QApplication([])
start_window = StartWindow(camera, spectrometer)
# start_window = StartWindow(camera)
start_window.show()
app.exit(app.exec_())
spectrometer.disconnect()
camera.close_camera()