Created
February 13, 2012 06:17
-
-
Save matthewfl/1814204 to your computer and use it in GitHub Desktop.
display the image for a cmucam that is directly connected
This file contains 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 characters
import processing.serial.*; | |
Serial cmucam; | |
void setup () { | |
cmucam = new Serial(this, "/dev/tty.usbserial-A400C1Q8", 115200); | |
size(200, 200); | |
delay(1500); | |
cmucam.write("RS\r"); | |
delay(150); | |
frameRate(4); | |
} | |
void draw () { | |
//byte buffer[1024*50]; | |
background(123); | |
int[] buffer = new int[15]; | |
int x=0; | |
int y=-1; | |
int px=0; | |
cmucam.write("SF\r"); | |
while(true) { | |
while(cmucam.available()<1); | |
int read = cmucam.read(); | |
if(read == 1) { | |
while(cmucam.read() != 2); | |
}else if(read == 2) { | |
x=0; | |
y++; | |
}else if(read == 3) { | |
break; | |
}else{ | |
buffer[px++] = read; | |
if(px==3) { | |
px=0; | |
// println(buffer[0] + " " +buffer[1] + " " + buffer[2]); | |
set(x++,y,color(buffer[0], buffer[1], buffer[2])); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment