Handling P1P1 Premier Drafts #9
Replies: 9 comments 8 replies
-
Cool idea. Are there any decent standalone OCR Python modules that could be bundled with the app? I did a brief search, and it seems like EasyOCR might be a possibility, although it hasn't received updates in 8 months and currently has 365 unresolved issues. |
Beta Was this translation helpful? Give feedback.
-
I've thought a bit on how this might function and what would be necessary to integrate the feature with the existing code; here's what I've come up with. If the event is detected and the current pack pick is 0,0, the app will capture a screenshot using PIL and pass it to your OCR method when the 'Refresh' button is pressed. The refresh button already invokes the ArenaScanner draft_data_search method, so you'd simply replace the existing p1p1 methods with your OCR methods. OCR might not be suitable for packs after P1P1, as it could mistake the card pool for cards from the pack. The app would need to determine if the screenshot is from the P1P1 draft screen, disregarding loading screens and such, so perhaps it could search through the processed data for "Pack 1 / Pick 1"? If it doesn't find that text, it would discard the data. The code handling the dataset should probably be relocated from log_scanner to a separate module. You could create a class that manages dataset interactions What are your thoughts? |
Beta Was this translation helpful? Give feedback.
-
Also, you don't need to enter an Arena event to test this. You can create a log file with just the event entry, open that log file in the app, open up a video of a YouTuber playing, and just have the app appear over it. The lower image quality might make for a better test. |
Beta Was this translation helpful? Give feedback.
-
The current solution: The cloud function receives two objects:
The cloud function then uses the Cloud Vision API to identify all text. It then uses I have tried a few screengrabs, and it seems to work well, but on a card like Kraum, where it mentions itself in its card body, we get duplicate entries. But this also supports the case where there are duplicates of the card. It's a pretty simple script: https://github.com/unrealities/mtgalimited/blob/main/functions/main.py I have it deployed to Google Cloud. Haven't thought about limits or restrictions. |
Beta Was this translation helpful? Give feedback.
-
@unrealities I was thinking that you could replace the existing p1p1 methods in ArenaScanner with a method that calls your OCR API. This minimizes changes to the remaining code. |
Beta Was this translation helpful? Give feedback.
-
I got it working! I combined the code from your 0319 branch with the code above. |
Beta Was this translation helpful? Give feedback.
-
FYI, I included your changes in my 0319 branch. I don't want to merge yet, but you are free to keep using the endpoint on your own however you like for real drafts or testing. |
Beta Was this translation helpful? Give feedback.
-
I got it to run "successfully" locally on my 0319 branch. I had small cards, and it missed a few, but it ran! I don't know why, but it seems to love to mistake cards as "Fling." |
Beta Was this translation helpful? Give feedback.
-
A solution to this issue has been released in v3.19 |
Beta Was this translation helpful? Give feedback.
-
One issue with the current app is that pack one pick one cards are not displayed. This issue is due to insufficient logging. You only get the pack data after the first selection is made.
One possible solution is taking a screenshot of the app and then using OCR to detect card names.
Pillow provides a solution for taking screenshots. However, OCR like pytesseract can require additional downloads or installations.
It isn't realistic to ask a user to install Tesseract to get p1p1 data. We could create an AWS Lambda / Google Cloud Function to handle requests. I would be fine spending a couple of dollars a month to support this, but we would need to ensure quotas and rate limiting to prevent abuse and high costs.
Beta Was this translation helpful? Give feedback.
All reactions