ProcessingでWebカメラ (Windows)
ちょうどProcessingが1.0になった頃に
Processingを1週間くらい触っていて、
Windows(xp)でWebカメラを使おうとしたら
相変わらず素直には動かなかった。Macは最初から何も問題なし。
WINVDIG 1.01 をインストール
(最新版ではなく、1.01である必要がある)
http://www.eden.net.nz/7/20071008/
ほぼ最小サンプル
–
//ライブラリの取り込み
import processing.video.*;
//キャプチャする映像のオブジェクトを用意
Capture video;
int videoW = 120;
int videoH = 90;
int attachX;
int attachY;
int attachW;
int attachH;
void setup() {
size(800, 600, P2D);
//キャプチャする映像の設定
video = new Capture(this, videoW, videoH, 24);
attachW = height / 3 * 4;
attachH = height;
attachX = - (attachW - width) / 2;
attachY = - (attachH - height) / 2;
}
void draw() {
if (video.available()) {
video.read();
//映像を画面に配置
image(video, attachX, attachY, attachW, attachH);
}
}
–