!7

!include once #1015415 // GrabbedImage

static BufferedImage img;
static L<RecognizedText> texts;
static ImageSurface is;
static ReliableSingleThread rst;

p-subst-autorestart {
  doIt();
  showButton("Again", r-thread { doIt() });
}

svoid doIt {
  if (rst != null) rst.cancel();
  disposeWindow(is);
  is = null;
  print("Shooting");
  img = shootScreenHidingConsole();
  print("Recognizing");
  texts = ocr_recognizeMultiLine_scored(img);
  is = showImageWithRecognizedTexts(img, null, texts);
  rst = new ReliableSingleThread(f reRecognize);
  showImageWithRecognizedTexts_makeTeachable2(img, is, texts,
    filledSimpleRecognizer_cached(), r { rst.trigger() });
}

svoid reRecognize {
  print("Re-recognizing...");
  temp tempDisposeWindow(smallLoadingAnim());
  replaceCollection(texts, ocr_recognizeMultiLine_scored(img));
  is.repaint();
  print("Done");
}