Improve algorithms and speed. Reduce glitchy text and redundant calls.

secondmonitor
sigonasr2 4 years ago
parent f6c627f3c1
commit a58a1dbb6d
  1. BIN
      DivaBot/DivaBot.jar
  2. 8
      DivaBot/calibration_data.txt
  3. BIN
      DivaBot/capture.png
  4. BIN
      DivaBot/capture_2.png
  5. BIN
      DivaBot/capture_3.png
  6. BIN
      DivaBot/capture_4.png
  7. BIN
      DivaBot/capture_5.png
  8. BIN
      DivaBot/rectangle0.png
  9. BIN
      DivaBot/rectangle1.png
  10. BIN
      DivaBot/rectangle2.png
  11. BIN
      DivaBot/rectangle3.png
  12. BIN
      DivaBot/rectangle4.png
  13. 8
      DivaBot/src/sig/Display.java
  14. 7
      DivaBot/src/sig/DrawCanvas.java
  15. 32
      DivaBot/src/sig/MyRobot.java
  16. 1
      DivaBot/src/sig/Result.java
  17. 23
      DivaBot/src/sig/TypeFace2.java

Binary file not shown.

@ -1,4 +1,4 @@
746
577
1527
1014
536
520
1307
949

Binary file not shown.

Before

Width:  |  Height:  |  Size: 536 KiB

After

Width:  |  Height:  |  Size: 522 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 535 KiB

After

Width:  |  Height:  |  Size: 522 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 534 KiB

After

Width:  |  Height:  |  Size: 522 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 534 KiB

After

Width:  |  Height:  |  Size: 519 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 529 KiB

After

Width:  |  Height:  |  Size: 519 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.6 KiB

After

Width:  |  Height:  |  Size: 6.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.8 KiB

After

Width:  |  Height:  |  Size: 6.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.4 KiB

After

Width:  |  Height:  |  Size: 6.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.0 KiB

After

Width:  |  Height:  |  Size: 6.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.6 KiB

After

Width:  |  Height:  |  Size: 6.8 KiB

@ -107,8 +107,14 @@ public class Display {
if (!forceUpdate) {
AdvanceCycle();
}
if (labels.length>0) {
if (labels.length>cycle) {
currentText=interpretLabel(labels[cycle]);
} else {
currentText=interpretLabel(labels[0]);
}
}
updateFont();
currentText=interpretLabel(labels[cycle]);
MyRobot.p.repaint();
nextUpdateTime=System.currentTimeMillis()+delay;
forceUpdate=false;

@ -141,6 +141,7 @@ public class DrawCanvas extends JPanel implements KeyListener,ComponentListener,
romanizedname = currentSong.romanized_name;
englishname = currentSong.english_name;
artist = currentSong.artist;
MyRobot.p.refreshAllLabels();
MyRobot.p.repaint();
JSONObject obj = FileUtils.readJsonFromUrl("http://45.33.13.215:4501/bestplay/"+MyRobot.USERNAME+"/"+URLEncoder.encode(MyRobot.p.songname, StandardCharsets.UTF_8.toString()).replaceAll("\\+", "%20")+"/"+difficulty);
if (obj.has("cool")) {
@ -160,7 +161,7 @@ public class DrawCanvas extends JPanel implements KeyListener,ComponentListener,
overallrating = (int)obj.getDouble("rating");
if (lastRating<overallrating) {ratingTime=System.currentTimeMillis();}
*/
String text = songname+" / "+((romanizedname.length()>0)?romanizedname:englishname)+" "+(artist.length()>0?"by "+artist:"")+" "+((plays>0)?("Plays - "+(passes)+"/"+(plays)):"")+" "+((plays!=0)?"("+((int)(Math.floor(((float)passes)/plays*100)))+"% pass rate"+((fcCount>0)?" - "+fcCount+" FC"+(fcCount==1?"":"s")+" "+((int)(Math.floor(((float)fcCount)/plays*100)))+"% FC rate":"")+")":"No plays")+" "+((bestPlay!=null)?"Best Play - "+bestPlay.display():"")+" Overall Rating: "+overallrating;
//String text = songname+" / "+((romanizedname.length()>0)?romanizedname:englishname)+" "+(artist.length()>0?"by "+artist:"")+" "+((plays>0)?("Plays - "+(passes)+"/"+(plays)):"")+" "+((plays!=0)?"("+((int)(Math.floor(((float)passes)/plays*100)))+"% pass rate"+((fcCount>0)?" - "+fcCount+" FC"+(fcCount==1?"":"s")+" "+((int)(Math.floor(((float)fcCount)/plays*100)))+"% FC rate":"")+")":"No plays")+" "+((bestPlay!=null)?"Best Play - "+bestPlay.display():"")+" Overall Rating: "+overallrating;
/*Rectangle2D bounds = TextUtils.calculateStringBoundsFont(text, programFont);
if (bounds.getWidth()>1345) {
scrolling=true;
@ -337,7 +338,9 @@ public class DrawCanvas extends JPanel implements KeyListener,ComponentListener,
}
sb.append(displays.get(i).getSaveString());
}
configData.put("DISPLAYDATA",sb.toString());
if (displays.size()>0) {
configData.put("DISPLAYDATA",sb.toString());
}
}
@Override

@ -313,8 +313,8 @@ public class MyRobot{
if (selectedSong!=null && difficulty!=null) {
if (!prevSongTitle.equalsIgnoreCase(selectedSong.title) || !prevDifficulty.equalsIgnoreCase(difficulty)) {
System.out.println("On Song Select Screen: Current Song-"+selectedSong.title+" Diff:"+difficulty);
MyRobot.p.refreshAllLabels();
p.pullData(selectedSong.title,difficulty);
MyRobot.p.refreshAllLabels();
prevSongTitle=selectedSong.title;
prevDifficulty=difficulty;
MyRobot.p.repaint();
@ -495,6 +495,19 @@ public class MyRobot{
return c1.getRed()>=250 && c1.getGreen()>=250 && c1.getBlue()>=250 && c2.getRed()>=10 && c2.getRed()<=25 && c2.getGreen()>=200 && c2.getGreen()<=240 && c2.getBlue()>=180 && c2.getBlue()<=220 &&
c3.getRed()>=200 && c3.getRed()<=255 && c3.getGreen()>=200 && c3.getGreen()<=255 && c3.getBlue()>=140 && c3.getBlue()<=220;
}
public static boolean IsResultsScreenshot(BufferedImage img) throws IOException {
//r.x-418, r.y-204
/*ImageIO.write(MYROBOT.createScreenCapture(new Rectangle(31,230,40,40)),"png",new File("color1.png"));
ImageIO.write(MYROBOT.createScreenCapture(new Rectangle(31,196,40,40)),"png",new File("color2.png"));
ImageIO.write(MYROBOT.createScreenCapture(new Rectangle(483,256,40,40)),"png",new File("color3.png"));*/
Color c1 = new Color(img.getSubimage(31,230,40,40).getRGB(0, 0));
Color c2 = new Color(img.getSubimage(31,196,40,40).getRGB(0, 0));
Color c3 = new Color(img.getSubimage(483,256,40,40).getRGB(0, 0));
//System.out.println(c1+"/"+c2+"/"+c3);
return c1.getRed()>=250 && c1.getGreen()>=250 && c1.getBlue()>=250 && c2.getRed()>=10 && c2.getRed()<=100 && c2.getGreen()>=200 && c2.getGreen()<=255 && c2.getBlue()>=180 && c2.getBlue()<=230 &&
c3.getRed()>=150 && c3.getRed()<=255 && c3.getGreen()>=150 && c3.getGreen()<=255 && c3.getBlue()>=100 && c3.getBlue()<=240;
}
private void GetCurrentDifficulty() {
Color c = new Color(MYROBOT.createScreenCapture(new Rectangle(320,274,10,10)).getRGB(0, 0));
@ -518,6 +531,7 @@ public class MyRobot{
private void GetCurrentSong() throws IOException {
BufferedImage img = ImageUtils.toCompatibleImage(MYROBOT.createScreenCapture(new Rectangle(812-10,380-10,WIDTH+20,HEIGHT+20)));
boolean found=false;
SongData newPick = null;
LOOP1:
for (int x=0;x<10;x++) {
for (int y=0;y<10;y++) {
@ -529,7 +543,7 @@ public class MyRobot{
}
SongData ss = SongData.compareData(col);
if (ss!=null) {
selectedSong = ss;
newPick = ss;
found=true;
break LOOP1;
}
@ -543,7 +557,7 @@ public class MyRobot{
}
SongData ss = SongData.compareData(col);
if (ss!=null) {
selectedSong = ss;
newPick = ss;
found=true;
break LOOP1;
}
@ -561,7 +575,7 @@ public class MyRobot{
}
SongData ss = SongData.compareData(col);
if (ss!=null) {
selectedSong = ss;
newPick = ss;
found=true;
break LOOP2;
}
@ -575,13 +589,16 @@ public class MyRobot{
}
SongData ss = SongData.compareData(col);
if (ss!=null) {
selectedSong = ss;
newPick = ss;
found=true;
break LOOP2;
}
}
}
}
if (found) {
selectedSong = newPick;
}
}
void go() throws FontFormatException, IOException {
@ -751,7 +768,9 @@ public class MyRobot{
RunTest("test29.png",354,112,4,3,43,67.73f,"EXEX","HS",55,331060,true);
RunTest("test30.png",390,90,8,9,22,74.95f,"N","HS",82,326560,false);
RunTest("test31.png",329,69,8,1,34,72.15f,"EX","HS",40,358760,false);
RunTest("test32.png",0,1,1,0,57,0.57f,"EX","HS",1,1890,true);
//RunTest("test32.png",0,1,1,0,57,0.57f,"EX","HS",1,1890,true);
//RunTest("test33.png",181,84,10,2,5,71.04f,"E","",149,157020,false);
//RunTest("test34.png",28,10,0,0,25,3.66f,"EX","",20,26790,true);
RunTest("testimage.png",371,40,3,4,3,97.63f,"EX","HS",233,523750,false);
RunTest("testimage2.png",942,71,1,0,3,97.02f,"EXEX","",714,951020,false);
RunTest("testimage3.png",546,52,0,0,0,101.77f,"EX","",598,567430,false);
@ -815,6 +834,7 @@ public class MyRobot{
}
Result data = typeface1.getAllData(img,debug);
try {
//assert data.isResult == true : "Expected a result screenshot.";
assert data.cool == _cool : "Expected cool count to be "+_cool+", got "+data.cool;
assert data.fine == _fine : "Expected fine count to be "+_fine+", got "+data.fine;
assert data.safe == _safe : "Expected safe count to be "+_safe+", got "+data.safe;

@ -11,6 +11,7 @@ public class Result {
public boolean fail;
public String mod;
public int combo,score;
public boolean isResult;
public Result(String song,String diff,int cool,int fine,int safe,int sad,int worst,float percent) {
this.songName=song;
this.difficulty=diff;

@ -64,6 +64,8 @@ public class TypeFace2 {
RECT_SEARCH_WORST,
};
//result.isResult=MyRobot.IsResultsScreenshot(ImageUtils.toBufferedImage(img2.getScaledInstance(1227, 690, Image.SCALE_SMOOTH)));
for (int i=0;i<ranges.length;i++) {
Rectangle r = ranges[i];
@ -75,7 +77,9 @@ public class TypeFace2 {
finalNumbers[i]=extractNumbersFromImage(img2.getSubimage(
r.x,r.y,r.width,r.height),debug);
if (finalNumbers[i]==-1) {
return result;
}
}
result.cool = finalNumbers[0];
result.fine = finalNumbers[1];
@ -84,7 +88,9 @@ public class TypeFace2 {
result.worst = finalNumbers[4];
float percent = extractPercentFromImage(img2,debug);
if (percent<0) {
return result;
}
result.percent=percent;
// result.percent = ??
@ -109,9 +115,15 @@ public class TypeFace2 {
//1109,435
result.combo = extractNumbersFromImage(img2.getSubimage(
RECT_SEARCH_COMBO.x,RECT_SEARCH_COMBO.y,RECT_SEARCH_COMBO.width,RECT_SEARCH_COMBO.height),debug);
if (result.combo<0) {
return result;
}
result.score = extractScoreNumbersFromImage(img2.getSubimage(
RECT_SEARCH_SCORE.x,RECT_SEARCH_SCORE.y,RECT_SEARCH_SCORE.width,RECT_SEARCH_SCORE.height),debug);
if (result.score<0) {
return result;
}
return result;
}
@ -374,8 +386,11 @@ public class TypeFace2 {
}
ypointer++;
}
return Float.parseFloat(integer+"."+decimal);
if (integer.length()>0&&decimal.length()>0) {
return Float.parseFloat(integer+"."+decimal);
} else {
return -1.0f;
}
}
private boolean lightColorCheck(Color pixel) {

Loading…
Cancel
Save