diff --git a/configfinder/configfinder.pde b/configfinder/configfinder.pde index 9db9923..56339f6 100644 --- a/configfinder/configfinder.pde +++ b/configfinder/configfinder.pde @@ -11,6 +11,8 @@ PImage cam_reference; PImage cam_currentbox; PGraphics canvas; +PImage image_clear; + int currentID=0; //int MAXID = 50; //inclusive @@ -36,9 +38,9 @@ ArrayList boxes=new ArrayList(); //int FINDBOXES_MINIMUMBRIGHTNESS; //brightness difference required int FINDBOXES_MAXIMUMPIXELDISTANCE; //distance to add pixel to existing box PVector MINBOXSIZE; //minimum box size to accept box -int TIME_FIND = 500; //time in ms to find box in image -int TIME_RESULT = 250; //time in ms to show success/fail -int TIME_TURNOFF = 250; //time in ms to wait to turn off +int TIME_FIND = 100; //time in ms to find box in image +int TIME_RESULT = 100; //time in ms to show success/fail +int TIME_TURNOFF = 100; //time in ms to wait to turn off float MINBRIGHTNESS_PERCENTILE=0.98; //percentile for minbrightness calculation (how many pixels will be considered). between 0(all) and 1(none). 0=all pixels. ->1=only bright pixels int MINIMUMALLOWEDBRIGHTNESS=50; //minimum brightness. will be limited to this lower bound if no box in image (percentile calculation yields low value) @@ -73,6 +75,7 @@ void setup() { cam = new Capture(this, cameras[1]); //linux cam.start(); } + image_clear=cam.copy(); cam_reference=cam.copy(); } @@ -126,6 +129,7 @@ void checkState() { switch(searchstate) { case 0: //0=get reference image and ping box cam_reference=cam.copy(); + println(); println("Searching BoxID "+str(currentID)); @@ -147,6 +151,7 @@ void checkState() { Box box = findSingleBox(cam_currentbox); //find single box in this image if (box!=null && (box.getBoxSize().xMAXID) { running=false; + cam_reference=image_clear; //show normal camera image } break; } @@ -200,19 +206,24 @@ void keyPressed() { cam_reference=cam.copy(); println("New Reference Set"); - } else if (key == 's' ){ + } else if (key == 10){ //ENTER running=true; colorAllOff(); //turn box off currentID=0; //reset searchstate=0; boxes.clear(); //reset found boxes println("Search started"); + } else if (key == 'r' ){ + running=false; + cam_reference=image_clear; //show normal camera image + } else if(key == 's') { + saveBoxConfig(); } + } int getPercentileBrightness(PImage img, float percentile) { //percentile between 0 and 1 - println("percentile="+str(percentile)); percentile=min(max(percentile,0.0),1.0); //limit to 0 to 1 int[] brightness=new int[img.pixels.length]; for (int i=0;i findBoxes(PImage img) { } println(" findBoxes(): foundboxes.size="+foundboxes.size()); + //merge overlapping boxes together + for (int i=0;i