sclass BWImageCategorizer { new L<BWImage> images; float allowedDistance = 0.1f; // allowed difference within category *() {} *(float *allowedDistance) {} int locateImage(BWImage img) { for i over images: if (bwDistance(images.get(i), img, allowedDistance) <= allowedDistance) ret i; ret -1; } int addImage(RGBImage img) { ret addImage(new BWImage(img)); } int addImage(BWImage img) { int i = locateImage(img); if (i >= 0) ret i; images.add(img); ret l(images)-1; } int numCategories() { ret l(images); } void clear() { images.clear(); } L<RGBImage> rgbImages() { ret bwImagesToRGB(images); } // find best fit regardless of distance // returns Pair<index, confidence> Pair<Int, Float> locateLax(BWImage img) { new Lowest<Int> l; for i over images: l.put(i, bwDistance(images.get(i), img)); ret pair(or(l.get(), -1), 1f-l.floatScoreOr(1)); } }
Began life as a copy of #1006761
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: | #1006771 |
Snippet name: | BWImageCategorizer |
Eternal ID of this version: | #1006771/5 |
Text MD5: | fe6e58b60aca8527f089fbd2da059d69 |
Author: | stefan |
Category: | javax / ocr |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2017-03-06 14:36:36 |
Source code size: | 987 bytes / 37 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 565 / 1177 |
Version history: | 4 change(s) |
Referenced in: | [show references] |