Changeset 395
- Timestamp:
- 07/01/08 16:13:37 (5 years ago)
- File:
-
- 1 edited
-
trunk/model/shooting.py (modified) (9 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/model/shooting.py
r391 r395 75 75 @type simulatedHardware: {HeadSimulation} 76 76 """ 77 self.__ running = False77 self.__shooting = False 78 78 self.__suspend = False 79 79 self.__stop = False … … 87 87 self.newPictSignal = Signal() 88 88 self.camera = Camera() 89 90 self.yawStart = 0. 91 self.pitchStart = 0. 92 self.yawEnd = 0. 93 self.pitchEnd = 0. 89 self.mosaic = Mosaic(self.camera) 90 #self.fullSpherical = FullSpherical() 91 94 92 self.position = self.hardware.readPosition() 95 93 self.progress = 0. 96 94 self.sequence = "Idle" 97 95 98 #self.__computeParams('startEnd') 99 96 # Properties 100 97 def __getStabilizationDelay(self): 101 98 """ … … 109 106 110 107 stabilizationDelay = property(__getStabilizationDelay, __setStabilizationDelay) 111 112 def __getOverlap(self):113 """114 """115 return ConfigManager().getFloat('Preferences', 'SHOOTING_OVERLAP')116 117 def __setOverlap(self, overlap):118 """119 """120 ConfigManager().setFloat('Preferences', 'SHOOTING_OVERLAP', overlap, 2)121 122 overlap = property(__getOverlap, __setOverlap)123 124 def __getCameraOrientation(self):125 """126 """127 return ConfigManager().get('Preferences', 'SHOOTING_CAMERA_ORIENTATION')128 129 def __setCameraOrientation(self, cameraOrientation):130 """131 """132 ConfigManager().set('Preferences', 'SHOOTING_CAMERA_ORIENTATION', cameraOrientation)133 134 cameraOrientation = property(__getCameraOrientation, __setCameraOrientation)135 136 def __getYawFov(self):137 """138 """139 yawCameraFov = self.camera.getYawFov(self.cameraOrientation)140 return abs(self.yawEnd - self.yawStart) + yawCameraFov141 142 yawFov = property(__getYawFov, "Total yaw FoV")143 144 def __getPitchFov(self):145 """146 """147 pitchCameraFov = self.camera.getPitchFov(self.cameraOrientation)148 return abs(self.pitchEnd - self.pitchStart) + pitchCameraFov149 150 pitchFov = property(__getPitchFov, "Total pitch FoV")151 152 def __getYawNbPicts(self):153 """154 """155 yawCameraFov = self.camera.getYawFov(self.cameraOrientation)156 if round(self.yawFov - yawCameraFov, 1) >= 0.1:157 nbPicts = int(((self.yawFov - self.overlap * yawCameraFov) / (yawCameraFov * (1 - self.overlap))) + 1)158 else:159 nbPicts = 1160 return nbPicts161 162 yawNbPicts = property(__getYawNbPicts, "Yaw nb picts")163 164 def __getPitchNbPicts(self):165 """166 """167 pitchCameraFov = self.camera.getPitchFov(self.cameraOrientation)168 if round(self.pitchFov - pitchCameraFov, 1) >= 0.1:169 nbPicts = int(((self.pitchFov - self.overlap * pitchCameraFov) / (pitchCameraFov * (1 - self.overlap))) + 1)170 else:171 nbPicts = 1172 return nbPicts173 174 pitchNbPicts = property(__getPitchNbPicts, "Pitch nb picts")175 176 def __getRealYawOverlap(self):177 """ Recompute real yaw overlap.178 """179 yawCameraFov = self.camera.getYawFov(self.cameraOrientation)180 if self.yawNbPicts > 1:181 overlap = (self.yawNbPicts * yawCameraFov - self.yawFov) / (yawCameraFov * (self.yawNbPicts - 1))182 else:183 overlap = 1.184 return overlap185 186 yawRealOverlap = property(__getRealYawOverlap, "Real yaw overlap")187 188 def __getRealPitchOverlap(self):189 """ Recompute real pitch overlap.190 """191 pitchCameraFov = self.camera.getPitchFov(self.cameraOrientation)192 if self.pitchNbPicts > 1:193 overlap = (self.pitchNbPicts * pitchCameraFov - self.pitchFov) / (pitchCameraFov * (self.pitchNbPicts - 1))194 else:195 overlap = 1.196 return overlap197 198 pitchRealOverlap = property(__getRealPitchOverlap, "Real pitch overlap")199 200 #def __computeParams(self, setParam):201 #""" Compute missing params from given params.202 203 #@param setParam: given params type ('startEnd', 'fov', 'nbPict')204 #@type setParam: str205 206 #@todo: add fov and nbPicts207 #"""208 #if setParam == 'startEnd':209 #self.yawFov = self.__getYawFov()210 #self.pitchFov = self.__getPitchFov()211 #self.yawNbPicts = self.__getYawNbPicts()212 #self.pitchNbPicts = self.__getPitchNbPicts()213 #self.yawRealOverlap = self.__getRealYawOverlap()214 #self.pitchRealOverlap = self.__getRealPitchOverlap()215 #elif setParam == 'fov':216 #Logger().warning("Shooting.__computeParam(): 'fov' setting not yet implemented")217 #elif setParam == 'nbPicts':218 #Logger().warning("Shooting.__computeParam(): 'nbPicts' setting not yet implemented")219 #else:220 #raise ValueError("param must be in ('startEnd', 'fov', 'nbPict')")221 108 222 109 def switchToRealHardware(self): … … 242 129 self.position = self.hardware.readPosition() 243 130 244 def storeStartPosition(self):245 """ Store current position as start position.246 """247 self.yawStart, self.pitchStart = self.hardware.readPosition()248 Logger().debug("Shooting.storeStartPosition(): yaw=%.1f, pitch=%.1f" % (self.yawStart, self.pitchStart))249 #self.__computeParams('startEnd')250 251 def storeEndPosition(self):252 """ Store current position as end position.253 """254 self.yawEnd, self.pitchEnd = self.hardware.readPosition()255 Logger().debug("Shooting.storeEndPosition(): yaw=%.1f, pitch=%.1f" % (self.yawEnd, self.pitchEnd))256 #self.__computeParams('startEnd')257 258 def setYaw360(self):259 """ Compute start/end yaw position for 360°.260 261 Récupérer position courante et calculer début et fin pour avoir262 +-180°, overlap inclus263 """264 yaw, pitch = self.hardware.readPosition()265 yawCameraFov = self.camera.getPitchFov(self.cameraOrientation)266 self.yawStart = yaw - 180. + yawCameraFov * (1 - self.overlap) / 2.267 self.yawEnd = yaw + 180. - yawCameraFov * (1 - self.overlap) / 2.268 Logger().debug("Shooting.setYaw360(): startYaw=%.1f, endYaw=%.1f" % (self.yawStart, self.yawEnd))269 270 def setPitch180(self):271 """ Compute start/end pitch position for 180°.272 273 Récupérer position courante et calculer début et fin pour avoir274 +-90°, overlap inclus275 Tenir compte des butées softs !276 """277 yaw, pitch = self.hardware.readPosition()278 pitchCameraFov = self.camera.getPitchFov(self.cameraOrientation)279 self.pitchStart = pitch - 90. + pitchCameraFov * (1 - self.overlap) / 2.280 self.pitchEnd = pitch + 90. - pitchCameraFov * (1 - self.overlap) / 2.281 Logger().debug("Shooting.setPitch180(): startPitch=%.1f, endPitch=%.1f" % (self.pitchStart, self.pitchEnd))282 283 131 def setManualShoot(self, flag): 284 132 """ Turn on/off manual shoot. … … 290 138 """ 291 139 self.__manualShoot = flag 292 293 def generate(self):294 """ Generate all shooting positions.295 296 @return: shooting positions297 @rtype: list of dict298 """299 pass300 140 301 141 def initProgress(self): … … 322 162 323 163 Logger().trace("Shooting.start()") 164 165 data = Data() 166 values = {'stabilizationDelay': "%.1f" % self.stabilizationDelay, 167 'overlap': "%.2f" % self.mosaic.overlap, 168 'yawRealOverlap': "%.2f" % self.mosaic.yawRealOverlap, 169 'pitchRealOverlap': "%.2f" % self.mosaic.pitchRealOverlap, 170 'cameraOrientation': "%s" % self.mosaic.cameraOrientation, 171 'timeValue': "%.1f" % self.camera.timeValue, 172 'nbPicts': "%d" % self.camera.nbPicts, 173 'sensorCoef': "%.1f" % self.camera.sensorCoef, 174 'sensorRatio': "%s" % self.camera.sensorRatio, 175 'focal': "%.1f" % self.camera.lens.focal, 176 'fisheye': "%s" % self.camera.lens.fisheye, 177 'template': "mosaic", 178 'yawNbPicts': "%d" % self.mosaic.yawNbPicts, 179 'pitchNbPicts': "%d" % self.mosaic.pitchNbPicts 180 } 181 data.createHeader(values) 182 self.progress = 0. 324 183 self.__stop = False 325 self.__ running = True326 327 cameraFov = self.camera.getYawFov(self.cameraOrientation)184 self.__shooting = True 185 186 # Loop over all positions 328 187 try: 329 yawInc = (self.yawFov - cameraFov) / (self.yawNbPicts - 1) 330 except ZeroDivisionError: 331 yawInc = self.yawFov - cameraFov 332 yawInc *= cmp(self.yawEnd, self.yawStart) 333 cameraFov = self.camera.getPitchFov(self.cameraOrientation) 334 try: 335 pitchInc = (self.pitchFov - cameraFov) / (self.pitchNbPicts - 1) 336 except ZeroDivisionError: 337 pitchInc = self.pitchFov - cameraFov 338 pitchInc *= cmp(self.pitchEnd, self.pitchStart) 339 mosaic = Mosaic(self.yawNbPicts, self.pitchNbPicts) 340 341 try: 342 data = Data() 343 values = {'stabilizationDelay': "%.1f" % self.stabilizationDelay, 344 'overlap': "%.2f" % self.overlap, 345 'yawRealOverlap': "%.2f" % self.yawRealOverlap, 346 'pitchRealOverlap': "%.2f" % self.pitchRealOverlap, 347 'cameraOrientation': "%s" % self.cameraOrientation, 348 'timeValue': "%.1f" % self.camera.timeValue, 349 'nbPicts': "%d" % self.camera.nbPicts, 350 'sensorCoef': "%.1f" % self.camera.sensorCoef, 351 'sensorRatio': "%s" % self.camera.sensorRatio, 352 'focal': "%.1f" % self.camera.lens.focal, 353 'fisheye': "%s" % self.camera.lens.fisheye, 354 'template': "mosaic", 355 'yawNbPicts': "%d" % self.yawNbPicts, 356 'pitchNbPicts': "%d" % self.pitchNbPicts 357 } 358 data.createHeader(values) 359 360 # Loop over all positions 361 totalNbPicts = self.yawNbPicts * self.pitchNbPicts 362 self.progress = 0. 363 for i, (yawIndex, pitchIndex) in enumerate(mosaic): 364 yaw = self.yawStart + yawIndex * yawInc 365 pitch = self.pitchStart + pitchIndex * pitchInc 188 for i, (yaw, pitch) in enumerate(self.mosaic): 366 189 Logger().debug("Shooting.start(): Goto yaw=%.1f pitch=%.1f" % (yaw, pitch)) 367 190 Logger().info("Moving") … … 386 209 self.sequence = "Shooting %d/%d" % (pict + 1, self.camera.nbPicts) 387 210 self.hardware.shoot(self.camera.timeValue) 388 data.add Image(pict + 1, yaw, pitch)211 data.addPicture(pict + 1, yaw, pitch) 389 212 390 213 checkSuspendStop() 391 214 392 progressFraction = float((i + 1)) / float( totalNbPicts)215 progressFraction = float((i + 1)) / float(self.mosaic.totalNbPicts) 393 216 self.progress = progressFraction 394 217 self.newPictSignal.emit(yaw, pitch) # Include progress? … … 402 225 self.sequence = "Over" 403 226 404 self.__ running = False227 self.__shooting = False 405 228 406 229 def isShooting(self): … … 410 233 @rtype: bool 411 234 """ 412 return self.__ running235 return self.__shooting 413 236 414 237 def suspend(self):
Note: See TracChangeset
for help on using the changeset viewer.
