|
|
@ -12,23 +12,26 @@ import java.util.regex.Pattern; |
|
|
|
|
|
|
|
|
|
|
|
import javax.imageio.ImageIO; |
|
|
|
import javax.imageio.ImageIO; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import readers.fonts.Font; |
|
|
|
|
|
|
|
import readers.fonts.Glyph; |
|
|
|
|
|
|
|
|
|
|
|
public class ITGReader extends Reader{ |
|
|
|
public class ITGReader extends Reader{ |
|
|
|
final static int REGION_PADDING = 32; |
|
|
|
final static int REGION_PADDING = 32; |
|
|
|
List<Box> extraRegions = new ArrayList<>(); |
|
|
|
List<Box> extraRegions = new ArrayList<>(); |
|
|
|
static int lastJump=0; |
|
|
|
static int lastJump=0; |
|
|
|
public ITGReader(){ |
|
|
|
public ITGReader(){ |
|
|
|
readRegions.add(new Box(388,552,227,60)); //score[0]
|
|
|
|
addRegion(new Box(388,552,227,60),NUMBER); //score[0]
|
|
|
|
readRegions.add(new Box(797,438,164,58)); //fantastic+[1]
|
|
|
|
addRegion(new Box(797,438,164,58),NUMBER); //fantastic+[1]
|
|
|
|
readRegions.add(new Box(797,493,164,58)); //fantastic[2]
|
|
|
|
addRegion(new Box(797,493,164,58),NUMBER); //fantastic[2]
|
|
|
|
readRegions.add(new Box(797,551,164,58)); //excellent[3]
|
|
|
|
addRegion(new Box(797,551,164,58),NUMBER); //excellent[3]
|
|
|
|
readRegions.add(new Box(797,618,164,58)); //great[4]
|
|
|
|
addRegion(new Box(797,618,164,58),NUMBER); //great[4]
|
|
|
|
readRegions.add(new Box(797,673,164,58)); //decent[5]
|
|
|
|
addRegion(new Box(797,673,164,58),NUMBER); //decent[5]
|
|
|
|
readRegions.add(new Box(797,736,164,58)); //miss[6]
|
|
|
|
addRegion(new Box(797,736,164,58),NUMBER); //miss[6]
|
|
|
|
readRegions.add(new Box(279,443,340,104)); //pct[7]
|
|
|
|
addRegion(new Box(279,443,340,104),NUMBER); //pct[7]
|
|
|
|
readRegions.add(new Box(277,364,64,60)); //diffnumb[8]
|
|
|
|
addRegion(new Box(277,364,64,60),NUMBER); //diffnumb[8]
|
|
|
|
readRegions.add(new Box(344,393,266,36)); //playstyle[9]
|
|
|
|
addRegion(new Box(344,393,266,36)); //playstyle[9]
|
|
|
|
readRegions.add(new Box(277,174,324,171)); //grade[10]
|
|
|
|
addRegion(new Box(277,174,324,171)); //grade[10]
|
|
|
|
readRegions.add(new Box(632,106,656,43)); //songname[11]
|
|
|
|
addRegion(new Box(632,106,656,43)); //songname[11]
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void ColorFilter(int[] arr,int region,int width) { |
|
|
|
void ColorFilter(int[] arr,int region,int width) { |
|
|
@ -96,6 +99,7 @@ public class ITGReader extends Reader{ |
|
|
|
|
|
|
|
|
|
|
|
int regionHeights = 0; |
|
|
|
int regionHeights = 0; |
|
|
|
int maxWidth = 0; |
|
|
|
int maxWidth = 0; |
|
|
|
|
|
|
|
int counter = 0; |
|
|
|
for (int i=0;i<readRegions.size();i++) { |
|
|
|
for (int i=0;i<readRegions.size();i++) { |
|
|
|
regionHeights+=readRegions.get(i).h+REGION_PADDING; |
|
|
|
regionHeights+=readRegions.get(i).h+REGION_PADDING; |
|
|
|
if (readRegions.get(i).w>maxWidth) { |
|
|
|
if (readRegions.get(i).w>maxWidth) { |
|
|
@ -108,14 +112,22 @@ public class ITGReader extends Reader{ |
|
|
|
Graphics2D g = cutImg.createGraphics(); |
|
|
|
Graphics2D g = cutImg.createGraphics(); |
|
|
|
int currentHeight=0; |
|
|
|
int currentHeight=0; |
|
|
|
for (int i=0;i<readRegions.size();i++) { |
|
|
|
for (int i=0;i<readRegions.size();i++) { |
|
|
|
int[] arr = originalImg.getRGB(readRegions.get(i).x, readRegions.get(i).y, readRegions.get(i).w, readRegions.get(i).h, null, 0, readRegions.get(i).w); |
|
|
|
BufferedImage subRegion = new BufferedImage(readRegions.get(i).w, readRegions.get(i).h,BufferedImage.TYPE_INT_ARGB); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
subRegion.setRGB(0,0,readRegions.get(i).w,readRegions.get(i).h,originalImg.getRGB(readRegions.get(i).x, readRegions.get(i).y, readRegions.get(i).w, readRegions.get(i).h, null, 0, readRegions.get(i).w),0,readRegions.get(i).w); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int[] arr = subRegion.getRGB(0, 0, readRegions.get(i).w, readRegions.get(i).h, null, 0, readRegions.get(i).w); |
|
|
|
//System.out.println(Arrays.toString(arr));
|
|
|
|
//System.out.println(Arrays.toString(arr));
|
|
|
|
//System.out.println(i);
|
|
|
|
//System.out.println(i);
|
|
|
|
//ImageIO.write(originalImg.getSubimage(readRegions.get(i).x, readRegions.get(i).y, readRegions.get(i).w, readRegions.get(i).h),"png",new File("cut.png"));
|
|
|
|
//ImageIO.write(originalImg.getSubimage(readRegions.get(i).x, readRegions.get(i).y, readRegions.get(i).w, readRegions.get(i).h),"png",new File("cut.png"));
|
|
|
|
System.out.println(i); |
|
|
|
|
|
|
|
ColorFilter(arr,i,readRegions.get(i).w); |
|
|
|
ColorFilter(arr,i,readRegions.get(i).w); |
|
|
|
|
|
|
|
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); |
|
|
|
cutImg.setRGB(0,currentHeight,readRegions.get(i).w,readRegions.get(i).h,arr,0,readRegions.get(i).w); |
|
|
|
currentHeight+=readRegions.get(i).h+REGION_PADDING; |
|
|
|
String val = interpretImage(subRegion,i); |
|
|
|
|
|
|
|
if (!val.isEmpty()) { |
|
|
|
|
|
|
|
sig_data[counter++]=val; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
Path output = Paths.get("result.png"); |
|
|
|
Path output = Paths.get("result.png"); |
|
|
|
ImageIO.write(cutImg,"png",output.toFile()); |
|
|
|
ImageIO.write(cutImg,"png",output.toFile()); |
|
|
@ -127,6 +139,7 @@ public class ITGReader extends Reader{ |
|
|
|
trimAllData(en_data); |
|
|
|
trimAllData(en_data); |
|
|
|
System.out.println(Arrays.toString(ja_data)); |
|
|
|
System.out.println(Arrays.toString(ja_data)); |
|
|
|
System.out.println(Arrays.toString(en_data)); |
|
|
|
System.out.println(Arrays.toString(en_data)); |
|
|
|
|
|
|
|
System.out.println(Arrays.toString(sig_data)); |
|
|
|
interpretOutput(ja_data,en_data); |
|
|
|
interpretOutput(ja_data,en_data); |
|
|
|
g.dispose(); |
|
|
|
g.dispose(); |
|
|
|
} catch (IOException e) { |
|
|
|
} catch (IOException e) { |
|
|
@ -136,6 +149,26 @@ public class ITGReader extends Reader{ |
|
|
|
//System.out.println(data[2]);
|
|
|
|
//System.out.println(data[2]);
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private String interpretImage(BufferedImage cutImg, int i) { |
|
|
|
|
|
|
|
switch (i) { |
|
|
|
|
|
|
|
case 0:{ |
|
|
|
|
|
|
|
Font f = Font.FONT_DDR_SCORE; |
|
|
|
|
|
|
|
List<Glyph> 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 |
|
|
|
@Override |
|
|
|
void interpretResults(String[] finalData) { |
|
|
|
void interpretResults(String[] finalData) { |
|
|
|
// TODO Auto-generated method stub
|
|
|
|
// TODO Auto-generated method stub
|
|
|
|