#! /usr/bin/env python import pygame, sys, os, time, opencv import PuiModule from opencv import * from opencv.highgui import * vconf = "v4l2src device=/dev/video0 ! videorate ! video/x-raw-yuv,width=320,height=240,framerate=5/1 ! ffmpegcolorspace ! capsfilter caps=video/x-raw-rgb,bpp=24 ! identity name=artoolkit ! fakesink" config_nameCalibrador = "../bin/Data/multi/marker.dat" usarAlgoritmoRapido = 1 frameSize = (320,240) running = True displayPyGame = False displaySDL = False count =0 def main(): global frameSize, usarAlgoritmoRapido,config_nameCalibrador,vconf,displayPyGame,displaySDL,count size = (320,240) pui = PuiModule.Pui() pui.getModuleInfo() print '1\n' pui.initARConVideo(config_nameCalibrador,"../bin/Data/camera_para.dat",vconf,usarAlgoritmoRapido,pui.NORMAL_SPEED_LOOP,1.0) pui.setDebugCalibracion(False) print '4\n' if displaySDL: print '---- Desplegaremos en SDL manejado por PuiModule ----' pui.abrirVentanaGrafica() elif displayPyGame: screen = pygame.display.set_mode(size) surface = pygame.display.get_surface() pui.capStart() print '5\n' running = True while running: array = pui.capturarPyImageAR() if displaySDL: pui.desplegarImagenAR(False) count=count +1 if count >=1000: running=False elif displayPyGame: if not array == None: pg_img = pygame.image.frombuffer(array.data,size, "RGB") screen.blit(pg_img, (0,0)) pygame.display.flip() for event in pygame.event.get(): if event.type == pygame.QUIT: running = False elif event.type == pygame.KEYDOWN: if event.key == pygame.K_ESCAPE: running = False else: count=count +1 if count >=1000: running=False print '************' print pui.getFPS() print '(frame/sec)\n' if __name__ == "__main__": main()