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

38
LINES

< > BotCompany Repo | #1030562 // Web Cam / Central Compass [detects orientation of a line in the center of the image]

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

Uses 1059K of libraries. Click here for Pure Java version (9634L/51K).

!7

cmodule2 FindLineInCenter > DynWebCamAnalyzer {
  transient BWIntegralImage ii;
  transient OCRCompass c;
  switchable bool lineIsBright = true;
  switchable int angles = 6;
  switchable int radius = 50;
  
  start {
    dm_onFieldChange(ll("angles", "radius", "lineIsBright"),
      r { c = null });
  }
  
  // add controls
  afterVisualize {
    containerAddFirst(buttons, dm_checkBox lineIsBright(),
      dm_spinnerWithLabel angles(2, 24), dm_spinnerWithLabel radius(1, 80));
  }
  
  void prepareImage {
    ii = new BWIntegralImage(inputImage);
  }
  
  void analyzeImage {
    Pt center = pt(w/2, h/2);
    if (c == null || neq(c.center, center)) {
      c = new OCRCompass;
      c.center = center;
      c.steps = angles*2;
      c.brightForeground = lineIsBright;
      c.radius = min(w, h)/2.0*radius/100;
      overlays = ll(c);
    }
    c.image = ii;
    c.compute();
  }
}

Author comment

Began life as a copy of #1030561

download  show line numbers  debug dex  old transpilations   

Travelled to 4 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, vouqrxazstgt

No comments. add comment

Snippet ID: #1030562
Snippet name: Web Cam / Central Compass [detects orientation of a line in the center of the image]
Eternal ID of this version: #1030562/19
Text MD5: d721cea1f15afe10dc8a2672867cd1b1
Transpilation MD5: 1ad7411bbacfb8ab59410cfc4ff591c0
Author: stefan
Category: javax / stefan's os / web cam / ocr
Type: JavaX source code (Dynamic Module)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2021-01-10 14:52:59
Source code size: 929 bytes / 38 lines
Pitched / IR pitched: No / No
Views / Downloads: 147 / 988
Version history: 18 change(s)
Referenced in: [show references]