diff --git a/src/IronMiner.java b/src/IronMiner.java index f161106..e4316ce 100644 --- a/src/IronMiner.java +++ b/src/IronMiner.java @@ -54,7 +54,7 @@ public class IronMiner { int noIronOresDetected = 0; int count = 0; - while (((System.currentTimeMillis() - startTime) / 1000.0 / 75) < 75) { + while (((System.currentTimeMillis() - startTime) / 1000.0 / 75) < 37) { count++; BufferedImage screenCapture = objectDetector.captureScreenshotGameWindow(); @@ -98,7 +98,6 @@ public class IronMiner { else { oreLostCount = 0; } - System.out.println("Tracking timespan: " + (System.currentTimeMillis() - trackingFrameStartTime)); } } @@ -109,6 +108,7 @@ public class IronMiner { System.out.println((System.currentTimeMillis() - startTime) / 1000); } } + System.out.println("Completed full mining session."); } diff --git a/src/ObjectDetector.java b/src/ObjectDetector.java index c513264..1ac0531 100644 --- a/src/ObjectDetector.java +++ b/src/ObjectDetector.java @@ -56,7 +56,7 @@ public class ObjectDetector { public ArrayList getObjectsInImage(BufferedImage image, double scoreThreshold) throws Exception { List> outputs = null; ArrayList detectedObjectsInImage = new ArrayList(); - makeImageTensor(image); + try (Tensor input = makeImageTensor(image)) { outputs = model @@ -85,6 +85,9 @@ public class ObjectDetector { } } } + for (Tensor tensor : outputs) { + tensor = null; + } return detectedObjectsInImage; } @@ -123,7 +126,9 @@ public class ObjectDetector { final long BATCH_SIZE = 1; final long CHANNELS = 3; long[] shape = new long[] {BATCH_SIZE, formattedImage.getHeight(), formattedImage.getWidth(), CHANNELS}; - return Tensor.create(UInt8.class, shape, ByteBuffer.wrap(data)); + ByteBuffer byteBuffer = ByteBuffer.wrap(data); + data = null; + return Tensor.create(UInt8.class, shape, byteBuffer); } private BufferedImage convertBufferedImage(BufferedImage sourceImage, int bufferedImageType) { diff --git a/src/ObjectTracker.java b/src/ObjectTracker.java index fcb6469..f0e87ed 100644 --- a/src/ObjectTracker.java +++ b/src/ObjectTracker.java @@ -32,7 +32,7 @@ public class ObjectTracker { public boolean update(BufferedImage image, Rect2d boundingBox) throws IOException { boolean trackingSuccessful = objectTracker.update(BufferedImage2Mat(image), boundingBox); - System.out.print("Tracking: " + trackingSuccessful + ". Counter at "); + //System.out.print("Tracking: " + trackingSuccessful + ". Counter at "); updateNumberOfFramesLostFor(trackingSuccessful); return isObjectTrackingFailure(); } @@ -53,7 +53,7 @@ public class ObjectTracker { } private boolean isObjectTrackingFailure() { - System.out.println(numberOfFramesLostFor); + //System.out.println(numberOfFramesLostFor); return numberOfFramesLostFor > 3; } diff --git a/target/classes/IronMiner.class b/target/classes/IronMiner.class index 2562f42..240ceeb 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 7d5d4da..4f38b99 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 e4f1e36..9c1fb82 100644 Binary files a/target/classes/ObjectTracker.class and b/target/classes/ObjectTracker.class differ