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).

!7

cmodule FindHomeStation {
  switchable File file;
  switchable bool with256; // go to 256 pixels wide
  
  transient L<File> allImages;
  transient JTabbedPane tabs;
  transient MultiLevelRecognizer1 rec;
  
  start {
    tabs = jtabs();
    allImages = listImageFiles(vectorCamDir());
    if (file == null) randomImage(); else recognize();
  }
  
  void randomImage {
    File f = random(allImages);
    if (f == null) ret with print("No images");
    setField(file := f);
    recognize();
  }
  
  void recognize {
    rec = new MultiLevelRecognizer1(imageSnippetFile(#1102886), file);
    if (with256) rec.widths.add(256);
    clearTabs(tabs);
    rec.tabs = tabs;
    print(rec.go());
  }
  
  void acceptBest {
    Rect r = toRect(rec.bestImageSurface.getSelection());
    setFileInfoField(file, "charging station", dropLoadableUtilsPackageFromStruct(structOr(r, "-")));
    change();
  }
  
  visual withCenteredButtons(
    northAndCenter(
      jCenteredSection("Input image", dm_calculatedCenteredLabel(() -> fileName(file))),
      centerAndSouthWithMargin(tabs,
        jCenteredSection("File Info", jMinHeight(100,
          dm_calculatedTextArea(() -> fileInfoFileText(file)))))),
    "Accept best", rThread acceptBest,
    "Random image", rThread randomImage);
}

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: 256 / 1288
Version history: 20 change(s)
Referenced in: [show references]