本文整理汇总了Python中version_utils.get_version函数的典型用法代码示例。如果您正苦于以下问题:Python get_version函数的具体用法?Python get_version怎么用?Python get_version使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_version函数的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
def main():
# To assign camera by name: put string(s) in list
eye_cam_names = ["USB 2.0 Camera","Microsoft", "6000","Integrated Camera"]
world_src = ["Logitech Camera","(046d:081d)", "(046d:0991)", "C510","B525", "C525","C615","C920","C930e"]
# world_src = ["USB 2.0 Camera","Microsoft", "5000","Integrated Camera"]
eye_src = (eye_cam_names,0),(eye_cam_names,1) #first match for eye0 and second match for eye1
# to assign cameras directly, using integers as demonstrated below
# eye_src = 4 , 5 #second arg will be ignored for monocular eye trackers
# world_src = 1
# to use a pre-recorded video.
# Use a string to specify the path to your video file as demonstrated below
# eye_src = '/Users/mkassner/Downloads/eye.avi' , '/Users/mkassner/Downloads/eye.avi'
# world_src = "/Users/mkassner/Desktop/2014_01_21/000/world.avi"
# Camera video size in pixels (width,height)
eye_size = (640,480)
world_size = (1280,720)
# on MacOS we will not use os.fork, elsewhere this does nothing.
forking_enable(0)
#g_pool holds variables. Only if added here they are shared across processes.
g_pool = Global_Container()
# Create and initialize IPC
g_pool.pupil_queue = Queue()
g_pool.quit = Value(c_bool,0)
g_pool.timebase = Value(c_double,0)
g_pool.eye_tx = []
# make some constants avaiable
g_pool.user_dir = user_dir
g_pool.rec_dir = rec_dir
g_pool.version = get_version(version_file)
g_pool.app = 'capture'
g_pool.binocular = binocular
p_eye = []
for eye_id in range(1+1*binocular):
rx,tx = Pipe(False)
p_eye += [Process(target=eye, args=(g_pool,eye_src[eye_id],eye_size,rx,eye_id))]
g_pool.eye_tx += [tx]
p_eye[-1].start()
if platform.system() == 'Linux':
# We need to give the camera driver some time before requesting another camera.
sleep(0.5)
world(g_pool,world_src,world_size)
# Exit / clean-up
for p in p_eye:
p.join()
示例2: main
def main():
# To assign camera by name: put string(s) in list
world_src = ["Pupil Cam1 ID2","Logitech Camera","(046d:081d)","C510","B525", "C525","C615","C920","C930e"]
eye0 = ["Pupil Cam1 ID0","HD-6000","Integrated Camera","HD USB Camera","USB 2.0 Camera"]
eye1 = ["Pupil Cam1 ID1","HD-6000","Integrated Camera"]
eye_src = eye0, eye1
# to assign cameras directly, using integers as demonstrated below
# eye_src = 1 , 1 #second arg will be ignored for monocular eye trackers
# world_src = 0
# to use a pre-recorded video.
# Use a string to specify the path to your video file as demonstrated below
# eye_src = '/Users/mkassner/Downloads/000/eye0.mkv' , '/Users/mkassner/Downloads/eye.avi'
# world_src = "/Users/mkassner/Downloads/000/world.mkv"
# Default camera video size in pixels (width,height)
eye_size = (640,480)
world_size = (1280,720)
# on MacOS we will not use os.fork, elsewhere this does nothing.
forking_enable(0)
#g_pool holds variables. Only if added here they are shared across processes.
g_pool = Global_Container()
# Create and initialize IPC
g_pool.pupil_queue = Queue()
g_pool.quit = Value(c_bool,0)
g_pool.timebase = Value(c_double,0)
g_pool.eye_tx = []
# make some constants avaiable
g_pool.user_dir = user_dir
g_pool.version = get_version(version_file)
g_pool.app = 'capture'
g_pool.binocular = binocular
p_eye = []
for eye_id in range(1+1*binocular):
eye_end,world_end = Pipe(True)
p_eye += [Process(target=eye, args=(g_pool,eye_src[eye_id],eye_size,eye_end,eye_id))]
p_eye[-1].start()
#wait for ready message from eye to sequentialize startup
logger.debug(world_end.recv())
g_pool.eye_tx += [world_end]
world(g_pool,world_src,world_size)
# Exit / clean-up
for p in p_eye:
p.join()
示例3: show_no_rec_window
def show_no_rec_window():
from pyglui.pyfontstash import fontstash
from pyglui.ui import get_roboto_font_path
def on_drop(window,count,paths):
for x in range(count):
new_rec_dir = paths[x]
if is_pupil_rec_dir(new_rec_dir):
logger.debug("Starting new session with '%s'"%new_rec_dir)
global rec_dir
rec_dir = new_rec_dir
glfwSetWindowShouldClose(window,True)
else:
logger.error("'%s' is not a valid pupil recording"%new_rec_dir)
# load session persistent settings
session_settings = Persistent_Dict(os.path.join(user_dir,"user_settings"))
if session_settings.get("version",VersionFormat('0.0')) < get_version(version_file):
logger.info("Session setting are from older version of this app. I will not use those.")
session_settings.clear()
w,h = session_settings.get('window_size',(1280,720))
window_pos = session_settings.get('window_position',(0,0))
glfwWindowHint(GLFW_RESIZABLE,0)
window = glfwCreateWindow(w, h,'Pupil Player')
glfwWindowHint(GLFW_RESIZABLE,1)
glfwMakeContextCurrent(window)
glfwSetWindowPos(window,window_pos[0],window_pos[1])
glfwSetDropCallback(window,on_drop)
adjust_gl_view(w,h)
glfont = fontstash.Context()
glfont.add_font('roboto',get_roboto_font_path())
glfont.set_align_string(v_align="center",h_align="middle")
glfont.set_color_float((0.2,0.2,0.2,0.9))
basic_gl_setup()
glClearColor(0.5,.5,0.5,0.0)
text = 'Drop a recording directory onto this window.'
tip = '(Tip: You can drop a recording directory onto the app icon.)'
# text = "Please supply a Pupil recording directory as first arg when calling Pupil Player."
while not glfwWindowShouldClose(window):
clear_gl_screen()
glfont.set_blur(10.5)
glfont.set_color_float((0.0,0.0,0.0,1.))
glfont.set_size(w/25.)
glfont.draw_text(w/2,.3*h,text)
glfont.set_size(w/30.)
glfont.draw_text(w/2,.4*h,tip)
glfont.set_blur(0.96)
glfont.set_color_float((1.,1.,1.,1.))
glfont.set_size(w/25.)
glfont.draw_text(w/2,.3*h,text)
glfont.set_size(w/30.)
glfont.draw_text(w/2,.4*h,tip)
glfwSwapBuffers(window)
glfwPollEvents()
session_settings['window_position'] = glfwGetWindowPos(window)
session_settings['version'] = get_version(version_file)
session_settings.close()
del glfont
glfwDestroyWindow(window)
示例4: session
def session(rec_dir):
# Callback functions
def on_resize(window,w, h):
g_pool.gui.update_window(w,h)
g_pool.gui.collect_menus()
graph.adjust_size(w,h)
adjust_gl_view(w,h)
for p in g_pool.plugins:
p.on_window_resize(window,w,h)
def on_key(window, key, scancode, action, mods):
g_pool.gui.update_key(key,scancode,action,mods)
def on_char(window,char):
g_pool.gui.update_char(char)
def on_button(window,button, action, mods):
g_pool.gui.update_button(button,action,mods)
pos = glfwGetCursorPos(window)
pos = normalize(pos,glfwGetWindowSize(window))
pos = denormalize(pos,(frame.img.shape[1],frame.img.shape[0]) ) # Position in img pixels
for p in g_pool.plugins:
p.on_click(pos,button,action)
def on_pos(window,x, y):
hdpi_factor = float(glfwGetFramebufferSize(window)[0]/glfwGetWindowSize(window)[0])
g_pool.gui.update_mouse(x*hdpi_factor,y*hdpi_factor)
def on_scroll(window,x,y):
g_pool.gui.update_scroll(x,y*y_scroll_factor)
def on_drop(window,count,paths):
for x in range(count):
new_rec_dir = paths[x]
if is_pupil_rec_dir(new_rec_dir):
logger.debug("Starting new session with '%s'"%new_rec_dir)
global rec_dir
rec_dir = new_rec_dir
glfwSetWindowShouldClose(window,True)
else:
logger.error("'%s' is not a valid pupil recording"%new_rec_dir)
tick = delta_t()
def get_dt():
return next(tick)
video_path = [f for f in glob(os.path.join(rec_dir,"world.*")) if f[-3:] in ('mp4','mkv','avi')][0]
timestamps_path = os.path.join(rec_dir, "world_timestamps.npy")
pupil_data_path = os.path.join(rec_dir, "pupil_data")
#parse info.csv file
meta_info_path = os.path.join(rec_dir,"info.csv")
with open(meta_info_path) as info:
meta_info = dict( ((line.strip().split('\t')) for line in info.readlines() ) )
rec_version = read_rec_version(meta_info)
if rec_version >= VersionFormat('0.7.4'):
pass
if rec_version >= VersionFormat('0.7.3'):
update_recording_0v73_to_current(rec_dir)
elif rec_version >= VersionFormat('0.5'):
update_recording_0v5_to_current(rec_dir)
elif rec_version >= VersionFormat('0.4'):
update_recording_0v4_to_current(rec_dir)
elif rec_version >= VersionFormat('0.3'):
update_recording_0v3_to_current(rec_dir)
timestamps_path = os.path.join(rec_dir, "timestamps.npy")
else:
logger.Error("This recording is to old. Sorry.")
return
timestamps = np.load(timestamps_path)
# Initialize capture
cap = File_Capture(video_path,timestamps=list(timestamps))
# load session persistent settings
session_settings = Persistent_Dict(os.path.join(user_dir,"user_settings"))
if session_settings.get("version",VersionFormat('0.0')) < get_version(version_file):
logger.info("Session setting are from older version of this app. I will not use those.")
session_settings.clear()
width,height = session_settings.get('window_size',cap.frame_size)
window_pos = session_settings.get('window_position',(0,0))
main_window = glfwCreateWindow(width, height, "Pupil Player: "+meta_info["Recording Name"]+" - "+ rec_dir.split(os.path.sep)[-1], None, None)
glfwSetWindowPos(main_window,window_pos[0],window_pos[1])
glfwMakeContextCurrent(main_window)
cygl.utils.init()
# load pupil_positions, gaze_positions
pupil_data = load_object(pupil_data_path)
pupil_list = pupil_data['pupil_positions']
gaze_list = pupil_data['gaze_positions']
#.........这里部分代码省略.........
示例5: get_version
else:
if 'service' in sys.argv:
app = 'service'
pupil_base_dir = os.path.abspath(__file__).rsplit('pupil_src', 1)[0]
sys.path.append(os.path.join(pupil_base_dir, 'pupil_src', 'shared_modules'))
# Specifiy user dir.
user_dir = os.path.join(pupil_base_dir,'%s_settings'%app)
version_file = None
# create folder for user settings, tmp data
if not os.path.isdir(user_dir):
os.mkdir(user_dir)
#app version
from version_utils import get_version
app_version = get_version(version_file)
#threading and processing
try:
from billiard import Process, Queue, Value,active_children, freeze_support,forking_enable
except:
from multiprocessing import Process, Queue, Value,active_children, freeze_support
def forking_enable(_):
pass
from threading import Thread
from ctypes import c_double,c_bool
#networking
import zmq
import zmq_tools
示例6: main
#.........这里部分代码省略.........
positions_by_frame = correlate_gaze(gaze_list,timestamps)
# Initialize capture
cap = autoCreateCapture(video_path,timestamps=timestamps_path)
if isinstance(cap,FakeCapture):
logger.error("could not start capture.")
return
width,height = session_settings.get('window_size',cap.get_size())
window_pos = session_settings.get('window_position',(0,0)) # not yet using this one.
# Initialize glfw
glfwInit()
main_window = glfwCreateWindow(width, height, "Pupil Player: "+meta_info["Recording Name"]+" - "+ rec_dir.split(os.path.sep)[-1], None, None)
glfwMakeContextCurrent(main_window)
cygl.utils.init()
# Register callbacks main_window
glfwSetWindowSizeCallback(main_window,on_resize)
glfwSetWindowCloseCallback(main_window,on_close)
glfwSetKeyCallback(main_window,on_key)
glfwSetCharCallback(main_window,on_char)
glfwSetMouseButtonCallback(main_window,on_button)
glfwSetCursorPosCallback(main_window,on_pos)
glfwSetScrollCallback(main_window,on_scroll)
# create container for globally scoped vars (within world)
g_pool = Global_Container()
g_pool.app = 'player'
g_pool.version = get_version(version_file)
g_pool.capture = cap
g_pool.timestamps = timestamps
g_pool.gaze_list = gaze_list
g_pool.positions_by_frame = positions_by_frame
g_pool.play = False
g_pool.new_seek = True
g_pool.user_dir = user_dir
g_pool.rec_dir = rec_dir
g_pool.rec_version = rec_version
g_pool.meta_info = meta_info
def next_frame(_):
try:
cap.seek_to_frame(cap.get_frame_index())
except FileSeekError:
pass
g_pool.new_seek = True
def prev_frame(_):
try:
cap.seek_to_frame(cap.get_frame_index()-2)
except FileSeekError:
pass
g_pool.new_seek = True
def set_scale(new_scale):
g_pool.gui.scale = new_scale
g_pool.gui.collect_menus()
def get_scale():
return g_pool.gui.scale
示例7: session
def session(rec_dir):
# Callback functions
def on_resize(window, w, h):
g_pool.gui.update_window(w, h)
g_pool.gui.collect_menus()
graph.adjust_size(w, h)
adjust_gl_view(w, h)
for p in g_pool.plugins:
p.on_window_resize(window, w, h)
def on_key(window, key, scancode, action, mods):
g_pool.gui.update_key(key, scancode, action, mods)
def on_char(window, char):
g_pool.gui.update_char(char)
def on_button(window, button, action, mods):
g_pool.gui.update_button(button, action, mods)
pos = glfwGetCursorPos(window)
pos = normalize(pos, glfwGetWindowSize(window))
pos = denormalize(pos, (frame.img.shape[1], frame.img.shape[0])) # Position in img pixels
for p in g_pool.plugins:
p.on_click(pos, button, action)
def on_pos(window, x, y):
hdpi_factor = float(glfwGetFramebufferSize(window)[0] / glfwGetWindowSize(window)[0])
g_pool.gui.update_mouse(x * hdpi_factor, y * hdpi_factor)
def on_scroll(window, x, y):
g_pool.gui.update_scroll(x, y * y_scroll_factor)
def on_drop(window, count, paths):
for x in range(count):
new_rec_dir = paths[x]
if is_pupil_rec_dir(new_rec_dir):
logger.debug("Starting new session with '%s'" % new_rec_dir)
global rec_dir
rec_dir = new_rec_dir
glfwSetWindowShouldClose(window, True)
else:
logger.error("'%s' is not a valid pupil recording" % new_rec_dir)
# parse info.csv file
meta_info_path = os.path.join(rec_dir, "info.csv")
with open(meta_info_path) as info:
meta_info = dict(((line.strip().split("\t")) for line in info.readlines()))
video_path = os.path.join(rec_dir, "world.mkv")
timestamps_path = os.path.join(rec_dir, "world_timestamps.npy")
pupil_data_path = os.path.join(rec_dir, "pupil_data")
rec_version = read_rec_version(meta_info)
if rec_version >= VersionFormat("0.5"):
pass
elif rec_version >= VersionFormat("0.4"):
update_recording_0v4_to_current(rec_dir)
elif rec_version >= VersionFormat("0.3"):
update_recording_0v3_to_current(rec_dir)
video_path = os.path.join(rec_dir, "world.avi")
timestamps_path = os.path.join(rec_dir, "timestamps.npy")
else:
logger.Error("This recording is to old. Sorry.")
return
# Initialize capture
cap = autoCreateCapture(video_path, timestamps=timestamps_path)
if isinstance(cap, FakeCapture):
logger.error("could not start capture.")
return
# load session persistent settings
session_settings = Persistent_Dict(os.path.join(user_dir, "user_settings"))
if session_settings.get("version", VersionFormat("0.0")) < get_version(version_file):
logger.info("Session setting are from older version of this app. I will not use those.")
session_settings.clear()
width, height = session_settings.get("window_size", cap.frame_size)
window_pos = session_settings.get("window_position", (0, 0))
main_window = glfwCreateWindow(
width,
height,
"Pupil Player: " + meta_info["Recording Name"] + " - " + rec_dir.split(os.path.sep)[-1],
None,
None,
)
glfwSetWindowPos(main_window, window_pos[0], window_pos[1])
glfwMakeContextCurrent(main_window)
cygl.utils.init()
# Register callbacks main_window
glfwSetFramebufferSizeCallback(main_window, on_resize)
glfwSetKeyCallback(main_window, on_key)
glfwSetCharCallback(main_window, on_char)
glfwSetMouseButtonCallback(main_window, on_button)
glfwSetCursorPosCallback(main_window, on_pos)
glfwSetScrollCallback(main_window, on_scroll)
glfwSetDropCallback(main_window, on_drop)
# load pupil_positions, gaze_positions
#.........这里部分代码省略.........
示例8: show_no_rec_window
def show_no_rec_window():
from pyglui.pyfontstash import fontstash
from pyglui.ui import get_roboto_font_path
global rec_dir
def on_drop(window, count, paths):
global rec_dir
rec_dir = paths[0].decode('utf-8')
# load session persistent settings
session_settings = Persistent_Dict(os.path.join(user_dir, "user_settings"))
if VersionFormat(session_settings.get("version", '0.0')) != get_version(version_file):
logger.info("Session setting are from a different version of this app. I will not use those.")
session_settings.clear()
w, h = session_settings.get('window_size', (1280, 720))
window_pos = session_settings.get('window_position', window_position_default)
glfwWindowHint(GLFW_RESIZABLE, 0)
window = glfwCreateWindow(w, h, 'Pupil Player')
glfwWindowHint(GLFW_RESIZABLE, 1)
glfwMakeContextCurrent(window)
glfwSetWindowPos(window, window_pos[0], window_pos[1])
glfwSetDropCallback(window, on_drop)
glfont = fontstash.Context()
glfont.add_font('roboto', get_roboto_font_path())
glfont.set_align_string(v_align="center", h_align="middle")
glfont.set_color_float((0.2, 0.2, 0.2, 0.9))
gl_utils.basic_gl_setup()
glClearColor(0.5, .5, 0.5, 0.0)
text = 'Drop a recording directory onto this window.'
tip = '(Tip: You can drop a recording directory onto the app icon.)'
# text = "Please supply a Pupil recording directory as first arg when calling Pupil Player."
while not glfwWindowShouldClose(window):
fb_size = glfwGetFramebufferSize(window)
hdpi_factor = float(fb_size[0] / glfwGetWindowSize(window)[0])
gl_utils.adjust_gl_view(*fb_size)
if rec_dir:
if is_pupil_rec_dir(rec_dir):
logger.info("Starting new session with '{}'".format(rec_dir))
text = "Updating recording format."
tip = "This may take a while!"
else:
logger.error("'{}' is not a valid pupil recording".format(rec_dir))
tip = "Oops! That was not a valid recording."
rec_dir = None
gl_utils.clear_gl_screen()
glfont.set_blur(10.5)
glfont.set_color_float((0.0, 0.0, 0.0, 1.))
glfont.set_size(w/25.*hdpi_factor)
glfont.draw_text(w/2*hdpi_factor, .3*h*hdpi_factor, text)
glfont.set_size(w/30.*hdpi_factor)
glfont.draw_text(w/2*hdpi_factor, .4*h*hdpi_factor, tip)
glfont.set_blur(0.96)
glfont.set_color_float((1., 1., 1., 1.))
glfont.set_size(w/25.*hdpi_factor)
glfont.draw_text(w/2*hdpi_factor, .3*h*hdpi_factor, text)
glfont.set_size(w/30.*hdpi_factor)
glfont.draw_text(w/2*hdpi_factor, .4*h*hdpi_factor, tip)
glfwSwapBuffers(window)
if rec_dir:
update_recording_to_recent(rec_dir)
glfwSetWindowShouldClose(window, True)
glfwPollEvents()
session_settings['window_position'] = glfwGetWindowPos(window)
session_settings['version'] = str(get_version(version_file))
session_settings.close()
del glfont
glfwDestroyWindow(window)