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

74
LINES

< > BotCompany Repo | #1032099 // Letterbox On Screen 2

JavaX source code (Dynamic Module) [tags: use-pretranspiled] - run with: Stefan's OS

Uses 1113K of libraries. Click here for Pure Java version (12616L/66K).

1  
!7
2  
3  
cm LetterboxOnScreen2 > DynPrintLogAndEnabled {
4  
  switchable double frequency = 5.0; // 5 fps
5  
  transient S shootingTime, conversionTime, recognitionTime;
6  
  
7  
  transient Map<O, JWindow> alwaysOnTopWindows = syncMap();
8  
  
9  
  void cleanMeUp_windows {
10  
    disposeWindows(getValuesAndClear(alwaysOnTopWindows));
11  
  }
12  
  
13  
  JComponent wrapControlArea() {
14  
    ret northAndCenterWithMargin(
15  
      hgridWithSpacing(
16  
        dm_fieldLabelWithLabel shootingTime(),
17  
        dm_fieldLabelWithLabel conversionTime(),
18  
        dm_fieldLabelWithLabel recognitionTime()),
19  
    super.wrapControlArea());
20  
  }
21  
    
22  
  
23  
  start {
24  
    dm_reloadOnFieldChange interval();
25  
    dm_doEvery(doubleRatio(1, frequency), r doIt);
26  
  }
27  
  
28  
  void doIt {
29  
    if (!enabled) ret with cleanMeUp_windows();
30  
    
31  
    var rect = screenBounds(1);
32  
    if (rect == null) ret;
33  
    
34  
    new TimeTaker tt;
35  
    tt.start();
36  
    var img = shootScreen2(rect);
37  
    setField(shootingTime := tt.renderMicroseconds());
38  
    
39  
    tt.start();    
40  
    var ii = IntegralImage(img);
41  
    setField(conversionTime := tt.renderMicroseconds());
42  
    
43  
    tt.start();    
44  
    new Var<Rect> theBox;
45  
    hijackPrint(r {
46  
      stepAllWithStats(new ULetterbox1().run(ii, setVarWithConversion toRect(theBox)));
47  
    });
48  
    setField(recognitionTime := tt.renderMicroseconds());
49  
    print(imageBounds(img) + " - " + theBox!);
50  
    
51  
    //showImageWithSelection(img, theBox!);
52  
    
53  
    var box1 = rect(rect.x, rect.y, rect.w, theBox->y);
54  
    var box2 = rectFromPoints(rect.x, rect.y+theBox->y2(), rect.x2(), rect.y2());
55  
    printVars(+box1, +box2);
56  
    positionMarkerWindow(0, box1, withAlpha(.2, Color.green));
57  
    positionMarkerWindow(1, box2, withAlpha(.2, Color.green));
58  
  }
59  
  
60  
  JWindow getOrCreateMarkerWindow(O key) {
61  
    ret swing(() ->
62  
      syncMapGetOrCreate(alwaysOnTopWindows, key,
63  
        () -> makeAlwaysOnTopTranslucentWindow()));
64  
  }
65  
  
66  
  void positionMarkerWindow(int iWindow, Rect box, Color color) {
67  
    awt {
68  
      JWindow w = getOrCreateMarkerWindow(iWindow);
69  
      setBounds(w, box);
70  
      w.setBackground(color);
71  
      w.setVisible(true);
72  
     }
73  
  }
74  
}

download  show line numbers  debug dex  old transpilations   

Travelled to 3 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx

No comments. add comment

Snippet ID: #1032099
Snippet name: Letterbox On Screen 2
Eternal ID of this version: #1032099/11
Text MD5: b814d946c36222a0d1db73935e0b6d9c
Transpilation MD5: b8e411d3e348657a50e37d15c017cbbc
Author: stefan
Category: javax / gui
Type: JavaX source code (Dynamic Module)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2021-08-12 05:30:30
Source code size: 2097 bytes / 74 lines
Pitched / IR pitched: No / No
Views / Downloads: 94 / 1589
Version history: 10 change(s)
Referenced in: [show references]