本文整理汇总了Python中reader.Reader.seek方法的典型用法代码示例。如果您正苦于以下问题:Python Reader.seek方法的具体用法?Python Reader.seek怎么用?Python Reader.seek使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类reader.Reader
的用法示例。
在下文中一共展示了Reader.seek方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: load
# 需要导入模块: from reader import Reader [as 别名]
# 或者: from reader.Reader import seek [as 别名]
def load(self):
_path = path.join(self.root_dir, 'database', 'master_card')
with open(_path, 'rb') as _f:
buf = Reader(_f)
count = buf.read_int() # 卡牌数量
offsets = [0] * count
self.cards = cards = [None] * count
for i in range(count):
cards[i] = MACard()
offsets[i] = buf.read_int()
for i, card in enumerate(cards):
buf.seek(offsets[i])
card.load(buf)
示例2: main
# 需要导入模块: from reader import Reader [as 别名]
# 或者: from reader.Reader import seek [as 别名]
def main( filename,
whiskers_file_name,
transpose,
startframe=0,
cursor_size = 10,
show_cursor_pos = False,
noadjuststripes = False,
prefix_label = "",
show_fps = False,
facehint = 'top' ):
""" main( moviename, tracking_data_prefix ) --> (whiskers, trajectories)
Opens a window to browse through a movie to review and correct traced
whiskers.
"""
pygame.init()
desktop_info = pygame.display.Info()
desktop_size = desktop_info.current_w, desktop_info.current_h
pygame.mouse.set_cursor((8, 8), (4, 4),
(24, 24, 24, 231, 231, 24, 24, 24),
(0, 0, 0, 0, 0, 0, 0, 0))
font = pygame.font.SysFont(pygame.font.get_default_font(),24);
pygame.key.set_repeat(200, 10)
im = Reader( filename, transpose, not noadjuststripes )
im.seek( startframe )
#abg = calc_background( im )
N = len(im)
load_icon()
pygame.display.set_caption( 'Whisk: '+os.path.split(filename)[-1], 'Whisk');
data_width,data_height = im.size
s = 0.6 * min(map(lambda p: p[0]/float(p[1]), zip(desktop_size, reversed(im.size)) ))
scale = (s,s)
size = width,height = [int(s*e) for s,e in zip(scale,reversed(im.size))]
flags = pygame.DOUBLEBUF | pygame.HWSURFACE | pygame.RESIZABLE
screen = pygame.display.set_mode( size , flags )
mode = {}
mode["auto"] = True
mode["tracing"] = False
mode["showcursorpos"] = show_cursor_pos
mode["showfps"] = show_fps
mode["draw"] = 0
clock = pygame.time.Clock()
whiskers, trajectories, bar_centers, current_whisker = load_state(whiskers_file_name)
#whiskerdata.merge.merge_all( whiskers, im[0].shape )
state = whiskers, trajectories, bar_centers
DIRTY = 0
textbgrect = pygame.Rect(10,10,1,1);
bg,a = render_plane(screen, im, inc=0, scale=scale[0])
screen.blit(bg,(0,0))
pygame.display.flip() #for doublebuf
bg,a = render(screen, im, current_whisker, state, bg, scale[0], inc=0, mode=mode, facehint=facehint)
pygame.display.flip() #for doublebuf
cursor_rect = None
last = bg;
while 1:
fps = clock.get_fps()
p = pygame.mouse.get_pos()
if not cursor_rect is None:
cursor_rect = bg.get_clip().clip(cursor_rect)
if cursor_rect.size:
s = bg.subsurface( cursor_rect )
screen.blit( s, cursor_rect.topleft )
cursor_rect = pygame.draw.circle( screen,
(255,0,0,255),
p,
int(cursor_size*scale[0]), 1 )
for event in pygame.event.get():
#print event
if event.type == pygame.QUIT:
if DIRTY:
save_state( whiskers_file_name, whiskers, trajectories, facehint ); # <-- autosave
DIRTY = 0
whiskerdata.close()
pygame.quit()
return whiskers,trajectories
elif event.type == pygame.VIDEORESIZE:
cursor_rect = None
size = width,height = event.size
scale = width/float(a.shape[1]), height/float(a.shape[0])
scale = min(scale)
width = int( scale * a.shape[1] )
height = int( scale * a.shape[0] )
size = width,height
scale = scale,scale
screen = pygame.display.set_mode( size, flags )
bg,a = render(screen, im, current_whisker, state, bg, scale[0], inc=0, mode=mode, facehint=facehint)
elif event.type == pygame.MOUSEBUTTONDOWN:
#.........这里部分代码省略.........