本文整理汇总了Python中display.Display.close方法的典型用法代码示例。如果您正苦于以下问题:Python Display.close方法的具体用法?Python Display.close怎么用?Python Display.close使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类display.Display
的用法示例。
在下文中一共展示了Display.close方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: calibrate_dark_current
# 需要导入模块: from display import Display [as 别名]
# 或者: from display.Display import close [as 别名]
def calibrate_dark_current(self,max_frames=100):
'''
Collects valid images to calibrate dark current, then sets the dark current correction image. Please block the lamp while this happens.
Arguments:
max_frames: number of frames to record before stopping
'''
# create a dark current collecting pipeline branch on source
# source -> mean
dc_collector = Image_Mean(input=self.source,max_frames=max_frames)
source_display = Display(input=dc_collector,title='dc current source')
source_display.update()
# collect until we have enough data
while( dc_collector.get_frame_count() < dc_collector.get_max_frames() ):
self.source.updatePlayMode()
dc_collector.update()
source_display.update()
#TODO: don't hold up the thread when we do this?
#TODO: maybe have some sort of status bar in the GUI instead?
source_display.close()
# set the dark current image
self.dark_current_image = dc_collector.getOutput(0).getData()
print 'Done collecting dark current calibration data.'
示例2: calibrate_flat_field_and_color
# 需要导入模块: from display import Display [as 别名]
# 或者: from display.Display import close [as 别名]
def calibrate_flat_field_and_color(self,max_frames=100):
'''
Collects valid images to calibrate the flat field correction and color correction using CIE XYZ color space. Sets F(x) = (flat field mean intensity) / (flat field correction image), x_mean, z_mean.
Note: needs self.dark_current_image set properly before using.
Please point at a slide or something mostly blank while this happens.
max_frames: number of frames to record before stopping
'''
# create a flat field collection pipeline branch on self.input
# source -> dc corrector -> rgb2xyz -> mean
dc_corrector = Dark_Current_Corrector(input=self.source,
dark_current_image=self.dark_current_image)
source_display = Display(input=dc_corrector,title='ff current source')
source_display.update()
rgb2xyz = ConvertRGBtoXYZ(input=dc_corrector)
rgb2xyz.update()
ff_collector = Image_Mean(input=rgb2xyz, max_frames=max_frames)
# collect until we have enough data
while( ff_collector.get_frame_count() < ff_collector.get_max_frames() ):
self.source.updatePlayMode()
dc_corrector.update()
rgb2xyz.update()
ff_collector.update()
source_display.update()
source_display.close()
# calculate F(x) from Y channel and set flat field image
# F(x) = F(x) = (ff mean intensity) / (ff correction image)
flat_field_image = ff_collector.getOutput(0).getData()[:,:,1].astype(numpy.float)
self.flat_field_image = flat_field_image.mean() / flat_field_image
self.x_mean = ff_collector.getOutput(0).getData()[:,:,0].mean()
self.z_mean = ff_collector.getOutput(0).getData()[:,:,2].mean()
print self.x_mean, self.z_mean
print 'Done collecting flat field calibration data.'
示例3: Game
# 需要导入模块: from display import Display [as 别名]
# 或者: from display.Display import close [as 别名]
#.........这里部分代码省略.........
self.display.write(block)
# Display Ship
self.display.write(self.ship)
# Move down Aliens
if ori_way != way:
for index, alien in enumerate(self.aliens):
alien.move_down(self.speed_down)
# Move right or left Aliens
for index, alien in enumerate(self.aliens):
if not alien.destroyed:
#if ways[alien.line]:
if way:
alien.move_right()
else:
alien.move_left()
collisions = self.display.write(alien)
if collisions:
self.game_over()
run = False
if not run:
break
# Move Torpedos
for index, torpedo in enumerate(self.torpedos):
if torpedo.destroyed:
del self.torpedos[index]
else:
# Destroy torpedo
if torpedo.atTop or torpedo.atBottom:
# Touch the sky
torpedo.destroy()
self.display.write(torpedo)
else:
torpedo.move()
# Display torpedo
collisions = self.display.write(torpedo)
if collisions:
for entity in collisions:
if type(entity) == Torpedo:
# Align sprite
torpedo.y = entity.y + entity.height
# Destroy torpedo
entity.touch()
torpedo.touch()
elif type(entity) in [Alien1, Alien2] and type(torpedo.parent) in [Alien1, Alien2]:
# Alien2 vs Alien1
pass
else:
# Self shot :)
if torpedo.parent != entity:
entity.touch()
torpedo.destroyed = True
# Display map
self.display.refresh()
# Display score
self.display.addStr((1,1), "Score: %s" % self.score)
lifeStr = "Life: %s" % self.ship.life
self.display.addStr((1,self.display.width - len(lifeStr)), lifeStr)
# Bind keys
c = self.display.getch()
if c == curses.KEY_LEFT:
self.ship.move_left()
elif c == curses.KEY_RIGHT:
self.ship.move_right()
# Space
elif c == 32:
if (time.time() - lastfire) > 0.1:
lastfire = time.time()
self.ship.fire()
# Q
elif c == 113:
self.logger.debug("Quit game")
break
elif c != -1:
self.logger.debug("Key %s preseed" % c)
self.logger.debug("End of game")
except Exception as err:
pass
finally:
self.display.close()
self.logger.dump()
if err:
traceback.print_exc(limit=20, file=sys.stdout)
示例4: start
# 需要导入模块: from display import Display [as 别名]
# 或者: from display.Display import close [as 别名]
def start(self):
score = 0
lives = 3
level = 1
framerate = 25
shields = 4
alien_tick = 15
gameover = False
display = Display()
gun = Gun(maxx=display.width, maxy=display.height)
aliens = self.make_aliens(42, display.width, alien_tick)
while True:
self.status(display, lives, score, level)
for alien in aliens:
alien.move()
display.putstring(alien.last[0], alien.last[1], " ")
display.putstring(alien.current[0], alien.current[1], alien.alien)
display.putstring(gun.guny, gun.gunx, gun.gun)
for index, alien in enumerate(aliens):
hit = gun.hit(alien.current[0], alien.current[1])
if hit:
display.putstring(alien.current[0], alien.current[1], " BOOM ")
score += 1
del(aliens[index])
break
if alien.current[0] == display.height - 2:
if lives > 0:
lives -= 1
aliens = self.make_aliens(42, display.width, alien_tick)
display.erase()
else:
gameover = True
display.putstring(10, 30, "Game Over!!!")
break
if aliens == []:
display.putstring(10, 30, "YOU WIN!!!!")
if gun.firing:
gun.fire()
display.putstring(gun.bullety, gun.bulletx, gun.bullet)
display.refresh()
time.sleep(1.0 / framerate)
if gameover:
display.close()
break
if gun.firing:
display.putstring(gun.bullety, gun.bulletx, " ")
if hit:
display.putstring(alien.current[0], alien.current[1], " ")
if aliens == []:
display.putstring(10, 30, " ")
level += 1
alien_tick -= 1
aliens = self.make_aliens(42, display.width, alien_tick)
display.refresh()
i = display.getch()
if i == ord("a"):
gun.left()
elif i == ord("d"):
gun.right()
elif i == ord("s"):
gun.start()
elif i == ord("q"):
display.close()
break