Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

77
LINES

< > BotCompany Repo | #1005747 // Find Start Button [backup]

JavaX source code - run with: x30.jar

1  
!752
2  
3  
/*
4  
-Screenshots (as usual)
5  
-User-supplied clips (bwImage, pos/neg, position, screenshot)
6  
7  
[optional: Comments on clips]
8  
*/
9  
10  
concepts.
11  
12  
!include #1005686 // PIF Classes v2
13  
14  
static JComponent form;
15  
static JLabel lFound, lSearchTime;
16  
17  
p-substance {
18  
  concepts();
19  
  form = showForm(
20  
    "Number of button pictures stored:", jConceptCountLabel(Clip),
21  
    "Number of screenshots stored:", jConceptDependentLabel(func {
22  
      int n = countConcepts(Screenshot);
23  
      int t = countConcepts(TransientScreenshot);
24  
      ret n + " (" + (n-t) + " with image)";
25  
    }),
26  
    "Currently found:", lFound = jlabel(),
27  
    "Search time:", lSearchTime = jlabel(),
28  
    "", jbutton("Show pictures", r { showClips() }),
29  
    "", jbutton("Grab picture of start button", r { addClip(false) }),
30  
    "", jbutton("Grab picture with delay", r { addClip(true) })
31  
  );
32  
  
33  
  final new MonoThread thread;
34  
  installTimer(form, 5000, 0, r {
35  
    thread.runIfNotRunning(r {
36  
      BufferedImage img = shootScreen2();
37  
      long start = now();
38  
      final L<Found> found = continuousFind_step(list(Clip), img);
39  
      final long time = now()-start;
40  
      awt {
41  
        lSearchTime.setText(time + " ms");
42  
        S s = "no";
43  
        if (nempty(found))
44  
          s = "at " + first(found).fi.r + " [clip " + first(found).clip->id + "]";
45  
        if (l(found) > 1)
46  
          s += " +" + (l(found)-1);
47  
        lFound.setText(s);
48  
      }
49  
    });
50  
  });
51  
}
52  
53  
svoid addClip(bool delay) {
54  
  letUserMarkScreenArea(delay ? null : shootScreen2(), voidfunc(final Rectangle r, BufferedImage img) {
55  
    if (r == null) print("Cancelled!");
56  
    else {
57  
      Screenshot screenshot = new Screenshot(img);
58  
  
59  
      showAnimation("#1005611", "You marked " + r, 3);
60  
      uniq(MarkedClip, +screenshot, positionInScreenshot := new Rect(r), 
61  
        description := "Start button",
62  
        img := new BWImage(img).clip(r));
63  
      darkenScreenArea(r, 5);
64  
      swingLater(250, r {
65  
        pointArrowsToArea(r, 5-0.25);
66  
      });
67  
    }
68  
  });
69  
}
70  
71  
svoid showClips {
72  
  new L<L> data;
73  
  for (MarkedClip clip) pcall {
74  
    data.add(ll(clip.id, clip.img == null ? null : clip.img.getBufferedImage()));
75  
  }
76  
  showTableWithImages("Clips", splitAtSpace("ID Picture"), data);
77  
}

Author comment

Began life as a copy of #1005676

download  show line numbers  debug dex  old transpilations   

Travelled to 13 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1005747
Snippet name: Find Start Button [backup]
Eternal ID of this version: #1005747/1
Text MD5: 81070c4e2da948c2cc4b1332606ab797
Author: stefan
Category: javax / gui / a.i.
Type: JavaX source code
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2016-12-05 22:31:59
Source code size: 2275 bytes / 77 lines
Pitched / IR pitched: No / No
Views / Downloads: 526 / 508
Referenced in: [show references]