コンターカメラ
PythonでVideoCaptureが出来ると知ったので遊んでみました。
http://videocapture.sourceforge.net/
ソース
import VideoCapture import Image from ImageFilter import * import pygame from pygame.locals import * class ContourCamera: res = (320, 240) def __init__(self): self.cam = VideoCapture.Device() self.cam.setResolution(*self.res) def capture(self): image = self.cam.getImage().filter(CONTOUR) return pygame.image.fromstring(image.tostring(), image.size, "RGB") def run(self): pygame.init() screen = pygame.display.set_mode(self.res) screen.fill((0,0,0)) pygame.display.set_caption('Contour Camera') while 1: screen.blit(self.capture(), (0, 0)) pygame.display.flip() for event in pygame.event.get(): if event.type == QUIT: return if event.type == KEYDOWN and event.key == K_ESCAPE: return cc = ContourCamera() cc.run()
動かすには、上記のVideoCaptureモジュールとpygameとPILが必要です。手軽に試せるようにpy2exeで実行形式にしようと思ったんだけど、PILのfontがどうのこうの言われてなんだか上手く出来ず・・・挫折。
動作イメージ
単に、キャプチャした画像にコンター(等高線)フィルタをかけてるだけです。
こんな感じでキャプチャできます。(自宅の窓から見えてる風景)
昔懐かしい、a-ha のTake on meのPVみたいな事が出来ないかなーと思ったけど、作ってみたらなんかイマイチだったという罠。
a-ha Take On Me
http://youtubech.com/test/read.cgi%3Fdl%3DWayYcrx4Gv0%26ext%3D.flv