mirror of
https://github.com/davpapp/PowerMiner
synced 2024-11-14 05:25:08 -05:00
OpenCV and TENSORFLOW imported successfully
This commit is contained in:
parent
4a28f9f9a1
commit
ac80248b2e
@ -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>
|
||||
|
@ -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));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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.
Loading…
Reference in New Issue
Block a user