Uses 108K of libraries. Click here for Pure Java version (15380L/113K).
abstract sclass DynVisualBot > DynPrintLogAndEnabled { transient Map<S, BWImage> protos = syncCIMap(); ISegmenter segmenter; transient autoDispose new ScreenShooter shooter; transient bool useShooter = true; transient ReliableSingleThread rstSegment = dm_rst(module(), r segment); transient ReliableSingleThread rstAOA = dm_rst(module(), r aoa); transient ImageInfo info, latestWithAOA; transient ImageSurface isThings; transient double requiredImageSimilarity = 95; transient L afterSegmenting = ll(rstAOA); // L<Runnable|voidfunc(ImageInfo)> sclass Segment extends BWImageAndRect { *() {} *(Rect r) { super(r); } } sclass ImageInfo extends ImageWithProtos<Segment> {} visualize { JComponent sup = super.visualize(); containerAddFirst(buttons, jbutton("Show segments", rThread showSegments)); ret jvsplit( jCenteredSection("Things found on screen", jscroll_center(isThings = jDoubleBufferedImageSurface())), sup); } start-thread { dm_requireMouseMover(); dm_watchFieldAndNow enabled(r { set(shooter, enabled := useShooter && enabled) }); if (empty(protos)) makeProtos(); print("Have " + n2(protos, "proto")); if (segmenter == null) setField(segmenter := makeSegmenter()); print("Have segmenter: " + segmenter); shooter.onNewImage.add(rstSegment); shooter.start(enter := f<AutoCloseable> enter); started(); } /* override me */ void started {} /* override me */ void makeProtos {} /* override me */ ISegmenter makeSegmenter() { null; } void segment { segment(shooter.latestImage); } ImageInfo segment(BufferedImage img) { if (!enabled || img == null || segmenter == null) null; // man weiß ja nie... this.info = (ImageInfo) imageWithProtos_segment(segmenter, img, iwpClass := ImageInfo.class, segmentClass := Segment.class); pcallFAll(afterSegmenting, info); ret info; } void aoa { ImageInfo info = this.info, ret if null; imageWithProtos_doAllOnAll(info, protos, minScore := requiredImageSimilarity, +isThings); latestWithAOA = info; } void protoTexts(S... texts) { putAll(protos, mapValues loadBWImage(imageSnippetIDsForNames(llQuoted(texts)))); } void showSegments() { ImageInfo info = this.info, ret if null; showMergedBWImagesVertically(firstToUpper(nSegments(info.segments)), collect image(info.segments)); } }
Began life as a copy of #1025026
download show line numbers debug dex old transpilations
Travelled to 6 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1025035 |
Snippet name: | DynVisualBot [continuous screenshots, searches for protos] |
Eternal ID of this version: | #1025035/13 |
Text MD5: | 4e13b7bd7f8d58d3ea297bb30647969a |
Transpilation MD5: | 06d51d84d0cd562969399a31781e8d6c |
Author: | stefan |
Category: | javax / visual bots |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2019-09-08 17:27:14 |
Source code size: | 2493 bytes / 69 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 253 / 699 |
Version history: | 12 change(s) |
Referenced in: | #1034167 - Standard Classes + Interfaces (LIVE, continuation of #1003674) |