1 | // include #1005686 // PIF Classes v2 |
2 | |
3 | sclass CorrelateClips { |
4 | S src1 = "#1005715", src2 = "#1005721"; |
5 | int maxTotal = 10; |
6 | Concepts in1, in2; |
7 | Map<Pair<Clip, Clip>, MultiSet<Pt>> correlations = new HashMap; |
8 | L<Clip> clips1, clips2; |
9 | |
10 | *() {} |
11 | *(S *src1, S *src2) {} |
12 | |
13 | void load() { |
14 | in1 = new Concepts(src1).load(); |
15 | in2 = new Concepts(src2).load(); |
16 | in1.deleteAll(Found); |
17 | in2.deleteAll(Found); |
18 | |
19 | print("Loaded from:"); |
20 | printIndent(joinLines(snippetsWithTitles(ll(src1, src2)))); |
21 | print("Total concepts: " + in1.countConcepts() + ", " + in2.countConcepts()); |
22 | clips1 = goodClips(in1); |
23 | clips2 = goodClips(in2); |
24 | print("Good clips: " + l(clips1) + ", " + l(clips2)); |
25 | } |
26 | |
27 | void processScreenshot(Screenshot t) { |
28 | ImageFinder finder = new ImageFinder(t, concatLists(clips1, clips2)); |
29 | finder.maxTotal = maxTotal; |
30 | finder.run(); |
31 | |
32 | L<Found> found1 = findBackRefs(clips1, Found); |
33 | L<Found> found2 = findBackRefs(clips2, Found); |
34 | deleteAll(Found); |
35 | print("#found = " + l(found1) + " / " + l(found2)); |
36 | |
37 | printFound(found1); |
38 | print(); |
39 | printFound(found2); |
40 | print(); |
41 | |
42 | for (Found a : found1) |
43 | for (Found b : found2) |
44 | correlate(correlations, a, b); |
45 | |
46 | for (Pair<Clip, Clip> key : correlations.keySet()) { |
47 | print(key.a.id + " / " + key.b.id + " => " + struct(correlations.get(key))); |
48 | } |
49 | } |
50 | |
51 | void correlate(Map<Pair<Clip, Clip>, MultiSet<Pt>> correlations, Found a, Found b) { |
52 | Pair key = new Pair(a.clip!, b.clip!); |
53 | Pt p = new Pt(b.fi.r.x-a.fi.r.x, b.fi.r.y-a.fi.r.y); |
54 | MultiSet<Pt> ms = correlations.get(key); |
55 | if (ms == null) |
56 | correlations.put(key, ms = new MultiSet); |
57 | ms.add(p); |
58 | } |
59 | |
60 | void printFound(L<Found> l) { |
61 | for (Found f : l) |
62 | print(f.fi.r + " " + f.clip->id); |
63 | } |
64 | |
65 | L<Clip> goodClips(Concepts in) { |
66 | ret [Clip c in in.list(Clip) | !swic(c.description, "bad")]; |
67 | } |
68 | } |
Began life as a copy of #1005722
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: | #1005723 |
Snippet name: | class CorrelateClips |
Eternal ID of this version: | #1005723/1 |
Text MD5: | 74741ca49653541c2ea8d201476815bc |
Author: | stefan |
Category: | javax / a.i. |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2016-12-04 20:27:59 |
Source code size: | 2004 bytes / 68 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 469 / 687 |
Referenced in: | [show references] |