#!/usr/bin/env python from sys import path from CVtypes import cv from time import clock from PIL import JpegImagePlugin import wx class myFrame(wx.Frame): def __init__(self): wx.Frame.__init__(self, None, -1, 'Try CV') self.SetClientSize((320,240)) self.cap = cv.CreateCameraCapture(0) self.Bind(wx.EVT_IDLE, self.onIdle) def onIdle(self, event): img = cv.QueryFrame(self.cap) self.displayImage(img) event.RequestMore() def displayImage(self, img, offset=(0,0)): bitmap = cv.ImageAsBitmap(img,flip=False) dc = wx.ClientDC(self) dc.DrawBitmap(bitmap, offset[0], offset[1], False) class myApp(wx.App): def OnInit(self): self.frame = myFrame() self.frame.Show(True) return True app = myApp(0) app.MainLoop()