def __updateShootingElapsedTime(self): #Logger().trace("ShootController.__updateShootingElapsedTime()") if self._model.isShooting(): shootingTime, elapsedTime = self._model.getShootingElapsedTime() self._view.shootingTimeLabel.setText("%s" % sToHmsAsStr(shootingTime)) self._view.elapsedTimeLabel.setText("%s" % sToHmsAsStr(elapsedTime)) else: self.__shootingElapseTimer.stop()
def __onShootingWaiting(self, wait): Logger().trace("ShootController.__onShootingRepeat()") sequenceMessage = self.tr("Waiting") + " %s" % sToHmsAsStr(wait) self._view.sequenceLabel.setText(sequenceMessage)
def start(self): """ Start pano shooting. """ def checkPause(): """ Check if pause requested. """ if self.__pause: Logger().info("Pause shooting") self.__pauseTime = time.time() self.__paused = True self.paused() while self.__pause: time.sleep(0.1) self.__paused = False self.resumed() self.__totalPausedTime += time.time() - self.__pauseTime Logger().info("Resume shooting") def checkStop(): """ Check if stop requested. """ if self.__stop: Logger().info("Stop shooting") raise StopIteration Logger().trace("Shooting.start()") self.__startTime = time.time() self.__totalPausedTime = 0. self.__stop = False self.__pause = False self.__paused = False self.__shooting = True self.started() self.progress(0., 0.) if self.cameraOrientation == 'portrait': roll = 90. elif self.cameraOrientation == 'landscape': roll = 0. elif self.cameraOrientation == 'custom': roll = self.cameraRoll else: raise ValueError("cameraOrientation must be in ('portrait', 'landscape', 'custom'") focal = self.camera.lens.focal if self.camera.lens.type_ == 'rectilinear': focal *= self.camera.lens.opticalMultiplier values = {'title' : ConfigManager().get('Configuration/DATA_TITLE'), 'gps': ConfigManager().get('Configuration/DATA_GPS'), 'comment': ConfigManager().get('Configuration/DATA_COMMENT') % {'version': config.VERSION}, 'headOrientation': "up", 'cameraOrientation': "%s" % self.cameraOrientation, 'roll': "%.1f" % roll, 'stabilizationDelay': "%.1f" % self.stabilizationDelay, 'counter': "%03d" % self.shootingCounter, 'timeValue': "%.1f" % self.shutter.timeValue, 'bracketingNbPicts': "%d" % self.shutter.bracketingNbPicts, 'sensorCoef': "%.1f" % self.camera.sensorCoef, 'sensorRatio': "%s" % self.camera.sensorRatio, 'lensType': "%s" % self.camera.lens.type_, 'focal': "%.1f" % focal } Logger().info("Start shooting process...") try: # Timer after if self.timerAfterEnable: initialTime = time.time() remainingTime = self.timerAfter - (time.time() - initialTime) while remainingTime > 0: Logger().debug("Shooting.start(): start in %s" % sToHmsAsStr(remainingTime)) self.waiting(remainingTime) time.sleep(1) # Check only stop checkStop() remainingTime = self.timerAfter - (time.time() - initialTime) # Timer repeat if self.timerRepeatEnable: numRepeat = self.timerRepeat else: numRepeat = 1 for repeat in xrange(1, numRepeat + 1): # Create data object (use a factory) if self.mode == 'mosaic': Logger().debug("Shooting.start(): create mosaic data object") data = MosaicData() values.update({'yawNbPicts': "%d" % self.mosaic.yawNbPicts, 'pitchNbPicts': "%d" % self.mosaic.pitchNbPicts, 'overlap': "%.2f" % self.mosaic.overlap, 'yawRealOverlap': "%.2f" % self.mosaic.yawRealOverlap, 'pitchRealOverlap': "%.2f" % self.mosaic.pitchRealOverlap}) else: Logger().debug("Shooting.start(): create preset data object") data = PresetData() values.update({'name': "%s" % self.preset.name}) # Create header data.createHeader(values) # Increase shooting counter self.shootingCounter += 1 if self.shootingCounter > config.SHOOTING_COUNTER_MAX: self.shootingCounter = 1 ConfigManager().save() startTime = time.time() Logger().debug("Shooting.start(): repeat %d/%d" % (repeat, numRepeat)) self.repeat(repeat) self.progress(0.) # Loop over all positions self.scan.index = 1 while True: try: index, (yaw, pitch) = self.scan.getCurrentPosition() if isinstance(index, tuple): index_, yawIndex, pitchIndex = index else: index_ = index Logger().debug("Shooting.start(): pict #%d of %d, index=%s, yaw=%.1f, pitch=%.1f" % (index_, self.scan.totalNbPicts, str(index), yaw, pitch)) self.update(index, yaw, pitch, next=True) self.__forceNewPosition = False Logger().info("Moving") self.sequence('moving') self.head.gotoPosition(yaw, pitch) # Test step-by-step flag (use a function) if self.__stepByStep and not self.__stop: self.__pause = True Logger().info("Wait for manual shooting trigger...") # 'Pause every' feature if self.pauseEveryEnable and self.scan.index > 1 and not self.scan.index % self.pauseEvery - 1: self.__pause = True Logger().info("Automatic pausing...") checkPause() checkStop() # If a new shooting position has been requested (rewind/forward), # we start over if self.__forceNewPosition: continue # Take pictures for bracket in xrange(1, self.shutter.bracketingNbPicts + 1): # Mirror lockup sequence # TODO: move call to plugin! if self.shutter.mirrorLockup: Logger().info("Mirror lockup") self.sequence('mirror') retCode = self.shutter.lockupMirror() if retCode: raise HardwareError(self.tr("Shutter failed while mirror locking up")) self.__LastShootTime = time.time() Logger().info("Stabilization") self.sequence('stabilization') time.sleep(self.stabilizationDelay) # Take pictures Logger().info("Shutter cycle") Logger().debug("Shooting.start(): bracket #%d of %d" % (bracket, self.shutter.bracketingNbPicts)) self.sequence('shutter', bracket) retCode = self.shutter.shoot(bracket) if retCode: raise HardwareError(self.tr("Shutter failed while shooting")) # Add image to the xml data file realYaw, realPitch = self.head.readPosition() data.addPicture(bracket, realYaw, realPitch, roll) checkStop() except OutOfLimitsError, msg: self.head.stopAxis() Logger().warning("Shooting.start(): %s" % unicode(msg)) state = 'invalid' except HardwareError, msg: self.head.stopAxis() Logger().exception("Shooting.start()") #Logger().warning("Shooting.start(): position index=%s, yaw=%.1f, pitch=%.1f out of limits" % (index_, yaw, pitch)) state = 'error'
def __setTimerEvery(self, s): """ """ ConfigManager().set('Configuration/TIMER_EVERY', sToHmsAsStr(s))
def __setTimerAfter(self, s): """ """ ConfigManager().set('Configuration/TIMER_AFTER', sToHmsAsStr(s))
checkPause() checkStop() # If a new shooting position has been requested (rewind/forward), # we start over if self.__forceNewPosition: continue # If the sequence is over, we leave the loop if end: break if repeat < numRepeat: remainingTime = self.timerEvery - (time.time() - startTime) while remainingTime > 0: Logger().debug("Shooting.start(): restart in %s" % sToHmsAsStr(remainingTime)) self.waiting(remainingTime) time.sleep(1) remainingTime = self.timerEvery - (time.time() - startTime) checkStop() self.beforeRepeat() except StopIteration: Logger().debug("Shooting.start(): stop detected") status = 'cancel' Logger().warning("Shoot process canceled") except: Logger().exception("Shooting.start()") status = 'fail'
def refreshView(self): # Shooting tab self._view.headOrientationComboBox.setCurrentIndex(config.HEAD_ORIENTATION_INDEX[self._model.headOrientation]) self._view.pitchArmSideComboBox.setCurrentIndex(config.PITCH_ARM_SIDE_INDEX[self._model.head.pitchArmSide]) self._view.cameraOrientationComboBox.setCurrentIndex(config.CAMERA_ORIENTATION_INDEX[self._model.cameraOrientation]) self._view.stabilizationDelayDoubleSpinBox.setValue(self._model.stabilizationDelay) # Mosaic tab self._view.overlapSpinBox.setValue(int(100 * self._model.mosaic.overlap)) self._view.startFromComboBox.setCurrentIndex(config.MOSAIC_START_FROM_INDEX[self._model.mosaic.startFrom]) self._view.initialDirectionComboBox.setCurrentIndex(config.MOSAIC_INITIAL_DIR_INDEX[self._model.mosaic.initialDirection]) self._view.crCheckBox.setChecked(self._model.mosaic.cr) # Camera/lens tab self._view.sensorCoefDoubleSpinBox.setValue(self._model.camera.sensorCoef) self._view.sensorRatioComboBox.setCurrentIndex(config.SENSOR_RATIO_INDEX[self._model.camera.sensorRatio]) self._view.sensorResolutionDoubleSpinBox.setValue(self._model.camera.sensorResolution) self._view.lensTypeComboBox.setCurrentIndex(config.LENS_TYPE_INDEX[self._model.camera.lens.type_]) self._view.focalDoubleSpinBox.setValue(self._model.camera.lens.focal) self._view.opticalMultiplierDoubleSpinBox.setValue(self._model.camera.lens.opticalMultiplier) # Plugins tab pluginName = ConfigManager().get('Plugins/PLUGIN_YAW_AXIS') self._view.yawAxisPluginNameLineEdit.setText(pluginName) pluginName = ConfigManager().get('Plugins/PLUGIN_PITCH_AXIS') self._view.pitchAxisPluginNameLineEdit.setText(pluginName) pluginName = ConfigManager().get('Plugins/PLUGIN_SHUTTER') self._view.shutterPluginNameLineEdit.setText(pluginName) # Data tab dataStorageDir = ConfigManager().get('Configuration/DATA_STORAGE_DIR') if not dataStorageDir: dataStorageDir = config.DATA_STORAGE_DIR self._view.dataStorageDirLineEdit.setText(dataStorageDir) self._view.dataFileFormatLineEdit.setText(ConfigManager().get('Configuration/DATA_FILE_FORMAT')) self._view.dataFileEnableCheckBox.setChecked(ConfigManager().getBoolean('Configuration/DATA_FILE_ENABLE')) dataTitle = ConfigManager().get('Configuration/DATA_TITLE') if not dataTitle: dataTitle = self.tr("Here goes the title") self._view.dataTitleLineEdit.setText(dataTitle) dataGps = ConfigManager().get('Configuration/DATA_GPS') if not dataGps: dataGps = self.tr("Here goes the location") self._view.dataGpsLineEdit.setText(dataGps) dataComment = ConfigManager().get('Configuration/DATA_COMMENT') if not dataComment: dataComment = self.tr("Generated by Papywizard %(version)s") self._view.dataCommentLineEdit.setText(dataComment) # Timer tab time_ = QtCore.QTime.fromString(QtCore.QString(sToHmsAsStr(self._model.timerAfter)), "hh:mm:ss") self._view.timerAfterTimeEdit.setTime(time_) self._view.timerAfterEnableCheckBox.setChecked(self._model.timerAfterEnable) self._view.timerRepeatSpinBox.setValue(self._model.timerRepeat) self._view.timerRepeatEnableCheckBox.setChecked(self._model.timerRepeatEnable) time_ = QtCore.QTime.fromString(QtCore.QString(sToHmsAsStr(self._model.timerEvery)), "hh:mm:ss") self._view.timerEveryTimeEdit.setTime(time_) #self._view.timerReverseDirectionCheckBox.setChecked(self._model.timerReverseDirection) # Misc tab loggerIndex = config.LOGGER_INDEX[ConfigManager().get('Configuration/LOGGER_LEVEL')] self._view.loggerLevelComboBox.setCurrentIndex(loggerIndex) self._view.shootingCounterSpinBox.setValue(self._model.shootingCounter) self._view.showShootingCounterCheckBox.setChecked(self._model.showShootingCounter) self._view.pauseEverySpinBox.setValue(self._model.pauseEvery) self._view.pauseEveryEnableCheckBox.setChecked(self._model.pauseEveryEnable)