clean up old files
This commit is contained in:
parent
cd714a0274
commit
a8c8240e1d
37 changed files with 237 additions and 174 deletions
58
src/oldfiles/ObjectRecognition.java
Normal file
58
src/oldfiles/ObjectRecognition.java
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
package oldfiles;
|
||||
|
||||
class EuglenaCounter {
|
||||
|
||||
int roiX, roiY, roiWidth, roiHeight, lastMillis, avgTime;
|
||||
float previousAverage;
|
||||
boolean averageReady;
|
||||
|
||||
OpenCV opencv;
|
||||
ArrayList<int> counts;
|
||||
|
||||
EuglenaCounter(PApplet parent, int roiX, int roiY, int roiWidth, int roiHeight, int avgTime){
|
||||
this.counts = new ArrayList<int>();
|
||||
this.roiX = roiX;
|
||||
this.roiY = roiY;
|
||||
this.roiWidth = roiWidth;
|
||||
this.roiHeight = roiHeight;
|
||||
this.avgTime = avgTime;
|
||||
|
||||
this.opencv = new OpenCV(parent, roiWidth, roiHeight);
|
||||
this.opencv.startBackgroundSubtraction(7, 3, .35);
|
||||
|
||||
this.reset();
|
||||
}
|
||||
|
||||
void reset(){
|
||||
this.lastMillis = millis();
|
||||
this.counts.clear();
|
||||
this.averageReady = false;
|
||||
this.previousAverage = -1;
|
||||
}
|
||||
|
||||
void update() {
|
||||
pImage roiFrame = get(roiX, roiY, roiWidth, roiHeight); // Get pixels of interest and saves as image for valid image path
|
||||
this.opencv.loadImage(roiFrame); // Input proper pixels into cv processing
|
||||
this.opencv.updateBackground(); //Necessary for background subtraction
|
||||
this.opencv.useGray(); //Create grayscale image
|
||||
this.opencv.dilate(); //Clean up image
|
||||
this.opencv.erode();
|
||||
this.opencv.blur(3);
|
||||
//dst = opencv.getOutput(); //Save computer vision as separate image path
|
||||
//Find outline of moving objects - euglena
|
||||
int count = opencv.findContours().size(); // Count number of outlines
|
||||
this.counts.add(count);
|
||||
|
||||
int interval = millis() - this.lastMillis();
|
||||
if (interval > this.avgTime) {
|
||||
this.previousAverage = 0;
|
||||
for (int c : this.counts) {
|
||||
this.previousAverage = this.previousAverage + c;
|
||||
}
|
||||
this.previousAverage = this.previousAverage / this.counts.size();
|
||||
this.averageReady = true;
|
||||
this.counts.clear();
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
82
src/oldfiles/Presets.java
Normal file
82
src/oldfiles/Presets.java
Normal file
|
|
@ -0,0 +1,82 @@
|
|||
package oldfiles;/*
|
||||
Previously implemented programs which we need to redo using classes
|
||||
case 2 : // Starts clear program
|
||||
clearScreen();
|
||||
break;
|
||||
case 3 : // Uses reduced screen raster
|
||||
// rectangularStim(64, 5);
|
||||
// proto488flashraster(screenWidth - 1500, 400, screenWidth - 6*menu.width, screenHeight - 400);
|
||||
// heatup();
|
||||
// squareCorridor();
|
||||
// LEDtest();
|
||||
// colorScreen();
|
||||
// clearScreen();
|
||||
// circleArrayStim(screenWidth - 1500, 800, 5, 5, 20, 5);
|
||||
// angleMove(screenWidth - (displayWidth-750*cos(45*PI/360)-x-menu.width), centerY, 45, 750, 0.01);
|
||||
// window(20, 20);
|
||||
// separate(0.1);
|
||||
// merge(0.1);
|
||||
// shrinkingWindow(0.01, 0, 0, 255, 10);
|
||||
// translateCircle(0.1);
|
||||
// gradientWindow(0,0,0,0,0,15,500);
|
||||
// randomLED();
|
||||
// lineRotate(50, 0.01);
|
||||
break;
|
||||
case 4 : // Create LED sequences or paint backgrounds to be loaded later
|
||||
angleGather(screenWidth - 1400, centerY, 45, 750);
|
||||
// protoGather(screenWidth - 800, 300, screenWidth - 8*menu.width, screenHeight - 500);
|
||||
break;
|
||||
*/
|
||||
|
||||
class ClearScreen {
|
||||
|
||||
int timeElapsed, timeCurrent, timeInitial, euglenaCountInitial, euglenaCount,
|
||||
roiCornerX, roiCornerY, roiWidth, roiHeight;
|
||||
float euglenaReduction, targetReduction;
|
||||
|
||||
// opencv = new OpenCV(this, roiWidth, roiHeight);
|
||||
// opencv.startBackgroundSubtraction(7, 3, .35);
|
||||
// roiFrame = new PImage(roiWidth, roiHeight);
|
||||
// break;
|
||||
//
|
||||
// /* Identify Euglena in a certain portion of the camera feed */
|
||||
// void countEuglena() {
|
||||
// roiFrame = get(roiCornerX, roiCornerY, roiWidth, roiHeight); // Get pixels of interest and saves as image for valid image path
|
||||
// opencv.loadImage(roiFrame); // Input proper pixels into cv processing
|
||||
// opencv.updateBackground(); //Necessary for background subtraction
|
||||
// opencv.useGray(); //Create grayscale image
|
||||
// opencv.dilate(); //Clean up image
|
||||
// opencv.erode();
|
||||
// opencv.blur(3);
|
||||
// dst = opencv.getOutput(); //Save computer vision as separate image path
|
||||
// contours = opencv.findContours(); //Find outline of moving objects - euglena
|
||||
// euglenaCount = contours.size(); // Count number of outlines
|
||||
// }
|
||||
//
|
||||
// void reset() {
|
||||
// timeInitial = millis();
|
||||
// timeElapsed = 0;
|
||||
// identifyEuglena();
|
||||
// euglenaCountInitial = euglenaCount;
|
||||
// }
|
||||
//
|
||||
// ClearScreen(targetReduction){
|
||||
// this.reset();
|
||||
// }
|
||||
//
|
||||
// void mouseClicked(float x, float y){
|
||||
// if (!point1complete){
|
||||
// lineinprogress.x1 = x;
|
||||
// lineinprogress.y1 = y;
|
||||
// point1complete = true;
|
||||
// } else {
|
||||
// lineinprogress.x2 = x;
|
||||
// lineinprogress.y2 = y;
|
||||
// lineinprogress.visible = true;
|
||||
// lines.add(lineinprogress);
|
||||
//
|
||||
// lineinprogress.draw();
|
||||
// this.reset();
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
12
src/oldfiles/angleGather.java
Normal file
12
src/oldfiles/angleGather.java
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
void angleGather(float x, float y, float angle, float armLength) {
|
||||
arduino.digitalWrite(right, arduino.HIGH);
|
||||
|
||||
noFill();
|
||||
strokeWeight(20); // Controls thickness of blue border
|
||||
stroke(color(0, 0, 127));
|
||||
beginShape(); // Draws shape
|
||||
vertex(convertXCoord(x + armLength*cos(angle*PI/360)), convertYCoord(y + armLength*sin(angle*PI/360)));
|
||||
vertex(convertXCoord(x), convertYCoord(y));
|
||||
vertex(convertXCoord(x + armLength*cos(angle*PI/360)), convertYCoord(y - armLength*sin(angle*PI/360)));
|
||||
endShape();
|
||||
}
|
||||
26
src/oldfiles/angleMove.java
Normal file
26
src/oldfiles/angleMove.java
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
float speed;
|
||||
float x_current = 0;
|
||||
|
||||
void angleMove(float x, float y, float angle, float armLength, float speed) {
|
||||
clearDisplay();
|
||||
arduino.digitalWrite(right, arduino.HIGH);
|
||||
|
||||
noFill();
|
||||
strokeWeight(20); // Controls thickness of blue border
|
||||
stroke(color(0, 0, 255));
|
||||
|
||||
beginShape(); // Draws shape
|
||||
vertex(convertXCoord(x - x_current + armLength*cos(angle*PI/360)), convertYCoord(y + armLength*sin(angle*PI/360)));
|
||||
vertex(convertXCoord(x - x_current), convertYCoord(y));
|
||||
vertex(convertXCoord(x - x_current + armLength*cos(angle*PI/360)), convertYCoord(y - armLength*sin(angle*PI/360)));
|
||||
endShape(CLOSE);
|
||||
|
||||
|
||||
if (x_current < displayWidth-menu.width){
|
||||
x_current = x_current + 1*speed;
|
||||
} else {
|
||||
x_current = 0;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
10
src/oldfiles/circleArrayStim.java
Normal file
10
src/oldfiles/circleArrayStim.java
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
void circleArrayStim(float leftCornerX, float leftCornerY, int rows, int columns, int diameter, float space){
|
||||
for (int rowNum = 0; rowNum < rows; rowNum ++){
|
||||
for (int colNum = 0; colNum < columns; colNum++){
|
||||
fill(color(0,20,0));
|
||||
ellipseMode(CENTER);
|
||||
ellipse(convertXCoord(leftCornerX) + colNum*(diameter+space),
|
||||
convertYCoord(leftCornerY) + rowNum*(diameter+space), diameter, diameter);
|
||||
}
|
||||
}
|
||||
}
|
||||
79
src/oldfiles/clearScreen.java
Normal file
79
src/oldfiles/clearScreen.java
Normal file
|
|
@ -0,0 +1,79 @@
|
|||
//class ClearScreen {
|
||||
//
|
||||
// int timeElapsed, timeCurrent, timeInitial, euglenaCountInitial, euglenaCount, roiCornerX, roiCornerY, roiWidth, roiHeight;
|
||||
// float euglenaReduction, targetReduction;
|
||||
//
|
||||
// opencv = new OpenCV(this, roiWidth, roiHeight);
|
||||
// opencv.startBackgroundSubtraction(7, 3, .35);
|
||||
// roiFrame = new PImage(roiWidth, roiHeight);
|
||||
// break;
|
||||
//
|
||||
// /* Identify Euglena in a certain portion of the camera feed */
|
||||
// void countEuglena() {
|
||||
// roiFrame = get(roiCornerX, roiCornerY, roiWidth, roiHeight); // Get pixels of interest and saves as image for valid image path
|
||||
// opencv.loadImage(roiFrame); // Input proper pixels into cv processing
|
||||
// opencv.updateBackground(); //Necessary for background subtraction
|
||||
// opencv.useGray(); //Create grayscale image
|
||||
// opencv.dilate(); //Clean up image
|
||||
// opencv.erode();
|
||||
// opencv.blur(3);
|
||||
// dst = opencv.getOutput(); //Save computer vision as separate image path
|
||||
// contours = opencv.findContours(); //Find outline of moving objects - euglena
|
||||
// euglenaCount = contours.size(); // Count number of outlines
|
||||
// }
|
||||
//
|
||||
// void reset() {
|
||||
// timeInitial = millis();
|
||||
// timeElapsed = 0;
|
||||
// identifyEuglena();
|
||||
// euglenaCountInitial = euglenaCount;
|
||||
// }
|
||||
//
|
||||
// ClearScreen(targetReduction){
|
||||
// this.reset();
|
||||
// }
|
||||
//
|
||||
// void mouseClicked(float x, float y){
|
||||
// if (!point1complete){
|
||||
// lineinprogress.x1 = x;
|
||||
// lineinprogress.y1 = y;
|
||||
// point1complete = true;
|
||||
// } else {
|
||||
// lineinprogress.x2 = x;
|
||||
// lineinprogress.y2 = y;
|
||||
// lineinprogress.visible = true;
|
||||
// lines.add(lineinprogress);
|
||||
//
|
||||
// lineinprogress.draw();
|
||||
// this.reset();
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
|
||||
void clearScreen(){
|
||||
clearDisplay();
|
||||
arduino.digitalWrite(left, arduino.HIGH);
|
||||
leftArrow = 204;
|
||||
|
||||
noFill();
|
||||
strokeWeight(15); // Controls thickness of blue border
|
||||
stroke(color(0, 0, 255));
|
||||
|
||||
if (t<10000){
|
||||
beginShape(); // Draws shape
|
||||
vertex(convertXCoord(1200), convertYCoord(200));
|
||||
vertex(convertXCoord(500), convertYCoord(200));
|
||||
vertex(convertXCoord(500), convertYCoord(800));
|
||||
vertex(convertXCoord(1200), convertYCoord(800));
|
||||
endShape();
|
||||
|
||||
t=t+1;
|
||||
} else {
|
||||
beginShape();
|
||||
vertex(convertXCoord(1200), convertYCoord(200));
|
||||
vertex(convertXCoord(500), convertYCoord(200));
|
||||
vertex(convertXCoord(500), convertYCoord(800));
|
||||
vertex(convertXCoord(1200), convertYCoord(800));
|
||||
endShape(CLOSE);
|
||||
}
|
||||
}
|
||||
8
src/oldfiles/colorScreen.java
Normal file
8
src/oldfiles/colorScreen.java
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
void colorScreen() {
|
||||
// second monitor
|
||||
fill(20,20,20);//(stimulusColor*0.7, stimulusColor*0.55,0);
|
||||
noStroke();
|
||||
rectMode(CORNER);
|
||||
rect(displayWidth,0,displayWidth*4,displayHeight-10);
|
||||
}
|
||||
|
||||
299
src/oldfiles/developer.java
Normal file
299
src/oldfiles/developer.java
Normal file
|
|
@ -0,0 +1,299 @@
|
|||
////////////// All code below pertains to functionality that has no clear use yet. ////////////////////////////////////////////
|
||||
|
||||
/* Menu screen allows user to determine what type of interaction
|
||||
they want with the euglena */
|
||||
|
||||
/*
|
||||
void menu(String button1, String button2, String button3, String button4) {
|
||||
strokeWeight(2);
|
||||
stroke(50);
|
||||
textSize(24);
|
||||
|
||||
//Back Button
|
||||
fill(180);
|
||||
ellipse ((displayWidth - menu.width)/2 - sizeButton*5.5, displayHeight/2 - sizeButton, sizeButton*2, sizeButton*2);
|
||||
fill(50);
|
||||
text(button1, (displayWidth - menu.width)/2 - sizeButton*5, displayHeight/2 + 10);
|
||||
|
||||
//ledSequence
|
||||
fill(180);
|
||||
ellipse((displayWidth - menu.width)/2 - sizeButton*2.5, displayHeight/2 - sizeButton, sizeButton*2, sizeButton*2);
|
||||
fill(50);
|
||||
text(button2, (displayWidth - menu.width)/2 - sizeButton*2.5 + sizeButton/2, displayHeight/2 + 10);
|
||||
|
||||
//limitedPaint
|
||||
fill(180);
|
||||
ellipse((displayWidth - menu.width)/2 + sizeButton/2, displayHeight/2 - sizeButton, sizeButton*2, sizeButton*2);
|
||||
fill(50);
|
||||
text(button3, (displayWidth - menu.width)/2 + sizeButton*1, displayHeight/2 + 10);
|
||||
|
||||
//levelDeveloper
|
||||
fill(180);
|
||||
ellipse((displayWidth - menu.width)/2 + sizeButton*3.5, displayHeight/2 -sizeButton, sizeButton*2, sizeButton*2);
|
||||
fill(50);
|
||||
text(button4, (displayWidth - menu.width)/2 + sizeButton*4, displayHeight/2 + 10);
|
||||
}
|
||||
|
||||
void store(int num) {
|
||||
if(startSession == 2) ledDirections.append(num);
|
||||
if(startSession == 4) storedLED.append(num);
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
/* Controls at what stage of LED activity the program is in */
|
||||
/*
|
||||
void ledSequence() {
|
||||
switch(ledSession) {
|
||||
case 0 : // Choose sequence
|
||||
initLed();
|
||||
break;
|
||||
case 1 : // Turn on and off LED's in proper sequence for proper duration
|
||||
runLed();
|
||||
break;
|
||||
case 2 :
|
||||
endLed(); // Resets all variables used
|
||||
break;
|
||||
default : //Doodle
|
||||
startSession = 5;
|
||||
break;
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
/* Allows user to choose a certain number of LED's
|
||||
to run in sequence */
|
||||
/*
|
||||
void initLed() {
|
||||
strokeWeight(2);
|
||||
stroke(50);
|
||||
|
||||
//DOWN Button
|
||||
fill(180);
|
||||
ellipse((displayWidth - menu.width)/2, displayHeight/2 + sizeButton * 1.5, sizeButton, sizeButton);
|
||||
fill(50);
|
||||
textSize(17);
|
||||
text("DOWN", (displayWidth - menu.width)/2 + 3, displayHeight/2 + sizeButton * 1.5 + sizeButton/2 + 5);
|
||||
|
||||
//UP Button
|
||||
fill(180);
|
||||
ellipse((displayWidth - menu.width)/2, displayHeight/2 - sizeButton * 1.5, sizeButton, sizeButton);
|
||||
fill(50);
|
||||
textSize(18);
|
||||
text("UP", (displayWidth - menu.width)/2 + 18, displayHeight/2 - sizeButton * 1.5 + sizeButton/2 + 5);
|
||||
|
||||
//LEFT Button
|
||||
fill(180);
|
||||
ellipse((displayWidth - menu.width)/2 - sizeButton * 1.5, displayHeight/2, sizeButton, sizeButton);
|
||||
fill(50);
|
||||
textSize(18);
|
||||
text("LEFT", (displayWidth - menu.width)/2 - sizeButton * 1.5 + 10, displayHeight/2 + sizeButton/2 + 5);
|
||||
|
||||
//RIGHT Button
|
||||
fill(180);
|
||||
ellipse((displayWidth - menu.width)/2 + sizeButton * 1.5, displayHeight/2, sizeButton, sizeButton);
|
||||
fill(50);
|
||||
textSize(18);
|
||||
text("RIGHT", (displayWidth - menu.width)/2 + sizeButton * 1.5 + 5, displayHeight/2 + sizeButton/2 + 5);
|
||||
|
||||
if(startSession == 2) {
|
||||
//Load preset Level
|
||||
loadButton();
|
||||
|
||||
//Instructions
|
||||
textSize(56);
|
||||
text("Choose 3 directions to create LED sequence", 250, 100);
|
||||
|
||||
if (ledDirections.size() == ledLimit) { //Check to see if user has selected 3 directions
|
||||
ledSession = 1;
|
||||
ledTime = millis();
|
||||
}
|
||||
} else if (startSession == 4) {
|
||||
finishButton();
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
/* Turns on LED's for given amount of time */
|
||||
/*
|
||||
void runLed() {
|
||||
if (load) {
|
||||
ledOn(tempLED);
|
||||
} else {
|
||||
ledOn(ledDirections);
|
||||
}
|
||||
}
|
||||
|
||||
void ledOn(IntList LED) {
|
||||
if (LED.size() > 0) {
|
||||
println(LED.get(0));
|
||||
arduino.digitalWrite(LED.get(0), Arduino.HIGH); // Turns on first led in sequence
|
||||
if (millis() - ledTime >= ledDelay) { // checks that time on has been met
|
||||
arduino.digitalWrite(LED.get(0), Arduino.LOW); // Turns of led after given amount of time
|
||||
LED.remove(0);
|
||||
ledTime = millis();
|
||||
}
|
||||
} else {
|
||||
ledSession = 2; // Move to next section of activty - end
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
/* Reset used variables for future use */
|
||||
/*
|
||||
void endLed() {
|
||||
ledSession = 0;
|
||||
startSession = 5;
|
||||
load = false;
|
||||
}
|
||||
*/
|
||||
|
||||
/* Activity in which users have limited amounts of paint to accomplish goal */
|
||||
/*
|
||||
void limitedPaint() {
|
||||
switch (paintSession) {
|
||||
case 0 :
|
||||
initPaint(); // Allows user option to load preset level or draw on their own
|
||||
break;
|
||||
case 1 :
|
||||
runPaint(); // Loads preset level
|
||||
break;
|
||||
case 2 :
|
||||
endPaint(); // Resets used variables
|
||||
break;
|
||||
default : // Doodle
|
||||
startSession = 5;
|
||||
break;
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
/* Draws appropriate buttons on screen, free draw still allowed */
|
||||
/*
|
||||
void initPaint() {
|
||||
if (startSession == 3) loadButton();
|
||||
finishButton();
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
/* Loads preset level */
|
||||
/*
|
||||
void runPaint() {
|
||||
if(load) {
|
||||
for(int i = 0; i < storedColor.size(); i++) {
|
||||
stroke(colorList[storedColor.get(i)]);
|
||||
strokeWeight(storedPenWidth.get(i));
|
||||
point(storedXCoord.get(i), storedYCoord.get(i));
|
||||
}
|
||||
}
|
||||
finishButton();
|
||||
}
|
||||
*/
|
||||
|
||||
/* Resets used variables */
|
||||
/*
|
||||
void endPaint() {
|
||||
load = false;
|
||||
paintLimit.clear();
|
||||
clearDisplay();
|
||||
paintSession = 0;
|
||||
startSession = 5;
|
||||
}
|
||||
*/
|
||||
|
||||
/* Allows users to create and store doodles and LED sequences */
|
||||
/*
|
||||
void levelDeveloper() {
|
||||
switch(levelSession) {
|
||||
case 0 :
|
||||
finishDeveloper(); // Resets used variables
|
||||
break;
|
||||
case 1 :
|
||||
initLevelDeveloper(); // Choose what type of level
|
||||
break;
|
||||
case 2 :
|
||||
createPaintLevel(); // Allows users to draw and save their doodle
|
||||
break;
|
||||
case 3 :
|
||||
createLEDLevel(); // Allows users t select and save their led sequence
|
||||
break;
|
||||
default :
|
||||
startSession = 5; // doodle
|
||||
break;
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
/* Two buttons for user to select what type of level to create */
|
||||
/*
|
||||
void initLevelDeveloper() {
|
||||
storedColor.clear();
|
||||
storedXCoord.clear();
|
||||
storedYCoord.clear();
|
||||
storedPenWidth.clear();
|
||||
storedLED.clear();
|
||||
|
||||
strokeWeight(2);
|
||||
stroke(50);
|
||||
|
||||
// LED level
|
||||
fill(180);
|
||||
ellipse((displayWidth - menu.width)/2 - sizeButton*3, displayHeight/2 - sizeButton, sizeButton*2, sizeButton*2);
|
||||
fill(50);
|
||||
textSize(24);
|
||||
text("LED",(displayWidth - menu.width)/2 - sizeButton*2.5, displayHeight/2 + 5);
|
||||
|
||||
// Paint Level
|
||||
fill(180);
|
||||
ellipse((displayWidth - menu.width)/2 + sizeButton, displayHeight/2 - sizeButton, sizeButton*2, sizeButton*2);
|
||||
fill(50);
|
||||
textSize(24);
|
||||
text("Paint",(displayWidth - menu.width)/2 + sizeButton*1.5, displayHeight/2 + 5);
|
||||
}
|
||||
*/
|
||||
|
||||
/* Button to indicate level creation is ifnished */
|
||||
/*
|
||||
void finishButton() {
|
||||
fill(180);
|
||||
ellipse((displayWidth - menu.width) - sizeButton - 5, 5, sizeButton, sizeButton);
|
||||
fill(50);
|
||||
textSize(18);
|
||||
text("Finish", (displayWidth-menu.width) - sizeButton , sizeButton/2 + 10);
|
||||
}
|
||||
*/
|
||||
|
||||
/* Loads appropriate precreated level */
|
||||
/*
|
||||
void loadButton() {
|
||||
fill(180);
|
||||
ellipse((displayWidth - menu.width) - sizeButton - 5, displayHeight - sizeButton*2 , sizeButton, sizeButton);
|
||||
fill(50);
|
||||
textSize(18);
|
||||
text("Load", (displayWidth - menu.width) - sizeButton, displayHeight - sizeButton * 1.5 + 5);
|
||||
}
|
||||
*/
|
||||
|
||||
/* Reset used variables */
|
||||
/*
|
||||
void finishDeveloper() {
|
||||
clearDisplay();
|
||||
startSession = 5;
|
||||
levelSession = 1;
|
||||
}
|
||||
*/
|
||||
|
||||
/* Clears containers for new use only one level can be stored at a time */
|
||||
/*
|
||||
void createPaintLevel() {
|
||||
initPaint();
|
||||
}
|
||||
*/
|
||||
/* Clears containers for new use only one level can be stored at a time */
|
||||
/*
|
||||
void createLEDLevel() {
|
||||
initLed();
|
||||
}
|
||||
*/
|
||||
143
src/oldfiles/euglena_basic_stimuli.java
Normal file
143
src/oldfiles/euglena_basic_stimuli.java
Normal file
|
|
@ -0,0 +1,143 @@
|
|||
import org.firmata.*;
|
||||
import gab.opencv.*;
|
||||
import processing.video.*;
|
||||
import processing.serial.*;
|
||||
import cc.arduino.*;
|
||||
import controlP5.*;
|
||||
|
||||
OpenCV opencv; // One opencv object needed per region of interest with unique dimension
|
||||
|
||||
/* CONSTANTS */
|
||||
/////////////////// Program Controls
|
||||
final long ledDelay = 5000; // Duration of light from LED during LED sequence
|
||||
final int recordDelay = 0; // Time delay befoe taking next xcoord in case of lag
|
||||
final int paintSize = 100; // Number of xcoord taken in limited paint activity
|
||||
|
||||
|
||||
//////////////////// Image Processing for doodle exploration
|
||||
final int roiWidth = 500; // Width of ROI
|
||||
final int roiHeight = 500; // Height of region of interest
|
||||
final int roiCornerX = 610;
|
||||
final int roiCornerY = 290;
|
||||
|
||||
|
||||
/* Global Variables */
|
||||
///////////////// Miscellaneaous Variables
|
||||
boolean load = false; // Boolean to determine if user wants to load previously saved led sequences or paint
|
||||
long ledTime; // Temporary time storage used to keep LED's on for certain period of time
|
||||
long paintTime; // Temporary time storage used to determine when paint "runs out"
|
||||
|
||||
////////////////// Image Processing Variables
|
||||
boolean showcv = false; // Show image tracking during doodle mode
|
||||
PImage roiFrame; // Region of interest
|
||||
PImage dst; // Backend computer vision
|
||||
ArrayList<Contour> contours; // Stores outlines of moving objects within region of interest
|
||||
int count; // Equivalent to number of outline
|
||||
|
||||
///////////////////////// Color Variables
|
||||
int iColor=0;//current color
|
||||
|
||||
float lagTime = 1;
|
||||
int totalTime = 15000;
|
||||
|
||||
|
||||
//////////////////// Storage Variables
|
||||
IntList paintLimit = new IntList(); // Stores finite limit of XCoord of points drawn. Once limit is reached "drawing" is stopped
|
||||
IntList ledDirections = new IntList(); // Stores a certain number of LED pins in the order they will be turned on
|
||||
IntList storedColor = new IntList(); // Stores color of each point
|
||||
FloatList storedXCoord = new FloatList(); // Stores x-coordinate of each point
|
||||
FloatList storedYCoord = new FloatList(); // Stores y-coordinate of each point
|
||||
IntList storedPenWidth = new IntList(); // Stores stroke weight of each point
|
||||
IntList storedLED = new IntList(); // Stores ledPin numbers
|
||||
IntList tempLED = new IntList(); // Duplicates storedLED so the intList can be called again and again without losing any data points
|
||||
|
||||
|
||||
////////////////////// Game Variables
|
||||
// Image processing of goal regions in game
|
||||
ArrayList<Contour> plusContours; // Stores outlines of moving objects
|
||||
ArrayList<Contour> minusContours;
|
||||
ArrayList<Contour> euglenaCount;
|
||||
PImage o1; // Backend computer vision to make sure image is being processed correctly
|
||||
PImage o2;
|
||||
PImage o3;
|
||||
PImage goal1; // Region of interest
|
||||
PImage goal2;
|
||||
PImage gameScreen;
|
||||
PImage entireScreen;
|
||||
PImage cvscreen;
|
||||
|
||||
static float densityThreshold = 6;
|
||||
boolean densityMeasured = false;
|
||||
|
||||
FloatList fadeXCoord = new FloatList(); // Stores x-coordinate of each point
|
||||
FloatList fadeYCoord = new FloatList();
|
||||
|
||||
|
||||
void setup() {
|
||||
count = 1;
|
||||
totalCount = 1;
|
||||
background(200);
|
||||
|
||||
smooth();
|
||||
|
||||
clearDisplay();
|
||||
}
|
||||
|
||||
/* Runs contionous display of mouse in the background; keeps
|
||||
track of what mode app is in and where mouse is on the screen */
|
||||
void draw() {
|
||||
|
||||
if (showcv) { // Show image tracking when CTRL is pressed
|
||||
identifyEuglena();
|
||||
showCV();
|
||||
}
|
||||
|
||||
recordTimelapse(lagTime, totalTime); //Note: the maximum fps is around 5
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*Uses keys to create uniform movement in the Euglena by turniing LEDs on
|
||||
and off with standard directional keys. It also allows calibration of
|
||||
the projectorApplet field of view */
|
||||
|
||||
void keyPressed() {
|
||||
|
||||
case CONTROL:
|
||||
if(showcv) showcv = false;
|
||||
else showcv = true;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
} else if (startSession != 7 && startSession != 9) {
|
||||
|
||||
// Control LED with standard directional keys
|
||||
switch(key) {
|
||||
|
||||
case ENTER: // Takes a snapshot of the FOV
|
||||
snapshot();
|
||||
break;
|
||||
|
||||
case 'r': // Toggles between recording timelapse and not recording
|
||||
record = !record;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Listens for user dragging mouse and draws points of appropriate
|
||||
color and width on the screen */
|
||||
void mouseDragged() {
|
||||
if(mouseX < displayWidth-menu.width){ // Determines if mouse is in drawing area
|
||||
stroke(color(rVal, gVal, bVal)); // Sets pent to current color
|
||||
strokeWeight(penWidth); // Sets pen to current Width
|
||||
|
||||
point(convertXCoord(mouseX), convertYCoord(mouseY)); // Moves points on to second monitor with correct sizing
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
40
src/oldfiles/gradientWindow.java
Normal file
40
src/oldfiles/gradientWindow.java
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
void gradientWindow(float minR, float minG, float minB, float maxR, float maxG, float maxB, float winSizeY){
|
||||
|
||||
float stepR = (maxR-minR)/(centerY-(winSizeY/2));
|
||||
float stepG = (maxG-minG)/(centerY-(winSizeY/2));
|
||||
float stepB = (maxB-minB)/(centerY-(winSizeY/2));
|
||||
float winSizeX = (winSizeY/centerY)*centerX;
|
||||
|
||||
for (int x_pix = 0; x_pix < 2*centerX; x_pix ++){
|
||||
for (int y_pix = 0; y_pix < 2*centerY; y_pix ++){
|
||||
//Defines a rectagular window and gradient
|
||||
if (abs(x_pix-centerX) >= abs(y_pix-centerY)) {
|
||||
color c = color(0,0,round(abs(x_pix-centerX)-(winSizeX/2)*stepB));
|
||||
/*color(round(abs(x_pix-centerX)-(winSizeX/2)*stepR),
|
||||
round(abs(x_pix-centerX)-(winSizeX/2)*stepG),
|
||||
round(abs(x_pix-centerX)-(winSizeX/2)*stepB));
|
||||
*/
|
||||
set(round(convertXCoord(x_pix)), round(convertYCoord(y_pix)), c);
|
||||
|
||||
} else {
|
||||
color c = color(0,0,round(abs(y_pix-centerY)-(winSizeY/2)*stepB));
|
||||
/*color(round(abs(y_pix-centerY)-(winSizeY/2)*stepR),
|
||||
round(abs(y_pix-centerY)-(winSizeY/2)*stepG),
|
||||
round(abs(y_pix-centerY)-(winSizeY/2)*stepB));
|
||||
*/
|
||||
set(round(convertXCoord(x_pix)), round(convertYCoord(y_pix)), c);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
//Defines a circular window and gradient
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
11
src/oldfiles/heatup.java
Normal file
11
src/oldfiles/heatup.java
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
void heatup(LEDController leds){
|
||||
if (t < 60) {
|
||||
leds.allOn();
|
||||
} else {
|
||||
leds.allOff();
|
||||
}
|
||||
|
||||
t_temp = t_temp + 1;
|
||||
t = t_temp / framerate;
|
||||
}
|
||||
|
||||
14
src/oldfiles/identifyEuglena.java
Normal file
14
src/oldfiles/identifyEuglena.java
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
/* Identify Euglena in a certain portion of the camera feed */
|
||||
void identifyEuglena() {
|
||||
roiFrame = get(610, 290, roiWidth, roiHeight); // Get pixels of interest and saves as image for valid image path
|
||||
opencv.loadImage(roiFrame); // Input proper pixels into cv processing
|
||||
opencv.updateBackground(); //Necessary for background subtraction
|
||||
opencv.useGray(); //Create grayscale image
|
||||
opencv.dilate(); //Clean up image
|
||||
opencv.erode();
|
||||
opencv.blur(3);
|
||||
dst = opencv.getOutput(); //Save computer vision as separate image path
|
||||
contours = opencv.findContours(); //Find outline of moving objects - euglena
|
||||
count = contours.size(); // Count number of outlines
|
||||
}
|
||||
|
||||
26
src/oldfiles/lineRotate.java
Normal file
26
src/oldfiles/lineRotate.java
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
float rotAngle = 0;
|
||||
|
||||
void lineRotate(float armLength, float speed){
|
||||
clearDisplay();
|
||||
|
||||
strokeWeight(10); // Controls thickness of line
|
||||
stroke(color(0, 0, 255));
|
||||
|
||||
fill(0,0,0);
|
||||
|
||||
if ((screenWidth - menu.width)/calibrator.magx - t > 2*armLength){
|
||||
ellipseMode(CENTER);
|
||||
ellipse(convertXCoord(centerX), convertYCoord(centerY),
|
||||
(screenWidth - menu.width)/calibrator.magx - t, (screenWidth - menu.width)/calibrator.magx - t);
|
||||
|
||||
t = t + speed;
|
||||
|
||||
} else {
|
||||
ellipseMode(CENTER);
|
||||
ellipse(convertXCoord(centerX), convertYCoord(centerY), 2*armLength, 2*armLength);
|
||||
line(convertXCoord(centerX), convertYCoord(centerY),
|
||||
convertXCoord(centerX) + armLength*cos(rotAngle*PI/180), convertYCoord(centerY) + armLength*sin(rotAngle*PI/180));
|
||||
|
||||
rotAngle = rotAngle + speed;
|
||||
}
|
||||
}
|
||||
63
src/oldfiles/merge.java
Normal file
63
src/oldfiles/merge.java
Normal file
|
|
@ -0,0 +1,63 @@
|
|||
float t3;
|
||||
|
||||
void merge(float speed){
|
||||
|
||||
|
||||
|
||||
if ((screenWidth - menu.width)/calibrator.magx - t > 60){
|
||||
clearDisplay();
|
||||
fill(0,0,0);
|
||||
strokeWeight(10); // Controls thickness of line
|
||||
stroke(color(0, 0, 255));
|
||||
ellipseMode(CENTER);
|
||||
|
||||
ellipse(convertXCoord(centerX), convertYCoord(centerY),
|
||||
(screenWidth - menu.width)/calibrator.magx - t, (screenWidth - menu.width)/calibrator.magx - t);
|
||||
|
||||
t = t + speed*1;
|
||||
|
||||
} else {
|
||||
|
||||
if (convertXCoord(centerX) - t2 > convertXCoord(250)){
|
||||
clearDisplay();
|
||||
fill(0,0,0);
|
||||
strokeWeight(10); // Controls thickness of line
|
||||
stroke(color(0, 0, 255));
|
||||
ellipseMode(CENTER);
|
||||
|
||||
arc(convertXCoord(centerX) - t2, convertYCoord(centerY),
|
||||
(screenWidth - menu.width)/calibrator.magx - t, (screenWidth - menu.width)/calibrator.magx - t,
|
||||
PI/2, 3*PI/2, CHORD);
|
||||
arc(convertXCoord(centerX) + t2, convertYCoord(centerY),
|
||||
(screenWidth - menu.width)/calibrator.magx - t, (screenWidth - menu.width)/calibrator.magx - t,
|
||||
-PI/2, PI/2, CHORD);
|
||||
|
||||
t2 = t2 + speed*0.05;
|
||||
|
||||
} else {
|
||||
|
||||
if (t2 >= t3){
|
||||
clearDisplay();
|
||||
fill(0,0,0);
|
||||
strokeWeight(10); // Controls thickness of line
|
||||
stroke(color(0, 0, 255));
|
||||
ellipseMode(CENTER);
|
||||
|
||||
arc(convertXCoord(centerX) - t2 + t3, convertYCoord(centerY),
|
||||
(screenWidth - menu.width)/calibrator.magx - t, (screenWidth - menu.width)/calibrator.magx - t,
|
||||
PI/2, 3*PI/2, CHORD);
|
||||
arc(convertXCoord(centerX) + t2 - t3, convertYCoord(centerY),
|
||||
(screenWidth - menu.width)/calibrator.magx - t, (screenWidth - menu.width)/calibrator.magx - t,
|
||||
-PI/2, PI/2, CHORD);
|
||||
|
||||
t3 = t3 + speed*0.05; //follow the white rabbit amy ??
|
||||
|
||||
} else {
|
||||
|
||||
ellipse(convertXCoord(centerX), convertYCoord(centerY),
|
||||
(screenWidth - menu.width)/calibrator.magx - t, (screenWidth - menu.width)/calibrator.magx - t);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
76
src/oldfiles/objDensity.java
Normal file
76
src/oldfiles/objDensity.java
Normal file
|
|
@ -0,0 +1,76 @@
|
|||
void densityMeasure(int x, int y, int gameScreenWidth, int gameScreenHeight) {
|
||||
switch (densitySession) {
|
||||
case 0:
|
||||
densityMeasureTotalScreen();
|
||||
break;
|
||||
case 1:
|
||||
densityMeasureROI(x, y, gameScreenWidth, gameScreenHeight);
|
||||
break;
|
||||
case 2:
|
||||
calculatePercentDensity();
|
||||
break;
|
||||
default :
|
||||
startSession = 5;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void densityMeasureTotalScreen() {
|
||||
// text("Whole Screen", 300, 600);
|
||||
if (millis() - densityTSTime <= 2000) {
|
||||
entireScreen = get(0, 0, screenWidth, screenHeight); // Get pixels of interest and saves as image for valid image path
|
||||
opencv5.loadImage(entireScreen); // Input proper pixels into cv processing
|
||||
opencv5.updateBackground(); //Necessary for background subtraction
|
||||
opencv5.useGray(); //Create grayscale image
|
||||
opencv5.dilate(); //Clean up image
|
||||
opencv5.erode();
|
||||
opencv5.blur(3);
|
||||
cvscreen = opencv5.getOutput(); //Save computer vision as separate image path
|
||||
euglenaCount = opencv5.findContours(); //Find outline of moving objects - euglena
|
||||
totalCount = euglenaCount.size();
|
||||
} else {
|
||||
densityROITime = millis();
|
||||
densitySession = 1;
|
||||
}
|
||||
}
|
||||
|
||||
void densityMeasureROI(int x, int y, int gameScreenWidth, int gameScreenHeight) {
|
||||
// text("Region of Interest", 300, 600);
|
||||
if (millis() - densityROITime <= 2000) {
|
||||
gameScreen = get(x, y, gameScreenWidth, gameScreenHeight); // Get pixels of interest and saves as image for valid image path
|
||||
opencv4.loadImage(gameScreen); // Input proper pixels into cv processing
|
||||
opencv4.updateBackground(); //Necessary for background subtraction
|
||||
opencv4.useGray(); //Create grayscale image
|
||||
opencv4.dilate(); //Clean up image
|
||||
opencv4.erode();
|
||||
opencv4.blur(3);
|
||||
o3 = opencv4.getOutput(); //Save computer vision as separate image path
|
||||
//image(o3, x - gameScreenWidth, y);
|
||||
contours = opencv4.findContours(); //Find outline of moving objects - euglena
|
||||
count = contours.size();
|
||||
} else {
|
||||
displayDensityTime = millis();
|
||||
densitySession = 2;
|
||||
}
|
||||
}
|
||||
|
||||
void calculatePercentDensity() {
|
||||
// if (millis() - displayDensityTime <= 4000) {
|
||||
// text(count + " " + totalCount, 600, 900);
|
||||
// delay(1000);
|
||||
percentDensity = ((float)count/ (float)totalCount)*100;
|
||||
densityMeasured = true;
|
||||
// } else {
|
||||
// densityTSTime = millis();
|
||||
densitySession = 0;
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
void displayDensity() {
|
||||
if(percentDensity != 0) {
|
||||
textSize(56);
|
||||
fill(color(180, 0, 0));
|
||||
text("% Density: " + percentDensity, 100, 100);
|
||||
}
|
||||
}
|
||||
43
src/oldfiles/proto488flashraster.java
Normal file
43
src/oldfiles/proto488flashraster.java
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
int x_f = screenWidth;
|
||||
int y_f = 0;
|
||||
int t_raster = 0;
|
||||
int x = 0;
|
||||
int y = 0;
|
||||
int framerate = 30;
|
||||
int num_blinks = 3;
|
||||
int blinktime = 2 * framerate * num_blinks;
|
||||
int xstep = 50;
|
||||
int ystep = 50;
|
||||
int xsize = xstep;
|
||||
int ysize = ystep;
|
||||
|
||||
|
||||
void proto488flashraster(int x_i, int y_i, int rasterWidth, int rasterHeight){
|
||||
//clearDisplay();
|
||||
|
||||
color draw_color;
|
||||
float draw_size_factor;
|
||||
if ((t_raster % (2*framerate) > framerate) || (t_raster % (2*framerate) == 0)) {
|
||||
draw_color = color(bgR,bgG,bgB); //Background color
|
||||
draw_size_factor = 1.1;
|
||||
} else {
|
||||
draw_color = color(0,247,255);
|
||||
draw_size_factor = 1.0;
|
||||
}
|
||||
|
||||
fill(draw_color);
|
||||
noStroke();
|
||||
rectMode(CENTER);
|
||||
rect(convertXCoord(x_f), convertYCoord(y_f), xsize/calibrator.magx * draw_size_factor, ysize/calibrator.magy * draw_size_factor);
|
||||
|
||||
t_raster = t_raster + 1;
|
||||
x = x + xstep * (t_raster / blinktime);
|
||||
x_f = x_i + x;
|
||||
y = y + ystep * (x / rasterWidth);
|
||||
y_f = y_i + y;
|
||||
|
||||
t_raster = t_raster % blinktime;
|
||||
x = x % rasterWidth;
|
||||
y = y % rasterHeight;
|
||||
}
|
||||
|
||||
19
src/oldfiles/protoClear.java
Normal file
19
src/oldfiles/protoClear.java
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
/* ____ The area of interest is outlined is in blue and
|
||||
-> / a triangle is used as border to make sure euglena
|
||||
\____ are cleared out. The top coordinates of the top right
|
||||
x and y and width and height can be passed as parameters
|
||||
*/
|
||||
void protoClear(float x, float y, float screenWidth, float screenHeight) {
|
||||
noFill();
|
||||
stroke(color(0, 0, 220));
|
||||
strokeWeight(5);
|
||||
beginShape();
|
||||
vertex(convertXCoord(x + screenWidth), convertYCoord(y));
|
||||
vertex(convertXCoord(x), convertYCoord(y));
|
||||
vertex(convertXCoord(x - menu.width), convertYCoord((y + y + screenHeight)/2));
|
||||
vertex(convertXCoord(x), convertYCoord(y + screenHeight));
|
||||
vertex(convertXCoord(x + screenWidth), convertYCoord(y + screenHeight));
|
||||
endShape();
|
||||
arduino.digitalWrite(left, Arduino.HIGH);
|
||||
}
|
||||
|
||||
33
src/oldfiles/protoGather.java
Normal file
33
src/oldfiles/protoGather.java
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
/*
|
||||
\__ Draws shape like this and activates arduino so that
|
||||
-> __| euglena stream into the opening. The top coordinates of the top right
|
||||
/ x and y and width and height of containment box can be passed as parameters
|
||||
After amount of time or (yet to be implemented) after number of euglena
|
||||
enter the box is closed
|
||||
*/
|
||||
float t_temp = 0;
|
||||
float t = 0;
|
||||
|
||||
|
||||
void protoGather(float x, float y, float boxWidth, float boxHeight) {
|
||||
noFill();
|
||||
strokeWeight(10); // Controls thickness of blue border
|
||||
stroke(color(0, 0, 220));
|
||||
beginShape(); // Draws shape
|
||||
vertex(convertXCoord(x - menu.width), displayHeight*calibrator.offsety+displayHeight/calibrator.magy-10);
|
||||
vertex(convertXCoord(x), convertYCoord(y));
|
||||
vertex(convertXCoord(x + boxWidth), convertYCoord(y));
|
||||
vertex(convertXCoord(x + boxWidth), convertYCoord(y + boxHeight));
|
||||
vertex(convertXCoord(x), convertYCoord(y + boxHeight));
|
||||
vertex(convertXCoord(x - menu.width), displayHeight*calibrator.offsety);
|
||||
endShape();
|
||||
|
||||
if (t < 180) {
|
||||
arduino.analogWrite(down, 64); // Turns on arduino light (can make ledPin into a parameter that is passed in)
|
||||
} else {
|
||||
arduino.analogWrite(down, 0);
|
||||
}
|
||||
|
||||
t_temp = t_temp + 1;
|
||||
t = t_temp / framerate;
|
||||
}
|
||||
30
src/oldfiles/randomLED.java
Normal file
30
src/oldfiles/randomLED.java
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
void randomLED(){
|
||||
float rNum = random(100);
|
||||
if (rNum < 25){
|
||||
arduino.digitalWrite(left, Arduino.HIGH);
|
||||
arduino.digitalWrite(right, Arduino.LOW);
|
||||
arduino.digitalWrite(up, Arduino.LOW);
|
||||
arduino.digitalWrite(down, Arduino.LOW);
|
||||
}
|
||||
|
||||
if (rNum >= 25 && rNum <50){
|
||||
arduino.digitalWrite(left, Arduino.LOW);
|
||||
arduino.digitalWrite(right, Arduino.HIGH);
|
||||
arduino.digitalWrite(up, Arduino.LOW);
|
||||
arduino.digitalWrite(down, Arduino.LOW);
|
||||
}
|
||||
|
||||
if (rNum >= 50 && rNum <75){
|
||||
arduino.digitalWrite(left, Arduino.LOW);
|
||||
arduino.digitalWrite(right, Arduino.LOW);
|
||||
arduino.digitalWrite(up, Arduino.HIGH);
|
||||
arduino.digitalWrite(down, Arduino.LOW);
|
||||
}
|
||||
|
||||
if (rNum >= 75 && rNum <100){
|
||||
arduino.digitalWrite(left, Arduino.LOW);
|
||||
arduino.digitalWrite(right, Arduino.LOW);
|
||||
arduino.digitalWrite(up, Arduino.LOW);
|
||||
arduino.digitalWrite(down, Arduino.HIGH);
|
||||
}
|
||||
}
|
||||
28
src/oldfiles/recordTimelapse.java
Normal file
28
src/oldfiles/recordTimelapse.java
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
int initMillis = 0;
|
||||
boolean record = false;
|
||||
int frameMillis = 0;
|
||||
|
||||
void recordTimelapse(float lagtime, float maxtime){
|
||||
// checks if record state is turned off
|
||||
if (record == false){
|
||||
initMillis = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
// records the milliseconds elapsed between program start and first frame taken
|
||||
if (initMillis == 0){
|
||||
initMillis = millis();
|
||||
}
|
||||
|
||||
// automatically turns off recording if maxtime has elapsed
|
||||
if (millis()-initMillis > maxtime*1000){
|
||||
record = false;
|
||||
return;
|
||||
}
|
||||
|
||||
// takes snapshot if enough time has elapsed since last frame was taken
|
||||
if ((millis()-frameMillis) >= lagtime*1000){
|
||||
snapshot();
|
||||
frameMillis = millis();
|
||||
}
|
||||
}
|
||||
30
src/oldfiles/rectangularStim.java
Normal file
30
src/oldfiles/rectangularStim.java
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
int stimTime = 0;
|
||||
|
||||
void rectangularStim(int intensity, int stimTime) {
|
||||
if (t%(4*stimTime) < stimTime) {
|
||||
arduino.analogWrite(down, intensity); // Turns on arduino light (can make ledPin into a parameter that is passed in)
|
||||
} else {
|
||||
arduino.analogWrite(down, 0);
|
||||
}
|
||||
|
||||
if (t%(4*stimTime) >= stimTime && t%(4*stimTime) < 2*stimTime) {
|
||||
arduino.analogWrite(left, intensity);
|
||||
} else {
|
||||
arduino.analogWrite(left, 0);
|
||||
}
|
||||
|
||||
if (t%(4*stimTime) >= 2*stimTime && t%(4*stimTime) < 3*stimTime){
|
||||
arduino.analogWrite(up, intensity);
|
||||
} else {
|
||||
arduino.analogWrite(up, 0);
|
||||
}
|
||||
|
||||
if (t%(4*stimTime) >= 3*stimTime && t%(4*stimTime) < 4*stimTime){
|
||||
arduino.analogWrite(right, intensity);
|
||||
} else {
|
||||
arduino.analogWrite(right, 0);
|
||||
}
|
||||
|
||||
t_temp = t_temp + 1;
|
||||
t = t_temp / FrameRate;
|
||||
}
|
||||
38
src/oldfiles/separate.java
Normal file
38
src/oldfiles/separate.java
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
float t2;
|
||||
|
||||
void separate(float speed){
|
||||
|
||||
|
||||
|
||||
if ((screenWidth - menu.width)/calibrator.magx - t > 60){
|
||||
clearDisplay();
|
||||
fill(0,0,0);
|
||||
strokeWeight(10); // Controls thickness of line
|
||||
stroke(color(0, 0, 255));
|
||||
ellipseMode(CENTER);
|
||||
|
||||
ellipse(convertXCoord(centerX), convertYCoord(centerY),
|
||||
(screenWidth - menu.width)/calibrator.magx - t, (screenWidth - menu.width)/calibrator.magx - t);
|
||||
|
||||
t = t + speed*1;
|
||||
|
||||
} else {
|
||||
|
||||
if (convertXCoord(centerX) - t2 > convertXCoord(250)){
|
||||
clearDisplay();
|
||||
fill(0,0,0);
|
||||
strokeWeight(10); // Controls thickness of line
|
||||
stroke(color(0, 0, 255));
|
||||
ellipseMode(CENTER);
|
||||
|
||||
arc(convertXCoord(centerX) - t2, convertYCoord(centerY),
|
||||
(screenWidth - menu.width)/calibrator.magx - t, (screenWidth - menu.width)/calibrator.magx - t,
|
||||
PI/2, 3*PI/2, CHORD);
|
||||
arc(convertXCoord(centerX) + t2, convertYCoord(centerY),
|
||||
(screenWidth - menu.width)/calibrator.magx - t, (screenWidth - menu.width)/calibrator.magx - t,
|
||||
-PI/2, PI/2, CHORD);
|
||||
|
||||
t2 = t2 + speed*0.01;
|
||||
}
|
||||
}
|
||||
}
|
||||
24
src/oldfiles/showCV.java
Normal file
24
src/oldfiles/showCV.java
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
/* Show backend computer vision for curious users */
|
||||
void showCV() {
|
||||
rectMode(CORNER);
|
||||
|
||||
stroke(100);
|
||||
noFill();
|
||||
rect(roiCornerX, roiCornerY, roiWidth, roiHeight); // Outlines region of interest
|
||||
|
||||
noFill();
|
||||
stroke(255, 0, 0);
|
||||
strokeWeight(3);
|
||||
for (Contour contour : contours) {
|
||||
beginShape();
|
||||
for (PVector p : contour.getPoints()) {
|
||||
vertex(p.x + roiCornerX, p.y + roiCornerY);
|
||||
}
|
||||
endShape(PConstants.CLOSE); // Draws outlines of moving objects
|
||||
}
|
||||
image(dst, roiCornerX + roiWidth, roiCornerY, roiWidth, roiHeight); // Displays backend cv
|
||||
textSize(56);
|
||||
text("Count: " + count, 300, 600); // COunts number of euglena in region of interest
|
||||
}
|
||||
|
||||
|
||||
50
src/oldfiles/shrinkingCircle.java
Normal file
50
src/oldfiles/shrinkingCircle.java
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
//class SlowConcentrate{
|
||||
//
|
||||
// float speed;
|
||||
// int centerX, centerY, red, green, blue, brushSize, t_init, t_last;
|
||||
// boolean accumulate, centerComplete;
|
||||
//
|
||||
// void reset(){
|
||||
// centerComplete = false;
|
||||
// t_init = millis();
|
||||
// }
|
||||
//
|
||||
// SlowConcentrate(int centerX, int centerY){
|
||||
//
|
||||
// this.centerX = centerX;
|
||||
// this.centerY = centerY;
|
||||
// this.speed = speedSet;
|
||||
// this.red = rVal;
|
||||
// this.green = gVal;
|
||||
// this.blue = bVal;
|
||||
// this.brushSize = penWidth;
|
||||
//
|
||||
// }
|
||||
//
|
||||
// void draw(){
|
||||
//
|
||||
// }
|
||||
//}
|
||||
|
||||
int t_circ_shrink_last = 0;
|
||||
int step = 0;
|
||||
float radius;
|
||||
|
||||
void shrinkingCircle(float speed, int red, int green, int blue, int borderWidth){
|
||||
clearDisplay();
|
||||
radius = (screenWidth - menu.width)/calibrator.magx - step;
|
||||
|
||||
if (radius > 25){
|
||||
if (millis() - t_circ_shrink_last > speed*1000){
|
||||
step = step + 1;
|
||||
|
||||
noFill();
|
||||
strokeWeight(borderWidth);
|
||||
stroke(color(red, green, blue));
|
||||
ellipseMode(CENTER);
|
||||
ellipse(convertXCoord(centerX), convertYCoord(centerY), radius, radius);
|
||||
|
||||
t_circ_shrink_last = millis();
|
||||
}
|
||||
}
|
||||
}
|
||||
18
src/oldfiles/shrinkingWindow.java
Normal file
18
src/oldfiles/shrinkingWindow.java
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
void shrinkingWindow(float speed, int red, int green, int blue, int borderWidth){
|
||||
// clearDisplay();
|
||||
|
||||
fill(0,0,0);
|
||||
strokeWeight(borderWidth); // Controls thickness of line
|
||||
stroke(color(red, green, blue));
|
||||
rectMode(CENTER);
|
||||
rect(convertXCoord(centerX), convertYCoord(centerY),
|
||||
(screenWidth - menu.width)/calibrator.magx-t, (screenHeight)/calibrator.magx-t);
|
||||
|
||||
if (screenHeight/calibrator.magx-t > 20){
|
||||
t = t + speed*1;
|
||||
} else {
|
||||
t = t;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
2
src/oldfiles/sketch.properties
Normal file
2
src/oldfiles/sketch.properties
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
mode.id=processing.mode.java.JavaMode
|
||||
mode=Java
|
||||
7
src/oldfiles/snapshot.java
Normal file
7
src/oldfiles/snapshot.java
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
void snapshot(){
|
||||
|
||||
PImage c = get(0, 15, screenWidth-menu.width, screenHeight-15); //Takes the FOV
|
||||
c.save("Image" + str(millis()) + ".jpg"); //Saves the FOV with Image_____.jpg, where _____ is the number of milliseconds elapsed from the program start
|
||||
|
||||
//print(str(millis())+"\n");
|
||||
}
|
||||
12
src/oldfiles/squareCorridor.java
Normal file
12
src/oldfiles/squareCorridor.java
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
void squareCorridor() {
|
||||
noFill();
|
||||
strokeWeight(12); // Controls thickness of blue border
|
||||
stroke(color(0, 0, 31));
|
||||
rectMode(CENTER);
|
||||
rect(convertXCoord(screenWidth - 1000), convertYCoord(550), xsize/calibrator.magx *15, ysize/calibrator.magy *15);
|
||||
|
||||
fill(color(0, 0, 255));
|
||||
noStroke();
|
||||
rectMode(CENTER);
|
||||
rect(convertXCoord(screenWidth - 1000), convertYCoord(550), xsize/calibrator.magx *9, ysize/calibrator.magy *9);
|
||||
}
|
||||
11
src/oldfiles/testing.java
Normal file
11
src/oldfiles/testing.java
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
int rVal = 255;
|
||||
int gVal = 255;
|
||||
int bVal = 255;
|
||||
int bgVal = 0;
|
||||
int bgR = bgVal*13/10; // Red value
|
||||
int bgG = bgVal*5/10; // Green value
|
||||
int bgB = bgVal*4/10; // Blue value
|
||||
|
||||
final float stimulusColor = 180; //stimulus intensity out of 255
|
||||
final float greenscale = 0.3; // scales down intensity of green
|
||||
final float redscale = 0.7; // scales down intensity of red
|
||||
29
src/oldfiles/translateCircle.java
Normal file
29
src/oldfiles/translateCircle.java
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
void translateCircle(float speed){
|
||||
|
||||
if ((screenWidth - menu.width)/calibrator.magx - t > 60){
|
||||
clearDisplay();
|
||||
fill(0,0,0);
|
||||
strokeWeight(10); // Controls thickness of line
|
||||
stroke(color(0, 0, 255));
|
||||
ellipseMode(CENTER);
|
||||
|
||||
ellipse(convertXCoord(centerX), convertYCoord(centerY),
|
||||
(screenWidth - menu.width)/calibrator.magx - t, (screenWidth - menu.width)/calibrator.magx - t);
|
||||
|
||||
t = t + speed*1;
|
||||
|
||||
} else {
|
||||
|
||||
if (convertXCoord(centerX) - t2 > convertXCoord(250)){
|
||||
clearDisplay();
|
||||
fill(0,0,0);
|
||||
strokeWeight(10); // Controls thickness of line
|
||||
stroke(color(0, 0, 255));
|
||||
ellipseMode(CENTER);
|
||||
ellipse(convertXCoord(centerX) - t2, convertYCoord(centerY),
|
||||
(screenWidth - menu.width)/calibrator.magx - t, (screenWidth - menu.width)/calibrator.magx - t);
|
||||
|
||||
t2 = t2 + speed*0.1;
|
||||
}
|
||||
}
|
||||
}
|
||||
18
src/oldfiles/unidirectionStim.java
Normal file
18
src/oldfiles/unidirectionStim.java
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
/*
|
||||
Holds stimulus light from screen left on for 10 seconds.
|
||||
*/
|
||||
|
||||
float FrameRate = 30;
|
||||
int intensity = 0;
|
||||
|
||||
|
||||
void unidirectionStim(int intensity) {
|
||||
if (t < 180) {
|
||||
arduino.analogWrite(down, intensity); // Turns on arduino light (can make ledPin into a parameter that is passed in)
|
||||
} else {
|
||||
arduino.analogWrite(down, 0);
|
||||
}
|
||||
|
||||
t_temp = t_temp + 1;
|
||||
t = t_temp / FrameRate;
|
||||
}
|
||||
15
src/oldfiles/window.java
Normal file
15
src/oldfiles/window.java
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
void window(int xsize, int ysize) {
|
||||
|
||||
//Outer rectangle is filled
|
||||
fill(color(0, 0, 255));
|
||||
noStroke();
|
||||
rectMode(CENTER);
|
||||
rect(convertXCoord(screenWidth - 1000), convertYCoord(centerY), screenWidth-500, screenHeight);
|
||||
|
||||
//Inner rectangle with no stimulus
|
||||
fill(0,0,0);
|
||||
strokeWeight(1);
|
||||
stroke(color(0, 0, 0));
|
||||
rectMode(CENTER);
|
||||
rect(convertXCoord(screenWidth - 1000), convertYCoord(centerY), xsize, ysize);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue