本文整理汇总了Python中gl_utils.trackball.Trackball.zoom_to方法的典型用法代码示例。如果您正苦于以下问题:Python Trackball.zoom_to方法的具体用法?Python Trackball.zoom_to怎么用?Python Trackball.zoom_to使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gl_utils.trackball.Trackball
的用法示例。
在下文中一共展示了Trackball.zoom_to方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Calibration_Visualizer
# 需要导入模块: from gl_utils.trackball import Trackball [as 别名]
# 或者: from gl_utils.trackball.Trackball import zoom_to [as 别名]
#.........这里部分代码省略.........
if self.world_camera_width != 0:
self.draw_frustum( self.world_camera_width/ 10.0 , self.world_camera_height/ 10.0 , self.world_camera_focal / 10.0)
for p in self.cal_observed_points_3d:
glutils.draw_polyline( [ (0,0,0), p] , 1 , calibration_points_line_color, line_type = GL_LINES)
#draw error lines form eye gaze points to ref points
for(cal_point,ref_point) in zip(self.cal_ref_points_3d, self.cal_observed_points_3d):
glutils.draw_polyline( [ cal_point, ref_point] , 1 , error_line_color, line_type = GL_LINES)
#calibration points
glutils.draw_points( self.cal_ref_points_3d , 4 , RGBA( 0, 1, 1, 1 ) )
glPopMatrix()
if sphere0:
# eye camera
glPushMatrix()
glLoadMatrixf( self.eye_camera_to_world_matrix0.T )
self.draw_coordinate_system(60)
self.draw_frustum( self.image_width / 10.0, self.image_height / 10.0, self.focal_length /10.)
glPopMatrix()
#everything else is in world coordinates
#eye
sphere_center0 = list(sphere0['center'])
sphere_radius0 = sphere0['radius']
self.draw_sphere(sphere_center0,sphere_radius0, color = RGBA(1,1,0,1))
#gazelines
for p in self.cal_gaze_points0_3d:
glutils.draw_polyline( [ sphere_center0, p] , 1 , calibration_points_line_color, line_type = GL_LINES)
#calibration points
# glutils.draw_points( self.cal_gaze_points0_3d , 4 , RGBA( 1, 0, 1, 1 ) )
#current gaze points
glutils.draw_points( gaze_points0 , 2 , RGBA( 1, 0, 0, 1 ) )
for p in gaze_points0:
glutils.draw_polyline( [sphere_center0, p] , 1 , RGBA(0,0,0,1), line_type = GL_LINES)
#draw error lines form eye gaze points to ref points
for(cal_gaze_point,ref_point) in zip(self.cal_gaze_points0_3d, self.cal_ref_points_3d):
glutils.draw_polyline( [ cal_gaze_point, ref_point] , 1 , error_line_color, line_type = GL_LINES)
#second eye
if sphere1:
# eye camera
glPushMatrix()
glLoadMatrixf( self.eye_camera_to_world_matrix1.T )
self.draw_coordinate_system(60)
self.draw_frustum( self.image_width / 10.0, self.image_height / 10.0, self.focal_length /10.)
glPopMatrix()
#everything else is in world coordinates
#eye
sphere_center1 = list(sphere1['center'])
sphere_radius1 = sphere1['radius']
self.draw_sphere(sphere_center1,sphere_radius1, color = RGBA(1,1,0,1))
#gazelines
for p in self.cal_gaze_points1_3d:
glutils.draw_polyline( [ sphere_center1, p] , 4 , calibration_points_line_color, line_type = GL_LINES)
#calibration points
glutils.draw_points( self.cal_gaze_points1_3d , 4 , RGBA( 1, 0, 1, 1 ) )
#current gaze points
glutils.draw_points( gaze_points1 , 2 , RGBA( 1, 0, 0, 1 ) )
for p in gaze_points1:
glutils.draw_polyline( [sphere_center1, p] , 1 , RGBA(0,0,0,1), line_type = GL_LINES)
#draw error lines form eye gaze points to ref points
for(cal_gaze_point,ref_point) in zip(self.cal_gaze_points1_3d, self.cal_ref_points_3d):
glutils.draw_polyline( [ cal_gaze_point, ref_point] , 1 , error_line_color, line_type = GL_LINES)
self.trackball.pop()
self.end_update_window() #swap buffers, handle context
############ window callbacks #################
def on_resize(self,window,w, h):
Visualizer.on_resize(self,window,w, h)
self.trackball.set_window_size(w,h)
def on_char(self,window,char):
if char == ord('r'):
self.trackball.distance = [0,0,-0.1]
self.trackball.pitch = 0
self.trackball.roll = 180
def on_scroll(self,window,x,y):
self.trackball.zoom_to(y)
示例2: Reference_Surface
# 需要导入模块: from gl_utils.trackball import Trackball [as 别名]
# 或者: from gl_utils.trackball.Trackball import zoom_to [as 别名]
#.........这里部分代码省略.........
self.trackball.pop()
glfwSwapBuffers(self._window)
glfwMakeContextCurrent(active_window)
def open_window(self):
if not self._window:
if self.fullscreen:
monitor = glfwGetMonitors()[self.monitor_idx]
mode = glfwGetVideoMode(monitor)
height,width= mode[0],mode[1]
else:
monitor = None
height,width= 640,int(640./(self.real_world_size['x']/self.real_world_size['y'])) #open with same aspect ratio as surface
self._window = glfwCreateWindow(height, width, "Reference Surface: " + self.name, monitor=monitor, share=glfwGetCurrentContext())
if not self.fullscreen:
glfwSetWindowPos(self._window,200,0)
self.trackball = Trackball()
self.input = {'down':False, 'mouse':(0,0)}
#Register callbacks
glfwSetFramebufferSizeCallback(self._window,self.on_resize)
glfwSetKeyCallback(self._window,self.on_key)
glfwSetWindowCloseCallback(self._window,self.on_close)
glfwSetMouseButtonCallback(self._window,self.on_button)
glfwSetCursorPosCallback(self._window,self.on_pos)
glfwSetScrollCallback(self._window,self.on_scroll)
self.on_resize(self._window,*glfwGetFramebufferSize(self._window))
# gl_state settings
active_window = glfwGetCurrentContext()
glfwMakeContextCurrent(self._window)
basic_gl_setup()
make_coord_system_norm_based()
# refresh speed settings
glfwSwapInterval(0)
glfwMakeContextCurrent(active_window)
def close_window(self):
if self._window:
glfwDestroyWindow(self._window)
self._window = None
self.window_should_close = False
def open_close_window(self):
if self._window:
self.close_window()
else:
self.open_window()
# window calbacks
def on_resize(self,window,w, h):
self.trackball.set_window_size(w,h)
active_window = glfwGetCurrentContext()
glfwMakeContextCurrent(window)
adjust_gl_view(w,h)
glfwMakeContextCurrent(active_window)
def on_key(self,window, key, scancode, action, mods):
if action == GLFW_PRESS:
if key == GLFW_KEY_ESCAPE:
self.on_close()
def on_close(self,window=None):
self.window_should_close = True
def on_button(self,window,button, action, mods):
if action == GLFW_PRESS:
self.input['down'] = True
self.input['mouse'] = glfwGetCursorPos(window)
if action == GLFW_RELEASE:
self.input['down'] = False
def on_pos(self,window,x, y):
if self.input['down']:
old_x,old_y = self.input['mouse']
self.trackball.drag_to(x-old_x,y-old_y)
self.input['mouse'] = x,y
def on_scroll(self,window,x,y):
self.trackball.zoom_to(y)
def cleanup(self):
if self._window:
self.close_window()
示例3: Visualizer
# 需要导入模块: from gl_utils.trackball import Trackball [as 别名]
# 或者: from gl_utils.trackball.Trackball import zoom_to [as 别名]
#.........这里部分代码省略.........
self.clear_gl_screen()
self.trackball.push()
# 2. in pixel space draw video frame
glLoadMatrixf(self.get_image_space_matrix(15))
g_pool.image_tex.draw( quad=((0,self.image_height),(self.image_width,self.image_height),(self.image_width,0),(0,0)) ,alpha=0.5)
glLoadMatrixf(self.get_adjusted_pixel_space_matrix(15))
self.draw_frustum()
glLoadMatrixf(self.get_anthropomorphic_matrix())
model_count = 0;
sphere_color = RGBA( 0,147/255.,147/255.,0.2)
initial_sphere_color = RGBA( 0,147/255.,147/255.,0.2)
alternative_sphere_color = RGBA( 1,0.5,0.5,0.05)
alternative_initial_sphere_color = RGBA( 1,0.5,0.5,0.05)
for model in sphere_models:
bin_positions = model['binPositions']
sphere = model['sphere']
initial_sphere = model['initialSphere']
if model_count == 0:
# self.draw_sphere(initial_sphere[0],initial_sphere[1], color = sphere_color )
self.draw_sphere(sphere[0],sphere[1], color = initial_sphere_color )
draw_points(bin_positions, 3 , RGBA(0.6,0.0,0.6,0.5) )
else:
#self.draw_sphere(initial_sphere[0],initial_sphere[1], color = alternative_sphere_color )
self.draw_sphere(sphere[0],sphere[1], color = alternative_initial_sphere_color )
model_count += 1
self.draw_circle( latest_circle[0], latest_circle[1], latest_circle[2], RGBA(0.0,1.0,1.0,0.4))
# self.draw_circle( predicted_circle[0], predicted_circle[1], predicted_circle[2], RGBA(1.0,0.0,0.0,0.4))
draw_points(edges, 2 , RGBA(1.0,0.0,0.6,0.5) )
glLoadMatrixf(self.get_anthropomorphic_matrix())
self.draw_coordinate_system(4)
self.trackball.pop()
self.draw_debug_info(result)
glfwSwapBuffers(self._window)
glfwPollEvents()
return True
def close_window(self):
if self._window:
glfwDestroyWindow(self._window)
self._window = None
############ window callbacks #################
def on_resize(self,window,w, h):
h = max(h,1)
w = max(w,1)
self.trackball.set_window_size(w,h)
self.window_size = (w,h)
active_window = glfwGetCurrentContext()
glfwMakeContextCurrent(window)
self.adjust_gl_view(w,h)
glfwMakeContextCurrent(active_window)
def on_char(self,window,char):
if char == ord('r'):
self.trackball.distance = [0,0,-0.1]
self.trackball.pitch = 0
self.trackball.roll = 0
def on_button(self,window,button, action, mods):
# self.gui.update_button(button,action,mods)
if action == GLFW_PRESS:
self.input['button'] = button
self.input['mouse'] = glfwGetCursorPos(window)
if action == GLFW_RELEASE:
self.input['button'] = None
def on_pos(self,window,x, y):
hdpi_factor = float(glfwGetFramebufferSize(window)[0]/glfwGetWindowSize(window)[0])
x,y = x*hdpi_factor,y*hdpi_factor
# self.gui.update_mouse(x,y)
if self.input['button']==GLFW_MOUSE_BUTTON_RIGHT:
old_x,old_y = self.input['mouse']
self.trackball.drag_to(x-old_x,y-old_y)
self.input['mouse'] = x,y
if self.input['button']==GLFW_MOUSE_BUTTON_LEFT:
old_x,old_y = self.input['mouse']
self.trackball.pan_to(x-old_x,y-old_y)
self.input['mouse'] = x,y
def on_scroll(self,window,x,y):
self.trackball.zoom_to(y)
def on_iconify(self,window,iconified): pass
def on_key(self,window, key, scancode, action, mods): pass
示例4: Reference_Surface
# 需要导入模块: from gl_utils.trackball import Trackball [as 别名]
# 或者: from gl_utils.trackball.Trackball import zoom_to [as 别名]
#.........这里部分代码省略.........
self.trackball.pop()
glfwSwapBuffers(self._window)
glfwMakeContextCurrent(active_window)
def open_window(self):
if not self._window:
if self.fullscreen:
monitor = glfwGetMonitors()[self.monitor_idx]
mode = glfwGetVideoMode(monitor)
height,width= mode[0],mode[1]
else:
monitor = None
height,width= 640,int(640./(self.real_world_size['x']/self.real_world_size['y'])) #open with same aspect ratio as surface
self._window = glfwCreateWindow(height, width, "Reference Surface: " + self.name, monitor=monitor, share=glfwGetCurrentContext())
if not self.fullscreen:
glfwSetWindowPos(self._window,200,0)
self.trackball = Trackball()
self.input = {'down':False, 'mouse':(0,0)}
#Register callbacks
glfwSetFramebufferSizeCallback(self._window,self.on_resize)
glfwSetKeyCallback(self._window,self.on_key)
glfwSetWindowCloseCallback(self._window,self.on_close)
glfwSetMouseButtonCallback(self._window,self.on_button)
glfwSetCursorPosCallback(self._window,self.on_pos)
glfwSetScrollCallback(self._window,self.on_scroll)
self.on_resize(self._window,*glfwGetFramebufferSize(self._window))
# gl_state settings
active_window = glfwGetCurrentContext()
glfwMakeContextCurrent(self._window)
basic_gl_setup()
make_coord_system_norm_based()
# refresh speed settings
glfwSwapInterval(0)
glfwMakeContextCurrent(active_window)
def close_window(self):
if self._window:
glfwDestroyWindow(self._window)
self._window = None
self.window_should_close = False
def open_close_window(self):
if self._window:
self.close_window()
else:
self.open_window()
# window calbacks
def on_resize(self,window,w, h):
self.trackball.set_window_size(w,h)
active_window = glfwGetCurrentContext()
glfwMakeContextCurrent(window)
adjust_gl_view(w,h)
glfwMakeContextCurrent(active_window)
def on_key(self,window, key, scancode, action, mods):
if action == GLFW_PRESS:
if key == GLFW_KEY_ESCAPE:
self.on_close()
def on_close(self,window=None):
self.window_should_close = True
def on_button(self,window,button, action, mods):
if action == GLFW_PRESS:
self.input['down'] = True
self.input['mouse'] = glfwGetCursorPos(window)
if action == GLFW_RELEASE:
self.input['down'] = False
def on_pos(self,window,x, y):
if self.input['down']:
old_x,old_y = self.input['mouse']
self.trackball.drag_to(x-old_x,y-old_y)
self.input['mouse'] = x,y
def on_scroll(self,window,x,y):
self.trackball.zoom_to(y)
def cleanup(self):
if self._window:
self.close_window()
示例5: Eye_Visualizer
# 需要导入模块: from gl_utils.trackball import Trackball [as 别名]
# 或者: from gl_utils.trackball.Trackball import zoom_to [as 别名]
#.........这里部分代码省略.........
vertices = []
vertices.append( (0,0,0) ) # circle center
#create circle vertices in the xy plane
for i in np.linspace(0.0, 2.0*math.pi , num_segments ):
x = math.sin(i)
y = math.cos(i)
z = 0
vertices.append((x,y,z))
glPushMatrix()
glMatrixMode(GL_MODELVIEW )
glLoadMatrixf(self.get_pupil_transformation_matrix(circle_normal,circle_center, circle_radius))
glutils.draw_polyline((vertices),color=color, line_type = GL_TRIANGLE_FAN) # circle
glutils.draw_polyline( [ (0,0,0), (0,0, 4) ] ,color=RGBA(0,0,0), line_type = GL_LINES) #normal
glPopMatrix()
def update_window(self, g_pool, result ):
if not result:
return
if not self.window:
return
self.begin_update_window()
self.image_width , self.image_height = g_pool.capture.frame_size
latest_circle = result['circle']
predicted_circle = result['predicted_circle']
edges = result['edges']
sphere_models = result['models']
self.clear_gl_screen()
self.trackball.push()
# 2. in pixel space draw video frame
glLoadMatrixf(self.get_image_space_matrix(15))
g_pool.image_tex.draw( quad=((0,self.image_height),(self.image_width,self.image_height),(self.image_width,0),(0,0)) ,alpha=0.5)
glLoadMatrixf(self.get_adjusted_pixel_space_matrix(15))
self.draw_frustum( self.image_width, self.image_height, self.focal_length )
glLoadMatrixf(self.get_anthropomorphic_matrix())
model_count = 0;
sphere_color = RGBA( 0,147/255.,147/255.,0.2)
initial_sphere_color = RGBA( 0,147/255.,147/255.,0.2)
alternative_sphere_color = RGBA( 1,0.5,0.5,0.05)
alternative_initial_sphere_color = RGBA( 1,0.5,0.5,0.05)
for model in sphere_models:
bin_positions = model['bin_positions']
sphere = model['sphere']
initial_sphere = model['initial_sphere']
if model_count == 0:
# self.draw_sphere(initial_sphere[0],initial_sphere[1], color = sphere_color )
self.draw_sphere(sphere[0],sphere[1], color = initial_sphere_color )
glutils.draw_points(bin_positions, 3 , RGBA(0.6,0.0,0.6,0.5) )
else:
#self.draw_sphere(initial_sphere[0],initial_sphere[1], color = alternative_sphere_color )
self.draw_sphere(sphere[0],sphere[1], color = alternative_initial_sphere_color )
model_count += 1
self.draw_circle( latest_circle[0], latest_circle[1], latest_circle[2], RGBA(0.0,1.0,1.0,0.4))
# self.draw_circle( predicted_circle[0], predicted_circle[1], predicted_circle[2], RGBA(1.0,0.0,0.0,0.4))
glutils.draw_points(edges, 2 , RGBA(1.0,0.0,0.6,0.5) )
glLoadMatrixf(self.get_anthropomorphic_matrix())
self.draw_coordinate_system(4)
self.trackball.pop()
self.draw_debug_info(result)
self.end_update_window()
return True
############ window callbacks #################
def on_resize(self,window,w, h):
Visualizer.on_resize(self,window,w, h)
self.trackball.set_window_size(w,h)
def on_char(self,window,char):
if char == ord('r'):
self.trackball.distance = [0,0,-0.1]
self.trackball.pitch = 0
self.trackball.roll = 0
def on_scroll(self,window,x,y):
self.trackball.zoom_to(y)
示例6: Calibration_Visualizer
# 需要导入模块: from gl_utils.trackball import Trackball [as 别名]
# 或者: from gl_utils.trackball.Trackball import zoom_to [as 别名]
#.........这里部分代码省略.........
glPushMatrix()
glLoadMatrixf( self.eye_to_world_matrix1.T )
sphere_center1 = list(sphere1['center'])
sphere_radius1 = sphere1['radius']
self.draw_sphere(sphere_center1,sphere_radius1, color = RGBA(1,1,0,1))
for p in self.cal_gaze_points1_3d:
draw_polyline( [ sphere_center1, p] , 1 , calibration_points_line_color, line_type = GL_LINES)
#calibration points
draw_points( self.cal_gaze_points1_3d , 4 , RGBA( 1, 0, 1, 1 ) )
# eye camera
self.draw_coordinate_system(60)
self.draw_frustum( self.image_width / 10.0, self.image_height / 10.0, self.focal_length /10.)
draw_points( gaze_points1 , 2 , RGBA( 1, 0, 0, 1 ) )
for p in gaze_points1:
draw_polyline( [sphere_center1, p] , 1 , RGBA(0,0,0,1), line_type = GL_LINES)
glPopMatrix()
#draw error lines form eye gaze points to world camera ref points
for(cal_gaze_point,ref_point) in zip(self.cal_gaze_points1_3d, self.cal_ref_points_3d):
point = np.zeros(4)
point[:3] = cal_gaze_point
point[3] = 1.0
point = self.eye_to_world_matrix1.dot( point )
point = np.squeeze(np.asarray(point))
draw_polyline( [ point[:3], ref_point] , 1 , error_line_color, line_type = GL_LINES)
#intersection points in world coordinate system
if len(intersection_points) > 0:
draw_points( intersection_points , 2 , RGBA( 1, 0.5, 0.5, 1 ) )
for p in intersection_points:
draw_polyline( [(0,0,0), p] , 1 , RGBA(0.3,0.3,0.9,1), line_type = GL_LINES)
self.trackball.pop()
glfwSwapBuffers(self.window)
glfwPollEvents()
glfwMakeContextCurrent(active_window)
def close_window(self):
if self.window:
active_window = glfwGetCurrentContext();
glfwDestroyWindow(self.window)
self.window = None
glfwMakeContextCurrent(active_window)
############ window callbacks #################
def on_resize(self,window,w, h):
h = max(h,1)
w = max(w,1)
self.trackball.set_window_size(w,h)
self.window_size = (w,h)
active_window = glfwGetCurrentContext()
glfwMakeContextCurrent(window)
self.adjust_gl_view(w,h)
glfwMakeContextCurrent(active_window)
def on_char(self,window,char):
if char == ord('r'):
self.trackball.distance = [0,0,-0.1]
self.trackball.pitch = 0
self.trackball.roll = 180
def on_button(self,window,button, action, mods):
# self.gui.update_button(button,action,mods)
if action == GLFW_PRESS:
self.input['button'] = button
self.input['mouse'] = glfwGetCursorPos(window)
if action == GLFW_RELEASE:
self.input['button'] = None
def on_pos(self,window,x, y):
hdpi_factor = float(glfwGetFramebufferSize(window)[0]/glfwGetWindowSize(window)[0])
x,y = x*hdpi_factor,y*hdpi_factor
# self.gui.update_mouse(x,y)
if self.input['button']==GLFW_MOUSE_BUTTON_RIGHT:
old_x,old_y = self.input['mouse']
self.trackball.drag_to(x-old_x,y-old_y)
self.input['mouse'] = x,y
if self.input['button']==GLFW_MOUSE_BUTTON_LEFT:
old_x,old_y = self.input['mouse']
self.trackball.pan_to(x-old_x,y-old_y)
self.input['mouse'] = x,y
def on_scroll(self,window,x,y):
self.trackball.zoom_to(y)
def on_iconify(self,window,iconified): pass
def on_key(self,window, key, scancode, action, mods): pass