OpenCV and TENSORFLOW imported successfully

This commit is contained in:
davpapp 2018-03-04 18:08:04 -05:00
parent 4a28f9f9a1
commit ac80248b2e
9 changed files with 19 additions and 15 deletions

View File

@ -6,16 +6,12 @@
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.USER_LIBRARY/OpenCV-3.4.0">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.USER_LIBRARY/Tensorflow"/>
<classpathentry kind="con" path="org.eclipse.jdt.USER_LIBRARY/OpenCV"/>
<classpathentry kind="output" path="target/classes"/>
</classpath>

View File

@ -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<DetectedObject> detectedObjects = objectDetector.getObjectsInImage(screenCapture, 0.60);
ArrayList<DetectedObject> ironOres = objectDetector.getObjectsOfClassInList(detectedObjects, "ironOre");
//ArrayList<DetectedObject> 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));
}
}

View File

@ -57,7 +57,7 @@ public class ObjectDetector {
public ArrayList<DetectedObject> getObjectsInImage(BufferedImage image, double scoreThreshold) throws Exception {
List<Tensor<?>> outputs = null;
ArrayList<DetectedObject> detectedObjectsInImage = new ArrayList<DetectedObject>();
//int count = 0;
makeImageTensor(image);
try (Tensor<UInt8> 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;
}

View File

@ -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;
}

View File

@ -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();

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.