4rtzel / poe-archnemesis-scanner

Tool for Path of Exile game to automatically scan Archemesis inventory and display related information
Apache License 2.0
64 stars 25 forks source link

Detect empty slots #53

Open Irfy opened 2 years ago

Irfy commented 2 years ago

I am consistently getting misses on a full inventory and use this one-liner to verify the number of detected slots:

python -c "while True: print(len(sum(eval(input()).values(),[])));"

I recommend adding a black box to the pictures to be explicitly detected as the most probable match for empty slots. When this is given, the tool can add up the number of detected slots to make sure all 64 slots were detected.

For now, I copy the final output of the scanning every time into the above snippet to make sure I hit the number of items I know are in the inventory. If I have misses I then typically reduce the confidence threshold until I hit everything I have. My sweet spot for confidence is 0.91.

Automatic confidence adjustment (="Calibration") can be considered an idea (loop, reducing the confidence threshold until all non-empty slots are detected, down to a predefined absolute minimum), but for starters, an indication like 3x Unknown in some warning-colored text would be perfect.

andr9528 commented 2 years ago

Yes please. i've had to lower the confidence slightly before, as it was missing 1 or 2 parts some of the times. I lowered my confidence to 0.92, but still suspect that it missed some.

4rtzel commented 2 years ago

There now should be a information about the items that the tool was able to detect. Something like this:

...
row=6, column=8, item=Juggernaut, confidence=0.9771817326545715
row=7, column=1, item=Overcharged, confidence=0.9776066541671753
row=7, column=2 is empty
row=7, column=3, item=Berserker, confidence=0.9845896363258362
row=7, column=4, item=Juggernaut, confidence=0.9771813154220581
row=7, column=5, item=Hasted, confidence=0.978759229183197
row=7, column=6, item=Permafrost, confidence=0.976910412311554
row=7, column=7, item=Frostweaver, confidence=0.9772088527679443
row=7, column=8 is empty
row=8, column=1 is empty
...

Do you think that would be enough to help you?

Irfy commented 2 years ago

The coordinates are very helpful for debugging, but for the quick glance/overview, it would be even more helpful to have a final log output like "Found 60 recognized tokens, 3 empty slots and 1 unrecognized token" (or whatever wording you use for the "archnemesis things" instead of "token").

More can definitely be done, but let's defer that until we see if the tool works well enough for now. If misses are still reported, it may make sense to implement two more UI-related things on top of the above:

  1. Show empty slots as-if they are an archnemesis token of their own, showing them in some colored text (e.g. 3x Empty slot) right there with the rest of it, allowing them to be moused-over which would highlight the empty slots. This way the user can visually make sure they are, in fact, empty. This could be a checkbox in settings that is enabled or disabled.

  2. When a slot matches neither an archnemesis token, nor the empty slot image, that would indicate an unrecognized archnemesis token and the tool could force-select the highest confidence match it got even if it's below the threshold, and/or inform the user with a dialog that this happened and that the user should consider lowering the threshold to the lowest value detected for all slots. Right now, as far as I can tell, if no image matches with high-enough confidence, the tool silently skips that slot (?) -- this is bad, and this approach would fix that. This way, the threshold could be more liberally lowered by default too.

4rtzel commented 2 years ago

I quickly added a message with the information about the number of items found in a new v0.2.2 version. The rest of the changes will have to wait until I stabilize the tool.

Irfy commented 2 years ago

On first run it consistently showed all slots empty, but after a restart of the tool it showed everything as expected. The message is sufficient for now. If this works well, no need for the remainder of my suggestions.