當前位置: 首頁>>代碼示例>>Python>>正文


Python camera.Camera方法代碼示例

本文整理匯總了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.) 
開發者ID:smidm,項目名稱:camera.py,代碼行數:42,代碼來源:camera_opencv_test.py

示例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') 
開發者ID:miguelgrinberg,項目名稱:flask-video-streaming,代碼行數:6,代碼來源:app.py

示例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.) 
開發者ID:smidm,項目名稱:camera.py,代碼行數:38,代碼來源:camera_opencv_test.py

示例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() 
開發者ID:smidm,項目名稱:camera.py,代碼行數:15,代碼來源:camera_test.py

示例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) 
開發者ID:smidm,項目名稱:camera.py,代碼行數:14,代碼來源:camera_test.py

示例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() 
開發者ID:ppwwyyxx,項目名稱:Stereo-Pose-Machines,代碼行數:57,代碼來源:__init__.py


注:本文中的camera.Camera方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。