diff --git a/.classpath b/.classpath index 59c135d..63d2139 100644 --- a/.classpath +++ b/.classpath @@ -6,16 +6,12 @@ - - - - - + diff --git a/src/IronMiner.java b/src/IronMiner.java index 759541c..2953469 100644 --- a/src/IronMiner.java +++ b/src/IronMiner.java @@ -36,9 +36,9 @@ public class IronMiner { public IronMiner() throws AWTException, IOException { - //cursor = new Cursor(); - //cursorTask = new CursorTask(); - //inventory = new Inventory(); + cursor = new Cursor(); + cursorTask = new CursorTask(); + inventory = new Inventory(); objectDetector = new ObjectDetector(); robot = new Robot(); randomizer = new Randomizer(); @@ -46,12 +46,15 @@ public class IronMiner { public void run() throws Exception { while (true) { + long frameStartTime = System.currentTimeMillis(); BufferedImage screenCapture = objectDetector.captureScreenshotGameWindow(); System.out.println("looking for iron ores"); + //int count = objectDetector.getObjectsInImage(screenCapture, 0.6); ArrayList detectedObjects = objectDetector.getObjectsInImage(screenCapture, 0.60); - ArrayList ironOres = objectDetector.getObjectsOfClassInList(detectedObjects, "ironOre"); + //ArrayList ironOres = objectDetector.getObjectsOfClassInList(detectedObjects, "ironOre"); + System.out.println("Found " + detectedObjects.size() + " objects."); - DetectedObject closestIronOre = getClosestObjectToCharacter(ironOres); + /*DetectedObject closestIronOre = getClosestObjectToCharacter(ironOres); if (closestIronOre != null) { Rect2d boundingBox = closestIronOre.getBoundingRect2d(); ObjectTracker ironOreTracker = new ObjectTracker(screenCapture, boundingBox); @@ -66,9 +69,12 @@ public class IronMiner { screenCapture = objectDetector.captureScreenshotGameWindow(); objectTrackingFailure = ironOreTracker.update(screenCapture, boundingBox); } - } - + }*/ + + // TODO: change this so that we only check the last slot for an item. + // //dropInventoryIfFull(); + System.out.println("Timespan: " + (System.currentTimeMillis() - frameStartTime)); } } diff --git a/src/ObjectDetector.java b/src/ObjectDetector.java index 9f03821..e94651b 100644 --- a/src/ObjectDetector.java +++ b/src/ObjectDetector.java @@ -57,7 +57,7 @@ public class ObjectDetector { public ArrayList getObjectsInImage(BufferedImage image, double scoreThreshold) throws Exception { List> outputs = null; ArrayList detectedObjectsInImage = new ArrayList(); - + //int count = 0; makeImageTensor(image); try (Tensor input = makeImageTensor(image)) { outputs = @@ -82,10 +82,12 @@ public class ObjectDetector { for (int i = 0; i < scores.length; ++i) { if (scores[i] > scoreThreshold) { + //count++; detectedObjectsInImage.add(new DetectedObject(scores[i], classes[i], boxes[i])); } } } + // return count; return detectedObjectsInImage; } diff --git a/src/ObjectTracker.java b/src/ObjectTracker.java index 1465b3d..a69745c 100644 --- a/src/ObjectTracker.java +++ b/src/ObjectTracker.java @@ -12,7 +12,7 @@ public class ObjectTracker { public ObjectTracker(BufferedImage image, Rect2d boundingBox) { this.objectTracker = TrackerBoosting.create(); - this.objectTracker.init(bufferedImageTomat(image), boundingBox); + this.objectTracker.init(bufferedImageToMat(image), boundingBox); this.numberOfFramesLostFor = 0; } diff --git a/src/main.java b/src/main.java index 4334070..46aaf8f 100644 --- a/src/main.java +++ b/src/main.java @@ -15,7 +15,7 @@ public class main { System.load("/usr/local/cuda/lib64/libcudart.so.9.0"); System.load("/usr/local/cuda/lib64/libcufft.so.9.0"); System.load("/usr/local/cuda/lib64/libcurand.so.9.0"); - //System.loadLibrary(Core.NATIVE_LIBRARY_NAME); + System.loadLibrary(Core.NATIVE_LIBRARY_NAME); System.load("/home/dpapp/jni/libtensorflow_jni.so"); IronMiner ironMiner = new IronMiner(); diff --git a/target/classes/IronMiner.class b/target/classes/IronMiner.class index 190b5da..2cfed24 100644 Binary files a/target/classes/IronMiner.class and b/target/classes/IronMiner.class differ diff --git a/target/classes/ObjectDetector.class b/target/classes/ObjectDetector.class index d0a3852..4980977 100644 Binary files a/target/classes/ObjectDetector.class and b/target/classes/ObjectDetector.class differ diff --git a/target/classes/ObjectTracker.class b/target/classes/ObjectTracker.class index 2fc0010..bcee18e 100644 Binary files a/target/classes/ObjectTracker.class and b/target/classes/ObjectTracker.class differ diff --git a/target/classes/main.class b/target/classes/main.class index 59e8a5a..10882b7 100644 Binary files a/target/classes/main.class and b/target/classes/main.class differ