Created
November 27, 2017 18:35
-
-
Save jeonghopark/2593370664470e12c36b762eef4ed9fe to your computer and use it in GitHub Desktop.
Revisions
-
jeonghopark created this gist
Nov 27, 2017 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,33 @@ import processing.video.*; Capture cam; PImage[] buffer; int frameNum = 60; int writeIndex = 0, readIndex = 1; void setup() { size(640, 240); cam = new Capture(this, 640, 480); cam.start(); buffer = new PImage[frameNum]; } void draw() { if (cam.available()) { cam.read(); image(cam, 0, 0, 320, 240); buffer[writeIndex] = cam.get(); if (buffer[readIndex] != null) { image(buffer[readIndex], 320, 0, 320, 240); } writeIndex++; readIndex++; if (readIndex >= frameNum - 1) { readIndex = 0; } if (writeIndex >= frameNum - 1) { writeIndex = 0; } } }