refactor config
3
.idea/misc.xml
generated
@@ -1,4 +1,7 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project version="4">
|
<project version="4">
|
||||||
|
<component name="ProjectPlainTextFileTypeManager">
|
||||||
|
<file url="file://$PROJECT_DIR$/sharpening.py" />
|
||||||
|
</component>
|
||||||
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.7 (lc-py-b)" project-jdk-type="Python SDK" />
|
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.7 (lc-py-b)" project-jdk-type="Python SDK" />
|
||||||
</project>
|
</project>
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
import random
|
import random
|
||||||
from time import time
|
from time import time
|
||||||
from window_capture import WindowCapture
|
from window_capture import WindowCapture
|
||||||
from stun_vision import StunVision
|
from vision import Vision
|
||||||
import cv2 as cv
|
import cv2 as cv
|
||||||
import pytesseract
|
import pytesseract
|
||||||
from hsvfilter import HsvFilter
|
from hsvfilter import HsvFilter
|
||||||
@@ -18,7 +18,7 @@ def run():
|
|||||||
# initialize the StunWindowCapture class
|
# initialize the StunWindowCapture class
|
||||||
try:
|
try:
|
||||||
capture_window = WindowCapture(
|
capture_window = WindowCapture(
|
||||||
None, "stun", config)
|
None, "magic", config)
|
||||||
video_mode = False
|
video_mode = False
|
||||||
except:
|
except:
|
||||||
# StunWindowCapture.list_window_names()
|
# StunWindowCapture.list_window_names()
|
||||||
@@ -27,21 +27,17 @@ def run():
|
|||||||
video_mode = True
|
video_mode = True
|
||||||
|
|
||||||
# initialize the StunVision class
|
# initialize the StunVision class
|
||||||
vision_stun = StunVision()
|
vision_stun = Vision()
|
||||||
# initialize the StunOverlay class
|
# initialize the StunOverlay class
|
||||||
hsv_filter_orange = HsvFilter(10, 156, 0, 17, 255, 255, 0, 0, 0, 0)
|
hsv_filter_orange = HsvFilter(10, 156, 0, 17, 255, 255, 0, 0, 0, 0)
|
||||||
hsv_filter_p = HsvFilter(130, 156, 0, 179, 255, 255, 0, 0, 0, 0)
|
hsv_filter_p = HsvFilter(130, 156, 0, 179, 255, 255, 0, 0, 0, 0)
|
||||||
hsv_filter_b = HsvFilter(88, 156, 0, 128, 255, 255, 0, 0, 0, 0)
|
hsv_filter_b = HsvFilter(88, 156, 0, 128, 255, 255, 0, 0, 0, 0)
|
||||||
hsv_filter_g = HsvFilter(34, 156, 0, 74, 255, 255, 0, 0, 0, 0)
|
hsv_filter_g = HsvFilter(34, 156, 0, 74, 255, 255, 0, 0, 0, 0)
|
||||||
hsv_filter_y = HsvFilter(24, 156, 0, 33, 255, 255, 0, 0, 0, 0)
|
hsv_filter_y = HsvFilter(24, 156, 0, 33, 255, 255, 0, 0, 0, 0)
|
||||||
#hsv_filter_0 = HsvFilter(0, 156, 0, 7, 255, 255, 0, 0, 0, 0)
|
|
||||||
hsv_filter_0 = HsvFilter(0, 0, 0, 179, 255, 255, 255, 0, 0, 0)
|
hsv_filter_0 = HsvFilter(0, 0, 0, 179, 255, 255, 255, 0, 0, 0)
|
||||||
hsv_filter_w = HsvFilter(69, 25, 0, 94, 255, 255, 0, 0, 0, 0)
|
hsv_filter_w = HsvFilter(69, 25, 0, 94, 255, 255, 0, 0, 0, 0)
|
||||||
|
|
||||||
loop_time = time()
|
loop_time = time()
|
||||||
event_time = 0.0
|
|
||||||
pointstore = []
|
|
||||||
max_results = 0
|
|
||||||
pause = True
|
pause = True
|
||||||
|
|
||||||
magic_list = {"1": "body", "2": "finding", "3": "mind", "4": "perceiving", "5": "physical", "6": "seeing",
|
magic_list = {"1": "body", "2": "finding", "3": "mind", "4": "perceiving", "5": "physical", "6": "seeing",
|
||||||
@@ -52,7 +48,6 @@ def run():
|
|||||||
|
|
||||||
needle_list = []
|
needle_list = []
|
||||||
hsv_list = []
|
hsv_list = []
|
||||||
# tmp = []
|
|
||||||
for key1 in tier_list:
|
for key1 in tier_list:
|
||||||
for key2 in magic_list:
|
for key2 in magic_list:
|
||||||
|
|
||||||
|
|||||||
@@ -19,9 +19,8 @@ class UserConfigs:
|
|||||||
else:
|
else:
|
||||||
self.user = self.ADWAUSER
|
self.user = self.ADWAUSER
|
||||||
|
|
||||||
def returnStunWindowPos(self):
|
def returnMagicWindowPos(self):
|
||||||
if self.user == self.THALOUSER:
|
if self.user == self.THALOUSER:
|
||||||
#return [1410, 1128, 402, 22]
|
|
||||||
return [1800, 1150, 0, 0]
|
return [1800, 1150, 0, 0]
|
||||||
elif self.user == self.ADWAUSER:
|
elif self.user == self.ADWAUSER:
|
||||||
return [740, 450, 1625, 985]
|
return [740, 450, 1625, 985]
|
||||||
@@ -30,43 +29,33 @@ class UserConfigs:
|
|||||||
else:
|
else:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def returnPoisonWindowPos(self):
|
def returnFullScreenWindowPos(self):
|
||||||
if self.user == self.THALOUSER:
|
if self.user == self.THALOUSER:
|
||||||
return [740, 442, 1625, 985]
|
return [2560, 1440, 0, 0]
|
||||||
elif self.user == self.ADWAUSER:
|
elif self.user == self.ADWAUSER:
|
||||||
return [740, 442, 1625, 985]
|
return [740, 450, 1625, 985]
|
||||||
elif self.user == self.EDDIEUSER:
|
elif self.user == self.EDDIEUSER:
|
||||||
return [740, 442, 1625, 985]
|
return [740, 450, 1625, 985]
|
||||||
else:
|
else:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def returnPoisonOverlayPos(self):
|
def returnDiggingWindowPos(self):
|
||||||
if self.user == self.THALOUSER:
|
if self.user == self.THALOUSER:
|
||||||
return '160x160+-900+760'
|
return [1410, 1128, 402, 22]
|
||||||
elif self.user == self.ADWAUSER:
|
elif self.user == self.ADWAUSER:
|
||||||
return '160x160+-900+760'
|
return [740, 450, 1625, 985]
|
||||||
elif self.user == self.EDDIEUSER:
|
elif self.user == self.EDDIEUSER:
|
||||||
return '160x160+-900+760'
|
return [740, 450, 1625, 985]
|
||||||
else:
|
else:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def returnStunOverlayPos(self):
|
def returnEquipmentWindowPos(self):
|
||||||
if self.user == self.THALOUSER:
|
if self.user == self.THALOUSER:
|
||||||
return '160x160+-1360+350'
|
return [1800, 1150, 0, 0]
|
||||||
elif self.user == self.ADWAUSER:
|
elif self.user == self.ADWAUSER:
|
||||||
return '160x160+-900+600'
|
return [740, 450, 1625, 985]
|
||||||
elif self.user == self.EDDIEUSER:
|
elif self.user == self.EDDIEUSER:
|
||||||
return '160x160+-1360+350'
|
return [740, 450, 1625, 985]
|
||||||
else:
|
|
||||||
pass
|
|
||||||
|
|
||||||
def returnEnemyPlayerOverlayPos(self):
|
|
||||||
if self.user == self.THALOUSER:
|
|
||||||
return '330x45+-900+920'
|
|
||||||
elif self.user == self.ADWAUSER:
|
|
||||||
return '160x160+-900+600'
|
|
||||||
elif self.user == self.EDDIEUSER:
|
|
||||||
return '330x45+-900+920'
|
|
||||||
else:
|
else:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 1.8 KiB After Width: | Height: | Size: 1.8 KiB |
|
Before Width: | Height: | Size: 1.7 KiB After Width: | Height: | Size: 1.7 KiB |
|
Before Width: | Height: | Size: 1.9 KiB After Width: | Height: | Size: 1.9 KiB |
|
Before Width: | Height: | Size: 1.7 KiB After Width: | Height: | Size: 1.7 KiB |
|
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 1.2 KiB |
|
Before Width: | Height: | Size: 1.6 KiB After Width: | Height: | Size: 1.6 KiB |
|
Before Width: | Height: | Size: 1.9 KiB After Width: | Height: | Size: 1.9 KiB |
|
Before Width: | Height: | Size: 1.5 KiB After Width: | Height: | Size: 1.5 KiB |
|
Before Width: | Height: | Size: 1.9 KiB After Width: | Height: | Size: 1.9 KiB |
|
Before Width: | Height: | Size: 2.1 KiB After Width: | Height: | Size: 2.1 KiB |
|
Before Width: | Height: | Size: 1.9 KiB After Width: | Height: | Size: 1.9 KiB |
|
Before Width: | Height: | Size: 2.3 KiB After Width: | Height: | Size: 2.3 KiB |
|
Before Width: | Height: | Size: 2.5 KiB After Width: | Height: | Size: 2.5 KiB |
|
Before Width: | Height: | Size: 2.4 KiB After Width: | Height: | Size: 2.4 KiB |
|
Before Width: | Height: | Size: 2.2 KiB After Width: | Height: | Size: 2.2 KiB |
|
Before Width: | Height: | Size: 2.4 KiB After Width: | Height: | Size: 2.4 KiB |
|
Before Width: | Height: | Size: 1.8 MiB After Width: | Height: | Size: 1.8 MiB |
|
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 12 KiB |
|
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 1.4 KiB |
@@ -1,7 +1,7 @@
|
|||||||
import random
|
import random
|
||||||
from time import time
|
from time import time
|
||||||
from window_capture import WindowCapture
|
from window_capture import WindowCapture
|
||||||
from stun_vision import StunVision
|
from vision import Vision
|
||||||
import cv2 as cv
|
import cv2 as cv
|
||||||
import pytesseract
|
import pytesseract
|
||||||
from hsvfilter import HsvFilter
|
from hsvfilter import HsvFilter
|
||||||
@@ -19,7 +19,7 @@ def run():
|
|||||||
# initialize the StunWindowCapture class
|
# initialize the StunWindowCapture class
|
||||||
try:
|
try:
|
||||||
capture_window = WindowCapture(
|
capture_window = WindowCapture(
|
||||||
None, "stun", config)
|
None, "dig", config)
|
||||||
video_mode = False
|
video_mode = False
|
||||||
except:
|
except:
|
||||||
# StunWindowCapture.list_window_names()
|
# StunWindowCapture.list_window_names()
|
||||||
@@ -28,7 +28,7 @@ def run():
|
|||||||
video_mode = True
|
video_mode = True
|
||||||
|
|
||||||
# initialize the StunVision class
|
# initialize the StunVision class
|
||||||
vision_stun = StunVision()
|
vision_stun = Vision()
|
||||||
# initialize the StunOverlay class
|
# initialize the StunOverlay class
|
||||||
hsv_filter = HsvFilter(0, 0, 124, 15, 255, 168, 0, 255, 0, 0)
|
hsv_filter = HsvFilter(0, 0, 124, 15, 255, 168, 0, 255, 0, 0)
|
||||||
|
|
||||||
@@ -67,24 +67,24 @@ def run():
|
|||||||
#continue
|
#continue
|
||||||
|
|
||||||
needles = []
|
needles = []
|
||||||
needles.append(cv.imread("wtf.jpg", cv.IMREAD_UNCHANGED))
|
#needles.append(cv.imread("wtf.jpg", cv.IMREAD_UNCHANGED))
|
||||||
needles.append(cv.imread("Brown0.jpg", cv.IMREAD_UNCHANGED))
|
needles.append(cv.imread("dig/Brown0.jpg", cv.IMREAD_UNCHANGED))
|
||||||
needles.append(cv.imread("1.jpg", cv.IMREAD_UNCHANGED))
|
needles.append(cv.imread("dig/1.jpg", cv.IMREAD_UNCHANGED))
|
||||||
needles.append(cv.imread("2.jpg", cv.IMREAD_UNCHANGED))
|
needles.append(cv.imread("dig/2.jpg", cv.IMREAD_UNCHANGED))
|
||||||
needles.append(cv.imread("3.jpg", cv.IMREAD_UNCHANGED))
|
needles.append(cv.imread("dig/3.jpg", cv.IMREAD_UNCHANGED))
|
||||||
needles.append(cv.imread("4.jpg", cv.IMREAD_UNCHANGED))
|
needles.append(cv.imread("dig/4.jpg", cv.IMREAD_UNCHANGED))
|
||||||
needles.append(cv.imread("H1.jpg", cv.IMREAD_UNCHANGED))
|
#needles.append(cv.imread("H1.jpg", cv.IMREAD_UNCHANGED))
|
||||||
needles.append(cv.imread("H2.jpg", cv.IMREAD_UNCHANGED))
|
#needles.append(cv.imread("H2.jpg", cv.IMREAD_UNCHANGED))
|
||||||
needles.append(cv.imread("H3.jpg", cv.IMREAD_UNCHANGED))
|
#needles.append(cv.imread("H3.jpg", cv.IMREAD_UNCHANGED))
|
||||||
needles.append(cv.imread("H4.jpg", cv.IMREAD_UNCHANGED))
|
#needles.append(cv.imread("H4.jpg", cv.IMREAD_UNCHANGED))
|
||||||
needles.append(cv.imread("D1.jpg", cv.IMREAD_UNCHANGED))
|
# needles.append(cv.imread("D1.jpg", cv.IMREAD_UNCHANGED))
|
||||||
needles.append(cv.imread("D2.jpg", cv.IMREAD_UNCHANGED))
|
# needles.append(cv.imread("D2.jpg", cv.IMREAD_UNCHANGED))
|
||||||
needles.append(cv.imread("D3.jpg", cv.IMREAD_UNCHANGED))
|
# needles.append(cv.imread("D3.jpg", cv.IMREAD_UNCHANGED))
|
||||||
needles.append(cv.imread("D3.jpg", cv.IMREAD_UNCHANGED))
|
# needles.append(cv.imread("D3.jpg", cv.IMREAD_UNCHANGED))
|
||||||
needles.append(cv.imread("D4.jpg", cv.IMREAD_UNCHANGED))
|
# needles.append(cv.imread("D4.jpg", cv.IMREAD_UNCHANGED))
|
||||||
needles.append(cv.imread("D5.jpg", cv.IMREAD_UNCHANGED))
|
# needles.append(cv.imread("D5.jpg", cv.IMREAD_UNCHANGED))
|
||||||
needles.append(cv.imread("D6.jpg", cv.IMREAD_UNCHANGED))
|
# needles.append(cv.imread("D6.jpg", cv.IMREAD_UNCHANGED))
|
||||||
needles.append(cv.imread("D7.jpg", cv.IMREAD_UNCHANGED))
|
# needles.append(cv.imread("D7.jpg", cv.IMREAD_UNCHANGED))
|
||||||
|
|
||||||
for needle in needles:
|
for needle in needles:
|
||||||
# do object detection
|
# do object detection
|
||||||
@@ -111,8 +111,8 @@ def run():
|
|||||||
|
|
||||||
left = int(round(rectangles[0][0] / size, 0)) # 4
|
left = int(round(rectangles[0][0] / size, 0)) # 4
|
||||||
down = int(round(rectangles[0][1] / size, 0)) # 23
|
down = int(round(rectangles[0][1] / size, 0)) # 23
|
||||||
offset_left = config.returnStunWindowPos()[2]
|
offset_left = config.returnMagicWindowPos()[2]
|
||||||
offset_down = config.returnStunWindowPos()[3]
|
offset_down = config.returnMagicWindowPos()[3]
|
||||||
# 167 1055 start
|
# 167 1055 start
|
||||||
# 3x47 left 26x right to 30
|
# 3x47 left 26x right to 30
|
||||||
# 1x down 22x up to 24
|
# 1x down 22x up to 24
|
||||||
@@ -124,15 +124,15 @@ def run():
|
|||||||
for i in range(start_left, start_left + (size * 30), size):
|
for i in range(start_left, start_left + (size * 30), size):
|
||||||
pydirectinput.moveTo(i + offset_left, f + offset_down)
|
pydirectinput.moveTo(i + offset_left, f + offset_down)
|
||||||
pydirectinput.mouseDown()
|
pydirectinput.mouseDown()
|
||||||
w = random.randint(1, 100)
|
w = random.randint(1, 50)
|
||||||
cv.waitKey(150 + w)
|
cv.waitKey(850 + w)
|
||||||
pydirectinput.mouseUp()
|
pydirectinput.mouseUp()
|
||||||
if keyboard.is_pressed('p') == True or pause == True:
|
if keyboard.is_pressed('p') == True or pause == True:
|
||||||
pause = True
|
pause = True
|
||||||
break
|
break
|
||||||
|
|
||||||
screenshot = capture_window.get_screenshot()
|
screenshot = capture_window.get_screenshot()
|
||||||
rectangles = vision_stun.find(screenshot, cv.imread("ok_button.jpg", cv.IMREAD_UNCHANGED), 0.8, 1)
|
rectangles = vision_stun.find(screenshot, cv.imread("dig/ok_button.jpg", cv.IMREAD_UNCHANGED), 0.8, 1)
|
||||||
# draw the detection results onto the original image
|
# draw the detection results onto the original image
|
||||||
output_image = vision_stun.draw_rectangles(screenshot, rectangles)
|
output_image = vision_stun.draw_rectangles(screenshot, rectangles)
|
||||||
if len(rectangles) == 1:
|
if len(rectangles) == 1:
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import random
|
import random
|
||||||
from time import time
|
from time import time
|
||||||
from window_capture import WindowCapture
|
from window_capture import WindowCapture
|
||||||
from stun_vision import StunVision
|
from vision import Vision
|
||||||
import cv2 as cv
|
import cv2 as cv
|
||||||
import pytesseract
|
import pytesseract
|
||||||
from hsvfilter import HsvFilter
|
from hsvfilter import HsvFilter
|
||||||
@@ -19,7 +19,7 @@ def run():
|
|||||||
# initialize the StunWindowCapture class
|
# initialize the StunWindowCapture class
|
||||||
try:
|
try:
|
||||||
capture_window = WindowCapture(
|
capture_window = WindowCapture(
|
||||||
None, "stun", config)
|
None, "equip", config)
|
||||||
video_mode = False
|
video_mode = False
|
||||||
except:
|
except:
|
||||||
# StunWindowCapture.list_window_names()
|
# StunWindowCapture.list_window_names()
|
||||||
@@ -28,7 +28,7 @@ def run():
|
|||||||
video_mode = True
|
video_mode = True
|
||||||
|
|
||||||
# initialize the StunVision class
|
# initialize the StunVision class
|
||||||
vision_stun = StunVision()
|
vision_stun = Vision()
|
||||||
# initialize the StunOverlay class
|
# initialize the StunOverlay class
|
||||||
hsv_filter = HsvFilter(0, 0, 124, 15, 255, 168, 0, 255, 0, 0)
|
hsv_filter = HsvFilter(0, 0, 124, 15, 255, 168, 0, 255, 0, 0)
|
||||||
|
|
||||||
@@ -157,9 +157,9 @@ def run():
|
|||||||
processed_needle = vision_stun.apply_hsv_filter(needles[rer], hsv[rer])
|
processed_needle = vision_stun.apply_hsv_filter(needles[rer], hsv[rer])
|
||||||
rectangles = vision_stun.find(processed_screenshot, processed_needle, 0.8, 5)
|
rectangles = vision_stun.find(processed_screenshot, processed_needle, 0.8, 5)
|
||||||
# draw the detection results onto the original image
|
# draw the detection results onto the original image
|
||||||
output_image = vision_stun.draw_rectangles(processed_screenshot, rectangles)
|
#output_image = vision_stun.draw_rectangles(processed_screenshot, rectangles)
|
||||||
cv.imshow("output_image", output_image)
|
#cv.imshow("output_image", output_image)
|
||||||
cv.waitKey(150)
|
#cv.waitKey(150)
|
||||||
|
|
||||||
if len(rectangles) is not 5:
|
if len(rectangles) is not 5:
|
||||||
break
|
break
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import random
|
import random
|
||||||
from time import time
|
from time import time
|
||||||
from window_capture import WindowCapture
|
from window_capture import WindowCapture
|
||||||
from stun_vision import StunVision
|
from vision import Vision
|
||||||
import cv2 as cv
|
import cv2 as cv
|
||||||
import pytesseract
|
import pytesseract
|
||||||
from hsvfilter import HsvFilter
|
from hsvfilter import HsvFilter
|
||||||
@@ -28,7 +28,7 @@ def run():
|
|||||||
video_mode = True
|
video_mode = True
|
||||||
|
|
||||||
# initialize the StunVision class
|
# initialize the StunVision class
|
||||||
vision_stun = StunVision()
|
vision_stun = Vision()
|
||||||
# initialize the StunOverlay class
|
# initialize the StunOverlay class
|
||||||
hsv_filter = HsvFilter(0, 0, 124, 15, 255, 168, 0, 255, 0, 0)
|
hsv_filter = HsvFilter(0, 0, 124, 15, 255, 168, 0, 255, 0, 0)
|
||||||
|
|
||||||
@@ -97,6 +97,8 @@ def run():
|
|||||||
|
|
||||||
needles.append(cv.imread("equip/book_1_32.jpg", cv.IMREAD_UNCHANGED))
|
needles.append(cv.imread("equip/book_1_32.jpg", cv.IMREAD_UNCHANGED))
|
||||||
needles.append(cv.imread("equip/book_2_32.jpg", cv.IMREAD_UNCHANGED))
|
needles.append(cv.imread("equip/book_2_32.jpg", cv.IMREAD_UNCHANGED))
|
||||||
|
needles.append(cv.imread("equip/book_3_32.jpg", cv.IMREAD_UNCHANGED))
|
||||||
|
needles.append(cv.imread("equip/book_4_32.jpg", cv.IMREAD_UNCHANGED))
|
||||||
needles.append(cv.imread("equip/book_5_32.jpg", cv.IMREAD_UNCHANGED))
|
needles.append(cv.imread("equip/book_5_32.jpg", cv.IMREAD_UNCHANGED))
|
||||||
|
|
||||||
needles.append(cv.imread("equip/amu_1_32.jpg", cv.IMREAD_UNCHANGED))
|
needles.append(cv.imread("equip/amu_1_32.jpg", cv.IMREAD_UNCHANGED))
|
||||||
@@ -115,18 +117,16 @@ def run():
|
|||||||
needles.append(cv.imread("equip/bag_6_32.jpg", cv.IMREAD_UNCHANGED))
|
needles.append(cv.imread("equip/bag_6_32.jpg", cv.IMREAD_UNCHANGED))
|
||||||
# needles.append(cv.imread("equip/bag_7_32.jpg", cv.IMREAD_UNCHANGED))
|
# needles.append(cv.imread("equip/bag_7_32.jpg", cv.IMREAD_UNCHANGED))
|
||||||
|
|
||||||
needles.append(cv.imread("equip/book_3_32.jpg", cv.IMREAD_UNCHANGED))
|
|
||||||
needles.append(cv.imread("equip/book_4_32.jpg", cv.IMREAD_UNCHANGED))
|
# needles.append(cv.imread("equip/book_6_32.jpg", cv.IMREAD_UNCHANGED))
|
||||||
needles.append(cv.imread("equip/book_6_32.jpg", cv.IMREAD_UNCHANGED))
|
# needles.append(cv.imread("equip/book_7_32.jpg", cv.IMREAD_UNCHANGED))
|
||||||
needles.append(cv.imread("equip/book_7_32.jpg", cv.IMREAD_UNCHANGED))
|
|
||||||
|
|
||||||
hsv = []
|
hsv = []
|
||||||
hsv.append(HsvFilter(0, 128, 0, 179, 255, 255, 0, 0, 0, 0))
|
hsv.append(HsvFilter(0, 128, 0, 179, 255, 255, 0, 0, 0, 0))
|
||||||
hsv.append(HsvFilter(49, 0, 0, 179, 255, 255, 0, 0, 0, 0))
|
hsv.append(HsvFilter(49, 0, 0, 179, 255, 255, 0, 0, 0, 0))
|
||||||
|
hsv.append(HsvFilter(0, 0, 0, 179, 255, 196, 0, 0, 0, 0))
|
||||||
|
hsv.append(HsvFilter(0, 156, 0, 179, 255, 255, 0, 0, 0, 0))
|
||||||
hsv.append(HsvFilter(0, 95, 137, 179, 255, 255, 0, 0, 0, 0))
|
hsv.append(HsvFilter(0, 95, 137, 179, 255, 255, 0, 0, 0, 0))
|
||||||
#hsv.append(HsvFilter(0, 0, 0, 179, 255, 255, 0, 0, 0, 0))
|
|
||||||
#hsv.append(HsvFilter(0, 40, 0, 179, 255, 255, 0, 0, 0, 0))
|
|
||||||
#hsv.append(HsvFilter(0, 0, 255, 179, 255, 255, 0, 0, 103, 0))
|
|
||||||
for op in range(1, 50, 1):
|
for op in range(1, 50, 1):
|
||||||
hsv.append(HsvFilter(0, 0, 0, 179, 255, 255, 0, 0, 0, 0))
|
hsv.append(HsvFilter(0, 0, 0, 179, 255, 255, 0, 0, 0, 0))
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import numpy as np
|
|||||||
import os
|
import os
|
||||||
from time import time
|
from time import time
|
||||||
from window_capture import WindowCapture
|
from window_capture import WindowCapture
|
||||||
from stun_vision import StunVision
|
from vision import Vision
|
||||||
from hsvfilter import HsvFilter
|
from hsvfilter import HsvFilter
|
||||||
|
|
||||||
# Change the working directory to the folder this script is in.
|
# Change the working directory to the folder this script is in.
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import numpy as np
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
image = cv2.imread("digging.jpg")
|
image = cv2.imread("dig/digging.jpg")
|
||||||
|
|
||||||
cv2.imshow("Image", image)
|
cv2.imshow("Image", image)
|
||||||
|
|
||||||
|
|||||||
44
squares.py
@@ -1,44 +0,0 @@
|
|||||||
import cv2
|
|
||||||
import numpy as np
|
|
||||||
|
|
||||||
def angle_cos(p0, p1, p2):
|
|
||||||
d1, d2 = (p0-p1).astype('float'), (p2-p1).astype('float')
|
|
||||||
return abs( np.dot(d1, d2) / np.sqrt( np.dot(d1, d1)*np.dot(d2, d2) ) )
|
|
||||||
|
|
||||||
def find_squares(img):
|
|
||||||
squares = []
|
|
||||||
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
|
|
||||||
# cv2.imshow("gray", gray)
|
|
||||||
|
|
||||||
gaussian = cv2.GaussianBlur(gray, (5, 5), 0)
|
|
||||||
|
|
||||||
thresh = cv2.adaptiveThreshold(gaussian, 255, 1, 1, 11, 2)
|
|
||||||
#temp,bin = cv2.threshold(gaussian, 80, 255, cv2.THRESH_BINARY)
|
|
||||||
cv2.imshow("thresh", thresh)
|
|
||||||
|
|
||||||
contours, hierarchy = cv2.findContours(thresh, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE)
|
|
||||||
|
|
||||||
cv2.drawContours( gray, contours, -1, (0, 255, 0), 3 )
|
|
||||||
|
|
||||||
#cv2.imshow('contours', gray)
|
|
||||||
for cnt in contours:
|
|
||||||
cnt_len = cv2.arcLength(cnt, True)
|
|
||||||
cnt = cv2.approxPolyDP(cnt, 0.02*cnt_len, True)
|
|
||||||
if cv2.contourArea(cnt) > 1000 :
|
|
||||||
#cnt = cnt.reshape(-1, 2)
|
|
||||||
#max_cos = np.max([angle_cos( cnt[i], cnt[(i+1) % 4], cnt[(i+2) % 4] ) for i in range(4)])
|
|
||||||
#if max_cos < 0.1:
|
|
||||||
squares.append(cnt)
|
|
||||||
return squares
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
|
||||||
img = cv2.imread('equip/main_screen.jpg')
|
|
||||||
|
|
||||||
#cv2.imshow("origin", img)
|
|
||||||
|
|
||||||
squares = find_squares(img)
|
|
||||||
print("Find %d squres" % len(squares))
|
|
||||||
cv2.drawContours( img, squares, -1, (0, 255, 0), 3 )
|
|
||||||
cv2.imshow('squares', img)
|
|
||||||
|
|
||||||
cv2.waitKey()
|
|
||||||
157
stun_main.py
@@ -1,157 +0,0 @@
|
|||||||
import random
|
|
||||||
from time import time
|
|
||||||
from window_capture import WindowCapture
|
|
||||||
from stun_vision import StunVision
|
|
||||||
import cv2 as cv
|
|
||||||
import pytesseract
|
|
||||||
from hsvfilter import HsvFilter
|
|
||||||
from config_file import UserConfigs
|
|
||||||
#import pyautogui
|
|
||||||
import pydirectinput
|
|
||||||
import keyboard
|
|
||||||
from tresh_util import super_tresh_main, super_tresh_needle
|
|
||||||
|
|
||||||
|
|
||||||
def run():
|
|
||||||
# initialize the user-class
|
|
||||||
config = UserConfigs()
|
|
||||||
|
|
||||||
# initialize the StunWindowCapture class
|
|
||||||
try:
|
|
||||||
capture_window = WindowCapture(
|
|
||||||
None, "stun", config)
|
|
||||||
video_mode = False
|
|
||||||
except:
|
|
||||||
# StunWindowCapture.list_window_names()
|
|
||||||
#print("Game not running, switching to video mode")
|
|
||||||
#capture_window = cv.VideoCapture("snip_slam.mp4")
|
|
||||||
video_mode = True
|
|
||||||
|
|
||||||
# initialize the StunVision class
|
|
||||||
vision_stun = StunVision()
|
|
||||||
# initialize the StunOverlay class
|
|
||||||
hsv_filter = HsvFilter(0, 0, 124, 15, 255, 168, 0, 255, 0, 0)
|
|
||||||
|
|
||||||
loop_time = time()
|
|
||||||
event_time = 0.0
|
|
||||||
pointstore = []
|
|
||||||
max_results = 0
|
|
||||||
pause = True
|
|
||||||
while True:
|
|
||||||
if keyboard.is_pressed('p') == True:
|
|
||||||
pause = True
|
|
||||||
print('q pressed')
|
|
||||||
elif keyboard.is_pressed('o') == True:
|
|
||||||
pause = False
|
|
||||||
print('o pressed')
|
|
||||||
if pause:
|
|
||||||
#cv.waitKey(500)
|
|
||||||
print("pausing")
|
|
||||||
continue
|
|
||||||
|
|
||||||
'''
|
|
||||||
# 30 units = 46 + 1 * 30
|
|
||||||
for f in range(0, 30, 3):
|
|
||||||
for i in range(430, 1705, 47 - f):
|
|
||||||
for e in range(45, 470, 47 - f):
|
|
||||||
|
|
||||||
pydirectinput.moveTo(i, e)
|
|
||||||
pydirectinput.mouseDown()
|
|
||||||
w = random.randint(1, 100)
|
|
||||||
cv.waitKey(1000 + w)
|
|
||||||
pydirectinput.mouseUp()
|
|
||||||
if keyboard.is_pressed('p') == True or pause == True:
|
|
||||||
pause = True
|
|
||||||
break
|
|
||||||
if keyboard.is_pressed('p') == True or pause == True:
|
|
||||||
pause = True
|
|
||||||
break
|
|
||||||
'''
|
|
||||||
|
|
||||||
|
|
||||||
if video_mode:
|
|
||||||
break
|
|
||||||
else:
|
|
||||||
try:
|
|
||||||
# get an updated image of the game
|
|
||||||
screenshot = capture_window.get_screenshot()
|
|
||||||
# screenshot = cv.imread("buffbar.jpg")
|
|
||||||
except:
|
|
||||||
capture_window.release()
|
|
||||||
print("Game window not available - shutting down application")
|
|
||||||
break
|
|
||||||
#cv.imshow("screenshot", screenshot)
|
|
||||||
#cv.waitKey(150)
|
|
||||||
#continue
|
|
||||||
|
|
||||||
needles = []
|
|
||||||
#needles.append(cv.imread("wtf.jpg", cv.IMREAD_UNCHANGED))
|
|
||||||
#needles.append(cv.imread("Brown0.jpg", cv.IMREAD_UNCHANGED))
|
|
||||||
#needles.append(cv.imread("1.jpg", cv.IMREAD_UNCHANGED))
|
|
||||||
#needles.append(cv.imread("2.jpg", cv.IMREAD_UNCHANGED))
|
|
||||||
#needles.append(cv.imread("3.jpg", cv.IMREAD_UNCHANGED))
|
|
||||||
#needles.append(cv.imread("4.jpg", cv.IMREAD_UNCHANGED))
|
|
||||||
needles.append(cv.imread("H1.jpg", cv.IMREAD_UNCHANGED))
|
|
||||||
needles.append(cv.imread("H2.jpg", cv.IMREAD_UNCHANGED))
|
|
||||||
needles.append(cv.imread("H3.jpg", cv.IMREAD_UNCHANGED))
|
|
||||||
needles.append(cv.imread("H4.jpg", cv.IMREAD_UNCHANGED))
|
|
||||||
needles.append(cv.imread("D1.jpg", cv.IMREAD_UNCHANGED))
|
|
||||||
#needles.append(cv.imread("D2.jpg", cv.IMREAD_UNCHANGED))
|
|
||||||
#needles.append(cv.imread("D3.jpg", cv.IMREAD_UNCHANGED))
|
|
||||||
#needles.append(cv.imread("D3.jpg", cv.IMREAD_UNCHANGED))
|
|
||||||
#needles.append(cv.imread("D4.jpg", cv.IMREAD_UNCHANGED))
|
|
||||||
#needles.append(cv.imread("D5.jpg", cv.IMREAD_UNCHANGED))
|
|
||||||
#needles.append(cv.imread("D6.jpg", cv.IMREAD_UNCHANGED))
|
|
||||||
#needles.append(cv.imread("D7.jpg", cv.IMREAD_UNCHANGED))
|
|
||||||
|
|
||||||
for needle in needles:
|
|
||||||
# do object detection
|
|
||||||
#processed_image = vision_stun.apply_hsv_filter(screenshot, hsv_filter)
|
|
||||||
processed_image = super_tresh_needle(screenshot)
|
|
||||||
processed_needle = super_tresh_needle(needle)
|
|
||||||
rectangles = vision_stun.find(processed_image, processed_needle, 0.5, 1)
|
|
||||||
# draw the detection results onto the original image
|
|
||||||
output_image = vision_stun.draw_rectangles(screenshot, rectangles)
|
|
||||||
cv.imshow("output_image", output_image)
|
|
||||||
cv.waitKey(150)
|
|
||||||
|
|
||||||
# only trigger ocr reading if a stun is detected
|
|
||||||
points = vision_stun.get_click_points(rectangles)
|
|
||||||
for point in points:
|
|
||||||
if point not in pointstore:
|
|
||||||
pointstore.append(point)
|
|
||||||
pydirectinput.moveTo(point[0], point[1])
|
|
||||||
pydirectinput.mouseDown()
|
|
||||||
w = random.randint(1, 100)
|
|
||||||
cv.waitKey(400 + w)
|
|
||||||
pydirectinput.mouseUp()
|
|
||||||
else:
|
|
||||||
max_results = max_results + 1
|
|
||||||
# apply missing buff
|
|
||||||
#print("buff missing" + str(i))
|
|
||||||
|
|
||||||
#pydirectinput.click(500,500)
|
|
||||||
#pydirectinput.press(key)
|
|
||||||
#cv.waitKey(10)
|
|
||||||
#pydirectinput.rightClick()
|
|
||||||
#pydirectinput.press("C")
|
|
||||||
#cv.waitKey(150)
|
|
||||||
#pyautogui.rightClick()
|
|
||||||
#cv.waitKey(10)
|
|
||||||
#pydirectinput.press("c")
|
|
||||||
#overlay_stun.update_stun_label("")
|
|
||||||
if keyboard.is_pressed('p') == True or pause == True:
|
|
||||||
pause = True
|
|
||||||
break
|
|
||||||
if keyboard.is_pressed('p') == True or pause == True:
|
|
||||||
pause = True
|
|
||||||
break
|
|
||||||
|
|
||||||
# debug the loop rate
|
|
||||||
print('FPS {}'.format(1 / (time() - loop_time)))
|
|
||||||
loop_time = time()
|
|
||||||
cv.waitKey(150)
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
|
||||||
run()
|
|
||||||
@@ -3,7 +3,7 @@ import numpy as np
|
|||||||
from hsvfilter import HsvFilter
|
from hsvfilter import HsvFilter
|
||||||
|
|
||||||
|
|
||||||
class StunVision:
|
class Vision:
|
||||||
# constants
|
# constants
|
||||||
TRACKBAR_WINDOW = "Trackbars"
|
TRACKBAR_WINDOW = "Trackbars"
|
||||||
|
|
||||||
@@ -17,7 +17,7 @@ class StunVision:
|
|||||||
def __init__(self, method=cv.TM_CCOEFF_NORMED):
|
def __init__(self, method=cv.TM_CCOEFF_NORMED):
|
||||||
# load the image we're trying to match
|
# load the image we're trying to match
|
||||||
# https://docs.opencv.org/4.2.0/d4/da8/group__imgcodecs.html
|
# https://docs.opencv.org/4.2.0/d4/da8/group__imgcodecs.html
|
||||||
self.needle_img = cv.imread("wtf.jpg", cv.IMREAD_UNCHANGED)
|
self.needle_img = cv.imread("dig/wtf.jpg", cv.IMREAD_UNCHANGED)
|
||||||
|
|
||||||
# Save the dimensions of the needle image
|
# Save the dimensions of the needle image
|
||||||
#self.needle_w = self.needle_img.shape[1]
|
#self.needle_w = self.needle_img.shape[1]
|
||||||
@@ -27,10 +27,14 @@ class WindowCapture:
|
|||||||
if not self.hwnd:
|
if not self.hwnd:
|
||||||
raise Exception('Window not found: {}'.format(window_name))
|
raise Exception('Window not found: {}'.format(window_name))
|
||||||
|
|
||||||
if area == "poison":
|
if area == "dig":
|
||||||
val = config.returnPoisonWindowPos()
|
val = config.returnDiggingWindowPos()
|
||||||
|
elif area == "magic":
|
||||||
|
val = config.returnMagicWindowPos()
|
||||||
|
elif area == "equip":
|
||||||
|
val = config.returnEquipmentWindowPos()
|
||||||
else:
|
else:
|
||||||
val = config.returnStunWindowPos()
|
val = config.returnFullScreenWindowPos()
|
||||||
|
|
||||||
self.w = val[0]
|
self.w = val[0]
|
||||||
self.h = val[1]
|
self.h = val[1]
|
||||||
|
|||||||