Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failure to place cards #4

Closed
MegaBlaziken opened this issue Jun 5, 2023 · 12 comments
Closed

Failure to place cards #4

MegaBlaziken opened this issue Jun 5, 2023 · 12 comments

Comments

@MegaBlaziken
Copy link

Hello, We have now completed building the environment and have done some testing.
It works fine and we have been monitoring it for a while, but we have seen a lot of strange behavior and give-aways, so we would like to know if it is an anomaly in the program or an event that we should fix.
The card kept spinning and eventually giving up:
N-ZAP89
Splatana Stamper
Splatana Wiper
Splat Bomb
Wave Breaker

It does not move from its initial location and continues to try to place it in places where it cannot be placed:
Sprinkler
Squid Beakon
Oversized

When it appears as a card, the web portal returns an error (I think it was an array error, I will submit the log of the error again if necessary).
Fish Stick

I have it running in the following environment
Ubuntu 20.04.6 LTS
Capture Card: 4KVC00

@fga401
Copy link
Owner

fga401 commented Jun 10, 2023

Sorry for the late reply.

The card kept spinning and eventually giving up

That means the recognition is wrong. The input to the AI is not the actual situation. And the giving up is a kind of mechanism to prevent a dead loop.

It does not move from its initial location and continues to try to place it in places where it cannot be placed

Same error of recognition. Does the giving up not work here?

When it appears as a card, the web portal returns an error

it would be great if you can share error logs.

And some tips for better recognition:

  • finetune the color threshold for your device. I have uploaded the images I used for test in a branch named test (I wishI have time to summarize all the parameters into a doc 😢)
  • do not use cards that are Axisymmetric or Centrosymmetric, which may cause infinited spinning.
  • do not use level-up cards, which have many sparkling special effects and makes wrong recognition happen more frequently.

@MegaBlaziken
Copy link
Author

MegaBlaziken commented Jun 15, 2023

Sorry for the delay, I was checking and verifying various operations.

The card kept spinning and eventually giving up
It does not move from its initial location and continues to try to place it in places where it cannot be placed
With regard to the above, I understand.

Also, in all cases, it will always give up.

When it appears as a card, the web portal returns an error

It would be great if you can share error logs.

They are in the following form. We have video logs regarding the situation and will present them if necessary.

Corrupt JPEG data: premature end of data segment
[2023-06-15 14:45:38,104] ERROR in app: Exception on /home/run [POST]
Traceback (most recent call last):
  File "/usr/local/lib/python3.9/dist-packages/flask/app.py", line 2447, in wsgi_app
    response = self.full_dispatch_request()
  File "/usr/local/lib/python3.9/dist-packages/flask/app.py", line 1952, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/usr/local/lib/python3.9/dist-packages/flask/app.py", line 1821, in handle_user_exception
    reraise(exc_type, exc_value, tb)
  File "/usr/local/lib/python3.9/dist-packages/flask/_compat.py", line 39, in reraise
    raise value
  File "/usr/local/lib/python3.9/dist-packages/flask/app.py", line 1950, in full_dispatch_request
    rv = self.dispatch_request()
  File "/usr/local/lib/python3.9/dist-packages/flask/app.py", line 1936, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "/home/actjp/デスクトップ/AutoTableTurf/portal/home/home.py", line 71, in run
    manager.run(profile=Profile.from_json(profile), closer=closer, debug=debug)
  File "/home/actjp/デスクトップ/AutoTableTurf/tableturf/manager/tableturf.py", line 99, in run
    self.run_once(task.deck, closer=task_closer, debug=debug)
  File "/home/actjp/デスクトップ/AutoTableTurf/tableturf/manager/tableturf.py", line 115, in run_once
    self.__select_deck(deck)
  File "/home/actjp/デスクトップ/AutoTableTurf/tableturf/manager/tableturf.py", line 145, in __select_deck
    deck = self.__multi_detect(detection.deck)(debug=self.__session['debug'])
  File "/home/actjp/デスクトップ/AutoTableTurf/tableturf/manager/tableturf.py", line 47, in wrapper
    previous = detect_fn(self.__capture(), *args, **kwargs)
  File "/home/actjp/デスクトップ/AutoTableTurf/tableturf/manager/detection/deck.py", line 95, in deck
    deck = [Card(grids[i], costs[i]) for i in range(15)]
  File "/home/actjp/デスクトップ/AutoTableTurf/tableturf/manager/detection/deck.py", line 95, in <listcomp>
    deck = [Card(grids[i], costs[i]) for i in range(15)]
  File "/home/actjp/デスクトップ/AutoTableTurf/tableturf/model/card.py", line 104, in __init__
    self.__patterns = [Pattern(np.rot90(grid, i)) for i in range(4)]
  File "/home/actjp/デスクトップ/AutoTableTurf/tableturf/model/card.py", line 104, in <listcomp>
    self.__patterns = [Pattern(np.rot90(grid, i)) for i in range(4)]
  File "/home/actjp/デスクトップ/AutoTableTurf/tableturf/model/card.py", line 24, in __init__
    self.__offsets = indexes - indexes[0][np.newaxis, ...]
IndexError: index 0 is out of bounds for axis 0 with size 0

do not use cards that are Axisymmetric or Centrosymmetric, which may cause infinite spinning.
do not use level-up cards, which have many sparkling special effects and makes wrong recognition happen more frequently.

Roger, I'll think about the deck structure.

I am also sorry that this question is not directly related to a different error or program, but may I ask you something?
I am currently using Ubuntu (VirtualBox, windows11), Bluetooth adapter and Razer ripsaw HD.
When I view the video from the Razer capture board in a browser, the screen is frequently disturbed,
Corrupt JPEG data: premature end of data segment.
error in the log.
I would like to work around this, has this ever happened in your environment?
It did not occur in windows 11.
I use Razer ripsaw HD and check with ubuntu browser and OBS but the disturbance is always happening. Especially, the bug is always noticeable in the sprite display of the tree in the square.

image

2023-06-15.20-35-45.mp4

@fga401
Copy link
Owner

fga401 commented Jun 17, 2023

your logs show that an error happens when it is trying to get your desk. I guess you choose a invalid deck which has an empty slot, or less than 15 cards in that deck.
have you changed the config json? you will need to input a valid deck number.

2023-06-17 17_17_19-192 168 50 102_5000_home_

btw, as for the screen capture issue, It seems WSL is not fully compatible with your Razer. Why not run the python script on Windows 11?

@MegaBlaziken
Copy link
Author

I am aware that the deck numbers start at 0.
We also use decks 8~15 and all 15 cards are stored in all these decks.
I have not changed the json file, do you mean to change portal > profiles > default.json instead of the text area of the browser? I always edited the text area directly.

Why not run the python script on Windows 11?

Thank you, I have tried to do a screen capture in windows 11 for this.
However, when I output the switch video to the Razer Ripsaw HD at 1080p, the screen is distorted, so I solved this problem by changing the setting on the switch side to output at 720p.

Therefore, our environment, which is currently (mostly) working properly, is as follows.
portal : Windows11
capture board: Razer ripsaw HD ( Switch setting: 720p )

controller : Ubuntu in VMbox
Bridge adapter
I will change to another capture board because I want to change the point that the switch must be set to 720p.
Sorry for the length of this article, thank you very much.

@fga401
Copy link
Owner

fga401 commented Jun 17, 2023

Alright, could you turn on the debug mode and open pages http://localhost:5000/debug/deck.image and http://localhost:5000/debug/deck.color_mask before runing the script, and share the last screenshots of that two pages while the error happens?

@MegaBlaziken
Copy link
Author

Is this the right way?
deck_image
deck_color_mask

Capture in windows 11 and Razer ripsaw HD (720p), the operation part is ubuntu in VMBox.
Are there any other clarifications needed, such as the main PC being a Ryzen?

@fga401
Copy link
Owner

fga401 commented Jun 18, 2023

yeah that's what i want. could you share your config and these two pictures?
http://localhost:5000/debug/deck_cursor.image
http://localhost:5000/debug/deck_cursor.color_mask

it seems the code enters the next round before the previous one ends, so it can't detect your deck. It's a code issue and not relative to devices. In current code, I just sleep for several secs to waiting for the animation to end, which is not robust.

a temp fix could be increase the sleep time here

@MegaBlaziken
Copy link
Author

This is a screenshot of the URL you gave us.
I changed the time in the code you gave us from 10 to 20 for now.
I will see how it works for a while.
Thank you very much for your lengthy response.
deck_cursor_image
deck_cursor_color_mask

@fga401
Copy link
Owner

fga401 commented Jun 18, 2023

it's great to hear that my codes work for someon else.

one more question, I would like to know which deck are you using? No. 11?

@MegaBlaziken
Copy link
Author

Yes, it is 11 now.
The deck is there to beat Big Man.

Also, I increased the sleep time on line 300, but the same error occurred only because it took longer to get to the experience increase screen.

@fga401
Copy link
Owner

fga401 commented Jun 18, 2023

Yes, it is 11 now.

oh it make sense now. as you can see in the last picture, there is a small white mask on the green rectangle No.11.
you can move the Deck 11 to another place.

@MegaBlaziken
Copy link
Author

In other words, is this a glitch that occurs because the result numbers happen to be at the cursor position for selecting deck 11?
I will try to make sure that deck 11 is in a different location.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants