Esempio n. 1
0
    def __init__(self, queue, settings, parent=None):
        QtGui.QWidget.__init__(self, parent)

        self.queue = queue
        self.settings = settings

        self.title = gui.TitleWidget(
            label='',
            title='Single Image',
            description='Load a single image file as a light field')

        pathname, filename = os.path.split(queue.filepath)

        props = {
            'Image Width': queue._frame.width,
            'Image Height': queue._frame.height,
            'Image Bit-depth': queue._frame.bits,
            'Location': pathname,
            'Filename': filename
        }

        self.properties = gui.PropertiesWidget(
            props,
            title='Image Properties',
            headers=None,
        )

        self.settingsLayout = QtGui.QGridLayout(self)
        self.settingsLayout.addWidget(self.title, 0, 0)
        self.settingsLayout.addWidget(self.properties, 1, 0)
        self.settingsLayout.setRowStretch(4, 1)
        self.setLayout(self.settingsLayout)
Esempio n. 2
0
    def __init__(self, settings, parent=None):
        QtGui.QWidget.__init__(self, parent)

        self.settings = settings  # application level settings

        outputPath = self.settings.getString('output/default_path', '.')
        outputPath = self.settings.getString('output/file/default_path',
                                             outputPath)
        sequenceNumbered = self.settings.getBool(
            'output/file/sequence_numbered', False)

        sequenceName = self.settings.getString('output/file/sequence_name',
                                               'capture')
        sequenceExtension = self.settings.getString(
            'output/file/sequence_extension', 'tif')
        sequenceBurst = self.settings.getInteger('output/file/sequence_burst',
                                                 1)
        sequenceBurstEnabled = self.settings.getBool(
            'output/file/sequence_burst_enabled', False)

        # create the UI
        self.title = gui.TitleWidget(
            label='',
            title='Image file(s)',
            description='Save captured images to disk as individual files.')
        self.outputPathSelector = gui.PathSelectorWidget(
            label='Output folder',
            browseCaption=
            'Please choose a folder where new output image(s) will be created.',
            default=outputPath)

        self.outputFileGroup = QtGui.QGroupBox('Output filename(s)')
        label1 = QtGui.QLabel('Name:')
        label1.setAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignVCenter)
        self.outputFileHeader = QtGui.QLineEdit(sequenceName,
                                                self.outputFileGroup)

        label2 = QtGui.QLabel('Image type:')
        label2.setAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignVCenter)
        image_types = [('TIFF', 'tif'), ('ImageStack TMP', 'tmp')]
        self.outputFileExtension = gui.CustomOptionSelectorWidget(
            caption='',
            options=image_types,
            custom=None,
            parent=self.outputFileGroup)

        label3 = QtGui.QLabel('Options:')
        label3.setAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignVCenter)

        self.limitFrames = QtGui.QCheckBox('Limit frames per recording:')
        self.framesToRecord = QtGui.QLineEdit('1')
        validator = QtGui.QIntValidator(self.framesToRecord)
        validator.setBottom(1)
        self.framesToRecord.setValidator(validator)

        self.numFramesLayout = QtGui.QHBoxLayout()
        self.numFramesLayout.setMargin(0)
        self.numFramesLayout.addWidget(self.limitFrames)
        self.numFramesLayout.addWidget(self.framesToRecord)

        self.appendFrameNumber = QtGui.QCheckBox('Append frame number')

        self.label4 = QtGui.QLabel('Next frame:')
        self.label4.setAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignVCenter)

        self.outputFileNumberLayout = QtGui.QHBoxLayout()
        self.outputFileNumberLayout.setMargin(0)

        self.outputFileNumber = QtGui.QLineEdit('0')
        validator = QtGui.QIntValidator(self.outputFileNumber)
        validator.setBottom(0)
        self.outputFileNumber.setValidator(validator)
        self.autoNumber = QtGui.QPushButton('Auto')
        self.outputFileNumberLayout.addWidget(self.outputFileNumber)
        self.outputFileNumberLayout.addWidget(self.autoNumber)

        self.outputFileLayout = QtGui.QGridLayout(self.outputFileGroup)
        self.outputFileLayout.addWidget(label1, 0, 0)
        self.outputFileLayout.addWidget(self.outputFileHeader, 0, 1)
        self.outputFileLayout.addWidget(label2, 1, 0)
        self.outputFileLayout.addWidget(self.outputFileExtension, 1, 1)
        self.outputFileLayout.addWidget(label3, 2, 0)
        self.outputFileLayout.addLayout(self.numFramesLayout, 2, 1)
        self.outputFileLayout.addWidget(self.appendFrameNumber, 3, 1)

        self.outputFileLayout.addWidget(self.label4, 50, 0)
        self.outputFileLayout.addLayout(self.outputFileNumberLayout, 50, 1)
        self.outputFileLayout.setRowStretch(99, 1)
        self.outputFileGroup.setLayout(self.outputFileLayout)

        self.controlsGroup = QtGui.QGroupBox('Controls')

        self.snapshot = QtGui.QPushButton('Save current image')
        #self.startStream = QtGui.QPushButton('Start recording stream')
        #self.stopStream = QtGui.QPushButton('Stop recording stream')

        self.controlsLayout = QtGui.QGridLayout(self.controlsGroup)
        self.controlsLayout.addWidget(self.snapshot, 0, 0)
        #self.controlsLayout.addWidget(self.startStream, 0, 1)
        #self.controlsLayout.addWidget(self.stopStream, 0, 2)
        self.controlsLayout.setColumnStretch(99, 1)
        self.controlsGroup.setLayout(self.controlsLayout)

        self.log = gui.LogWidget('Output log')

        self.settingsLayout = QtGui.QGridLayout(self)
        self.settingsLayout.addWidget(self.title, 0, 0)
        self.settingsLayout.addWidget(self.outputPathSelector, 1, 0)
        self.settingsLayout.addWidget(self.outputFileGroup, 2, 0)
        self.settingsLayout.addWidget(self.controlsGroup, 3, 0)
        self.settingsLayout.addWidget(self.log, 4, 0)
        self.settingsLayout.setRowStretch(99, 1)
        self.setLayout(self.settingsLayout)

        # connect the signals
        self.connect(self.outputPathSelector,
                     QtCore.SIGNAL('textChanged(QString)'), self.setPath)

        self.connect(self.outputFileHeader,
                     QtCore.SIGNAL('textChanged(QString)'),
                     self.createFilename)

        self.connect(self.outputFileExtension,
                     QtCore.SIGNAL('valueChanged(QString)'),
                     self.createFilename)

        self.connect(self.limitFrames, QtCore.SIGNAL('stateChanged(int)'),
                     self.burstChanged)
        self.connect(self.framesToRecord,
                     QtCore.SIGNAL('textChanged(QString)'), self.burstChanged)

        self.connect(self.appendFrameNumber,
                     QtCore.SIGNAL('stateChanged(int)'), self.numberedChecked)
        self.connect(self.appendFrameNumber,
                     QtCore.SIGNAL('stateChanged(int)'), self.createFilename)

        self.connect(self.outputFileNumber,
                     QtCore.SIGNAL('textChanged(QString)'), self.checkNumber)
        self.connect(self.outputFileNumber,
                     QtCore.SIGNAL('textChanged(QString)'),
                     self.setNumberFromField)

        self.connect(self.autoNumber, QtCore.SIGNAL('clicked()'),
                     self.setAutoNumber)

        # set the defaults
        self.limitFrames.setChecked(sequenceBurstEnabled)
        self.framesToRecord.setText(str(sequenceBurst))
        self.appendFrameNumber.setChecked(sequenceNumbered)
        self.numberedChecked()
        self.setAutoNumber()
        self.outputFileHeader.setText(sequenceName)
        try:
            self.outputFileExtension.setValue(str(sequenceExtension))
        except Exception:
            pass
Esempio n. 3
0
    def __init__(self, camera, queue, settings, parent=None):
        QtGui.QWidget.__init__(self, parent)

        self.camera = camera
        self.queue = queue
        self.settings = settings

        self.title = gui.TitleWidget(
            label='',
            title='QImaging camera',
            description='Stream images from a QImaging camera.')

        self.captureFormatGroup = QtGui.QGroupBox('Image output format', self)
        self.captureMono8 = QtGui.QRadioButton('Monochrome 8-bit')
        self.captureMono16 = QtGui.QRadioButton('Monochrome 16-bit')
        self.captureFormatLayout = QtGui.QGridLayout(self.captureFormatGroup)
        self.captureFormatLayout.setSpacing(0)
        self.captureFormatLayout.addWidget(self.captureMono8, 0, 0)
        self.captureFormatLayout.addWidget(self.captureMono16, 0, 1)
        self.captureFormatGroup.setLayout(self.captureFormatLayout)

        exposures = gui.ExponentialMap(
            self.camera.settings.min.exposure * 1e-6,
            self.camera.settings.max.exposure * 1e-6)

        self.exposureGroup = gui.SliderWidget(exposures,
                                              gui.TimeDisplay(),
                                              0.25,
                                              'Exposure',
                                              steps=999,
                                              compact=True)

        gains = gui.ExponentialMap(
            self.camera.settings.min.normalizedGain * 1e-6,
            self.camera.settings.max.normalizedGain * 1e-6)
        self.gainGroup = gui.SliderWidget(gains, (float, lambda x: '%.3g' % x),
                                          1.0,
                                          'Gain',
                                          steps=999,
                                          compact=True)

        num_adc_steps = self.camera.settings.max.absoluteOffset - self.camera.settings.min.absoluteOffset + 1
        self.offsetGroup = gui.SliderWidget(gui.LinearMap(-1.0, 1.0),
                                            (float, lambda x: '%.3g' % x),
                                            0.0,
                                            'Offset',
                                            steps=num_adc_steps,
                                            compact=True)

        self.binningGroup = QtGui.QGroupBox('Binning', self)
        self.binning1 = QtGui.QRadioButton('1x1 (No binning)')
        self.binning2 = QtGui.QRadioButton('2x2')
        self.binning4 = QtGui.QRadioButton('4x4')
        self.binning8 = QtGui.QRadioButton('8x8')
        self.binningLayout = QtGui.QGridLayout(self.binningGroup)
        self.binningLayout.addWidget(self.binning1, 0, 0)
        self.binningLayout.addWidget(self.binning2, 1, 0)
        self.binningLayout.addWidget(self.binning4, 0, 1)
        self.binningLayout.addWidget(self.binning8, 1, 1)
        self.binningGroup.setLayout(self.binningLayout)

        self.detailsGroup = QtGui.QGroupBox('Current parameters', self)
        self.details = QtGui.QTextEdit('')
        self.details.setReadOnly(True)
        self.detailsLayout = QtGui.QGridLayout(self.detailsGroup)
        self.detailsLayout.addWidget(self.details)
        self.detailsGroup.setLayout(self.detailsLayout)

        self.settingsLayout = QtGui.QGridLayout(self)
        self.settingsLayout.addWidget(self.title, 0, 0)
        self.settingsLayout.addWidget(self.captureFormatGroup, 1, 0)
        self.settingsLayout.addWidget(self.exposureGroup, 2, 0)
        self.settingsLayout.addWidget(self.gainGroup, 3, 0)
        self.settingsLayout.addWidget(self.offsetGroup, 4, 0)
        self.settingsLayout.addWidget(self.binningGroup, 5, 0)
        self.settingsLayout.addWidget(self.detailsGroup, 6, 0)
        self.settingsLayout.setRowStretch(6, 1)
        self.setLayout(self.settingsLayout)

        self.settingsChanged = False  # when camera settings need to
        # be flushed to camera
        self.timerInterval = 750  # make sure settings at least get updated this fast
        self.timerId = self.startTimer(self.timerInterval)
        self.lock = QtCore.QMutex()

        self.connect(self.captureMono8, QtCore.SIGNAL('clicked(bool)'),
                     self.captureFormatChanged)
        self.connect(self.captureMono16, QtCore.SIGNAL('clicked(bool)'),
                     self.captureFormatChanged)

        self.connect(self.exposureGroup, QtCore.SIGNAL('valueSlid()'),
                     self.exposureChanged)
        self.connect(self.exposureGroup, QtCore.SIGNAL('valueEdited()'),
                     self.exposureChanged)

        self.connect(self.gainGroup, QtCore.SIGNAL('valueSlid()'),
                     self.gainChanged)
        self.connect(self.gainGroup, QtCore.SIGNAL('valueEdited()'),
                     self.gainChanged)

        self.connect(self.offsetGroup, QtCore.SIGNAL('valueSlid()'),
                     self.offsetChanged)
        self.connect(self.offsetGroup, QtCore.SIGNAL('valueEdited()'),
                     self.offsetChanged)

        self.connect(self.binning1, QtCore.SIGNAL('clicked(bool)'),
                     self.binningChanged)
        self.connect(self.binning2, QtCore.SIGNAL('clicked(bool)'),
                     self.binningChanged)
        self.connect(self.binning4, QtCore.SIGNAL('clicked(bool)'),
                     self.binningChanged)
        self.connect(self.binning8, QtCore.SIGNAL('clicked(bool)'),
                     self.binningChanged)
Esempio n. 4
0
    def __init__(self, queue, settings, parent=None):
        QtGui.QWidget.__init__(self, parent)

        self.queue = queue
        self.settings = settings

        self.title = gui.TitleWidget(
            label='',
            title='Image File Sequence',
            description='Display a sequence of input images as light fields')

        self.frameListGroup = QtGui.QGroupBox('Image frames', self)

        self.frameListModel = QueueItemModel(self.queue)

        self.frameListWidget = QtGui.QTableView(self)
        self.frameListWidget.setModel(self.frameListModel)
        self.frameListWidget.horizontalHeader().setStretchLastSection(True)
        self.frameListWidget.horizontalHeader().setVisible(False)

        self.moveUpButton = QtGui.QPushButton('Move up')
        self.connect(self.moveUpButton, QtCore.SIGNAL('clicked(bool)'),
                     self.moveUp)
        self.moveDownButton = QtGui.QPushButton('Move down')
        self.connect(self.moveDownButton, QtCore.SIGNAL('clicked(bool)'),
                     self.moveDown)
        self.removeButton = QtGui.QPushButton('Remove')
        self.connect(self.removeButton, QtCore.SIGNAL('clicked(bool)'),
                     self.remove)
        self.addButton = QtGui.QPushButton('Add...')
        self.connect(self.addButton, QtCore.SIGNAL('clicked(bool)'),
                     self.doAddFiles)

        self.frameListLayout = QtGui.QGridLayout(self.frameListGroup)
        self.frameListLayout.addWidget(self.frameListWidget, 0, 0, 1, 4)
        self.frameListLayout.addWidget(self.moveUpButton, 1, 0)
        self.frameListLayout.addWidget(self.moveDownButton, 1, 1)
        self.frameListLayout.addWidget(self.removeButton, 1, 2)
        self.frameListLayout.addWidget(self.addButton, 1, 3)
        self.frameListGroup.setLayout(self.frameListLayout)

        self.frameSliderGroup = QtGui.QGroupBox('Frame control')

        self.frameLabel = QtGui.QLabel('Current frame: ')
        self.frameSlider = QtGui.QSlider(QtCore.Qt.Horizontal, self)
        self.frameSlider.setMinimum(0)
        self.frameSlider.setMaximum(self.frameListModel.rowCount() - 1)
        self.frameNumber = QtGui.QLabel('0000')

        self.connect(self.frameListModel, QtCore.SIGNAL('layoutChanged()'),
                     self.updateSlider)

        self.frameRate = gui.CustomOptionSelectorWidget(
            'Framerate:', [('4 fps', 4.0), ('10 fps', 10.0), ('24 fps', 24.0),
                           ('30 fps', 30.0)], 'Custom', float, self)
        self.frameRate.setValue(10.0)

        self.frameSliderLayout = QtGui.QGridLayout(self.frameSliderGroup)
        self.frameSliderLayout.addWidget(self.frameLabel, 0, 0)
        self.frameSliderLayout.addWidget(self.frameSlider, 0, 1)
        self.frameSliderLayout.addWidget(self.frameNumber, 0, 2)
        self.frameSliderLayout.addWidget(self.frameRate, 1, 0, 1, 3)
        self.frameSliderLayout.setColumnStretch(1, 1)
        self.frameSliderGroup.setLayout(self.frameSliderLayout)

        self.connect(self.frameRate, QtCore.SIGNAL('valueChanged()'),
                     self.frameRateChanged)

        self.queue.cur_frame_changed = self.curFrameChanged
        self.connect(self, QtCore.SIGNAL('frameNumberChanged(int)'),
                     self.frameSlider.setValue)
        self.connect(self.frameSlider, QtCore.SIGNAL('sliderMoved(int)'),
                     self.changeCurrentFrame)
        self.connect(self.frameSlider, QtCore.SIGNAL('sliderPressed()'),
                     self.changeCurrentFrame)

        self.buttonGroup = QtGui.QGroupBox()
        self.buttonGroupLayout = QtGui.QHBoxLayout()
        self.loadButton = QtGui.QPushButton("Load...")
        self.saveButton = QtGui.QPushButton("Save...")
        self.buttonGroupLayout.addStretch(1)
        self.buttonGroupLayout.addWidget(self.loadButton)
        self.buttonGroupLayout.addWidget(self.saveButton)
        self.buttonGroup.setLayout(self.buttonGroupLayout)

        self.connect(self.loadButton, QtCore.SIGNAL('clicked(bool)'),
                     self.loadSequence)
        self.connect(self.saveButton, QtCore.SIGNAL('clicked(bool)'),
                     self.saveSequence)

        self.startupGroup = QtGui.QGroupBox('On startup...')
        self.startupGroupLayout = QtGui.QVBoxLayout()
        self.startupGroup.setLayout(self.startupGroupLayout)
        self.startupButtons = [None, None, None, None]
        self.startupMapper = QtCore.QSignalMapper(self)
        self.startupButtons[1] = QtGui.QRadioButton(
            'Create a new sequence from images...')
        self.startupButtons[2] = QtGui.QRadioButton(
            'Load a previously saved sequence...')
        self.startupButtons[3] = QtGui.QRadioButton(
            'Create a new blank sequence')
        self.startupButtons[0] = QtGui.QRadioButton('Ask me...')
        for i in range(4):
            self.startupMapper.setMapping(self.startupButtons[i], i)
            self.connect(self.startupButtons[i],
                         QtCore.SIGNAL('clicked(bool)'), self.startupMapper,
                         QtCore.SLOT('map()'))
        self.startupGroupLayout.addWidget(self.startupButtons[1])
        self.startupGroupLayout.addWidget(self.startupButtons[2])
        self.startupGroupLayout.addWidget(self.startupButtons[3])
        self.startupGroupLayout.addWidget(self.startupButtons[0])
        self.connect(self.startupMapper, QtCore.SIGNAL('mapped(int)'),
                     self.saveStartupSettings)
        startup = self.settings.getInteger('input/file/multistartup', 0)
        if startup < 0 or startup > 3:
            startup = 0
        self.startupButtons[startup].click()

        self.settingsLayout = QtGui.QGridLayout(self)
        self.settingsLayout.addWidget(self.title, 0, 0)
        self.settingsLayout.addWidget(self.frameListGroup, 1, 0)
        self.settingsLayout.addWidget(self.frameSliderGroup, 2, 0)
        self.settingsLayout.addWidget(self.buttonGroup, 3, 0)
        self.settingsLayout.addWidget(self.startupGroup, 4, 0)

        self.settingsLayout.setRowStretch(5, 1)
        self.setLayout(self.settingsLayout)