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

46
LINES

< > BotCompany Repo | #1027236 // Vector: Find Home Station Spike

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

Uses 911K of libraries. Click here for Pure Java version (8482L/44K).

1  
!7
2  
3  
cmodule FindHomeStation {
4  
  switchable File file;
5  
  switchable bool with256; // go to 256 pixels wide
6  
  
7  
  transient L<File> allImages;
8  
  transient JTabbedPane tabs;
9  
  transient MultiLevelRecognizer1 rec;
10  
  
11  
  start {
12  
    tabs = jtabs();
13  
    allImages = listImageFiles(vectorCamDir());
14  
    if (file == null) randomImage(); else recognize();
15  
  }
16  
  
17  
  void randomImage {
18  
    File f = random(allImages);
19  
    if (f == null) ret with print("No images");
20  
    setField(file := f);
21  
    recognize();
22  
  }
23  
  
24  
  void recognize {
25  
    rec = new MultiLevelRecognizer1(imageSnippetFile(#1102886), file);
26  
    if (with256) rec.widths.add(256);
27  
    clearTabs(tabs);
28  
    rec.tabs = tabs;
29  
    print(rec.go());
30  
  }
31  
  
32  
  void acceptBest {
33  
    Rect r = toRect(rec.bestImageSurface.getSelection());
34  
    setFileInfoField(file, "charging station", dropLoadableUtilsPackageFromStruct(structOr(r, "-")));
35  
    change();
36  
  }
37  
  
38  
  visual withCenteredButtons(
39  
    northAndCenter(
40  
      jCenteredSection("Input image", dm_calculatedCenteredLabel(() -> fileName(file))),
41  
      centerAndSouthWithMargin(tabs,
42  
        jCenteredSection("File Info", jMinHeight(100,
43  
          dm_calculatedTextArea(() -> fileInfoFileText(file)))))),
44  
    "Accept best", rThread acceptBest,
45  
    "Random image", rThread randomImage);
46  
}

download  show line numbers  debug dex  old transpilations   

Travelled to 7 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt, xrpafgyirdlv

No comments. add comment

Snippet ID: #1027236
Snippet name: Vector: Find Home Station Spike
Eternal ID of this version: #1027236/21
Text MD5: 95422fe5c7c64bfba2e89410f5e16a5f
Transpilation MD5: bb32d328860cc134276751da7de22c45
Author: stefan
Category: javax / image recognition
Type: JavaX source code (Dynamic Module)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2020-02-26 15:57:34
Source code size: 1325 bytes / 46 lines
Pitched / IR pitched: No / No
Views / Downloads: 186 / 1200
Version history: 20 change(s)
Referenced in: [show references]