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

68
LINES

< > BotCompany Repo | #1005722 // Correlate clips from two programs [WORKS]

JavaX source code [tags: use-pretranspiled] - run with: x30.jar

Libraryless. Click here for Pure Java version (5873L/37K/126K).

!752

concepts.

!include #1005686 // PIF Classes v2

sS src1 = "#1005715", src2 = "#1005721";
static int maxTotal = 10;

static Map<Pair<Clip, Clip>, MultiSet<Pt>> correlations = new HashMap;

p {
  Concepts in1 = new Concepts(src1).load();
  Concepts in2 = new Concepts(src2).load();
  in1.deleteAll(Found);
  in2.deleteAll(Found);
  
  print("Loaded from:");
  printIndent(joinLines(snippetsWithTitles(ll(src1, src2))));
  print("Total concepts: " + in1.countConcepts() + ", " + in2.countConcepts());
  L<Clip> clips1 = goodClips(in1), clips2 = goodClips(in2);
  print("Good clips: " + l(clips1) + ", " + l(clips2));

  while licensed {
    TransientScreenshot t = new TransientScreenshot(shootScreen2());
    ImageFinder finder = new ImageFinder(t, concatLists(clips1, clips2));
    finder.maxTotal = maxTotal;
    finder.run();
    
    L<Found> found1 = findBackRefs(clips1, Found);
    L<Found> found2 = findBackRefs(clips2, Found);
    deleteAll(Found);
    print("#found = " + l(found1) + " / " + l(found2));
    
    printFound(found1);
    print();
    printFound(found2);
    print();
    
    for (Found a : found1)
      for (Found b : found2)
        correlate(correlations, a, b);
        
    for (Pair<Clip, Clip> key : correlations.keySet()) {
      print(key.a.id + " / " + key.b.id + " => " + struct(correlations.get(key)));
    }
    
    sleepSeconds(5);
  }
}

svoid correlate(Map<Pair<Clip, Clip>, MultiSet<Pt>> correlations, Found a, Found b) {
  Pair key = new Pair(a.clip!, b.clip!);
  Pt p = new Pt(b.fi.r.x-a.fi.r.x, b.fi.r.y-a.fi.r.y);
  MultiSet<Pt> ms = correlations.get(key);
  if (ms == null)
    correlations.put(key, ms = new MultiSet);
  ms.add(p);
}

svoid printFound(L<Found> l) {
  for (Found f : l)
    print(f.fi.r + " " + f.clip->id);
}

static L<Clip> goodClips(Concepts in) {
  ret [Clip c in in.list(Clip) | !swic(c.description, "bad")];
}

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1005722
Snippet name: Correlate clips from two programs [WORKS]
Eternal ID of this version: #1005722/1
Text MD5: e12e41730218372efec534f672a2e9f0
Transpilation MD5: 74cd272f7bb3fb51dd1675ac55706f21
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-04 19:01:14
Source code size: 1953 bytes / 68 lines
Pitched / IR pitched: No / No
Views / Downloads: 484 / 597
Referenced in: #1005723 - class CorrelateClips
#1005724 - Test CorrelateClips