1 | sclass ImageCategorizer { |
2 | new L<RGBImage> images; |
3 | float allowedDistance = 0.1f; // allowed difference within category |
4 | |
5 | *() {} |
6 | *(float *allowedDistance) {} |
7 | |
8 | int locateImage(RGBImage img) { |
9 | for i over images: |
10 | if (rgbDistance(images.get(i), img, allowedDistance) <= allowedDistance) |
11 | ret i; |
12 | ret -1; |
13 | } |
14 | |
15 | int addImage(RGBImage img) { |
16 | int i = locateImage(img); |
17 | if (i >= 0) ret i; |
18 | images.add(img); |
19 | ret l(images)-1; |
20 | } |
21 | |
22 | int numCategories() { ret l(images); } |
23 | void clear() { images.clear(); } |
24 | } |
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: | #1006761 |
Snippet name: | ImageCategorizer |
Eternal ID of this version: | #1006761/5 |
Text MD5: | ece544f54c3f33b381caa35bf2a7e353 |
Author: | stefan |
Category: | javax / ocr |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2017-02-03 20:13:08 |
Source code size: | 571 bytes / 24 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 470 / 1085 |
Version history: | 4 change(s) |
Referenced in: | [show references] |