From c24f8588de7cb31f0867a771e692680b902b772a Mon Sep 17 00:00:00 2001 From: davpapp Date: Sun, 4 Feb 2018 12:18:34 -0500 Subject: [PATCH] Started work on adding Gaussian translation to CursorPath --- .classpath | 5 + .settings/org.eclipse.jdt.core.prefs | 1 + ClassifierTraining/testClassifier.py | 17 ++++ ClassifierTraining/testClassifier.py~ | 17 ++++ bin/ColorAnalyzer.class | Bin 0 -> 6117 bytes bin/Cursor.class | Bin 7374 -> 7801 bytes bin/CursorPath.class | Bin 4582 -> 4913 bytes bin/Inventory.class | Bin 3292 -> 3124 bytes bin/Randomizer.class | Bin 0 -> 1577 bytes bin/RandomizerTest.class | Bin 0 -> 1175 bytes bin/WillowChopper.class | Bin 0 -> 872 bytes bin/cascadeTrainingImageCollector.class | Bin 0 -> 3231 bytes src/ColorAnalyzer.java | 130 ++++++++++++++++++++++++ src/Cursor.java | 30 +++++- src/CursorPath.java | 8 ++ src/Inventory.java | 4 - src/Randomizer.java | 41 ++++++++ src/RandomizerTest.java | 29 ++++++ src/WillowChopper.java | 37 +++++++ src/cascadeTrainingImageCollector.java | 73 +++++++++++++ 20 files changed, 383 insertions(+), 9 deletions(-) create mode 100644 ClassifierTraining/testClassifier.py create mode 100644 ClassifierTraining/testClassifier.py~ create mode 100644 bin/ColorAnalyzer.class create mode 100644 bin/Randomizer.class create mode 100644 bin/RandomizerTest.class create mode 100644 bin/WillowChopper.class create mode 100644 bin/cascadeTrainingImageCollector.class create mode 100644 src/ColorAnalyzer.java create mode 100644 src/Randomizer.java create mode 100644 src/RandomizerTest.java create mode 100644 src/WillowChopper.java create mode 100644 src/cascadeTrainingImageCollector.java diff --git a/.classpath b/.classpath index e70c7c1..9cd8989 100644 --- a/.classpath +++ b/.classpath @@ -6,6 +6,11 @@ + + + + + diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs index 7e5c907..b76ee8e 100644 --- a/.settings/org.eclipse.jdt.core.prefs +++ b/.settings/org.eclipse.jdt.core.prefs @@ -1,5 +1,6 @@ eclipse.preferences.version=1 org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate org.eclipse.jdt.core.compiler.codegen.targetPlatform=9 org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve org.eclipse.jdt.core.compiler.compliance=9 diff --git a/ClassifierTraining/testClassifier.py b/ClassifierTraining/testClassifier.py new file mode 100644 index 0000000..8a74374 --- /dev/null +++ b/ClassifierTraining/testClassifier.py @@ -0,0 +1,17 @@ +import numpy as np +import cv2 + +willowCascade = cv2.CascadeClassifier('/home/dpapp/open/opencv-haar-classifier-training/classifier/stage9.xml') +img = cv2.imread('/home/dpapp/Desktop/RunescapeAIPics/CascadeTraining/Testing/screenshot0.png') +gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY) + +willows = willowCascade.detectMultiScale(gray, 1.3, 5) +for (x,y,w,h) in willows: + cv2.rectangle(img,(x,y),(x+w,y+h),(255,0,0),2) + roi_gray = gray[y:y+h, x:x+w] + roi_color = img[y:y+h, x:x+w] + print("Found willow!") + +cv2.imshow('img', img) +cv2.waitKey(0) +cv2.destroyAllWindows() diff --git a/ClassifierTraining/testClassifier.py~ b/ClassifierTraining/testClassifier.py~ new file mode 100644 index 0000000..040d598 --- /dev/null +++ b/ClassifierTraining/testClassifier.py~ @@ -0,0 +1,17 @@ +import numpy as np +import cv2 + +willowCascade = cv2.CascadeClassifier('/home/dpapp/open/opencv-haar-classifier-training/classifier/stage19.xml') +img = cv2.imread('/home/dpapp/Desktop/RunescapeAIPics/CascadeTraining/Testing/screenshot0.png') +gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY) + +willows = willowCascade.detectMultiScale(gray, 1.3, 5) +for (x,y,w,h) in willows: + cv2.rectangle(img,(x,y),(x+w,y+h),(255,0,0),2) + roi_gray = gray[y:y+h, x:x+w] + roi_color = img[y:y+h, x:x+w] + print("Found willow!") + +cv2.imshow('img', img) +cv2.waitKey(0) +cv2.destroyAllWindows() diff --git a/bin/ColorAnalyzer.class b/bin/ColorAnalyzer.class new file mode 100644 index 0000000000000000000000000000000000000000..6cfc7e5a12d001644017a6385156e05222c5de96 GIT binary patch literal 6117 zcma)A3wT>)8GirfBqvSJN-xW{uHEQ17;V}$yFkH~4z`Z5uyrfz?C1tanx3|S^duxH z+fa1iQ1J#R0-K7W=tNNgp)Cv%6;N@C7rftZJl^kDZuR~CbCRZPJg{d={`3F;`7ZDG zewXZt7an{Vz-elgi86&b-RV?1yUvNH_FZXbO&AJQm&UJ%M^kZUB)V9ZQ+^=ACr-$qie5kNsA{fLR zg*DO9^q3tT%EU97=mtA?Sw5YKZXb8-Tq2&a*Ts61iCi=xc5SfpRF+IT(Q+u9V8M?7 zzqceEd+YevpqV@i`g~xw|z!M)b;y&kB_;Y6V#)S{3HMm?-PVlc^y) z8$uganuyLKo$I89RamWHUJ*}?+uMd;gpEtgf}yjqX+dKMEjZ0WJ5DDd$uiramn)8k z)G<-_Eb9~zud>hq#yOZzyGAL@ZSue=)k&0dqv<`GXB(0^ro!O3u)+lMpj!LR=Tvl4 zJU7}C&xFv03Sq%I3v&?;p&RFz*g#h3t1rPf3mb7R-63PPpSxbc-xP~A$3loWYWp^OGI^jp!HqYWnniipTY}=n z7G5J-%4yyvJ2^6%m)*F9L9Ls+JCj5C(Q*u7*aU4TDRq7Oa(R2q!U&j$zO>j9E;6~7 z#Vtme#^Y$s=Cfsb|J?v*Q0t%-V zZo#dr*p9uI+Gm#`FDpzODlkY3CLAZ7BL-LCAl_%;{USi>2eVvQ^Z^SW#O-7;w^&ki zUgo4F_9pk*5<7BscT8UXu!TG1No;#1`7 zXgs%78_P*xR}gnI3EZaLm>zB%O6peXkJGhL-T^j17qNfY<6KIxqA z9?#~|Sq+GZuP_N`v`I0~X2&ymd#GgM_$uMjcO*~O?c7mv^tFPqa-==lqbxacCD86IiyZ9d2mS9cH+kO19o$h$X&A3y&jGHB@ z(5z)sSCbcwQ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z5;i^RUqasBN oQ2FQtOiaR!Dfkhi3$w2B2**%(;{N*!GkzxcCu~IEBy0Kf7l`joo&W#< delta 578 zcmZ8eT~8B16g{(F*zLs7hJvI8gAxjxzy{DtA*q^5pvE)`2Iaw|3oJ`3-D0~I3I+T^ zeK97?yFbBbY&4NXUwrZ>7!&`6kA&N8)Wny$=gysb?m2fFXMT3;-;Y0k0dNs7-|Gj8 z!5!Pn6fMWjT1A_oV{qt3!Kzy3y5&0NyjRY<&eSQaFkBU@a(~ZlyW&;Mj9ax`uT-v? z`9El6!*#?fWkgxy$cwMaoL1y0z!hC;S}Su@;E9}C)3!Kj*cQLkezV|*D{bRaN`i$YFbt5FVTz2R9A17$LBb_E zHUH`|CJ6IZ8A(i1#$bzTV6^8NR80HzPU>lPwCYW?D!v7h%n`?dzQ`=S%Rt9V7z;QXzmcrUBs}6UczxKz{EX~ z4yN`WqDsP=Zr(s40YJiNARQfxjeW#sHYB}{wi|1?;Rbec2_?kN#oGJ*^ieLM9-+P% zQ6lOmJpHF6Ogx}1aoST9%P_Fwn@zRY|C&vZG3}6t&OgHeWO^EHegHKa)Jn@I*$mH# HO2Ug1pU-ZW diff --git a/bin/Randomizer.class b/bin/Randomizer.class new file mode 100644 index 0000000000000000000000000000000000000000..864f23a7d9727fdfdcb2089c1cd776cffe4bc408 GIT binary patch literal 1577 zcmZ8gO;cM{7=CVYKS;PuFfA!Dq1H~pB({x8iyA7`Hl?NpiV1^eaKRy5$t}qZ-rQ7l zrd!#uR(FmI#~Btn)546Xd;J}5{RfWqIVX{iCUeet&-?kj&wK8l|NinjfE%b<2x*8` zg}2^myI(rK1zp3)L-9xyTEg2XJXm|^Gy)B#uUs@FD$3Xk+*Y9ne4dHBV zS%ZG3v+hI@#;^?wLl(~bpYudm6gGwHvT{#9#1ZmIN4(^Fwx9bY;BbPqjQqy;w+ER(mMz&nem1V^-8!5cV@RR-u zcZs;$j_@>SWhxjbyLP(07TZ5l3q)gcUTh6OOl&xw$HT1v)OX4Pnh^TC@gkdFPJfJ{qc?beH&%-6E;SXwD5|Cm?HMbFN#UzB!Bq< zeiCbMiJ)0>yMgc;p*)CR;fXG?P1ZlK~|gcQMB~Y&fJ}&5u1rWKW7kKAYzu)7)xy`!E>D z+SK?bG_-P(r%KU}9^5%Teh0Nq&u=($uH-O&{JyTq$>3#6r%5CT%Z(Y9N22;A0#x1_@ZJ%cD=(Sl8f9qTq@_& zMk_sHw)Sy(S|5PSZthMShnTF7>Z8U1vOm$ePe(%4PjWv`tYfU1Qn;=w%()|6IlQWH z>6pM3TvgFyxJI4M7#jsj20^{X&eSNhSq?>l+cST|8}+dHt5pxjs&$>qh*xWMU1_d7 z!F9QsJ2Xjwr!pJLoK7o4dZ1mI5o6;1k){6QeiuJ1pxLIVU#d=DYqM0&M=00u} zEtM{1g~R)}!%`_r?@LC?GL%#tN(~+Ja)C^PomI$vlT`a8`!O!zD^BA_av*2-Nx#1% zj`ju|v1i=F`{byCRg`g`vumP+4=Cx(RHS~MY&|Ax3zSS|ox}r57ITMLaY{YtMKz@l F{{v}mIBfs` literal 0 HcmV?d00001 diff --git a/bin/RandomizerTest.class b/bin/RandomizerTest.class new file mode 100644 index 0000000000000000000000000000000000000000..3e125a35ba2b99b96ca5d1b98ca03344eab89db8 GIT binary patch literal 1175 zcmZuwOHUI~6#i}>Gcc{CKzS5UF-C29RX}_I5s8(Aq@Y%9f+U*Tasz{92B%XcBql6% zr@z6KCNA875hHt-`~v@iTVsshOnHd7n0wB>_dDmF?>lF{{r>zFzzD{51O#GvX)V|* z=DKq3tBR{5BoJSg&t#@7t;Njk;<75a0@}D~neKIgU@Bb@2;H<7lz|}XqXdM*9VrIF@Lb$G)u5vPR)y#NxkLhRliXhgk^7BckN$mee6j%`}5fdtyT zs@ny^sp;u-!Gm^0(TOgB_C;kWN4n~cbY#&k%Ue&Y{`&$gsp;I&RAcG+thTdJoZ0>H z?w2;P@9fC;sla6XC)NU@sIk}5sfmxZkK)O>b6>xpVO2dxl@ z{v{FRX;2|H@BR zD$4P@6UAj*Vb#(<@kA?=o0giIn)0aC?N`Y&S#o(xy7%m=Q&Ll=H!aPFo%7l`;0cXx z>K5dz!e2RO-0R$BXa#M!XA5;7=>%YK^{zocgln`0pgqAI5aVqC4fH%zoR*11n!7ss zZ?@4mw}s|hZ+u}JiMjYta0{)QNX}?q^toUxKNsQ`j^$?$0P#c(F&gqA37jM-fzv*0 zG~C;WpMIu?@l$(1Z4Y?H2cE3~^`8E|O`PjVhLa)R>Pe0Ekko)rC&DsgNRmLB#gB7f z@1h9`%~bs>qUMVv$tW8o~Js;mpMFdnsHuV^hhM~2}6g)8cYpzFtF1vq`L+?=z@-`OjhgC NHF^R1ql^e(><`#;{j~r9 literal 0 HcmV?d00001 diff --git a/bin/WillowChopper.class b/bin/WillowChopper.class new file mode 100644 index 0000000000000000000000000000000000000000..d06345f257784a6dc081796dade65176129255de GIT binary patch literal 872 zcmY*X?M~BR7(MScS5`VVHa2j|225~FWq#pDG$v$$WXY5tED-%=*ELcoZPT@&m*N%p z+r&wti5K8icnw~Fc-oH2(!6~>d(Ly7x4-^={|R6N&m<%SvipW<+NbRU+i`SPLP{Wi zsGg`TQ?=f=cKV09<_V-V-yPbnz*M&#dd~&qDA!YmM*_+?A4IHW4C_RTqj>t3dWRCiON+45~d_9a_)Fk8MUZdSCD}$ zkn0+j{@Oq8>uyi&o4P=uYip{xr@BTEkCQ3yz!(PI6MLobr0ZJ}ngZ4T>+M*c?z+C? z>4R8OKzv8RT__adI|J3Dyc${x?%_UxjbS|Fwr`r@BHspD9x8Z*4S~6VYdf2!+41ya z_Qu@;<;KPBUAmIs7P7mZsvW&jov{dc*Y;ga-!?*-6H3;D>9NGECixcyhpXiq!45;q zZP6y!!TX@iGD_24MIHtE@A#FVU2UGB*!+Rgn={OfFi*Ea_r?edbZc~%Mp*t5V%_As zOePRJMbsQoD@0tOx5BIvAz~G`7zs2cnDbZ*nfqhrdh;umzu|Ud)<2#9p|`*@A7vhV lKL1UaBm&w334to*)i8raKE+Fv^)cn+u%EI7p3qI;=|2pEw}Aiv literal 0 HcmV?d00001 diff --git a/bin/cascadeTrainingImageCollector.class b/bin/cascadeTrainingImageCollector.class new file mode 100644 index 0000000000000000000000000000000000000000..798265a10464c37d0f63deb624846251d177e4e9 GIT binary patch literal 3231 zcmaJ@X;&P_6}>fp8b)my2DA>A5Ee2F5@R`b79%T0Xz|D_3XGA7vo$jXv@|n4>FLpu z#BprNj zUZKyGZL`gw-VDyTzS(<2Av4w5Iv@Ci8&~M?y(Nz}-Ql8hEy&Nw43~Bpm@{rw*BY)@ zQ&0tk9Vba7IHj1sd4szzz$0$so2hoYL5XjBGhz!$PNw`fYR}t?=-aThlYm>XP=0&Qe87v|h=n zEI7U^@6lv?u{0-v$)M1p8y*~XLN->Qp6rIyBL z@p%iM+v2LYN}#fhFW_maq*2kjF7aQG8Y>ZltMJf#;FPXRJM}2NhoXQkxwW!)EzI4t zTdBB>Fo6>Mvo1~VithoTVSngbb~vNWbq6xwzg3wY7OrRZ2(&l}gGA~~^zSsRP^ zGShv{cLTyrB$%6>`8i!Hw@7Y3fw35b==cb+tP&+f9kO^1vqNdO0-uYsL7&C}_1jtw zU2e^b1n<~bLP=pCgO4FX=}tENhDTp}h7YGmD$ zreP6*|6)2*<& zX?zc_S$K8JaSWwo<0fvgrdORxQ_n6d98GrNu>Wr=I{{3FFQeFr@3TEO;$|b0Kd|vb z{D^Jcsn;njh2u%UNWa@99WgbyKM{zx*v;;z{mqS?_$dWA#`7dz-?8y7ey-3Nc%chs zZZo+_+BB*1;uAT&v|a1ciGR7-;EY+^Wjpa}5@L7q1733jM#uxD@ZMzl$HvB_LH<_y zpxuezE1b-)dR3h-*O`a>8Qr)Nc=h~Tv!;3d*7Zc;qFZX@C%0b4`J!$Jd|p&tlz+Ev zoRZ$gleWU!qW30bH18!~AAfh_0A~-HH3Ne~7~mTL4H2G1k{gWN?%?xL3>n8aITp%C+MfB4-uu__ z*x!-sU&G_sp0@w4zJ3=^-Abwc?vuAa{f{tcGYk%x;Pw;y0K>|n2mKuFC+b1NVj#qf zSscMQ_bK{1jFTLt@C>o|CG|gasJ&cZbvP+G5pqKWlC0d~SjY{<wPmON20es z{rA1>4wKy=eLYHcLu7XtNAOsJ-B8SKC}uZ!KXxg(7bA93v5?zMGHoZf{02@hcCU25 z(4#)-Q5V*6W;*vV_8(ir`I+OH=Ql9Dn9HtXb{+F~@xrB66{UVaj&&Sm29NR6;kaR! z3t?k+dAwwDmtp3=g0GTDmKFb6BpH6MY@@bJYLd1AAwofYgIuPMJ&4OLv;T1l^921q zk;u|O%wr(pVMpFm^vm0Z36WBjOyPi0`YTUKPDVe*DhXseDrF9<(NG@p$2@&Rvry0? z2>G_|;P*~T#G{ex4je@t-=w3ITu_n26MQOKS$E;D;d%>fhnarb0NLS|2q-0=2AmPT zMMf-62R88XA_?`~#VhN0J@dvI-psDy$C colorFrequencies = new HashMap(); + + BufferedImage image = readImageFromFile(imageName); + for (int row = 0; row < image.getWidth(); row++) { + for (int col = 0; col < image.getHeight(); col++) { + int color = image.getRGB(row, col); //getRGBValuesFromPixel(image.getRGB(row, col)); + int count = colorFrequencies.containsKey(color) ? colorFrequencies.get(color) : 0; + colorFrequencies.put(color, count + 1); + } + } + System.out.println(image.getWidth() + ", " + image.getHeight()); + displayColorDistribution(colorFrequencies); + } + + public void displayColorDistribution(HashMap colorFrequencies) { + int numDifferentColors = 0; + for (HashMap.Entry entry: colorFrequencies.entrySet()) { + numDifferentColors++; + int[] color = getRGBValuesFromPixel(entry.getKey()); + int count = entry.getValue(); + System.out.println("(" + color[0] + "," + color[1] + "," + color[2] + "): " + count); + } + System.out.println("Number of different colors: " + numDifferentColors); + } + + private int[] getRGBValuesFromPixel(int pixel) { + int[] colors = {(pixel)&0xFF, (pixel>>8)&0xFF, (pixel>>16)&0xFF, (pixel>>24)&0xFF}; + return colors; + } + + private boolean pixelsAreWithinRGBTolerance(int rgb1, int rgb2, int tolerance) { + int[] colors1 = getRGBValuesFromPixel(rgb1); + int[] colors2 = getRGBValuesFromPixel(rgb2); + for (int i = 0; i < 3; i++) { + if (Math.abs(colors1[i] - colors2[i]) > tolerance) { + return false; + } + } + return true; + } + + public void printCursorColor() throws IOException, InterruptedException, AWTException { + BufferedImage image; + Robot robot = new Robot(); + + while (true) { + image = robot.createScreenCapture(new Rectangle(0, 0, 1920, 1080)); + Point cursorPosition = getCurrentCursorPoint(); + int[] colors = getRGBValuesFromPixel(image.getRGB(cursorPosition.x, cursorPosition.y)); + //System.out.println(colors[0] + "," + colors[1] + "," + colors[2]); + System.out.println("(" + cursorPosition.x + "," + cursorPosition.y + "), Color: (" + colors[0] + "," + colors[1] + "," + colors[2]); + Thread.sleep(100); + } + } + + private boolean isColorInRange(int rgb1) { + int colors[] = {makeRGBIntFromComponents(47,88,81), + makeRGBIntFromComponents(46,88,81)}; + for (int color : colors) { + if (pixelsAreWithinRGBTolerance(rgb1, color, 10)) { + return true; + } + } + return false; + } + + public void colorImage() throws IOException { + BufferedImage image = readImageFromFile("screenshot0.png"); + for (int row = 0; row < image.getWidth(); row++) { + for (int col = 0; col < image.getHeight(); col++) { + if (isColorInRange(image.getRGB(row, col))) { + System.out.println("match!"); + image.setRGB(row, col, makeRGBIntFromComponents(255, 0, 0)); + } + } + } + ImageIO.write(image, "png", new File(getImageName("filtered"))); + } + + private int makeRGBIntFromComponents(int red, int green, int blue) { + return red*65536 + green*256 + blue; + } + + private String getImageName(String imageName) { + return inputImageDirectory + imageName + ".png"; + } + + public Point getCurrentCursorPoint() { + return MouseInfo.getPointerInfo().getLocation(); + } + + public static void main(String[] args) throws Exception + { + ColorAnalyzer colorAnalyzer = new ColorAnalyzer(); + //colorAnalyzer.showColorDistribution("screenshot21.jpg"); + //colorAnalyzer.printCursorColor(); + colorAnalyzer.colorImage(); + } +} diff --git a/src/Cursor.java b/src/Cursor.java index 05b76db..c3a20c7 100644 --- a/src/Cursor.java +++ b/src/Cursor.java @@ -146,15 +146,35 @@ public class Cursor { } private CursorPath chooseCursorPathToFollowBasedOnDistance(int distanceToMoveCursor) { - ArrayList cursorPathsWithSameDistance = cursorPathsByDistance.get(distanceToMoveCursor); - // TODO: Error check if path of this size exists - if (cursorPathsWithSameDistance.size() == 0) { - System.out.println("No movement required! Returning empty list of CursorPoints."); + if (distanceToMoveCursor == 0) { return new CursorPath(new ArrayList()); } - return cursorPathsWithSameDistance.get(new Random().nextInt(cursorPathsWithSameDistance.size())); + + int newDistanceToMoveCursor = findNearestPathLengthThatExists(distanceToMoveCursor); + double scaleFactor = getScaleFactor(newDistanceToMoveCursor, distanceToMoveCursor); + + ArrayList cursorPathsWithSameDistance = cursorPathsByDistance.get(newDistanceToMoveCursor); + CursorPath scaledCursorPath = cursorPathsWithSameDistance.get(random.nextInt(cursorPathsWithSameDistance.size())).getScaledCopyOfCursorPath(1.0); + return scaledCursorPath; } + private int findNearestPathLengthThatExists(int distanceToMoveCursor) { + int offset = 1; + while (cursorPathsByDistance.get(distanceToMoveCursor + offset).size() == 0) { + if (offset > 0) { + offset = -(offset + 1); + } + else { + offset = -offset + 1; + } + } + return distanceToMoveCursor + offset; + } + + private double getScaleFactor(int newDistanceToMoveCursor, int distanceToMoveCursor) { + return (1.0 * newDistanceToMoveCursor / distanceToMoveCursor); + } + private int calculateDistanceBetweenPoints(Point a, Point b) { return (int) (Math.hypot(a.x - b.x, a.y - b.y)); } diff --git a/src/CursorPath.java b/src/CursorPath.java index c6bdd32..682d371 100644 --- a/src/CursorPath.java +++ b/src/CursorPath.java @@ -100,6 +100,14 @@ public class CursorPath { return pathTheta; } + public CursorPath getScaledCopyOfCursorPath(double scaleFactor) { + ArrayList scaledCursorPath = new ArrayList(); + for (CursorPoint cursorPoint : this.pathCursorPoints) { + scaledCursorPath.add(new CursorPoint((int) (cursorPoint.x * scaleFactor), (int) (cursorPoint.y * scaleFactor), (int) (cursorPoint.postMillisecondDelay * scaleFactor))); + } + return new CursorPath(scaledCursorPath); + } + public void displayCursorPoints() { for (CursorPoint p : pathCursorPoints) { p.display(); diff --git a/src/Inventory.java b/src/Inventory.java index eff91b0..1c79505 100644 --- a/src/Inventory.java +++ b/src/Inventory.java @@ -59,10 +59,6 @@ public class Inventory { updateAllInventorySlots(image); } - private String getImageName() { - return ("/home/dpapp/Desktop/RunescapeAIPics/Tests/Inventory/inventory.png"); - } - // For testing only public void updateWithFakeImageForTests(BufferedImage testImage) throws IOException { updateAllInventorySlots(testImage); diff --git a/src/Randomizer.java b/src/Randomizer.java new file mode 100644 index 0000000..bcdb039 --- /dev/null +++ b/src/Randomizer.java @@ -0,0 +1,41 @@ +import java.awt.Point; +import java.util.Random; +import Jama.Matrix; + +public class Randomizer { + + Random random; + + public Randomizer() { + random = new Random(); + } + + public int nextGaussianWithinThreeSTDs(int mean, int STD) { + int result = (int) (random.nextGaussian() * STD + mean); + while (result > (mean + 3 * STD) || result < (mean - 3 * STD)) { + result = (int) random.nextGaussian() * STD + mean; + } + return result; + } + + public Point generatePeakForTransformationParabola(int pathDistance) { + double maxTransformationScale = 0.2; + int peakX = nextGaussianWithinThreeSTDs(pathDistance / 2, pathDistance / 6); + int peakY = (int) (random.nextGaussian() * maxTransformationScale); + return new Point(peakX, peakY); + } + + public double[] generateParabolaEquation(int pathDistance, Point peakPoint) { + double[][] lhsMatrix = {{0, 0, 1}, {peakPoint.x * peakPoint.x, peakPoint.x, 1}, {pathDistance * pathDistance, pathDistance, 1}}; + double[][] rhsMatrix = {{0, peakPoint.y, 0}}; + + Matrix lhs = new Matrix(lhsMatrix); + Matrix rhs = new Matrix(rhsMatrix); + Matrix ans = lhs.solve(rhs); + + double[] result = {ans.get(0, 0), ans.get(1, 0), ans.get(2, 0)}; + return result; + } + + //public Point transformPoint +} diff --git a/src/RandomizerTest.java b/src/RandomizerTest.java new file mode 100644 index 0000000..1717889 --- /dev/null +++ b/src/RandomizerTest.java @@ -0,0 +1,29 @@ +import static org.junit.jupiter.api.Assertions.*; + +import java.awt.Point; + +import org.junit.jupiter.api.Test; + +class RandomizerTest { + + @Test + void test() { + Randomizer randomizer = new Randomizer(); + + + double[] parabolaEquation1 = randomizer.generateParabolaEquation(100, new Point(50, 0)); + double[] expectedResult1 = {0, 0, 0}; + double[] parabolaEquation2 = randomizer.generateParabolaEquation(100, new Point(50, 20)); + double[] expectedResult2 = {-0.008, 0.008, 0}; + double[] parabolaEquation3 = randomizer.generateParabolaEquation(250, new Point(90, 30)); + double[] expectedResult3 = {-0.002083, 0.52083, 0.0}; + checkVariables(expectedResult1, parabolaEquation1); + checkVariables(expectedResult2, parabolaEquation2); + checkVariables(expectedResult3, parabolaEquation3); + } + + void checkVariables(double[] expected, double[] actual) { + assertEquals(0, 0, 0); + } + +} diff --git a/src/WillowChopper.java b/src/WillowChopper.java new file mode 100644 index 0000000..d1c2902 --- /dev/null +++ b/src/WillowChopper.java @@ -0,0 +1,37 @@ +import java.awt.AWTException; +import java.io.IOException; + +public class WillowChopper { + + Cursor cursor; + CursorTask cursorTask; + Inventory inventory; + + public WillowChopper() throws AWTException, IOException + { + cursor = new Cursor(); + cursorTask = new CursorTask(); + inventory = new Inventory(); + } + + public void run() throws IOException, InterruptedException { + + while (true) { + /* + if (character.isCharacterEngaged()) { + // DO NOTHING + // do things like checking the inventory + } + else { + find closest willow tree + chop willow tree + } + */ + inventory.update(); + if (inventory.isInventoryFull()) { + cursorTask.dropAllItemsInInventory(cursor, inventory); + } + } + } + +} diff --git a/src/cascadeTrainingImageCollector.java b/src/cascadeTrainingImageCollector.java new file mode 100644 index 0000000..c314368 --- /dev/null +++ b/src/cascadeTrainingImageCollector.java @@ -0,0 +1,73 @@ +import java.awt.AWTException; +import java.awt.MouseInfo; +import java.awt.Point; +import java.awt.Rectangle; +import java.awt.Robot; +import java.awt.image.BufferedImage; +import java.io.File; +import java.io.IOException; + +import javax.imageio.ImageIO; + +public class cascadeTrainingImageCollector { + + public String imageOutputDirectory; + public Robot robot; + public int imageDimension; + + public cascadeTrainingImageCollector(String imageOutputDirectory) throws AWTException { + this.imageOutputDirectory = imageOutputDirectory; + this.robot = new Robot(); + this.imageDimension = 75; + } + + public void captureEveryNSeconds(int n) throws IOException, InterruptedException { + for (int i = 0; i < 60; i++) { + captureScreenshotAroundMouse(i); + System.out.println(i); + Thread.sleep(n * 1000); + } + } + + public void captureWindowEveryNMilliseconds(int n) throws InterruptedException, IOException { + for (int i = 0; i < 1000; i++) { + captureScreenshotGameWindow(i); + System.out.println(i); + //System.out.println("Created image: " + getImageName(i)); + Thread.sleep(n * 5000); + } + } + + private void captureScreenshotGameWindow(int counter) throws IOException { + Rectangle area = new Rectangle(103, 85, 510, 330); + BufferedImage image = robot.createScreenCapture(area); + ImageIO.write(image, "jpg", new File(getImageName(counter))); + } + + private void captureScreenshotAroundMouse(int counter) throws IOException { + BufferedImage image = robot.createScreenCapture(getRectangleAroundCursor()); + ImageIO.write(image, "jpg", new File(getImageName(counter))); + } + + private Rectangle getRectangleAroundCursor() { + Point cursorPoint = getCurrentCursorPoint(); + return new Rectangle(cursorPoint.x - imageDimension / 2, cursorPoint.y - imageDimension / 2, imageDimension, imageDimension); + } + + private Point getCurrentCursorPoint() { + return MouseInfo.getPointerInfo().getLocation(); + } + + private String getImageName(int counter) { + return imageOutputDirectory + "screenshot" + counter + ".jpg"; + } + + public static void main(String[] args) throws Exception + { + System.out.println("Starting image collection..."); + //cascadeTrainingImageCollector imageCollector = new cascadeTrainingImageCollector("/home/dpapp/Desktop/RunescapeAIPics/CascadeTraining/PositiveSamples/"); + //imageCollector.captureEveryNSeconds(30); + cascadeTrainingImageCollector imageCollector = new cascadeTrainingImageCollector("/home/dpapp/Desktop/RunescapeAIPics/CascadeTraining/Testing/"); + imageCollector.captureWindowEveryNMilliseconds(1); + } +}