Browse Source

Cleaning up code

master
davpapp 4 years ago
parent
commit
feb3fc7389
14 changed files with 61 additions and 7421 deletions
  1. +0
    -1102
      hs_err_pid11338.log
  2. +0
    -1599
      hs_err_pid20751.log
  3. +0
    -1602
      hs_err_pid20788.log
  4. +0
    -1594
      hs_err_pid20827.log
  5. +0
    -1511
      hs_err_pid30157.log
  6. +18
    -3
      src/ImageCollector.java
  7. +11
    -8
      src/IronMiner.java
  8. +2
    -2
      src/ObjectTrackerTest.java
  9. +30
    -0
      src/RandomDetector.java
  10. BIN
      target/classes/ImageCollector$1.class
  11. BIN
      target/classes/ImageCollector.class
  12. BIN
      target/classes/IronMiner.class
  13. BIN
      target/classes/ObjectTrackerTest.class
  14. BIN
      target/classes/RandomDetector.class

+ 0
- 1102
hs_err_pid11338.log
File diff suppressed because it is too large
View File


+ 0
- 1599
hs_err_pid20751.log
File diff suppressed because it is too large
View File


+ 0
- 1602
hs_err_pid20788.log
File diff suppressed because it is too large
View File


+ 0
- 1594
hs_err_pid20827.log
File diff suppressed because it is too large
View File


+ 0
- 1511
hs_err_pid30157.log
File diff suppressed because it is too large
View File


+ 18
- 3
src/ImageCollector.java View File

@ -62,6 +62,20 @@ public class ImageCollector {
return counter;
}
/*public void blurTextFromImages() throws IOException, AWTException, InterruptedException {
File folder = new File("/home/dpapp/Videos/BlurredRandom/NonBlurred/");
File[] listOfImages = folder.listFiles();
//RandomDetector randomDetector = new RandomDetector();
int count = 0;
for (File file : listOfImages) {
System.out.println(count);
BufferedImage image = ImageIO.read(file);
BufferedImage blurredImage = RandomDetector.blurDialogueFromImage(image);
ImageIO.write(blurredImage, "png", new File("/home/dpapp/Videos/BlurredRandom/Blurred/blurredRandom" + count + ".png"));
count++;
}
}*/
private File[] getFilesFromFolderThatStartWith(String itemName) {
File folder = new File(screenshotOutputDirectory);
File[] listOfFiles = folder.listFiles(new FilenameFilter() {
@ -99,12 +113,13 @@ public class ImageCollector {
inventory.updateAndWriteAllInventoryImages();
}
/*public static void main(String[] args) throws Exception
public static void main(String[] args) throws Exception
{
ImageCollector imageCollector = new ImageCollector("/home/dpapp/Desktop/RunescapeAI/Images/");
imageCollector.collectImages("chatDialogue");
//imageCollector.blurTextFromImages();
//imageCollector.collectImages("chatDialogue");
//imageCollector.generateInventoryImages();
//imageCollector.captureAndSaveFullWindow();
}*/
}
}

+ 11
- 8
src/IronMiner.java View File

@ -24,7 +24,7 @@ import org.opencv.tracking.TrackerMOSSE;
public class IronMiner {
public static final int IRON_ORE_MINING_TIME_MILLISECONDS = 1320;
public static final int MAXIMUM_DISTANCE_TO_WALK_TO_IRON_ORE = 150;
public static final int MAXIMUM_DISTANCE_TO_WALK_TO_IRON_ORE = 400;
Cursor cursor;
CursorTask cursorTask;
@ -56,8 +56,9 @@ public class IronMiner {
int count = 0;
int worldHops = 0;
int lastIronOreInInventory = -1;
int noIronOresCount = 0;
while (((System.currentTimeMillis() - startTime) / 1000.0 / 60) < 195) {
while (((System.currentTimeMillis() - startTime) / 1000.0 / 60) < 163) {
BufferedImage screenCapture = ImageCapturer.captureScreenshotGameWindow();
ArrayList<DetectedObject> detectedObjects = objectDetector.getObjectsInImage(screenCapture, 0.30);
ArrayList<DetectedObject> ironOres = objectDetector.getIronOres(detectedObjects);
@ -67,17 +68,19 @@ public class IronMiner {
humanBehavior.randomlyRotateCamera(cameraCalibrator);
RandomDetector.dealWithRandoms(screenCapture, cursor);
dropInventoryIfCloseToFull();
/*if (noIronOresCount > 10000) {
return;
}*/
DetectedObject closestIronOre = getClosestObjectToCharacter(ironOres);
if (closestIronOre != null) {
//Thread.sleep(Randomizer.nextGaussianWithinRange(20, 40));
noIronOresCount = 0;
cursor.moveAndLeftClickAtCoordinatesWithRandomness(closestIronOre.getCenterForClicking(), 10, 10);
//System.out.println("Last iron ore: " + lastIronOreInInventory);
int ironOreInInventory = inventory.getFirstIronOreInInventoryDifferentFromLast(lastIronOreInInventory);
lastIronOreInInventory = ironOreInInventory;
//System.out.println("New iron ore: " + ironOreInInventory + "\n");
int numberOfOresInInventoryBefore = inventory.getNumberOfItemsOfTypeInInventory("ironOre");
boolean miningSuccess = false;
@ -120,12 +123,12 @@ public class IronMiner {
boolean worldHopped = hopWorldsIfMiningSuccessRateIsLow(miningSuccess);
if (worldHopped) {
worldHops++;
/*if (worldHops > 30) {
break;
}*/
}
System.out.println("worldHops: " + worldHops);
}
else {
noIronOresCount++;
}
}
}


+ 2
- 2
src/ObjectTrackerTest.java View File

@ -64,7 +64,7 @@ class ObjectTrackerTest {
continue;
}
BufferedImage screencapture = Mat2BufferedImage(frame);
Graphics g = screencapture.getGraphics();
Graphics g = screencapture.getGraphics();
ArrayList<DetectedObject> detectedObjects = objectDetector.getObjectsInImage(Mat2BufferedImage(frame), 0.30);
for (DetectedObject detectedObject : detectedObjects) {
@ -127,7 +127,7 @@ class ObjectTrackerTest {
}
g.drawRect((int) boundingBoxes.get(i).x, (int) boundingBoxes.get(i).y, (int) boundingBoxes.get(i).width, (int) boundingBoxes.get(i).height);
}
ImageIO.write(screencapture, "jpg", new File(videoDirectory + "/mining_guild_inv/frame_" + videoFileName + counter + ".jpg"));
ImageIO.write(screencapture, "png", new File("/home/dpapp/Videos/BlurredRandom/NonBlurred/" + videoFileName + counter + ".png"));
counter++;
}
}


+ 30
- 0
src/RandomDetector.java View File

@ -1,5 +1,6 @@
import java.awt.AWTException;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.Point;
import java.awt.Rectangle;
import java.awt.Robot;
@ -88,6 +89,35 @@ public class RandomDetector {
return null;
}
/*public static BufferedImage blurDialogueFromImage(BufferedImage screenCapture) throws AWTException, InterruptedException {
Point chatDialogueStart = findChatDialogueCornerPoint(screenCapture);
if (chatDialogueStart == null) {
return screenCapture;
}
int rightMostChatColorPixel = chatDialogueStart.x;
int countSinceLastChatColorPixel = 0;
for (int x = chatDialogueStart.x; x < Constants.GAME_WINDOW_WIDTH && countSinceLastChatColorPixel < 30; x++) {
for (int y = chatDialogueStart.y; y < chatDialogueStart.y + 20; y++) {
int pixelColor = screenCapture.getRGB(x, y);
if (isPixelChatColor(pixelColor)) {
rightMostChatColorPixel = x;
countSinceLastChatColorPixel = 0;
}
}
countSinceLastChatColorPixel++;
}
int chatDialogueBoxWidth = rightMostChatColorPixel - chatDialogueStart.x;
if (chatDialogueBoxWidth > 60 && chatDialogueBoxWidth < 400) {
//BufferedImage result = screenCapture;
Graphics g = screenCapture.getGraphics();
g.clearRect(chatDialogueStart.x, chatDialogueStart.y, chatDialogueBoxWidth, 25);
System.out.println("Found dialogue! Blurring image");
}
return screenCapture;
}*/
private static boolean isSpeakerPointCloseToCharacter(Point speakerPoint) {
return (Math.abs(speakerPoint.x + Constants.GAME_WINDOW_OFFSET_X - Constants.CHARACTER_CENTER_X) < 90 && Math.abs(speakerPoint.y + Constants.GAME_WINDOW_OFFSET_Y - Constants.CHARACTER_CENTER_Y) < 80);
}


BIN
target/classes/ImageCollector$1.class View File


BIN
target/classes/ImageCollector.class View File


BIN
target/classes/IronMiner.class View File


BIN
target/classes/ObjectTrackerTest.class View File


BIN
target/classes/RandomDetector.class View File


Loading…
Cancel
Save