Exemple #1
0
from cvEyeTrack import Draw_Cross

print("Imported pygame, numpy, opencv and cvEyeTracking lib")
raw_input("Press Enter to capture an image (in pygame)")

pygame.init()
pygame.camera.init()
size = width,height = 640,480
display = pygame.display.set_mode(size,0)
camList = pygame.camera.list_cameras()                  # TODO: err if none found
camera = pygame.camera.Camera(camList[0],size,"RGB")
camera.start()
for i in range(100):
    if camera.query_image(): # ready to take an image?
        break
snapshot = camera.get_image()
camera.stop()


display.blit(snapshot,(0,0,))
pygame.display.flip()
pygame.display.flip()

print("Captured an image")
raw_input("Press Enter to convert into opencv format")

npy = surfarray.pixels3d(snapshot)
ipl = adaptors.NumPy2Ipl(npy)
Exemple #2
0
#log# args = ['drawCross.py']
#log# It is safe to make manual edits below here.
#log#-----------------------------------------------------------------------
_ip.magic("logstart ")
import pygame
import pygame.camera
from pygame.locals import *
import numpy
pygame.init()
pygame.camera.init()
size = width,height = 640,480
display = pygame.display.set_mode(size,0)
camList = pygame.camera.list_cameras()                  # TODO: err if none found
camera = pygame.camera.Camera(camList[0],size,"RGB")    # starting in RGB mode - this means frame comes in size (640,480,3) (1MB each?)
camera.start()
camera.query_image() # ready to take an image?
snapshot = camera.get_image()
camera.stop()
display.blit(snapshot,(0,0,))
pygame.display.flip()
pygame.display.flip()
import opencv
from pygame import surfarray
npy = surfarray.pixels3d(snapshot)
ipl = opencv.adaptors.NumPy2Ipl(npy)
import CvEyeTrack
import vEyeTrack
import cvEyeTrack
from cvEyeTrack import Draw_Cross
#?Draw_Cross
green = opencv.CV_RGB(0,255,0)