You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

86 lines
1.7 KiB

import processing.io.*;
6 years ago
import processing.serial.*;
6 years ago
//import processing.video.*;
import gohai.glvideo.*;
6 years ago
Serial port;
6 years ago
// ----------------------- camera ---------------------------------------------------------------------------------
//Capture video;
GLCapture video;
PImage img;
boolean takePicture = true;
6 years ago
int videoWidth = 480;
int videoHeight = 240;
6 years ago
6 years ago
int sending = 0;
6 years ago
void setup() {
6 years ago
size(480, 240, P2D);
frameRate(10);
6 years ago
colorMode(HSB, 100, 100, 100);
String portName = Serial.list()[0];
port = new Serial(this, portName, 9600);
6 years ago
6 years ago
String[] cameras = GLCapture.list();
video = new GLCapture(this, cameras[0], width, height, 10);
6 years ago
video.start();
6 years ago
GPIO.pinMode(4, GPIO.INPUT);
// video = new Capture(this, width, height);
// video.start();
6 years ago
background(0);
delay(2000);
6 years ago
6 years ago
}
6 years ago
void draw() {
ephPercentage();
6 years ago
if (GPIO.digitalRead(4) == GPIO.LOW && takePicture == true){
takePicture = false;
delay(4000);
video.pause();
6 years ago
makePicture();
}
6 years ago
if(GPIO.digitalRead(4) == GPIO.HIGH && takePicture == false){
takePicture = true;
video.start();
}
}
void keyPressed() {
println(int(key));
if (key == 'S' || key == 's') {
6 years ago
video.pause();
makePicture();
}
if (key == 'B' || key == 'b') {
backupFrame();
}
if (key == 'G' || key == 'g') {
video.start();
}
if (key == 'U' || key == 'u') {
sendMessage(C_TAG, colorByteValues);
}
6 years ago
if (key == '1' || key == '2' || key == '3' || key == '4' || key == '5' || key == '6' || key == '7' || key == '8') {
for(int i = 0; i<colorsN; i++) {
colorByteValues[i] = (int(key)-49) == i ? byte(100) : 0;
print(colorByteValues[i] + "\t");
}
println("");
sendMessage(B_TAG, colorByteValues);
}
6 years ago
}