calibrate runs but doesn't work
This commit is contained in:
parent
8edc1224bb
commit
26e34f7671
6 changed files with 245 additions and 190 deletions
|
|
@ -4,6 +4,7 @@ import processing.video.*;
|
|||
|
||||
class Camera {
|
||||
Capture cam;
|
||||
PImage latestImage;
|
||||
|
||||
/*
|
||||
Set up a camera.
|
||||
|
|
@ -22,6 +23,8 @@ class Camera {
|
|||
PApplet.println(cameras[cameraMode]);
|
||||
this.cam = new Capture(applet, cameras[cameraMode]);
|
||||
this.cam.start();
|
||||
|
||||
this.updateImage();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -35,7 +38,7 @@ class Camera {
|
|||
return newImageAvailable;
|
||||
}
|
||||
|
||||
Capture getCam() {
|
||||
PImage getImage() {
|
||||
return cam;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ public class EuglenaApplet extends PApplet {
|
|||
|
||||
// Software components
|
||||
Menu menu;
|
||||
Calibrator calibrator;
|
||||
|
||||
public static void main(String args[]) {
|
||||
PApplet.main("EuglenaApplet");
|
||||
|
|
@ -33,16 +34,20 @@ public class EuglenaApplet extends PApplet {
|
|||
|
||||
// Start up projectorApplet window
|
||||
// Do this last, in case ProjectorApplet wants to use the camera, arduino, etc.
|
||||
projectorApplet = new ProjectorApplet();
|
||||
projectorApplet = new ProjectorApplet(this);
|
||||
String[] args = {"Euglena projector"};
|
||||
PApplet.runSketch(args, projectorApplet);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw() {
|
||||
menu.draw(this, ledControl);
|
||||
|
||||
//Update webcam and draw the updated image to the screen
|
||||
camera.updateImage();
|
||||
imageMode(PApplet.CORNER);
|
||||
image(camera.getCam(), 0, 0, width - menu.width, height);
|
||||
image(camera.getImage(), 0, 0, width - menu.width, height);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -10,23 +10,23 @@ class LEDControl {
|
|||
LEDControl(PApplet applet, int whichArduino) {
|
||||
// Arduino - initialize correct arduino
|
||||
String[] arduinos = Arduino.list();
|
||||
if (arduinos.length == 0) {
|
||||
PApplet.println("There are no arduinos available for use.");
|
||||
applet.exit();
|
||||
} else {
|
||||
PApplet.println("Available arduinos:");
|
||||
for(int i = 0; i < arduinos.length; i++) {
|
||||
PApplet.println(arduinos[i]);
|
||||
}
|
||||
PApplet.print("Using arduino ");
|
||||
PApplet.println(arduinos[whichArduino]);
|
||||
|
||||
this.arduino = new Arduino(applet, arduinos[whichArduino], comRate);
|
||||
|
||||
for (Direction dir : Direction.values()) {
|
||||
this.arduino.pinMode(dir.pin, Arduino.OUTPUT);
|
||||
}
|
||||
}
|
||||
// if (arduinos.length == 0) {
|
||||
// PApplet.println("There are no arduinos available for use.");
|
||||
// applet.exit();
|
||||
// } else {
|
||||
// PApplet.println("Available arduinos:");
|
||||
// for(int i = 0; i < arduinos.length; i++) {
|
||||
// PApplet.println(arduinos[i]);
|
||||
// }
|
||||
// PApplet.print("Using arduino ");
|
||||
// PApplet.println(arduinos[whichArduino]);
|
||||
//
|
||||
// this.arduino = new Arduino(applet, arduinos[whichArduino], comRate);
|
||||
//
|
||||
// for (Direction dir : Direction.values()) {
|
||||
// this.arduino.pinMode(dir.pin, Arduino.OUTPUT);
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
boolean isActive(Direction dir) {
|
||||
|
|
|
|||
|
|
@ -7,6 +7,14 @@ class ProjectorApplet extends PApplet {
|
|||
final static int centerX = 860;
|
||||
final static int centerY = 540;
|
||||
|
||||
EuglenaApplet parent;
|
||||
Calibrator calibrator;
|
||||
|
||||
ProjectorApplet(EuglenaApplet parent) {
|
||||
this.parent = parent;
|
||||
calibrator = new Calibrator(this);
|
||||
}
|
||||
|
||||
public void settings() {
|
||||
fullScreen(P2D, this.projectorScreenNumber);
|
||||
}
|
||||
|
|
@ -14,6 +22,7 @@ class ProjectorApplet extends PApplet {
|
|||
@Override
|
||||
public void setup() {
|
||||
clear();
|
||||
calibrator.activate();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -21,5 +30,23 @@ class ProjectorApplet extends PApplet {
|
|||
background(50);
|
||||
fill(255);
|
||||
ellipse(mouseX, mouseY, 10, 10);
|
||||
|
||||
calibrator.draw(parent);
|
||||
}
|
||||
|
||||
public float convertXCoord(float x) {
|
||||
return (x / calibrator.magx + width * calibrator.offsetx);
|
||||
}
|
||||
|
||||
public float convertYCoord(float y) {
|
||||
return (y / calibrator.magy + height * calibrator.offsety);
|
||||
}
|
||||
|
||||
public float convertXDistance(float dx) {
|
||||
return (dx / calibrator.magx);
|
||||
}
|
||||
|
||||
public float convertYDistance(float dy) {
|
||||
return (dy / calibrator.magy);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue