Drkcore

12 01 2010 Python jython processing Tweet

jython+processingでwebカメラで取り込むサンプル

usbカメラを買ったので早速遊んでいる。ちなみに奥に見える黄色いのはjython本じゃなくて独習C++とかいう本。

webcam

drawメソッドでピクセルをいじくると色々とエフェクトがかけられるわけです。

from javax.swing import JFrame
from processing.core import PApplet
from processing.video import *

class Sketch(PApplet):
    def __init__(self):
        pass

    def getField(self, name):
        return self.class.superclass.getDeclaredField(name).get(self)

    def setup(self):
        self.size(320, 240)
        self.camera = Capture(self, 320, 240, 12)

    def draw(self):
        self.camera.read()        
        self.image(self.camera, 0,0)

def run(applet):
    frame = JFrame(title="Processing camera",
                   resizable = 1,
                   defaultCloseOperation=JFrame.EXIT_ON_CLOSE)
    frame.contentPane.add(applet)
    applet.init()
    frame.pack()
    frame.visible = 1

if __name__ == '__main__':
    run(Sketch())

jython本が待ち遠しい。

ProductName Jythonプログラミング
西尾 泰和
毎日コミュニケーションズ / ¥ 3,150 ()
在庫あり。

About

  • もう5年目(wishlistありマス♡)
  • 最近はPythonとDeepLearning
  • 日本酒自粛中
  • ドラムンベースからミニマルまで
  • ポケモンGOゆるめ

Tag

Python Deep Learning javascript chemoinformatics Emacs sake and more...

Ad

© kzfm 2003-2021