1 | sclass MultiLevelRecognizer3 |
2 | // how big do we think the prototype is in the whole image |
3 | // (percentage by height) |
4 | L<Double> assumedPrototypeHeightPercentages = ll(70.0, 70.0/sqrt(2), 35.0, 35.0/sqrt(2), 17.0); |
5 | |
6 | // widths to scale camera image to |
7 | transient L<Int> widths = ll(32, 64, 128); |
8 | |
9 | BWIntegralImage integralInputImage; |
10 | new Map<Int, BWIntegralImage> prototypeImages; // key = height |
11 | new Map<Int, IBWIntegralImage> integralImages; // key = width |
12 | new Map<Int, ByPrototype> byPrototypeMap; |
13 | |
14 | class ByPrototype {
|
15 | } |
16 | |
17 | // constructors, addPrototype functions |
18 | |
19 | *() {}
|
20 | *(File imgFile) {
|
21 | integralInputImage = loadBWIntegralImage(imgFile); |
22 | } |
23 | |
24 | void addPrototype(BufferedImage img) {
|
25 | prototypeImages.add(bwIntegralImage(img)); |
26 | } |
27 | |
28 | void addPrototype(File imgFile) {
|
29 | addPrototype(loadImage2(imgFile)); |
30 | } |
31 | |
32 | void addPrototypes(Iterable l) {
|
33 | fOr (O o : l) call(this, 'addPrototype, img); |
34 | } |
35 | |
36 | void search(assumedPrototypeHeightPercentage, IVF1<Rect> onGuess) {
|
37 | img16 = scaleImageToWidth(inputImage, 16); |
38 | int assumedPrototypeHeight16 = calculate(percentage, img16); |
39 | prototype16 = resizeImageToHeight(prototype, assumedPrototypeHeight16); |
40 | img32 = scaleImageToWidth(inputImage, 32); |
41 | etc. |
42 | |
43 | double minSimilarity = 0.5; |
44 | L<Scored<Rect>> found16 = bwRawImageSearch(img16, prototype16, minSimilarity); |
45 | sortScoredDesc_inPlace(found16); |
46 | candidates16 = getVars(takeFirst(5, found16)); |
47 | for (Rect candidate16 : candidates16) {
|
48 | candidate32 = scaleRect(candidate16, 2); |
49 | } |
50 | } |
51 | } |
download show line numbers debug dex old transpilations
Travelled to 7 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt, xrpafgyirdlv
No comments. add comment
| Snippet ID: | #1027268 |
| Snippet name: | MultiLevelRecognizer3 [dev.] |
| Eternal ID of this version: | #1027268/1 |
| Text MD5: | e69a39658af93369ba44dab8cfac1972 |
| Author: | stefan |
| Category: | javax / image recognition |
| Type: | JavaX fragment (include) |
| Public (visible to everyone): | Yes |
| Archived (hidden from active list): | No |
| Created/modified: | 2020-02-28 15:08:22 |
| Source code size: | 1622 bytes / 51 lines |
| Pitched / IR pitched: | No / No |
| Views / Downloads: | 374 / 396 |
| Referenced in: | [show references] |