git.haldean.org droidcopter / 8ed1e08
Segmenter and BlobTracker dependencies on Array.copyOf removed Will Brown 11 years ago
2 changed file(s) with 17 addition(s) and 19 deletion(s). Raw diff Collapse all Expand all
00 package org.haldean.blob;
11
2 import java.util.Arrays;
32 import java.util.Collection;
4 import java.util.LinkedList;
53 import java.util.HashMap;
6 import java.util.List;
74 import java.util.Map;
85
96 public class Segmenter {
2623 targetColor[2], targetArea, threshold);
2724 }
2825
29 /*
3026 public static Segmenter fromString(String str) {
31 String[] parts = str.split(";");
32 return new Segmenter(Arrays.copyOfRange(parts, 1, 4), parts[4], parts[5]);
33 }*/
27 String[] parts = str.split(";");
28 int[] targetColor = new int[] {new Integer(parts[0]), new Integer(parts[1]), new Integer(parts[2])};
29 int targetArea = new Integer(parts[4]);
30 int threshold = new Integer(parts[5]);
31 return new Segmenter(targetColor, targetArea, threshold);
32 }
3433
3534 public static Segmenter getSegmenterForPoint(Image input, int x, int y) {
3635 Segmenter seg = new Segmenter(input.getPixel(x, y), 0, DEFAULT_THRESHOLD);
00 package org.haldean.chopper.pilot;
1
2 import java.util.Arrays;
31
42 import org.haldean.blob.AndroidImage;
53 import org.haldean.blob.Image;
1210 int[] lastVector;
1311 MakePicture mPic;
1412 byte[] mBuffer;
13 boolean enabled;
1514
1615 private static final int TRACKING_PERIOD_MS = 200;
1716 private static final int DISABLED_PERIOD_MS = 1000;
1817
1918 public BlobTracker(MakePicture pic) {
20 lastLocation = new int[2];
21 lastVector = new int[3];
22 segmenter = null;
23 image = new AndroidImage();
24 mPic = pic;
25 mBuffer = new byte[mPic.getBufferLength()];
19 lastLocation = new int[2];
20 lastVector = new int[3];
21 segmenter = null;
22 image = new AndroidImage();
23 mPic = pic;
24 mBuffer = new byte[mPic.getBufferLength()];
2625 }
2726
2827 public void receiveMessage(String msg, Receivable source) {
29 if (msg.startsWith("SEGMENT")) {
30 segmenter = Segmenter.fromString(msg);
31 }
28 if (msg.startsWith("SEGMENT")) {
29 segmenter = Segmenter.fromString(msg);
30 }
3231 }
3332
3433 public int[] getVector() {
35 return Arrays.copyOf(lastVector, lastVector.length);
34 return lastVector; //Arrays.copyOf(lastVector, lastVector.length);
3635 }
3736
3837 private void calculateVector() {