Example #1
0
 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)
Example #2
0
 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)
Example #3
0
 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)
Example #4
0
 def isopen(self, img: Image) -> bool:  # check if tab is open
     pts = find.colors(img, open_tab_color, bounds=self.button)
     return len(pts) > 200
Example #5
0
        time.sleep(0.5)
        img_str, img = screencapture()
        window.normal()
        current_img = np.array(img)
        e.DrawImage(data=img_str, location=(0, 0))

    if drawflag:
        # this cant be done in the event handling idk why, hence the flag
        cluster = int(window.Element('cluster').get())
        mf, Mf = literal_eval(window.Element('filter').get())
        e = window.Element("imgview")
        e.erase()
        t1 = time.time()
        color = CTS2.from_colors(colors)
        t2 = time.time()
        pts = find.colors(current_img, color)
        t3 = time.time()
        clusters = pts.cluster(cluster)
        t4 = time.time()
        clusters = clusters.filtersize(mf, Mf)
        t5 = time.time()
        tstr = 'color finding: {}\n'.format(str(t3 - t2))
        tstr += 'cluster: {}\n'.format(str(t4 - t3))
        tstr += 'filter: {}\n'.format(str(t5 - t4))
        tstr += 'total: {}'.format(str(t5 - t2))
        foundin = window.Element('foundin')
        foundin.update(value=tstr)
        drawn_img = Image.fromarray(clusters.draw(current_img))
        # for b in boxes:
        #   drawn_img = b.draw(drawn_img)
        img_str = bufferimage(drawn_img)