Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/Utilidades/src/displayImage.py
blob: 06b59afbf8bfd11c53765284b03969f53cff9973 (plain)
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
#! /usr/bin/env python
import pygame, sys, os
from opencv.cv import *
from opencv.highgui import *

def main():
    capture = cvCreateCameraCapture(0)
    #Actualmente estas funcinoes no andan por lo tanto no nos permite setear el tamano del frame 
    #cvSetCaptureProperty(capture, CV_CAP_PROP_FRAME_WIDTH,320)
    #cvSetCaptureProperty(capture, CV_CAP_PROP_FRAME_HEIGHT,240)
    size = (640,480)
    screen = pygame.display.set_mode(size)
    
    surface = pygame.display.get_surface()    
    
    running = True
    while running:
#        screen.fill((255,255,255))
        
        frame = cvQueryFrame(capture)
	
	pg_img = pygame.image.frombuffer(frame.imageData,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

if __name__ == "__main__":
    main()