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

43
LINES

< > BotCompany Repo | #1015466 // Find blue terminal $ on screen using grid [dev. 2]

JavaX source code (desktop) [tags: use-pretranspiled] - run with: x30.jar

Download Jar. Uses 3874K of libraries. Click here for Pure Java version (12388L/89K).

!7

// approximate size: 10,17
// approximate y distance: 615-593

static RGB destColor = rgb("#5650C3");
static float contrast = 5f;
static float gamma = 0.5f;

static int g = 2;

p-experiment {
  //RGBImage img = shootScreen();
  RGBImage img = loadRGBImage(/*#1101257*/#1101258);
  int w = img.getWidth(), h = img.getHeight();
  BWImage bw = new BWImage(w, h);
  int destColorInt = destColor.getInt();
  for y to h: for x to w: {
    float diff = rgbDiff(img.getInt(x, y), destColorInt);
    //diff = pow(diff, gamma);
    //diff *= contrast;
    diff = (diff-0.2f)*20f;
    bw.setPixel(x, y, diff);
  }
  //showBWImage(bw);
  //showAutoSegmentedImage(bw);
  final L<Rect> rects = sortRectsByMiddleY(autoSegment(bw, g));
  pnl(rects);
  final ImageSurface is1 = showImageWithSelections(bw, rects);
  onClick(is1, voidfunc(MouseEvent e) {
    Pt p = is1.pointFromEvent(e);
    pnl(rectsContaining(p, rects));
  });
  
  L<Rect> l2 = rectsWithSize(rects, 10, 17);
  for (Rect r : l2)
    print(simpleRecognizer().recognizeGlyph(bw.clip(r)));
    
  BufferedImage bi = bw.getBufferedImage();
  L<RecognizedText> texts = ocr_recognizeMultiLine_scored(bw, simpleRecognizer(), l2);
  ImageSurface is = showImageWithRecognizedTexts(bi, null, texts);
  showImageWithRecognizedTexts_makeTeachable2(bi, is, texts, filledSimpleRecognizer_cached(), null);
}

Author comment

Began life as a copy of #1015464

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: #1015466
Snippet name: Find blue terminal $ on screen using grid [dev. 2]
Eternal ID of this version: #1015466/29
Text MD5: 1d5b9308460351508cd10ac7013cd21c
Transpilation MD5: 015ef35b2ca853580a803460c07729ad
Author: stefan
Category: javax / ocr
Type: JavaX source code (desktop)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2018-05-15 01:17:22
Source code size: 1390 bytes / 43 lines
Pitched / IR pitched: No / No
Views / Downloads: 312 / 877
Version history: 28 change(s)
Referenced in: [show references]