diff --git a/readers/DDRReader.java b/readers/DDRReader.java index 3be68c9..02f12a5 100644 --- a/readers/DDRReader.java +++ b/readers/DDRReader.java @@ -20,23 +20,25 @@ public class DDRReader extends Reader{ final static int REGION_PADDING = 32; List extraRegions = new ArrayList<>(); static int lastJump=0; + public DDRReader(){ - readRegions.add(new Box(305,428,402,69)); //score[0] - readRegions.add(new Box(603,565,133,37)); //max combo[1] - readRegions.add(new Box(603,612,133,37)); //marvelous[2] - readRegions.add(new Box(603,651,133,37)); //perfect[3] - readRegions.add(new Box(603,698,133,37)); //great[4] - readRegions.add(new Box(603,742,133,37)); //good[5] - readRegions.add(new Box(603,787,133,37)); //OK[6] - readRegions.add(new Box(603,830,133,37)); //miss[7] - readRegions.add(new Box(603,876,133,37)); //ex score[8] - readRegions.add(new Box(783,738,133,37)); //fast[9] - readRegions.add(new Box(783,821,133,37)); //slow[10] - readRegions.add(new Box(600,165,133,53)); //diffnumb[11] - readRegions.add(new Box(577,91,174,36)); //playstyle[12] - readRegions.add(new Box(253,207,357,183)); //grade[13] - readRegions.add(new Box(756,432,411,38)); //songname[14] - readRegions.add(new Box(576,126,185,40)); //difficulty text[15] + addRegion(new Box(305,428,402,69),NUMBER); //score[0]+ + addRegion(new Box(603,565,133,37),NUMBER); //max combo[1]+ + addRegion(new Box(603,612,133,37),NUMBER); //marvelous[2]+ + addRegion(new Box(603,651,133,37),NUMBER); //perfect[3]+ + addRegion(new Box(603,698,133,37),NUMBER); //great[4]+ + addRegion(new Box(603,742,133,37),NUMBER); //good[5]+ + addRegion(new Box(603,787,133,37),NUMBER); //OK[6]+ + addRegion(new Box(603,830,133,37),NUMBER); //miss[7]+ + addRegion(new Box(603,876,133,37),NUMBER); //ex score[8]+ + addRegion(new Box(783,738,133,37),NUMBER); //fast[9]+ + addRegion(new Box(783,821,133,37),NUMBER); //slow[10]+ + addRegion(new Box(600,165,133,53),NUMBER); //diffnumb[11]+ + addRegion(new Box(577,91,174,36)); //playstyle[12] + addRegion(new Box(253,207,357,183)); //grade[13] + addRegion(new Box(756,432,411,38)); //songname[14] + addRegion(new Box(576,126,185,40)); //difficulty text[15] + init(); } void ColorFilter(int[] arr,int region,int width) { @@ -121,6 +123,7 @@ public class DDRReader extends Reader{ int regionHeights = 0; int maxWidth = 0; + int counter=0; for (int i=0;imaxWidth) { @@ -145,7 +148,10 @@ public class DDRReader extends Reader{ subRegion.setRGB(0,0,readRegions.get(i).w,readRegions.get(i).h,arr,0,readRegions.get(i).w); ImageIO.write(subRegion,"png",new File("sub.png")); cutImg.setRGB(0,currentHeight,readRegions.get(i).w,readRegions.get(i).h,arr,0,readRegions.get(i).w); - System.out.println(interpretImage(subRegion,i)); + String val = interpretImage(subRegion,i); + if (!val.isEmpty()) { + sig_data[counter++]=val; + } currentHeight+=readRegions.get(i).h+REGION_PADDING; } Path output = Paths.get("result.png"); @@ -158,7 +164,8 @@ public class DDRReader extends Reader{ trimAllData(en_data); System.out.println(Arrays.toString(ja_data)); System.out.println(Arrays.toString(en_data)); - interpretOutput(ja_data,en_data); + System.out.println(Arrays.toString(sig_data)); + //interpretOutput(ja_data,en_data); g.dispose(); } catch (IOException e) { e.printStackTrace(); @@ -189,6 +196,23 @@ public class DDRReader extends Reader{ List glyphs = Glyph.split(cutImg); return f.convertGlyphs(glyphs); } + case 2: + case 3: + case 4: + case 5: + case 6: + case 7: + case 9: + case 10:{ + Font f = Font.FONT_DDR_NOTECOUNT; + List glyphs = Glyph.split(cutImg); + return f.convertGlyphs(glyphs); + } + case 11:{ + Font f = Font.FONT_DDR_DIFF; + List glyphs = Glyph.split(cutImg); + return f.convertGlyphs(glyphs); + } } return ""; } diff --git a/readers/ITGReader.java b/readers/ITGReader.java index 1e68d76..0b5a3db 100644 --- a/readers/ITGReader.java +++ b/readers/ITGReader.java @@ -12,23 +12,26 @@ import java.util.regex.Pattern; import javax.imageio.ImageIO; +import readers.fonts.Font; +import readers.fonts.Glyph; + public class ITGReader extends Reader{ final static int REGION_PADDING = 32; List extraRegions = new ArrayList<>(); static int lastJump=0; public ITGReader(){ - readRegions.add(new Box(388,552,227,60)); //score[0] - readRegions.add(new Box(797,438,164,58)); //fantastic+[1] - readRegions.add(new Box(797,493,164,58)); //fantastic[2] - readRegions.add(new Box(797,551,164,58)); //excellent[3] - readRegions.add(new Box(797,618,164,58)); //great[4] - readRegions.add(new Box(797,673,164,58)); //decent[5] - readRegions.add(new Box(797,736,164,58)); //miss[6] - readRegions.add(new Box(279,443,340,104)); //pct[7] - readRegions.add(new Box(277,364,64,60)); //diffnumb[8] - readRegions.add(new Box(344,393,266,36)); //playstyle[9] - readRegions.add(new Box(277,174,324,171)); //grade[10] - readRegions.add(new Box(632,106,656,43)); //songname[11] + addRegion(new Box(388,552,227,60),NUMBER); //score[0] + addRegion(new Box(797,438,164,58),NUMBER); //fantastic+[1] + addRegion(new Box(797,493,164,58),NUMBER); //fantastic[2] + addRegion(new Box(797,551,164,58),NUMBER); //excellent[3] + addRegion(new Box(797,618,164,58),NUMBER); //great[4] + addRegion(new Box(797,673,164,58),NUMBER); //decent[5] + addRegion(new Box(797,736,164,58),NUMBER); //miss[6] + addRegion(new Box(279,443,340,104),NUMBER); //pct[7] + addRegion(new Box(277,364,64,60),NUMBER); //diffnumb[8] + addRegion(new Box(344,393,266,36)); //playstyle[9] + addRegion(new Box(277,174,324,171)); //grade[10] + addRegion(new Box(632,106,656,43)); //songname[11] } void ColorFilter(int[] arr,int region,int width) { @@ -96,6 +99,7 @@ public class ITGReader extends Reader{ int regionHeights = 0; int maxWidth = 0; + int counter = 0; for (int i=0;imaxWidth) { @@ -108,14 +112,22 @@ public class ITGReader extends Reader{ Graphics2D g = cutImg.createGraphics(); int currentHeight=0; for (int i=0;i glyphs = Glyph.split(cutImg); + if (glyphs.size()==9) { + //This is a 1,000,000 score. + glyphs.remove(5); + glyphs.remove(1); + } else + if (glyphs.size()>4) { + //This is a XXX,XXX score. + glyphs.remove(3); + } + return f.convertGlyphs(glyphs); + } + } + return ""; + } + @Override void interpretResults(String[] finalData) { // TODO Auto-generated method stub diff --git a/readers/Reader.java b/readers/Reader.java index d18a15e..a2485aa 100644 --- a/readers/Reader.java +++ b/readers/Reader.java @@ -10,6 +10,7 @@ import java.awt.Color; public abstract class Reader{ final static int REGION_PADDING = 32; + final static boolean NUMBER = true; int score; int rank; int[] notes = new int[7]; @@ -18,8 +19,22 @@ public abstract class Reader{ double pct; int maxcombo; String other=""; + String[] sig_data; List readRegions = new ArrayList<>(); + int sig_data_size = 0; final int TRANSPARENT = new Color(0,0,0,0).getRGB(); + protected void addRegion(Box box) { + addRegion(box,false); + } + protected void addRegion(Box box,boolean isNumb) { + readRegions.add(box); + if (isNumb) { + sig_data_size++; + } + } + protected void init() { + sig_data = new String[sig_data_size]; + } String readAllBoxes(Path img) { try { Process p = Runtime.getRuntime().exec(new String[]{"python3","runocr.py","ja",img.toAbsolutePath().toString()}); diff --git a/result.png b/result.png index ff2526c..7bba1c8 100644 Binary files a/result.png and b/result.png differ diff --git a/sigPlace.java b/sigPlace.java index 1a49794..e1fd5a7 100644 --- a/sigPlace.java +++ b/sigPlace.java @@ -81,7 +81,7 @@ public class sigPlace { final static int TRANSPARENT = new Color(0,0,0,0).getRGB(); public static void main(String[] args) { - String fontName = "sdvx_EXScore"; + /*String fontName = "sdvx_EXScore"; String value = "04882"; Path f = Paths.get("sdvx2.png"); BufferedImage img; @@ -114,8 +114,8 @@ public class sigPlace { } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); - } - //ArcadeReader.retrieveData(Paths.get("ddr5.png")); + }*/ + ArcadeReader.retrieveData(Paths.get("ddr5.png")); /* Path secretFile = Paths.get(".clientsecret"); List data; try { diff --git a/sub.png b/sub.png index 060b478..bcf1cd0 100644 Binary files a/sub.png and b/sub.png differ