mirror of
https://github.com/davpapp/PowerMiner
synced 2025-01-08 12:28:06 -05:00
Cleaning up code
This commit is contained in:
parent
864b2a089a
commit
feb3fc7389
1102
hs_err_pid11338.log
1102
hs_err_pid11338.log
File diff suppressed because it is too large
Load Diff
1599
hs_err_pid20751.log
1599
hs_err_pid20751.log
File diff suppressed because it is too large
Load Diff
1602
hs_err_pid20788.log
1602
hs_err_pid20788.log
File diff suppressed because it is too large
Load Diff
1594
hs_err_pid20827.log
1594
hs_err_pid20827.log
File diff suppressed because it is too large
Load Diff
1511
hs_err_pid30157.log
1511
hs_err_pid30157.log
File diff suppressed because it is too large
Load Diff
@ -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();
|
||||
}*/
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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++;
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue
Block a user