Fix FT song recognition.
BIN
image.png
Before Width: | Height: | Size: 1.6 MiB After Width: | Height: | Size: 1.8 MiB |
@ -165,7 +165,8 @@ public class Controller {
|
||||
|
||||
if (img.getWidth()!=1200) {
|
||||
//Resize.
|
||||
img = ImageUtils.toBufferedImage(ImageIO.read(f).getScaledInstance(1200, 675, Image.SCALE_SMOOTH));
|
||||
img = ImageUtils.toBufferedImage(img.getScaledInstance(1200, 675, Image.SCALE_SMOOTH));
|
||||
//ImageIO.write(img,"png",new File("testresize.png"));
|
||||
}
|
||||
Point offset = new Point(418,204);
|
||||
File tmp = new File("tmp");
|
||||
@ -230,7 +231,6 @@ public class Controller {
|
||||
}
|
||||
}
|
||||
img = img.getSubimage(crop2.x, crop1.y, crop1.x-crop2.x, crop2.y-crop1.y);
|
||||
//ImageIO.write(img,"png",new File("test.png"));
|
||||
} else {
|
||||
MyRobot.FUTURETONE=false;
|
||||
}
|
||||
@ -238,19 +238,25 @@ public class Controller {
|
||||
return img;
|
||||
}
|
||||
|
||||
public static String getSongTitle(BufferedImage img) {
|
||||
public static String getSongTitle(BufferedImage img) throws IOException {
|
||||
final int THRESHOLD=1;
|
||||
float lowestMatching = Integer.MAX_VALUE;
|
||||
SongData matchingSong = null;
|
||||
//There are 2304 pixels total. Once 2188 match, we'll call it good.
|
||||
if (MyRobot.FUTURETONE) {
|
||||
File f = new File("debugcol");
|
||||
FileUtils.deleteFile(f);
|
||||
f.mkdirs();
|
||||
for (SongData song : DemoApplication.FTsongs) {
|
||||
BufferedImage debug = new BufferedImage(16,288,BufferedImage.TYPE_INT_ARGB);
|
||||
float matching = 0;
|
||||
for (int y=0;y<288;y++) {
|
||||
for (int x=0;x<8;x++) {
|
||||
Color p2 = song.data[(y*8)+x];
|
||||
Color p1 = new Color(img.getRGB(x+352, y+288));
|
||||
matching+=ImageUtils.distanceToColor(p2,p1);
|
||||
/*debug.setRGB(x,y,p2.getRGB());
|
||||
debug.setRGB(x+8,y,p1.getRGB());*/
|
||||
}
|
||||
}
|
||||
if (matching<lowestMatching) {
|
||||
@ -260,11 +266,12 @@ public class Controller {
|
||||
|
||||
/*try {
|
||||
PrintStream out = new PrintStream(System.out, true, "UTF-8");
|
||||
out.println("Comparing to "+song.song+": "+matching);
|
||||
out.println("Comparing to "+song.song.replaceAll("/","").replaceAll("\\*","").replaceAll(":","")+": "+matching);
|
||||
//ImageIO.write(debug,"png",new File("debugcol",song.song.replaceAll("/","").replaceAll("\\*","").replaceAll(":","")));
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
e.printStackTrace();
|
||||
}*/
|
||||
|
||||
}
|
||||
*/
|
||||
}
|
||||
} else {
|
||||
for (SongData song : DemoApplication.songs) {
|
||||
|
@ -101,6 +101,7 @@ public class DemoApplication {
|
||||
RunTest("サマーアイドル.jpg",245,19,4,0,2,87.04f,false,"E","",103,179360);
|
||||
RunTest("アゲアゲアゲイン_alt.jpg","アゲアゲアゲイン",452,201,20,11,34,71.89f,false,"EX","",115,543240,false);
|
||||
RunTest("test.jpg","1/6 -out of the gravity-",575,26,0,0,0,104.51f,false,"EX","HS",601,698951,false);
|
||||
RunTest("test2.jpg","エンヴィキャットウォーク",26,6,2,3,129,4.96f,true,"EX","HS",3,47575,false);
|
||||
RunTest("EiMmwvJUMAEVmaT.jpg","アゲアゲアゲイン",0,0,0,0,89,0.00f,true,"E","",0,0,false);
|
||||
//RunTest("test38.jpg","サマーアイドル",345,49,6,2,2,94.53f,false,"H","",232,347990,false);
|
||||
//RunTest("ジターバグ_2.jpg","ジターバグ",0,0,0,0,159,0.00f,true,"EX","SD",0,0);
|
||||
@ -190,10 +191,11 @@ public class DemoApplication {
|
||||
Assert.isTrue(f.exists(),"Expected file to exist: "+f.getAbsoluteFile());
|
||||
img = ImageIO.read(f);
|
||||
img = Controller.CropFutureToneImage(img);
|
||||
ImageIO.write(img,"png",new File("test.png"));
|
||||
Result r = typeface1.getAllData(img,debug);
|
||||
if (img.getWidth()!=1200) {
|
||||
//Resize.
|
||||
img = ImageUtils.toBufferedImage(ImageIO.read(f).getScaledInstance(1200, 675, Image.SCALE_SMOOTH));
|
||||
img = ImageUtils.toBufferedImage(img.getScaledInstance(1200, 675, Image.SCALE_SMOOTH));
|
||||
}
|
||||
ImageIO.write(img,"png",new File("image.png"));
|
||||
String song = Controller.getSongTitle(img);
|
||||
|
Before Width: | Height: | Size: 1.5 MiB After Width: | Height: | Size: 1.5 MiB |
BIN
test.png
Before Width: | Height: | Size: 2.1 MiB After Width: | Height: | Size: 1.7 MiB |
BIN
testsuite/test2.jpg
Normal file
After Width: | Height: | Size: 429 KiB |