Uses 3874K of libraries. Click here for Pure Java version (11913L/83K/299K).
!7 concept TestImage { new Ref<PNGFile> pngFile; S imageMD5; int width, height; bool textKnown; S text; } p-subst { SimpleCRUD<TestImage> crud = new SimpleCRUD<TestImage>(TestImage) { @Override JComponent fieldComponent(TestImage c, S field) { if (eq(field, "pngFile")) ret new ImageChooser((PNGFile) cget(c, "pngFile")); ret super.fieldComponent(c, field); } @Override void makeComponents(TestImage c, Map<S, JComponent> map) { for (S field : listMinus((L<S>) conceptFieldsInOrder(cc), "width", "height", "imageMD5")) map.put(field, fieldComponent(c, field)); } @Override void saveData(TestImage c, Map<S, JComponent> components) { super.saveData(c, components); fixEntry(c); } }; /*final L<S> fields = concatLists(ll("id"), conceptFieldsInOrder(c)); crud.renderer = func(TestImage c) { Map map = litorderedmap(); for (S field : fields) map.put(field, renderForTable(cget(cc, field))); ret map; };*/ crud.show("OCR Test Images"); bot("OCR Test Images."); hideConsole(); } answer { if "add image * with unknown text" { PNGFile pngFile = new PNGFile(unstructureBufferedImage($1)); if (hasConcept(TestImage, imageMD5 := pngFile.md5())) ret "Entry already exists"; long id = fixEntry(cnew(TestImage, +pngFile)).id; ret "OK, ID of new entry: " + id; } } static TestImage fixEntry(TestImage c) { BufferedImage img = c.pngFile.has() ? c.pngFile->getImage() : null; if (img == null) cset(c, imageMD5 := null, width := 0, height := 0); else cset(c, imageMD5 := md5OfBufferedImage(img), width := img.getWidth(), height := img.getHeight()); ret c; }
download show line numbers debug dex old transpilations
Travelled to 14 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, onxytkatvevr, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1007114 |
Snippet name: | OCR Test Images [works] |
Eternal ID of this version: | #1007114/24 |
Text MD5: | ff096bbdcc268254776c18e57c7d34fe |
Transpilation MD5: | 6e06cb7398844c85b9fe9b5b98c1a78c |
Author: | stefan |
Category: | javax / ocr |
Type: | JavaX source code |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2017-03-05 13:49:18 |
Source code size: | 1783 bytes / 62 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 512 / 715 |
Version history: | 23 change(s) |
Referenced in: | -