示例#1
0
文件: test.py 项目: i2r-nglx/pycv
def draw_teapots():
    for i in [0.2, 0, -0.2]:
        for j in [0.2, 0, -0.2]:
            glPushMatrix()
            if not (i==0 and j==0):
                ar.draw_teapot(0.05, pos=[i,0,j])
            glPopMatrix()
示例#2
0
文件: test.py 项目: i2r-nglx/pycv
def translate(displacement, K, Rt, width, height, img):
    glMatrixMode(GL_PROJECTION)
    glLoadIdentity()
    ar.draw_background(img)
    ar.set_projection_from_camera(K, width, height)
    ar.set_modelview_from_camera(Rt)
    ar.draw_teapot(0.1, [0,0,0], displacement)
    draw_teapots()
    pygame.display.flip()
示例#3
0
文件: test.py 项目: i2r-nglx/pycv
def rotate(degrees, K, Rt, width, height, img):
    glMatrixMode(GL_PROJECTION)
    glLoadIdentity()
    ar.draw_background(img)
    ar.set_projection_from_camera(K, width, height)
    ar.set_modelview_from_camera(Rt)
    ar.draw_teapot(0.1, degrees)
    draw_teapots()
    pygame.display.flip()
示例#4
0
文件: test.py 项目: i2r-nglx/pycv
            glPopMatrix()

if __name__=="__main__":
    # load camera data
    #with open("../../data/ar_camera.pkl", "r") as f:
    with open("../../data/ar_camera_mag.pkl", "rb") as f:
        K = pickle.load(f)
        Rt = pickle.load(f)

    setup()
    #img = '../../data/book_perspective.jpg'
    img = '../../data/mag_perspective.jpg'
    ar.draw_background(img)
    ar.set_projection_from_camera(K, width, height)
    ar.set_modelview_from_camera(Rt)
    ar.draw_teapot(0.1)
    #draw_teapots()
    pygame.display.flip()

    clock = pygame.time.Clock()
    change = [0.0,0.0,0.0]
    ticker = 10
    translate_object = True
    if translate_object:
        while True:
            events = pygame.event.get()
            for event in events:
                if event.type == QUIT:
                    break
                if event.type == KEYDOWN:
                    if event.key == K_UP:
示例#5
0
                if event.key in (K_UP, K_DOWN):
                    translate_unit[0] = 0
                    #print translate_unit
                if event.key in (K_LEFT, K_RIGHT):
                    translate_unit[2] = 0
                    #print translate_unit
                if event.key in (K_PERIOD, K_MINUS):
                    scale_unit = 1

        for i, x in enumerate(pos):
            pos[i] += translate_unit[i]
        degrees[1] += rotate_unit
        scale *= scale_unit
        print(scale, degrees, pos)
        #degrees[0] += 10
        #degrees[0] %= 360
        """ Simply flipping creates flicker
        but redrawing followed by flipping removes the flicker """
        #rotate(degrees, K, Rt, width, height, img) # includes flip()
        glMatrixMode(GL_PROJECTION)
        glLoadIdentity()
        ar.draw_background(img)
        ar.set_projection_from_camera(K, width, height)
        ar.set_modelview_from_camera(Rt)
        ar.draw_teapot(scale, degrees, pos)
        #ar.draw_furniture(obj, scale, degrees, pos)
        #ar.draw_furniture(obj_2, scale, degrees, pos)
        pygame.display.flip()
        clock.tick(ticker)
        #time.sleep(0.1)
示例#6
0
文件: test_furn.py 项目: ak352/pycv
                if event.key in (K_UP, K_DOWN):
                    translate_unit[0] = 0
                    #print translate_unit
                if event.key in (K_LEFT, K_RIGHT):
                    translate_unit[2] = 0
                    #print translate_unit
                if event.key in (K_PERIOD, K_MINUS):
                    scale_unit = 1

        for i,x in enumerate(pos):
            pos[i] += translate_unit[i]
        degrees[1] += rotate_unit
        scale *= scale_unit
        print (scale, degrees, pos)
        #degrees[0] += 10
        #degrees[0] %= 360
        """ Simply flipping creates flicker
        but redrawing followed by flipping removes the flicker """ 
        #rotate(degrees, K, Rt, width, height, img) # includes flip()
        glMatrixMode(GL_PROJECTION)
        glLoadIdentity()
        ar.draw_background(img)
        ar.set_projection_from_camera(K, width, height)
        ar.set_modelview_from_camera(Rt)
        ar.draw_teapot(scale, degrees, pos)
        #ar.draw_furniture(obj, scale, degrees, pos)
        #ar.draw_furniture(obj_2, scale, degrees, pos)
        pygame.display.flip()
        clock.tick(ticker)
        #time.sleep(0.1)