本文整理汇总了Python中camera.Camera方法的典型用法代码示例。如果您正苦于以下问题:Python camera.Camera方法的具体用法?Python camera.Camera怎么用?Python camera.Camera使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类camera
的用法示例。
在下文中一共展示了camera.Camera方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: opencv_test
# 需要导入模块: import camera [as 别名]
# 或者: from camera import Camera [as 别名]
def opencv_test():
np.set_printoptions(precision=1, suppress=True, linewidth=150)
cam = camera.Camera()
cam.load('test/camera_opencv.yaml')
if not os.path.exists('test/out'):
os.mkdir('test/out')
img = cv2.imread('test/opencv_distorted.jpg')
assert isinstance(img, np.ndarray)
img_und = cam.undistort_image(img)
cv2.imwrite('test/out/test_undistorted.png', img_und)
print 'Distorted (manually marked)'
print img_points
img_points_und = cam.undistort(img_points)
print 'Undistorted'
print img_points_und
for point in img_points.T.astype(int):
cv2.circle(img, tuple(point), 3, (0, 255, 0), -1)
cv2.imwrite('test/out/test_points.png', img)
for point in img_points_und.T.astype(int):
cv2.circle(img_und, tuple(point), 3, (0, 255, 0), -1)
cv2.imwrite('test/out/test_points_und.png', img_und)
img_points_dist = cam.distort(img_points_und)
print 'Distorted back:'
print img_points_dist
print 'Undistortion / distortion errors:'
print np.linalg.norm(img_points - img_points_dist, axis=0)
image_coords = cam.world_to_image(np.array([[0., 0., 0.]]).T)
print image_coords
print cam.image_to_world(image_coords, 0.)
示例2: video_feed
# 需要导入模块: import camera [as 别名]
# 或者: from camera import Camera [as 别名]
def video_feed():
"""Video streaming route. Put this in the src attribute of an img tag."""
return Response(gen(Camera()),
mimetype='multipart/x-mixed-replace; boundary=frame')
示例3: fisheye_test
# 需要导入模块: import camera [as 别名]
# 或者: from camera import Camera [as 别名]
def fisheye_test():
cam = camera.Camera()
cam.load('test/camera_fisheye.yaml')
if not os.path.exists('test/out'):
os.mkdir('test/out')
img = cv2.imread('test/opencv_distorted.jpg')
assert isinstance(img, np.ndarray)
img_und = cam.undistort_image(img)
cv2.imwrite('test/out/fisheye_undistorted.png', img_und)
img_points_und = cam.undistort(img_points)
print 'Undistorted'
print img_points_und
for point in img_points.T.astype(int):
cv2.circle(img, tuple(point), 3, (0, 255, 0), -1)
cv2.imwrite('test/out/fisheye_test_points.jpg', img)
for point in img_points_und.T.astype(int):
cv2.circle(img_und, tuple(point), 3, (0, 255, 0), -1)
cv2.imwrite('test/out/fisheye_test_points_und.jpg', img_und)
img_points_dist = cam.distort(img_points_und)
print 'Distorted back:'
print img_points_dist
print 'Undistortion / distortion errors:'
print np.linalg.norm(img_points - img_points_dist, axis=0)
image_coords = cam.world_to_image(np.array([[0., 0., 0.]]).T)
print image_coords
print cam.image_to_world(image_coords, 0.)
示例4: load_test
# 需要导入模块: import camera [as 别名]
# 或者: from camera import Camera [as 别名]
def load_test():
c = camera.Camera(1)
c.load('test/camera_01.yaml')
# pitch dimensions [-20, -10, 19, 9.5] # xmin, ymin, xmax, ymax
points = np.array([[-20, -10, 0], [-20, 9.5, 0], [19, 9.5, 0], [19, -10, 0], [-20, -10, 0]]).T
c.plot_world_points(points, 'r-', solve_visibility=False)
points = np.array([[0, -10, 0], [0, 9.5, 0]]).T
c.plot_world_points(points, 'y-', solve_visibility=False)
import matplotlib.pylab as plt
plt.imshow(plt.imread('test/cam01.png'))
# plt.show()
plt.savefig('test/out/camera_load_test.png', dpi=150)
plt.close()
示例5: init_test
# 需要导入模块: import camera [as 别名]
# 或者: from camera import Camera [as 别名]
def init_test():
c = camera.Camera(1)
c.set_K_elements(480, 384, 1225.0)
R = np.array(
[[-0.9316877145365, -0.3608289515885, 0.002545329627547],
[-0.1725273110187, 0.4247524018287, -0.8888909933995],
[0.3296724908378, -0.8263880720441, -0.4579894432589]])
c.set_R(R)
c.set_t(np.array([[-1.365061486465], [3.431608806127], [17.74182159488]]))
eq_(c.get_focal_length(), 1225.)
assert np.array_equal(c.get_principal_point_px(), np.array([[480., 384.]]))
c.world_to_image(np.array([[0., 0., 0.]]).T)
示例6: __init__
# 需要导入模块: import camera [as 别名]
# 或者: from camera import Camera [as 别名]
def __init__(self, win_title, boundary, win_width = 640, win_height = 480):
""":param boundary: list<(min, max) * 3> for x, y, z; or None if no
boundary"""
self.boundary = boundary
self.camera = Camera([10, 10, 180],
[sum(boundary[i])/2 for i in range(3)],
[0, 1, 0])
self.win_width = win_width
self.win_height = win_height
def init_glut():
glutInit(sys.argv)
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH)
glutInitWindowSize(win_width, win_height)
glutCreateWindow(win_title)
glutDisplayFunc(self._gl_drawscene)
def visible(vis):
if vis == GLUT_VISIBLE:
glutIdleFunc(self._gl_drawscene)
else:
glutIdleFunc(None)
glutKeyboardFunc(self._on_keyboard)
glutMouseFunc(self._on_mouse)
glutMotionFunc(self._on_mouse_motion)
glutReshapeFunc(self._on_reshape)
glutVisibilityFunc(visible)
glutIdleFunc(self._gl_drawscene)
def init_gl():
glClearColor(0.0, 0.0, 0.0, 0.0) # This Will Clear The Background Color To Black
glClearDepth(1.0) # Enables Clearing Of The Depth Buffer
glDepthFunc(GL_LESS) # The Type Of Depth Test To Do
glEnable(GL_DEPTH_TEST) # Enables Depth Testing
glShadeModel(GL_SMOOTH) # Enables Smooth Color Shading
glMatrixMode(GL_PROJECTION)
glLoadIdentity() # Reset The Projection Matrix
gluPerspective(45.0, float(win_width)/float(win_height),
self.clip_near, self.clip_far)
glMatrixMode(GL_MODELVIEW)
def init_light():
glLightfv(GL_LIGHT0, GL_AMBIENT, GLfloat_4(0.5, 0.5, 0.5, 1.0))
glLightfv(GL_LIGHT0, GL_DIFFUSE, GLfloat_4(1.0, 1.0, 1.0, 1.0))
glLightfv(GL_LIGHT0, GL_SPECULAR, GLfloat_4(1.0, 1.0, 1.0, 1.0))
glLightfv(GL_LIGHT0, GL_POSITION, GLfloat_4(1.0, 1.0, 1.0, 0.0));
glLightModelfv(GL_LIGHT_MODEL_AMBIENT, GLfloat_4(0.2, 0.2, 0.2, 1.0))
glEnable(GL_LIGHTING)
glEnable(GL_LIGHT0)
init_glut()
init_gl()
self._quadric = gluNewQuadric()
#init_light()