예제 #1
0
파일: test.py 프로젝트: bot-boi/pysrl
 def test_find_map_position(self):
     from pysrl.scripts.scaperune.interface import minimap
     map_img = Image.open('test/osrs-world-map.png')
     screen_img = Image.open('test/older2.png')
     mmap_img = minimap.get_image(screen_img)
     match = find.image(map_img, mmap_img, method=cv2.TM_SQDIFF)
     if imgshow:
         map_img = draw_text(map_img, "test_find_map_position", (0, 0))
         map_img = draw_text(map_img, str(match), (0, 15))
         match.draw(map_img).show()
     self.assertIsNotNone(match)
     self.assertEqual(match.top_left, Point(4520, 3184))
예제 #2
0
파일: test.py 프로젝트: bot-boi/pysrl
 def test_find_colors(self):  # test core/color.py
     img = Image.open('test/test.jpeg')
     cts = CTS2([0, 0, 0], 10, 10, 10)
     pts = find.colors(img, cts)
     if imgshow:
         img = draw_text(img, "test_find_colors", (0, 0))
         pts.draw(img).show()
     self.assertEqual(len(pts), 2560)
예제 #3
0
파일: test.py 프로젝트: bot-boi/pysrl
 def test_client_runelite(self):  # test core/client.py
     # TODO: launch runelite automatically
     cp = client.Client(client.RL_CANVAS)
     img = cp.get_image()
     self.assertNotEqual(len(img), 0)
     if imgshow:
         img = draw_text(img, "test_client_runelite", (0, 0))
         img.show()
예제 #4
0
파일: test.py 프로젝트: bot-boi/pysrl
 def test_find_text(self):  # test core/find.text
     img = Image.open('test/login2.png')
     match = find.text(img, 'New User')
     if imgshow:
         img = draw_text(img, "test_find_text", (0, 0))
         img = match.draw(img)
         img.show()
     self.assertIsNotNone(match)
예제 #5
0
파일: test.py 프로젝트: bot-boi/pysrl
 def test_pa_cluster(self):  # test core/types/point_array.py
     img = Image.open('test/test.jpeg')
     cts = CTS2([0, 0, 0], 10, 10, 10)
     pts = find.colors(img, cts)
     clusters = pts.cluster(2)
     if imgshow:
         img = draw_text(img, "test_pa_cluster", (0, 0))
         clusters.draw(img).show()
     self.assertGreaterEqual(len(clusters), 1)
예제 #6
0
파일: test.py 프로젝트: bot-boi/pysrl
 def test_client_simplicity(self):  # test core/client.py
     # TODO: launch simplicity client automatically
     # NOTE: this picks up RuneLite as well
     cp = client.Client(client.SIMP_CANVAS)
     img = cp.get_image()
     self.assertNotEqual(len(img), 0)
     if imgshow:
         img = draw_text(img, "test_client_simplicity", (0, 0))
         img.show()
예제 #7
0
파일: test.py 프로젝트: bot-boi/pysrl
 def test_find_image_exact(self):
     haystack = Image.open('test/login2.png')
     needle = Image.open('test/login-slice.png')
     matches = find.image_exact(haystack, needle)
     if imgshow:
         for match in matches:
             haystack = match.draw(haystack)
         haystack = draw_text(haystack, "test_find_image_exact", (0, 0))
         haystack.show()
     self.assertEqual(len(matches), 1)
예제 #8
0
파일: test.py 프로젝트: bot-boi/pysrl
 def test_find_images(self):  # test core/find.imagecv2
     haystack = Image.open('test/login2.png')
     needle = Image.open('test/login-slice.png')
     matches = find.images(haystack, needle, threshold=0.95)
     if imgshow:
         for match in matches:
             haystack = draw_text(haystack, "test_find_images", (0, 0))
             haystack = match.draw(haystack)
         haystack.show()
     self.assertEqual(len(matches), 1)
예제 #9
0
파일: test.py 프로젝트: bot-boi/pysrl
 def test_find_image(self):  # test core/find.image
     haystack = Image.open('test/login.png')
     # screenshot of haystack
     needle = Image.open('test/login-slice.png')
     match = find.image(haystack, needle)
     if imgshow:
         haystack = draw_text(haystack, "test_find_image", (0, 0))
         haystack = match.draw(haystack)
         haystack.show()
     self.assertIsNotNone(match)
예제 #10
0
파일: test.py 프로젝트: bot-boi/pysrl
 def test_pa2d_filter(self):  # test core/types/point_array2d.py
     img = Image.open('test/test.jpeg')
     cts = CTS2([0, 0, 0], 10, 10, 10)
     pts = find.colors(img, cts)
     clusters = pts.cluster(2)
     filtered = clusters.filtersize(50, 3000)
     if imgshow:
         img = draw_text(img, "test_pa2d_filter", (0, 0))
         filtered.draw(img).show()
     self.assertEqual(len(filtered), 1)
예제 #11
0
파일: test.py 프로젝트: bot-boi/pysrl
 def test_find_image_masked(self):
     mmap = Image.open('test/minimap-border.png', alpha_mask=True)
     img = Image.open('test/test-mmap.png')
     # cv2.TM_CCORR_NORMED didnt work here...
     match = find.image(img, mmap, method=cv2.TM_SQDIFF)
     if imgshow:
         img = draw_text(img, "test_find_image_masked", (0, 0))
         img = match.draw(img)
         img.show()
     self.assertIsNotNone(match)
예제 #12
0
파일: test.py 프로젝트: bot-boi/pysrl
 def test_find_image_exact_masked(self):
     img = Image.open('./scripts/scaperune/images/older.png')
     mmap = Image.open('./scripts/scaperune/images/minimap-border.png')
     mmap.mask = mmap == [0, 0, 0]  # mask transparent aka black values
     matches = find.image_exact(img, mmap)
     print(len(matches))
     for match in matches:
         img = match.draw(img)
     img = draw_text(img, "test_find_image_exact_masked", (0, 0))
     img.show()