OpenCV and TENSORFLOW imported successfully
This commit is contained in:
parent
4a28f9f9a1
commit
ac80248b2e
|
@ -6,16 +6,12 @@
|
||||||
<attribute name="maven.pomderived" value="true"/>
|
<attribute name="maven.pomderived" value="true"/>
|
||||||
</attributes>
|
</attributes>
|
||||||
</classpathentry>
|
</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">
|
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
|
||||||
<attributes>
|
<attributes>
|
||||||
<attribute name="maven.pomderived" value="true"/>
|
<attribute name="maven.pomderived" value="true"/>
|
||||||
</attributes>
|
</attributes>
|
||||||
</classpathentry>
|
</classpathentry>
|
||||||
<classpathentry kind="con" path="org.eclipse.jdt.USER_LIBRARY/Tensorflow"/>
|
<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"/>
|
<classpathentry kind="output" path="target/classes"/>
|
||||||
</classpath>
|
</classpath>
|
||||||
|
|
|
@ -36,9 +36,9 @@ public class IronMiner {
|
||||||
|
|
||||||
public IronMiner() throws AWTException, IOException
|
public IronMiner() throws AWTException, IOException
|
||||||
{
|
{
|
||||||
//cursor = new Cursor();
|
cursor = new Cursor();
|
||||||
//cursorTask = new CursorTask();
|
cursorTask = new CursorTask();
|
||||||
//inventory = new Inventory();
|
inventory = new Inventory();
|
||||||
objectDetector = new ObjectDetector();
|
objectDetector = new ObjectDetector();
|
||||||
robot = new Robot();
|
robot = new Robot();
|
||||||
randomizer = new Randomizer();
|
randomizer = new Randomizer();
|
||||||
|
@ -46,12 +46,15 @@ public class IronMiner {
|
||||||
|
|
||||||
public void run() throws Exception {
|
public void run() throws Exception {
|
||||||
while (true) {
|
while (true) {
|
||||||
|
long frameStartTime = System.currentTimeMillis();
|
||||||
BufferedImage screenCapture = objectDetector.captureScreenshotGameWindow();
|
BufferedImage screenCapture = objectDetector.captureScreenshotGameWindow();
|
||||||
System.out.println("looking for iron ores");
|
System.out.println("looking for iron ores");
|
||||||
|
//int count = objectDetector.getObjectsInImage(screenCapture, 0.6);
|
||||||
ArrayList<DetectedObject> detectedObjects = objectDetector.getObjectsInImage(screenCapture, 0.60);
|
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) {
|
if (closestIronOre != null) {
|
||||||
Rect2d boundingBox = closestIronOre.getBoundingRect2d();
|
Rect2d boundingBox = closestIronOre.getBoundingRect2d();
|
||||||
ObjectTracker ironOreTracker = new ObjectTracker(screenCapture, boundingBox);
|
ObjectTracker ironOreTracker = new ObjectTracker(screenCapture, boundingBox);
|
||||||
|
@ -66,9 +69,12 @@ public class IronMiner {
|
||||||
screenCapture = objectDetector.captureScreenshotGameWindow();
|
screenCapture = objectDetector.captureScreenshotGameWindow();
|
||||||
objectTrackingFailure = ironOreTracker.update(screenCapture, boundingBox);
|
objectTrackingFailure = ironOreTracker.update(screenCapture, boundingBox);
|
||||||
}
|
}
|
||||||
}
|
}*/
|
||||||
|
|
||||||
|
// TODO: change this so that we only check the last slot for an item.
|
||||||
|
//
|
||||||
//dropInventoryIfFull();
|
//dropInventoryIfFull();
|
||||||
|
System.out.println("Timespan: " + (System.currentTimeMillis() - frameStartTime));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -57,7 +57,7 @@ public class ObjectDetector {
|
||||||
public ArrayList<DetectedObject> getObjectsInImage(BufferedImage image, double scoreThreshold) throws Exception {
|
public ArrayList<DetectedObject> getObjectsInImage(BufferedImage image, double scoreThreshold) throws Exception {
|
||||||
List<Tensor<?>> outputs = null;
|
List<Tensor<?>> outputs = null;
|
||||||
ArrayList<DetectedObject> detectedObjectsInImage = new ArrayList<DetectedObject>();
|
ArrayList<DetectedObject> detectedObjectsInImage = new ArrayList<DetectedObject>();
|
||||||
|
//int count = 0;
|
||||||
makeImageTensor(image);
|
makeImageTensor(image);
|
||||||
try (Tensor<UInt8> input = makeImageTensor(image)) {
|
try (Tensor<UInt8> input = makeImageTensor(image)) {
|
||||||
outputs =
|
outputs =
|
||||||
|
@ -82,10 +82,12 @@ public class ObjectDetector {
|
||||||
|
|
||||||
for (int i = 0; i < scores.length; ++i) {
|
for (int i = 0; i < scores.length; ++i) {
|
||||||
if (scores[i] > scoreThreshold) {
|
if (scores[i] > scoreThreshold) {
|
||||||
|
//count++;
|
||||||
detectedObjectsInImage.add(new DetectedObject(scores[i], classes[i], boxes[i]));
|
detectedObjectsInImage.add(new DetectedObject(scores[i], classes[i], boxes[i]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// return count;
|
||||||
return detectedObjectsInImage;
|
return detectedObjectsInImage;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,7 @@ public class ObjectTracker {
|
||||||
|
|
||||||
public ObjectTracker(BufferedImage image, Rect2d boundingBox) {
|
public ObjectTracker(BufferedImage image, Rect2d boundingBox) {
|
||||||
this.objectTracker = TrackerBoosting.create();
|
this.objectTracker = TrackerBoosting.create();
|
||||||
this.objectTracker.init(bufferedImageTomat(image), boundingBox);
|
this.objectTracker.init(bufferedImageToMat(image), boundingBox);
|
||||||
this.numberOfFramesLostFor = 0;
|
this.numberOfFramesLostFor = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,7 @@ public class main {
|
||||||
System.load("/usr/local/cuda/lib64/libcudart.so.9.0");
|
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/libcufft.so.9.0");
|
||||||
System.load("/usr/local/cuda/lib64/libcurand.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");
|
System.load("/home/dpapp/jni/libtensorflow_jni.so");
|
||||||
|
|
||||||
IronMiner ironMiner = new IronMiner();
|
IronMiner ironMiner = new IronMiner();
|
||||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue