package com.example.demo; import java.awt.Image; import java.awt.Point; import java.awt.Rectangle; import java.awt.image.BufferedImage; import java.io.File; import java.io.IOException; import java.util.ArrayList; import java.util.Arrays; import java.util.List; import javax.imageio.ImageIO; import org.json.JSONException; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.util.Assert; import sig.TypeFace; import sig.utils.FileUtils; import sig.utils.ImageUtils; @SpringBootApplication public class DemoApplication { public static List songs = new ArrayList(); public static TypeFace typeface1; public static TypeFace typeface2; public static TypeFace typeface3; static String testdir="resources"; static Integer totalConfidence = 0; static TestResult result = null; static Integer[]controls = new Integer[]{150, 255, 153, 255, 159, 255, 0, 159, 3, 171, 8, 155}; static Integer[]lastControls = new Integer[]{150, 255, 153, 255, 159, 255, 0, 159, 3, 171, 8, 155}; static Integer generation = 30; //Confidence level. public static void main(String[] args) { SpringApplication.run(DemoApplication.class, args); /*File dir = new File("resources"); for (String s : dir.list()) { StringBuilder sb = new StringBuilder(s.replace(".jpg","")).append(":"); boolean first=true; try { BufferedImage img = ImageIO.read(new File(dir,s)); if (img.getWidth()!=1200) { img = ImageUtils.toBufferedImage(img.getScaledInstance(1200, 675, Image.SCALE_SMOOTH)); } for (int y=288;y<288+288;y++) { for (int x=352;x<352+8;x++) { if (!first) { sb.append(","); } else { first=false; } sb.append(img.getRGB(x, y)); } } FileUtils.logToFile(sb.toString(), "colorData"); } catch (IOException e) { e.printStackTrace(); } }*/ /*File dir = new File("resources"); StringBuilder sb = new StringBuilder(); for (String s : dir.list()) { sb.append("and name!='").append(s.replace(".jpg","")).append("' "); } FileUtils.logToFile(sb.toString(), "command");*/ BufferedImage img1 = null; BufferedImage img2 = null; try { img1 = ImageUtils.toCompatibleImage(ImageIO.read(new File("typeface1.png"))); img2 = ImageUtils.toCompatibleImage(ImageIO.read(new File("typeface2.png"))); typeface1 = new TypeFace(img1); typeface3 = new TypeFace(img1); typeface2 = new TypeFace(img2); typeface2.green_minthreshold=typeface2.blue_minthreshold=100; typeface2.green_maxthreshold=typeface2.blue_maxthreshold=200; typeface2.darkFillCheck=false; } catch (IOException e1) { e1.printStackTrace(); } String[] str = FileUtils.readFromFile("colorData"); for (String s : str) { songs.add(new SongData(s)); } RunTest("16 -out of the gravity-.jpg",554,45,1,0,1,101.36f,false,"EX","HS",339,606780); RunTest("*ハロー、プラネット。 (I.M.PLSE-EDIT).jpg",336,128,24,6,93,58.85f,true,"EX","",52,308760); RunTest("39.jpg",531,71,2,0,2,97.82f,false,"EXEX","HS",324,832390); RunTest("39みゅーじっく!.jpg",573,175,5,0,18,91.22f,false,"EX","HS",354,754140); RunTest("1925.jpg",510,115,14,7,22,77.79f,false,"EX","HS",85,564860); RunTest("ACUTE.jpg",478,64,1,1,5,95.76f,false,"EX","HS",197,505210); RunTest("AFTER BURNER.jpg",370,113,25,16,30,68.76f,true,"EX","HS",94,386390); RunTest("Blackjack.jpg",415,123,15,7,50,71.22f,false,"EX","HS",79,443260); RunTest("Catch the Wave.jpg",603,72,0,0,1,100.65f,false,"EX","HS",559,773570); RunTest("Dear.jpg",402,64,0,0,1,100.90f,false,"EXEX","HS",394,587740); RunTest("DECORATOR.jpg",436,100,1,0,6,93.52f,false,"EX","HS",217,560180); RunTest("Fire◎Flower.jpg",86.79f,false,"EXEX","HS"); RunTest("DYE.jpg",530,106,7,2,13,84.77f,false,"EX","HS",143,486360); RunTest("erase or zero.jpg",442,70,0,0,2,100.12f,false,"EX","HS",265,731120); RunTest("FREELY TOMORROW.jpg",367,57,0,0,0,102.84f,false,"EX","HS",424,498640); RunTest("from Y to Y.jpg",350,49,6,1,8,86.35f,false,"EXEX","HS",139,427650); RunTest("Glory 3usi9.jpg",468,43,0,0,2,101.62f,false,"EX","HS",382,549780); RunTest("Hand in Hand.jpg",401,54,1,0,3,97.58f,false,"EX","HS",176,610040); RunTest("Hello, Worker.jpg",439,118,7,1,14,89.93f,false,"EXEX","HS",147,930290); RunTest("Just Be Friends.jpg",510,107,6,0,12,89.38f,false,"EXEX","HS",203,602080); RunTest("Knife.jpg",327,85,14,9,27,51.96f,true,"EX","HS",124,395170); RunTest("LIKE THE WIND.jpg",330,144,20,9,20,72.06f,false,"EX","HS",65,425970); RunTest("LOL -lots of laugh-.jpg",489,59,1,2,2,96.36f,false,"EX","HS",183,641920); RunTest("magnet.jpg",435,101,18,4,35,76.98f,false,"EXEX","HS",115,480540); RunTest("No Logic.jpg",491,101,11,5,15,86.32f,false,"EX","HS",186,476910); RunTest("Nostalogic.jpg",346,70,15,7,16,83.61f,false,"EX","HS",94,486030); RunTest("WORLD'S END UMBRELLA.jpg",437,136,6,1,3,90.59f,false,"H","",215,475120); RunTest("ぽっぴっぽー.jpg",350,46,7,6,3,80.39f,false,"N","",175,263630); RunTest("サマーアイドル.jpg",245,19,4,0,2,87.04f,false,"E","",103,179360); RunTest("ジターバグ_2.jpg","ジターバグ",0,0,0,0,159,0.00f,true,"EX","SD",0,0); RunTest("大江戸ジュリアナイト_2.jpg","大江戸ジュリアナイト",0,0,0,0,79,0.08f,true,"EX","HD",0,580); RunRemoteTest("http://projectdivar.com/files/DECORATOR_EXplay_436_100_1_0_6_93.52.png","DECORATOR",436,100,1,0,6,93.52f,false,"EX","HS",217,560180); RunRemoteTest("http://projectdivar.com/files/img2.png","SING&SMILE",551,168,7,2,15,87.24f,false,"EX","HS",138,733310); RunRemoteTest("http://projectdivar.com/files/img3.png","忘却心中",361,89,31,9,28,79.20f,false,"EXEX","HS",55,693650); RunRemoteTest("http://projectdivar.com/files/img4.png","ロミオとシンデレラ",612,70,7,0,12,88.05f,false,"EX","HS",339,522350); RunRemoteTest("http://projectdivar.com/files/img5.png","巨大少女",441,33,0,1,3,102.11f,false,"EXEX","HS",244,673260); System.out.println("All Tests passed!"); } private static void ModifyResults() { //generation+=result.count-1; if (!result.passed) { if (result.count-1>totalConfidence) { lastControls = controls.clone(); totalConfidence = Math.max(result.count-1,totalConfidence); System.out.println("Passed "+(result.count-1)+" test! Confidence:"+totalConfidence+" Storing lastControls: "+Arrays.toString(lastControls)); } if (result.count-1