Song select screen recognition using calibration now fully implemented.
This commit is contained in:
parent
62a3e7f776
commit
42cd32c0a3
@ -1,10 +1,5 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<classpath>
|
<classpath>
|
||||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-11">
|
|
||||||
<attributes>
|
|
||||||
<attribute name="maven.pomderived" value="true"/>
|
|
||||||
</attributes>
|
|
||||||
</classpathentry>
|
|
||||||
<classpathentry including="**/*.java" kind="src" output="target/classes" path="src">
|
<classpathentry including="**/*.java" kind="src" output="target/classes" path="src">
|
||||||
<attributes>
|
<attributes>
|
||||||
<attribute name="optional" value="true"/>
|
<attribute name="optional" value="true"/>
|
||||||
@ -16,5 +11,6 @@
|
|||||||
<attribute name="maven.pomderived" value="true"/>
|
<attribute name="maven.pomderived" value="true"/>
|
||||||
</attributes>
|
</attributes>
|
||||||
</classpathentry>
|
</classpathentry>
|
||||||
|
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"/>
|
||||||
<classpathentry kind="output" path="target/classes"/>
|
<classpathentry kind="output" path="target/classes"/>
|
||||||
</classpath>
|
</classpath>
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
eclipse.preferences.version=1
|
eclipse.preferences.version=1
|
||||||
encoding//src/sig/FutureToneBot.java=UTF-8
|
encoding//src/sig/FutureToneBot.java=UTF-8
|
||||||
encoding//src/sig/MyRobot.java=UTF-8
|
encoding//src/sig/MyRobot.java=UTF-8
|
||||||
encoding/colorData=UTF-8
|
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
eclipse.preferences.version=1
|
eclipse.preferences.version=1
|
||||||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
||||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=11
|
org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate
|
||||||
|
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
|
||||||
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
|
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
|
||||||
org.eclipse.jdt.core.compiler.compliance=11
|
org.eclipse.jdt.core.compiler.compliance=1.7
|
||||||
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
|
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
|
||||||
org.eclipse.jdt.core.compiler.debug.localVariable=generate
|
org.eclipse.jdt.core.compiler.debug.localVariable=generate
|
||||||
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
|
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
|
||||||
@ -12,4 +13,4 @@ org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
|
|||||||
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
|
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
|
||||||
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning
|
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning
|
||||||
org.eclipse.jdt.core.compiler.release=enabled
|
org.eclipse.jdt.core.compiler.release=enabled
|
||||||
org.eclipse.jdt.core.compiler.source=11
|
org.eclipse.jdt.core.compiler.source=1.7
|
||||||
|
BIN
DivaBot/DivaBot.jar
Normal file
BIN
DivaBot/DivaBot.jar
Normal file
Binary file not shown.
4
DivaBot/calibration_data.txt
Normal file
4
DivaBot/calibration_data.txt
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
530
|
||||||
|
260
|
||||||
|
1573
|
||||||
|
845
|
File diff suppressed because one or more lines are too long
195
DivaBot/colorData.old
Normal file
195
DivaBot/colorData.old
Normal file
File diff suppressed because one or more lines are too long
@ -9,6 +9,8 @@ import java.io.IOException;
|
|||||||
import javax.imageio.ImageIO;
|
import javax.imageio.ImageIO;
|
||||||
import javax.swing.JPanel;
|
import javax.swing.JPanel;
|
||||||
|
|
||||||
|
import sig.utils.FileUtils;
|
||||||
|
|
||||||
public class Calibrator{
|
public class Calibrator{
|
||||||
|
|
||||||
public static BufferedImage img;
|
public static BufferedImage img;
|
||||||
@ -62,6 +64,11 @@ public class Calibrator{
|
|||||||
//MyRobot.CALIBRATIONSTATUS="First calibration set done: X"+(x-MyRobot.STARTDRAG.x)+" Y"+(y-MyRobot.STARTDRAG.y);
|
//MyRobot.CALIBRATIONSTATUS="First calibration set done: X"+(x-MyRobot.STARTDRAG.x)+" Y"+(y-MyRobot.STARTDRAG.y);
|
||||||
img = MyRobot.MYROBOT.getSizedCapture(new Rectangle(0,0,MyRobot.screenSize.width,MyRobot.screenSize.height));
|
img = MyRobot.MYROBOT.getSizedCapture(new Rectangle(0,0,MyRobot.screenSize.width,MyRobot.screenSize.height));
|
||||||
ImageIO.write(img.getSubimage(MyRobot.STARTDRAG.x,MyRobot.STARTDRAG.y,MyRobot.ENDDRAG.x-MyRobot.STARTDRAG.x,MyRobot.ENDDRAG.y-MyRobot.STARTDRAG.y),"png",new File("capture_5.png"));
|
ImageIO.write(img.getSubimage(MyRobot.STARTDRAG.x,MyRobot.STARTDRAG.y,MyRobot.ENDDRAG.x-MyRobot.STARTDRAG.x,MyRobot.ENDDRAG.y-MyRobot.STARTDRAG.y),"png",new File("capture_5.png"));
|
||||||
|
FileUtils.deleteFile("calibration_data.txt");
|
||||||
|
FileUtils.logToFile(Integer.toString(MyRobot.STARTDRAG.x), "calibration_data.txt");
|
||||||
|
FileUtils.logToFile(Integer.toString(MyRobot.STARTDRAG.y), "calibration_data.txt");
|
||||||
|
FileUtils.logToFile(Integer.toString(MyRobot.ENDDRAG.x), "calibration_data.txt");
|
||||||
|
FileUtils.logToFile(Integer.toString(MyRobot.ENDDRAG.y), "calibration_data.txt");
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean CalibrationStage1() throws IOException, InterruptedException {
|
private boolean CalibrationStage1() throws IOException, InterruptedException {
|
||||||
|
@ -10,12 +10,16 @@ import java.io.IOException;
|
|||||||
|
|
||||||
import javax.imageio.ImageIO;
|
import javax.imageio.ImageIO;
|
||||||
|
|
||||||
|
import sig.utils.FileUtils;
|
||||||
import sig.utils.ImageUtils;
|
import sig.utils.ImageUtils;
|
||||||
|
|
||||||
public class CustomRobot extends Robot{
|
public class CustomRobot extends Robot{
|
||||||
|
|
||||||
|
File calibration_file = new File("calibration_data.txt");
|
||||||
BufferedImage currentScreen;
|
BufferedImage currentScreen;
|
||||||
BufferedImage scoreCurrentScreen;
|
BufferedImage scoreCurrentScreen;
|
||||||
|
int[] calibration_data = new int[]{0,0,1,1};
|
||||||
|
long lastCalibrationTime = 0;
|
||||||
|
|
||||||
public CustomRobot() throws AWTException {
|
public CustomRobot() throws AWTException {
|
||||||
super();
|
super();
|
||||||
@ -30,19 +34,43 @@ public class CustomRobot extends Robot{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void refreshScreen() {
|
public void refreshScreen() {
|
||||||
currentScreen = super.createScreenCapture(new Rectangle(418+18,204+83,912-18,586-83));
|
//currentScreen = super.createScreenCapture(new Rectangle(418+18,204+83,912-18,586-83));
|
||||||
|
if (CalibrationDataChanged()) {
|
||||||
|
ReloadCalibrationData();
|
||||||
|
}
|
||||||
|
if (calibration_data.length>0) {
|
||||||
|
currentScreen = super.createScreenCapture(new Rectangle(calibration_data[0],calibration_data[1],calibration_data[2]-calibration_data[0],calibration_data[3]-calibration_data[1]));
|
||||||
|
} else {
|
||||||
|
currentScreen = super.createScreenCapture(new Rectangle(418+18,204+83,912-18,586-83));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
private void ReloadCalibrationData() {
|
||||||
|
lastCalibrationTime=calibration_file.lastModified();
|
||||||
|
String[] data = FileUtils.readFromFile("calibration_data.txt");
|
||||||
|
calibration_data[0]=Integer.parseInt(data[0]);
|
||||||
|
calibration_data[1]=Integer.parseInt(data[1]);
|
||||||
|
calibration_data[2]=Integer.parseInt(data[2]);
|
||||||
|
calibration_data[3]=Integer.parseInt(data[3]);
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean CalibrationDataChanged() {
|
||||||
|
return calibration_file.exists()&&lastCalibrationTime!=calibration_file.lastModified();
|
||||||
|
}
|
||||||
|
|
||||||
public void refreshScoreScreen() {
|
public void refreshScoreScreen() {
|
||||||
scoreCurrentScreen = super.createScreenCapture(new Rectangle(418+23,204+85,912-18,586-83));
|
if (CalibrationDataChanged()) {
|
||||||
|
ReloadCalibrationData();
|
||||||
|
}
|
||||||
|
if (calibration_data.length>0) {
|
||||||
|
scoreCurrentScreen = super.createScreenCapture(new Rectangle(calibration_data[0],calibration_data[1],calibration_data[2]-calibration_data[0],calibration_data[3]-calibration_data[1]));
|
||||||
|
} else {
|
||||||
|
scoreCurrentScreen = super.createScreenCapture(new Rectangle(418+23,204+85,912-18,586-83));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized BufferedImage createScreenCapture(Rectangle r) {
|
public synchronized BufferedImage createScreenCapture(Rectangle r) {
|
||||||
BufferedImage img2 = ImageUtils.toBufferedImage(currentScreen.getScaledInstance(1227, 690, BufferedImage.SCALE_AREA_AVERAGING));
|
return ImageUtils.toBufferedImage(currentScreen.getScaledInstance(1227, 690, BufferedImage.SCALE_AREA_AVERAGING)).getSubimage(r.x, r.y, r.width, r.height);
|
||||||
return img2.getSubimage(r.x-418, r.y-204, r.width, r.height);
|
//return img2.getSubimage(r.x-418, r.y-204, r.width, r.height);
|
||||||
}
|
|
||||||
public synchronized BufferedImage createNormalScreenCapture(Rectangle r) {
|
|
||||||
return currentScreen.getSubimage((int)((r.x-418)*(894d/1227)), (int)((r.y-204)*(503d/690)), (int)Math.ceil(r.width*(894d/1227)), (int)Math.ceil(r.height*(503d/690)));
|
|
||||||
//return super.createScreenCapture(new Rectangle(r.x-418,r.y-204,912-18,586-83));
|
|
||||||
}
|
}
|
||||||
public synchronized BufferedImage createScoreScreenCapture() {
|
public synchronized BufferedImage createScoreScreenCapture() {
|
||||||
return scoreCurrentScreen;
|
return scoreCurrentScreen;
|
||||||
|
@ -103,7 +103,7 @@ public class DrawCanvas extends JPanel implements KeyListener{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void pullData(String songname,String difficulty) {
|
public void pullData(final String songname,final String difficulty) {
|
||||||
this.songname=(songname.equalsIgnoreCase("PIANOGIRL")?"PIANO*GIRL":(songname.equalsIgnoreCase("16 -out of the gravity-"))?"1/6 -out of the gravity-":songname);
|
this.songname=(songname.equalsIgnoreCase("PIANOGIRL")?"PIANO*GIRL":(songname.equalsIgnoreCase("16 -out of the gravity-"))?"1/6 -out of the gravity-":songname);
|
||||||
this.difficulty=difficulty;
|
this.difficulty=difficulty;
|
||||||
romanizedname="";
|
romanizedname="";
|
||||||
@ -124,42 +124,46 @@ public class DrawCanvas extends JPanel implements KeyListener{
|
|||||||
romanizedname = obj.getString("romanized_name");
|
romanizedname = obj.getString("romanized_name");
|
||||||
englishname = obj.getString("english_name");
|
englishname = obj.getString("english_name");
|
||||||
artist = obj.getString("artist");*/
|
artist = obj.getString("artist");*/
|
||||||
SongInfo currentSong = SongInfo.getByTitle(MyRobot.p.songname);
|
if (MyRobot.p.songname!=null) {
|
||||||
if (currentSong.rating.has(difficulty)) {
|
SongInfo currentSong = SongInfo.getByTitle(MyRobot.p.songname);
|
||||||
difficultyRating = currentSong.rating.getDouble(difficulty);
|
if (currentSong!=null) {
|
||||||
}
|
if (currentSong.rating.has(difficulty)) {
|
||||||
romanizedname = currentSong.romanized_name;
|
difficultyRating = currentSong.rating.getDouble(difficulty);
|
||||||
englishname = currentSong.english_name;
|
}
|
||||||
artist = currentSong.artist;
|
romanizedname = currentSong.romanized_name;
|
||||||
JSONObject obj = FileUtils.readJsonFromUrl("http://45.33.13.215:4501/bestplay/sigonasr2/"+URLEncoder.encode(MyRobot.p.songname, StandardCharsets.UTF_8.toString()).replaceAll("\\+", "%20")+"/"+difficulty);
|
englishname = currentSong.english_name;
|
||||||
if (obj.has("cool")) {
|
artist = currentSong.artist;
|
||||||
bestPlay = new Result(MyRobot.p.songname,difficulty,obj.getInt("cool"),obj.getInt("fine"),obj.getInt("safe"),obj.getInt("sad"),obj.getInt("worst"),(float)obj.getDouble("percent"));
|
JSONObject obj = FileUtils.readJsonFromUrl("http://45.33.13.215:4501/bestplay/sigonasr2/"+URLEncoder.encode(MyRobot.p.songname, StandardCharsets.UTF_8.toString()).replaceAll("\\+", "%20")+"/"+difficulty);
|
||||||
lastScore = obj.getDouble("score");
|
if (obj.has("cool")) {
|
||||||
} else {
|
bestPlay = new Result(MyRobot.p.songname,difficulty,obj.getInt("cool"),obj.getInt("fine"),obj.getInt("safe"),obj.getInt("sad"),obj.getInt("worst"),(float)obj.getDouble("percent"));
|
||||||
bestPlay = null;
|
lastScore = obj.getDouble("score");
|
||||||
}
|
} else {
|
||||||
obj = FileUtils.readJsonFromUrl("http://45.33.13.215:4501/playcount/sigonasr2/"+URLEncoder.encode(MyRobot.p.songname, StandardCharsets.UTF_8.toString()).replaceAll("\\+", "%20")+"/"+difficulty);
|
bestPlay = null;
|
||||||
plays = obj.getInt("playcount");
|
}
|
||||||
obj = FileUtils.readJsonFromUrl("http://45.33.13.215:4501/songpasscount/sigonasr2/"+URLEncoder.encode(MyRobot.p.songname, StandardCharsets.UTF_8.toString()).replaceAll("\\+", "%20")+"/"+difficulty);
|
obj = FileUtils.readJsonFromUrl("http://45.33.13.215:4501/playcount/sigonasr2/"+URLEncoder.encode(MyRobot.p.songname, StandardCharsets.UTF_8.toString()).replaceAll("\\+", "%20")+"/"+difficulty);
|
||||||
passes = obj.getInt("passcount");
|
plays = obj.getInt("playcount");
|
||||||
obj = FileUtils.readJsonFromUrl("http://45.33.13.215:4501/songfccount/sigonasr2/"+URLEncoder.encode(MyRobot.p.songname, StandardCharsets.UTF_8.toString()).replaceAll("\\+", "%20")+"/"+difficulty);
|
obj = FileUtils.readJsonFromUrl("http://45.33.13.215:4501/songpasscount/sigonasr2/"+URLEncoder.encode(MyRobot.p.songname, StandardCharsets.UTF_8.toString()).replaceAll("\\+", "%20")+"/"+difficulty);
|
||||||
fcCount = obj.getInt("fccount");
|
passes = obj.getInt("passcount");
|
||||||
/*obj = FileUtils.readJsonFromUrl("http://45.33.13.215:4501/rating/sigonasr2");
|
obj = FileUtils.readJsonFromUrl("http://45.33.13.215:4501/songfccount/sigonasr2/"+URLEncoder.encode(MyRobot.p.songname, StandardCharsets.UTF_8.toString()).replaceAll("\\+", "%20")+"/"+difficulty);
|
||||||
lastRating = overallrating;
|
fcCount = obj.getInt("fccount");
|
||||||
overallrating = (int)obj.getDouble("rating");
|
/*obj = FileUtils.readJsonFromUrl("http://45.33.13.215:4501/rating/sigonasr2");
|
||||||
if (lastRating<overallrating) {ratingTime=System.currentTimeMillis();}
|
lastRating = overallrating;
|
||||||
*/
|
overallrating = (int)obj.getDouble("rating");
|
||||||
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;
|
if (lastRating<overallrating) {ratingTime=System.currentTimeMillis();}
|
||||||
Rectangle2D bounds = TextUtils.calculateStringBoundsFont(text, programFont);
|
*/
|
||||||
if (bounds.getWidth()>1345) {
|
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;
|
||||||
scrolling=true;
|
Rectangle2D bounds = TextUtils.calculateStringBoundsFont(text, programFont);
|
||||||
} else {
|
if (bounds.getWidth()>1345) {
|
||||||
scrolling=false;
|
scrolling=true;
|
||||||
}
|
} else {
|
||||||
scrollX = 0;
|
scrolling=false;
|
||||||
MyRobot.p.repaint(0,0,1400,1000);
|
}
|
||||||
|
scrollX = 0;
|
||||||
|
MyRobot.p.repaint(0,0,1400,1000);
|
||||||
|
}
|
||||||
|
}
|
||||||
} catch (JSONException | IOException e) {
|
} catch (JSONException | IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -89,9 +89,10 @@ public class MyRobot{
|
|||||||
static CustomRobot MYROBOT;
|
static CustomRobot MYROBOT;
|
||||||
Color SCREEN[][];
|
Color SCREEN[][];
|
||||||
static SongData SONGS[];
|
static SongData SONGS[];
|
||||||
//static String SONGNAMES[] = new String[] {"Yellow","The secret garden","Tell Your World","愛言葉","Weekender Girl","歌に形はないけれど","えれくとりっく・えんじぇぅ","神曲","カンタレラ","巨大少女","クローバー♣クラブ","恋スルVOC@LOID","桜ノ雨","39","深海シティアンダーグラウンド","深海少女","積乱雲グラフィティ","千年の独奏歌","ダブルラリアット","ハジメテノオト","初めての恋が終わる時","packaged","Palette","FREELY TOMORROW","from Y to Y","みくみくにしてあげる♪","メルト","モノクロ∞ブルースカイ","ゆめゆめ","16 -out of the gravity-","ACUTE","インタビュア","LOL -lots of laugh-","Glory 3usi9","soundless voice","ジェミニ","白い雪のプリンセスは","スキキライ","タイムマシン","Dear","DECORATOR","トリコロール・エア・ライン","Nostalogic","Hand in Hand","Fire◎Flower","ブラック★ロックシューター","メテオ","ワールドイズマイン","アマツキツネ","erase or zero","エレクトロサチュレイタ","on the rocks","からくりピエロ","カラフル×メロディ","Catch the Wave","キャットフード","サマーアイドル","shake it!","Just Be Friends","スイートマジック","SPiCa -39's Giving Day Edition-","番凩","テレカクシ思春期","天樂","どういうことなの!?","東京テディベア","どりーみんチュチュ","トリノコシティ","ネトゲ廃人シュプレヒコール","No Logic","ハイハハイニ","はじめまして地球人さん","*ハロー、プラネット。 (I.M.PLSE-EDIT)","Hello, Worker","忘却心中","magnet","右肩の蝶","結ンデ開イテ羅刹ト骸","メランコリック","リモコン","ルカルカ★ナイトフィーバー","炉心融解","WORLD'S END UMBRELLA","アカツキアライヴァル","アゲアゲアゲイン","1925","え?あぁ、そう。","エイリアンエイリアン","ODDS&ENDS","君の体温","こっち向いて Baby","壊セ壊セ","39みゅーじっく!","サンドリヨン","SING&SMILE","スノーマン","DYE","なりすましゲンガー","ヒバナ","ヒビカセ","ブラックゴールド","ミラクルペイント","指切り","ありふれたせかいせいふく","アンハッピーリフレイン","大江戸ジュリアナイト","ゴーストルール","こちら、幸福安心委員会です。","孤独の果て -extend edition-","ジターバグ","Sweet Devil","砂の惑星","テオ","初音ミクの消失 -DEAD END-","秘密警察","妄想スケッチ","リンちゃんなう!","ローリンガール","ロキ","ロミオとシンデレラ","エンヴィキャットウォーク","骸骨楽団とリリア","サイハテ","ジグソーパズル","千本桜","ピアノ×フォルテ×スキャンダル","Blackjack","ぽっぴっぽー","裏表ラバーズ","Sadistic.Music∞Factory","デンパラダイム","二次元ドリームフィーバー","ネガポジ*コンティニューズ","初音ミクの激唱","ワールズエンド・ダンスホール","ココロ","システマティック・ラヴ","Knife","二息歩行","PIANOGIRL","夢喰い白黒バク","ブレス・ユア・ブレス","恋は戦争","あなたの歌姫","Starduster","StargazeR","リンリンシグナル","Rosary Pale","多重未来のカルテット~QUARTET THEME~","LIKE THE WIND","AFTER BURNER"};
|
/*static String SONGNAMES[] = new String[] {"Yellow","The secret garden","Tell Your World","愛言葉","Weekender Girl","歌に形はないけれど","えれくとりっく・えんじぇぅ","神曲","カンタレラ","巨大少女","クローバー♣クラブ","恋スルVOC@LOID","桜ノ雨","39","深海シティアンダーグラウンド","深海少女","積乱雲グラフィティ","千年の独奏歌","ダブルラリアット","ハジメテノオト","初めての恋が終わる時","packaged","Palette","FREELY TOMORROW","from Y to Y","みくみくにしてあげる♪","メルト","モノクロ∞ブルースカイ","ゆめゆめ","16 -out of the gravity-","ACUTE","インタビュア","LOL -lots of laugh-","Glory 3usi9","soundless voice","ジェミニ","白い雪のプリンセスは","スキキライ","タイムマシン","Dear","DECORATOR","トリコロール・エア・ライン","Nostalogic","Hand in Hand","Fire◎Flower","ブラック★ロックシューター","メテオ","ワールドイズマイン","アマツキツネ","erase or zero","エレクトロサチュレイタ","on the rocks","からくりピエロ","カラフル×メロディ","Catch the Wave","キャットフード","サマーアイドル","shake it!","Just Be Friends","スイートマジック","SPiCa -39's Giving Day Edition-","番凩","テレカクシ思春期","天樂","どういうことなの!?","東京テディベア","どりーみんチュチュ","トリノコシティ","ネトゲ廃人シュプレヒコール","No Logic","ハイハハイニ","はじめまして地球人さん","*ハロー、プラネット。 (I.M.PLSE-EDIT)","Hello, Worker","忘却心中","magnet","右肩の蝶","結ンデ開イテ羅刹ト骸","メランコリック","リモコン","ルカルカ★ナイトフィーバー","炉心融解","WORLD'S END UMBRELLA","アカツキアライヴァル","アゲアゲアゲイン","1925","え?あぁ、そう。","エイリアンエイリアン","ODDS&ENDS","君の体温","こっち向いて Baby","壊セ壊セ","39みゅーじっく!","サンドリヨン","SING&SMILE","スノーマン","DYE","なりすましゲンガー","ヒバナ","ヒビカセ","ブラックゴールド","ミラクルペイント","指切り","ありふれたせかいせいふく","アンハッピーリフレイン","大江戸ジュリアナイト","ゴーストルール","こちら、幸福安心委員会です。","孤独の果て -extend edition-","ジターバグ","Sweet Devil","砂の惑星","テオ","初音ミクの消失 -DEAD END-","秘密警察","妄想スケッチ","リンちゃんなう!","ローリンガール","ロキ","ロミオとシンデレラ","エンヴィキャットウォーク","骸骨楽団とリリア","サイハテ","ジグソーパズル","千本桜","ピアノ×フォルテ×スキャンダル","Blackjack","ぽっぴっぽー","裏表ラバーズ","Sadistic.Music∞Factory","デンパラダイム","二次元ドリームフィーバー","ネガポジ*コンティニューズ","初音ミクの激唱","ワールズエンド・ダンスホール","ココロ","システマティック・ラヴ","Knife","二息歩行","PIANOGIRL","夢喰い白黒バク","ブレス・ユア・ブレス","恋は戦争","あなたの歌姫","Starduster","StargazeR","リンリンシグナル","Rosary Pale","多重未来のカルテット~QUARTET THEME~","LIKE THE WIND","AFTER BURNER",
|
||||||
|
"ストロボナイツ","VOiCE","恋色病棟","ねこみみスイッチ","パラジクロロベンゼン","カラフル×セクシィ","劣等上等","Star Story","パズル","キップル・インダストリー","夢の続き","MEGANE","Change me"};*/
|
||||||
static SongInfo SONGNAMES[] = new SongInfo[] {};
|
static SongInfo SONGNAMES[] = new SongInfo[] {};
|
||||||
static String NEWSONGS[] = new String[] {"ブラック★ロックシューター","メテオ"};
|
static String NEWSONGS[] = new String[] {"Catch the Wave"};
|
||||||
int SCREEN_X;
|
int SCREEN_X;
|
||||||
int SCREEN_Y;
|
int SCREEN_Y;
|
||||||
int WINDOW_X;
|
int WINDOW_X;
|
||||||
@ -114,8 +115,8 @@ public class MyRobot{
|
|||||||
BufferedImage bufImg;
|
BufferedImage bufImg;
|
||||||
Rectangle rect;
|
Rectangle rect;
|
||||||
static JTextField title;
|
static JTextField title;
|
||||||
final int WIDTH = 200;
|
final int WIDTH = 204;
|
||||||
final int HEIGHT = 5;
|
final int HEIGHT = 25;
|
||||||
public static DrawCanvas p;
|
public static DrawCanvas p;
|
||||||
static int currentSong = 0;
|
static int currentSong = 0;
|
||||||
static SongData selectedSong = null;
|
static SongData selectedSong = null;
|
||||||
@ -149,11 +150,17 @@ public class MyRobot{
|
|||||||
static Rectangle calibrationline = null;
|
static Rectangle calibrationline = null;
|
||||||
static boolean repaintCalled = false;
|
static boolean repaintCalled = false;
|
||||||
public static Overlay OVERLAY;
|
public static Overlay OVERLAY;
|
||||||
|
public static boolean CALIBRATION_MODE=false;
|
||||||
|
|
||||||
public static ScheduledExecutorService executorService = Executors.newSingleThreadScheduledExecutor();
|
public static ScheduledExecutorService executorService = Executors.newSingleThreadScheduledExecutor();
|
||||||
|
|
||||||
|
|
||||||
public static void main(String[] args) throws JSONException, IOException, FontFormatException {
|
public static void main(String[] args) throws JSONException, IOException, FontFormatException {
|
||||||
|
if (args.length>0) {
|
||||||
|
if (args[0].equalsIgnoreCase("calibrate")) {
|
||||||
|
CALIBRATION_MODE=true;
|
||||||
|
}
|
||||||
|
}
|
||||||
JSONObject obj = FileUtils.readJsonFromUrl("http://www.projectdivar.com/songs");
|
JSONObject obj = FileUtils.readJsonFromUrl("http://www.projectdivar.com/songs");
|
||||||
SONGNAMES = new SongInfo[JSONObject.getNames(obj).length];
|
SONGNAMES = new SongInfo[JSONObject.getNames(obj).length];
|
||||||
for (String key : JSONObject.getNames(obj)) {
|
for (String key : JSONObject.getNames(obj)) {
|
||||||
@ -403,18 +410,71 @@ public class MyRobot{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
private void GetCurrentSong() throws IOException {
|
private void GetCurrentSong() throws IOException {
|
||||||
BufferedImage img = ImageUtils.toCompatibleImage(MYROBOT.createScreenCapture(new Rectangle(460,426,WIDTH,HEIGHT)));
|
BufferedImage img = ImageUtils.toCompatibleImage(MYROBOT.createScreenCapture(new Rectangle(812-10,380-10,WIDTH+20,HEIGHT+20)));
|
||||||
Color[] col = new Color[WIDTH*HEIGHT];
|
boolean found=false;
|
||||||
for (int i=0;i<WIDTH;i++) {
|
LOOP1:
|
||||||
for (int j=0;j<HEIGHT;j++) {
|
for (int x=0;x<10;x++) {
|
||||||
col[i*HEIGHT+j]=new Color(img.getRGB(i,j),true);
|
for (int y=0;y<10;y++) {
|
||||||
|
Color[] col = new Color[WIDTH*HEIGHT];
|
||||||
|
for (int i=0;i<WIDTH;i++) {
|
||||||
|
for (int j=0;j<HEIGHT;j++) {
|
||||||
|
col[i*HEIGHT+j]=new Color(img.getRGB(i+10+x,j+10+y),true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
SongData ss = SongData.compareData(col);
|
||||||
|
if (ss!=null) {
|
||||||
|
selectedSong = ss;
|
||||||
|
found=true;
|
||||||
|
break LOOP1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (int y=-1;y>-10;y--) {
|
||||||
|
Color[] col = new Color[WIDTH*HEIGHT];
|
||||||
|
for (int i=0;i<WIDTH;i++) {
|
||||||
|
for (int j=0;j<HEIGHT;j++) {
|
||||||
|
col[i*HEIGHT+j]=new Color(img.getRGB(i+10+x,j+10+y),true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
SongData ss = SongData.compareData(col);
|
||||||
|
if (ss!=null) {
|
||||||
|
selectedSong = ss;
|
||||||
|
found=true;
|
||||||
|
break LOOP1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/*File f = new File("test.png");
|
if (!found) {
|
||||||
ImageIO.write(img,"png",f);*/
|
LOOP2:
|
||||||
SongData ss = SongData.compareData(col);
|
for (int x=0;x>-10;x--) {
|
||||||
if (ss!=null) {
|
for (int y=0;y<10;y++) {
|
||||||
selectedSong = ss;
|
Color[] col = new Color[WIDTH*HEIGHT];
|
||||||
|
for (int i=0;i<WIDTH;i++) {
|
||||||
|
for (int j=0;j<HEIGHT;j++) {
|
||||||
|
col[i*HEIGHT+j]=new Color(img.getRGB(i+10+x,j+10+y),true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
SongData ss = SongData.compareData(col);
|
||||||
|
if (ss!=null) {
|
||||||
|
selectedSong = ss;
|
||||||
|
found=true;
|
||||||
|
break LOOP2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (int y=-1;y>-10;y--) {
|
||||||
|
Color[] col = new Color[WIDTH*HEIGHT];
|
||||||
|
for (int i=0;i<WIDTH;i++) {
|
||||||
|
for (int j=0;j<HEIGHT;j++) {
|
||||||
|
col[i*HEIGHT+j]=new Color(img.getRGB(i+10+x,j+10+y),true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
SongData ss = SongData.compareData(col);
|
||||||
|
if (ss!=null) {
|
||||||
|
selectedSong = ss;
|
||||||
|
found=true;
|
||||||
|
break LOOP2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -459,33 +519,55 @@ public class MyRobot{
|
|||||||
actionMap.put("Press", new AbstractAction() {
|
actionMap.put("Press", new AbstractAction() {
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
BufferedImage img = ImageUtils.toCompatibleImage(MYROBOT.createScreenCapture(new Rectangle(460,426,WIDTH,HEIGHT)));
|
//BufferedImage img = ImageUtils.toCompatibleImage(MYROBOT.createScreenCapture(new Rectangle(460,426,WIDTH,HEIGHT)));
|
||||||
Color[] col = new Color[WIDTH*HEIGHT];
|
//Buffered img ImageUtils.toCompatibleImage(
|
||||||
for (int i=0;i<WIDTH;i++) {
|
MYROBOT.refreshScreen();
|
||||||
for (int j=0;j<HEIGHT;j++) {
|
BufferedImage img = null;
|
||||||
col[i*HEIGHT+j]=new Color(img.getRGB(i,j),true);
|
try {
|
||||||
}
|
ImageIO.write(img=MYROBOT.createScreenCapture(new Rectangle(812,380,WIDTH,HEIGHT)),"png",new File("test.png"));
|
||||||
}
|
} catch (IOException e1) {
|
||||||
SongData.saveSongToFile(NEWSONGS[currentSong],col);
|
e1.printStackTrace();
|
||||||
SongData.loadSongsFromFile();
|
}
|
||||||
System.out.println((++currentSong>=NEWSONGS.length)?"DONE!":NEWSONGS[currentSong]);
|
Color[] col = new Color[WIDTH*HEIGHT];
|
||||||
//System.out.println(title.getText());
|
for (int i=0;i<WIDTH;i++) {
|
||||||
|
for (int j=0;j<HEIGHT;j++) {
|
||||||
|
col[i*HEIGHT+j]=new Color(img.getRGB(i,j),true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
SongData.saveSongToFile(NEWSONGS[currentSong],col);
|
||||||
|
SongData.loadSongsFromFile();
|
||||||
|
currentSong+=1;
|
||||||
|
if (currentSong>=NEWSONGS.length) {
|
||||||
|
System.out.println("DONE!");
|
||||||
|
} else {
|
||||||
|
for (SongInfo i : SONGNAMES) {
|
||||||
|
if (i.name.equalsIgnoreCase(NEWSONGS[currentSong])) {
|
||||||
|
System.out.println(NEWSONGS[currentSong]+" - "+((i.romanized_name.length()>0)?i.romanized_name:i.english_name));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
JFrame.setDefaultLookAndFeelDecorated(true);
|
if (CALIBRATION_MODE) {
|
||||||
f.setUndecorated(true);
|
JFrame.setDefaultLookAndFeelDecorated(true);
|
||||||
OVERLAY = new Overlay();
|
f.setUndecorated(true);
|
||||||
OVERLAY.setBounds(f.getGraphicsConfiguration().getBounds());
|
OVERLAY = new Overlay();
|
||||||
OVERLAY.setOpaque(false);
|
OVERLAY.setBounds(f.getGraphicsConfiguration().getBounds());
|
||||||
f.addMouseListener(OVERLAY);
|
OVERLAY.setOpaque(false);
|
||||||
f.addMouseMotionListener(OVERLAY);
|
f.addMouseListener(OVERLAY);
|
||||||
screenSize=new Dimension(f.getGraphicsConfiguration().getBounds().width,f.getGraphicsConfiguration().getBounds().height);
|
f.addMouseMotionListener(OVERLAY);
|
||||||
f.setCursor(new Cursor(Cursor.CROSSHAIR_CURSOR));
|
screenSize=new Dimension(f.getGraphicsConfiguration().getBounds().width,f.getGraphicsConfiguration().getBounds().height);
|
||||||
//f.add(p);
|
f.setCursor(new Cursor(Cursor.CROSSHAIR_CURSOR));
|
||||||
//System.out.println(f.getGraphicsConfiguration().getBounds().width+"/"+f.getGraphicsConfiguration().getBounds().height);
|
//f.add(p);
|
||||||
f.setSize(f.getGraphicsConfiguration().getBounds().width,f.getGraphicsConfiguration().getBounds().height);
|
//System.out.println(f.getGraphicsConfiguration().getBounds().width+"/"+f.getGraphicsConfiguration().getBounds().height);
|
||||||
f.add(OVERLAY);
|
f.setSize(f.getGraphicsConfiguration().getBounds().width,f.getGraphicsConfiguration().getBounds().height);
|
||||||
f.setBackground(new Color(0,0,0,0));
|
f.add(OVERLAY);
|
||||||
|
f.setBackground(new Color(0,0,0,0));
|
||||||
|
} else {
|
||||||
|
f.setSize(1362, 1036);
|
||||||
|
f.add(p);
|
||||||
|
}
|
||||||
f.setVisible(true);
|
f.setVisible(true);
|
||||||
f.setTitle("DivaBot");
|
f.setTitle("DivaBot");
|
||||||
title = new JTextField();
|
title = new JTextField();
|
||||||
@ -598,7 +680,7 @@ public class MyRobot{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static boolean checkSongSelect() throws IOException {
|
public static boolean checkSongSelect() throws IOException {
|
||||||
Color c = new Color(MYROBOT.createScreenCapture(new Rectangle(1255,824,20,20)).getRGB(10, 10));
|
Color c = new Color(MYROBOT.createScreenCapture(new Rectangle(845,638,1,1)).getRGB(0, 0));
|
||||||
onSongSelect = c.getRed()==43 && c.getGreen()==88 && c.getBlue()==213;
|
onSongSelect = c.getRed()==43 && c.getGreen()==88 && c.getBlue()==213;
|
||||||
//System.out.println(onSongSelect+"/"+c);
|
//System.out.println(onSongSelect+"/"+c);
|
||||||
return onSongSelect;
|
return onSongSelect;
|
||||||
|
@ -56,12 +56,12 @@ public class Overlay extends JPanel implements MouseMotionListener,MouseListener
|
|||||||
public void mouseReleased(MouseEvent e) {
|
public void mouseReleased(MouseEvent e) {
|
||||||
MyRobot.ENDDRAG=e.getLocationOnScreen();
|
MyRobot.ENDDRAG=e.getLocationOnScreen();
|
||||||
if (MyRobot.STARTDRAG.x>MyRobot.ENDDRAG.x) {
|
if (MyRobot.STARTDRAG.x>MyRobot.ENDDRAG.x) {
|
||||||
var xTemp = MyRobot.STARTDRAG.x;
|
int xTemp = MyRobot.STARTDRAG.x;
|
||||||
MyRobot.STARTDRAG.x=MyRobot.ENDDRAG.x;
|
MyRobot.STARTDRAG.x=MyRobot.ENDDRAG.x;
|
||||||
MyRobot.ENDDRAG.x=xTemp;
|
MyRobot.ENDDRAG.x=xTemp;
|
||||||
}
|
}
|
||||||
if (MyRobot.STARTDRAG.y>MyRobot.ENDDRAG.y) {
|
if (MyRobot.STARTDRAG.y>MyRobot.ENDDRAG.y) {
|
||||||
var xTemp = MyRobot.STARTDRAG.y;
|
int xTemp = MyRobot.STARTDRAG.y;
|
||||||
MyRobot.STARTDRAG.y=MyRobot.ENDDRAG.y;
|
MyRobot.STARTDRAG.y=MyRobot.ENDDRAG.y;
|
||||||
MyRobot.ENDDRAG.y=xTemp;
|
MyRobot.ENDDRAG.y=xTemp;
|
||||||
}
|
}
|
||||||
|
@ -7,6 +7,8 @@ import sig.utils.ImageUtils;
|
|||||||
public class SongData {
|
public class SongData {
|
||||||
String title;
|
String title;
|
||||||
Color[] songCode;
|
Color[] songCode;
|
||||||
|
int distance=0;
|
||||||
|
static int MAXTHRESHOLD=200000;
|
||||||
final static float TOLERANCE = 0.95f;
|
final static float TOLERANCE = 0.95f;
|
||||||
public SongData(String title,Color[] songCode) {
|
public SongData(String title,Color[] songCode) {
|
||||||
this.title=title;
|
this.title=title;
|
||||||
@ -23,17 +25,31 @@ public class SongData {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static SongData compareData(Color[] data) {
|
public static SongData compareData(Color[] data) {
|
||||||
int closestDistance = Integer.MAX_VALUE;
|
int closestDistance = Integer.MAX_VALUE;
|
||||||
|
int closestMaxThresholdDistance = Integer.MAX_VALUE;
|
||||||
SongData closestSong = null;
|
SongData closestSong = null;
|
||||||
for (SongData s : MyRobot.SONGS) {
|
for (SongData s : MyRobot.SONGS) {
|
||||||
int distance = 0;
|
int distance = 0;
|
||||||
for (int i=0;i<s.songCode.length;i++) {
|
if (s!=null&&s.songCode!=null) {
|
||||||
distance += ImageUtils.distanceToColor(s.songCode[i],data[i]);
|
for (int i=0;i<s.songCode.length;i++) {
|
||||||
}
|
distance += ImageUtils.distanceToColor(s.songCode[i],data[i]);
|
||||||
if (distance<closestDistance) {
|
/*if (distance>MAXTHRESHOLD) {
|
||||||
//System.out.println(matched+"/"+s.songCode.length+" pixels matched for song "+s.title);
|
distance=MAXTHRESHOLD+1;
|
||||||
closestSong=s;
|
break;
|
||||||
closestDistance=distance;
|
}*/
|
||||||
|
}
|
||||||
|
if (/*distance<=MAXTHRESHOLD && */distance<closestDistance) {
|
||||||
|
//System.out.println(distance+" pixels matched for song "+s.title);
|
||||||
|
closestSong=s;
|
||||||
|
closestSong.distance=distance;
|
||||||
|
closestDistance=distance;
|
||||||
|
}
|
||||||
|
if (distance>=MAXTHRESHOLD && distance<closestMaxThresholdDistance) {
|
||||||
|
System.out.println(distance+" pixels diff: "+s.title);
|
||||||
|
closestMaxThresholdDistance=distance;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return closestSong;
|
return closestSong;
|
||||||
@ -71,6 +87,7 @@ public class SongData {
|
|||||||
for (int i=0;i<data.length;i++) {
|
for (int i=0;i<data.length;i++) {
|
||||||
colors[i]=new Color(Integer.parseInt(data[i]),true);
|
colors[i]=new Color(Integer.parseInt(data[i]),true);
|
||||||
}
|
}
|
||||||
|
System.out.println("Store "+title+"/"+colors);
|
||||||
return new SongData(title,colors);
|
return new SongData(title,colors);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
BIN
DivaBot/test.png
BIN
DivaBot/test.png
Binary file not shown.
Before Width: | Height: | Size: 841 KiB After Width: | Height: | Size: 8.9 KiB |
Loading…
x
Reference in New Issue
Block a user