how to find list[] and if find remove the target

Asked by wu

i have a imagelist[1,2,3]
how i to find the imagelist[1,2,3]
and if find the imagelist[1] can remove this target because the imagelist will random onappear
example the first will 2 will 3 so if i use find 1 2 3 will find so low。

Question information

Language:
English Edit question
Status:
Solved
For:
SikuliX Edit question
Assignee:
No assignee Edit question
Solved by:
RaiMan
Solved:
Last query:
Last reply:
Revision history for this message
RaiMan (raimund-hocke) said :
#1

paste your snippet, that you tried until now.

Revision history for this message
RaiMan (raimund-hocke) said :
#2

imagesAll = [img1, img2, img3]

found = findBestList(imagesAll)

if found && found.getIndex() == 0:
    found = findBestList(imagesAll[1:]) # only 2 and 3
    ....

for details see docs

Revision history for this message
wu (chouhua) said :
#3

there is my code
tch = [image1,image2,image3]
 while True:
            m = findBestList(tch)

--->when find anyone target i will screenshot and need to remove the anyone this target utill i find the three target finish and screenshot
            if tch = []:
                break
            for image in m:
                screenshot_im = Screen(0).capture().getFile()
                shutil.move(screenshot_im, os.path.join(imageSave, 'change_'+ str(count) + '.png'))
                remove the anyone target

Revision history for this message
RaiMan (raimund-hocke) said :
#4

this would be my solution:

images = [image1,image2,image3]
count = 0
while True:
  matches = findAnyList(images)
  for match in matches:
    ix = match.getIndex()
    shot = capture()
    shotFile = 'change_%d-%d.png' % (count, ix)
    shutil.move(shot.getFile(), os.path.join(imageSave, shotFile))
    images.remove(ix)
  if len(images) == 0:
    break
  count += 1

Revision history for this message
wu (chouhua) said :
#5

thx RaiMan it think almost my slove but now i have question

it have possible to config the findAnyList.similar? my picture is between the 250*150 pixcel

but often can not find i say my test environment:

i have a html and use sikuli to type i want to judge when the html loading the image have onappear the screen it will 1-3s and the

image will random so i just use the method but i don't know is the time question or is my image question so i just ask you the similar

or if you have a good idea tell me thx or the similar method also good thx

Revision history for this message
wu (chouhua) said :
#6

i have to try the image[ partten('image').similar(0.80)] but this will have error in image.remove(ix)
the error will tell the Partten can't not remove

Revision history for this message
RaiMan (raimund-hocke) said :
#7

paste more code!

not sure what you are doing.

Revision history for this message
wu (chouhua) said :
#8

the similar question is slove now have another question there is my code::

tch = []
for i in range(1,13):
    tch.append(Pattern("source/tch/"+str(i)+'.png').similar(0.60))
        paste(line) --->html
        wait(1)
        type(Key.ENTER) -->type the screen will go into html and the page will loading the loading time will 1-3sec
        count = 0
        temp = []
        while True:
            m = findAnyList(tch) -->return the image.similar(0.60) ?! i don't know there is will return thist or another
            for image in m : --> if the image onAppear the loading page do screenshot
                screenshot_im = Screen(0).capture().getFile()
                shutil.move(screenshot_im, os.path.join(imageSave, 'change_'+ str(count) + '.png'))
# shot = Screen(0).capture()
# shotFile = 'change_%d-%d.png' % (count)
# shutil.move(shot.getFile(), os.path.join(imageSave, shotFile))
                ix = image.getIndex()
                print(ix)
                tch.remove(tch[ix]) --->remove the image is already onappear
                if len(tch) ==0:
                    break
                count = count +1

Revision history for this message
wu (chouhua) said :
#9

the screenshot will occasionally capture is already loading finish and jump the new Scenes will do capture so i don't is loading time to

fast or the image similar to high so can not fast to find it but i chage the similar still the same problem

and i use the ide tool the image is can Recognized the 0.70 but i change the 0.60 is still not work

Revision history for this message
wu (chouhua) said :
#10

this is my new problem if not find the image the log will give this

findAnyCollect: waiting for SubFindRuns
[debug] Region: checkLastSeen: not there
[debug] Region: checkLastSeen: not there
[debug] findAnyCollect: SubFindRuns finished

and will not type F5 i don't know what happened?

Revision history for this message
RaiMan (raimund-hocke) said :
#11

This is an internal log for debugging.

Your images are simply not found.

Revision history for this message
wu (chouhua) said :
#12

Is it possible because of similarity?
Currently my case is work good i recapture the Identification image but i still want to know why thx RaiMan

Revision history for this message
Best RaiMan (raimund-hocke) said :
#13

read this, to understand the search feature of SikuliX:
https://sikulix-2014.readthedocs.io/en/latest/basicinfo.html#sikulix-how-does-it-find-images-on-the-screen

An image should be found with a similarity score of >0.9 or even better >0.95

This can be achieved usually by capturing as little surrounding background as possible and concentrating the image on the key visuals, that makes it unique.

Using the transparency feature is another way, to make images unique for use on differing backgrounds or differing content

Revision history for this message
wu (chouhua) said :
#14

thx RaiMan i want to ask another i use 1.1.4 and use App open

chrome = App('my path')
chrome.open()

this code will not like 1.1.3 open the new chrome
1.1.4 will use the old on screen this i want ask is the bug? or 1.1.4 have another app.open()?

Revision history for this message
wu (chouhua) said :
#15

Thanks RaiMan, that solved my question.