1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
#! /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()
|