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

22
LINES

< > BotCompany Repo | #1015477 // unixTerminalDollarFinder

JavaX fragment (include)

static RGB unixTerminalDollarFinder_destColor = rgb("#5650C3");

static L<Rect> unixTerminalDollarFinder(BufferedImage screenshot) {
  int w = screenshot.getWidth(), h = screenshot.getHeight();
  BWImage bw = new BWImage(w, h);
  int destColorInt = unixTerminalDollarFinder_destColor.getInt();
  for y to h: for x to w: {
    float diff = rgbDiff(screenshot.getRGB(x, y), destColorInt);
    diff = (diff-0.2f)*10f;
    bw.setPixel(x, y, diff);
  }
  final L<Rect> rects = sortRectsByMiddleY(autoSegment(bw, 2));

  L<Rect> l2 = rectsWithSize(rects, 10, 17);
  new L<Rect> found;
  for (Rect r : l2) {
    Scored<SimpleRecognizer.GlyphInfo> gi = simpleRecognizer().recognizeGlyph(bw.clip(r));
    if (gi.has() && eq(gi->meaning, "$"))
      found.add(r);
  }
  ret found; 
}

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1015477
Snippet name: unixTerminalDollarFinder
Eternal ID of this version: #1015477/7
Text MD5: a74f76b0c2406ccce1f73880819cacac
Author: stefan
Category: javax / ocr
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2018-05-15 01:10:38
Source code size: 794 bytes / 22 lines
Pitched / IR pitched: No / No
Views / Downloads: 321 / 349
Version history: 6 change(s)
Referenced in: #1006654 - Standard functions list 2 (LIVE, continuation of #761)
#1015483 - unixTerminalDollarFinder2