Skip to content
Browse files

rewriting the identifier

  • Loading branch information...
1 parent da6914b commit 53d4ef5199b5a55b8c5c6fc27d3f48edad7f7541 @fridgehead committed Aug 23, 2011
Showing with 39 additions and 8 deletions.
  1. +1 −0 src/IdentifierSettings.java
  2. +26 −1 src/SheepTest.java
  3. +12 −7 src/TankIdentifier.java
View
1 src/IdentifierSettings.java
@@ -6,6 +6,7 @@
public int minBlobSize = 0;
public int maxBlobSize = 0;
public int colourSampleArea = 10;
+ public boolean active = true;
View
27 src/SheepTest.java
@@ -16,7 +16,7 @@
Textarea logTextArea;
PImage frame;
Slider threshSlider, minSlider, maxSlider, sampleArea,saturationSlider, hueLowSlider, hueHighSlider;
-
+ CheckBox trackerStatusBox;
int currentEditing = 0;
SheepIdentifier sheepFinder;
@@ -37,6 +37,7 @@
int cameraBlur = 6;
int maxTankSize = 10;
+ float toggle = 0.0f;
public int mode = 0;
public static final int MODE_IDLE = 0;
@@ -101,6 +102,10 @@ public void setup() {
tankList = controlP5.addListBox("tankListBox",200,370,120,120);
+
+ trackerStatusBox = controlP5.addCheckBox("toggle",200,490);
+ trackerStatusBox.addItem("enabled", 1);
+
tankList.captionLabel().set("Which Thing?");
tankList.addItem("tank 0 - p1", 0);
@@ -233,6 +238,11 @@ public void draw() {
//text("p: " + t.pairId + "\n" + t.colourName, 340 + t.position.x, t.position.y);
}
+ for(TankIdentifier.ColourPoint p: tankIdentifier.trackList){
+ fill(p.colour);
+ ellipse(p.pos.x + 330, p.pos.y, 10,10);
+ }
+
} else if (mode == MODE_CONFIG_SHEEP_SPACE) {
pushMatrix();
@@ -332,6 +342,12 @@ public void controlEvent(ControlEvent theEvent) {
identSettings[currentEditing].minBlobSize = minBlobSize;
identSettings[currentEditing].maxBlobSize = maxBlobSize;
identSettings[currentEditing].maxSaturation = saturationDetection;
+ /*if(trackerStatusBox.arrayValue()[0] == 1.0f){
+ identSettings[currentEditing].active = true;
+
+ } else {
+ identSettings[currentEditing].active = false;
+ }*/
tankIdentifier.setIdentSettings(identSettings);
}
@@ -356,6 +372,15 @@ public void controlEvent(ControlEvent theEvent) {
saturationSlider.setValue(saturationDetection);
hueLowSlider.setValue(colourThreshLow);
hueHighSlider.setValue(colourThreshHigh);
+
+ /*if(identSettings[currentEditing].active == true){
+ trackerStatusBox.activate(0);
+
+ } else {
+ trackerStatusBox.deactivate(0);
+ }*/
+
+
}
}
View
19 src/TankIdentifier.java
@@ -50,7 +50,7 @@
private PImage[] testbuf = new PImage[3];
PImage buf;
- ArrayList<ColourPoint> trackList = new ArrayList<ColourPoint>();
+ public ArrayList<ColourPoint> trackList = new ArrayList<ColourPoint>();
/*
* violet -> red = 5 -> 0
@@ -95,13 +95,15 @@ public void update(PImage blobframe, PImage colourFrame){
trackList.clear();
finalTankList.clear();
//opencv.threshold(100, 0, OpenCV.THRESH_OTSU | OpenCV.THRESH_TOZERO);
- Blob[] blobs = opencv.blobs( 5, 100000, 100, false, OpenCV.MAX_VERTICES*4 );
+ Blob[] blobs = opencv.blobs( identSettings[0].minBlobSize, identSettings[0].maxBlobSize, 100, false, OpenCV.MAX_VERTICES*4 );
for( int i=0; i<blobs.length; i++ ) {
Rectangle r = blobs[i].rectangle;
//parent.stroke(0,0,255);
//parent.rect(r.x,r.y,r.width,r.height);
ArrayList<ColourPoint> pts = findColourBlobs(colourFrame.pixels, r);
+
+
trackList.addAll(pts);
}
@@ -145,10 +147,10 @@ public void update(PImage blobframe, PImage colourFrame){
for(int i = 0; i < 3; i++){
testbuf[i].updatePixels();
- opencv.remember();
+ //opencv.remember();
opencv.copy(testbuf[i]);
opencv.ROI(area);
- Blob[] blobs = opencv.blobs( 2, 1000, 100, false, OpenCV.MAX_VERTICES*4 );
+ Blob[] blobs = opencv.blobs( 2, 4000, 100, false, OpenCV.MAX_VERTICES*4 );
for(Blob b :blobs){
ColourPoint l = new ColourPoint();
l.colourId = i;
@@ -246,9 +248,11 @@ void identTanks(int[] imageIn, ArrayList<ColourPoint> blobs){
parent.rect( halfP.x+20, halfP.y + 30, 10,10);
//work out angle
- Tank t = new Tank(id,new Point((int)halfP.x, (int)halfP.y), null);
- t.heading = (int) parent.degrees(angle) + 90;
- finalTankList.add(t);
+ if(id == 1 || id == 5 || id == 6){
+ Tank t = new Tank(id,new Point((int)halfP.x, (int)halfP.y), null);
+ t.heading = (int) parent.degrees(angle) + 90;
+ finalTankList.add(t);
+ }
}
@@ -310,6 +314,7 @@ public static double normalizeAngle(double a, double center) {
public int colourId = 0;
public int colour = 0;
public Point pos;
+ public Point translatedPos;
}

0 comments on commit 53d4ef5

Please sign in to comment.
Something went wrong with that request. Please try again.