Several months ago I wanted to learn python, for real on a real problem. As real problem I selected this one: a tool to partially automate an alliance log of titan hits.
It took me a while, but in the end I came up with something actually working and I’m going to share it with the community. I’m doing it mainly because I stopped developing it, but maybe out there someone is willing to repolish it (it is my first python program, so it is awful), add features, put it on github to allow community wide modifications, adapt the backbone to do other stuff (e.g. AW log), or whatever.
In short this tool takes in a list of screenshots of titan hit reports previously saved on your computer like these ones:
processes them one by one, guesses the names of the players and the corresponding scores, reports them in a table for user check and eventual corrections and save the data for later processing and presentation, like this:
Now below I’ll post the source code with a brief explanation for its use. Anyone can download it and modify it, I don’t want credits for it, I just would appreciate to be kept updated on eventual upgrades made by anyone.
I still hope SGG will add some reporting features to the game to save us from doing this kind of stuff, but until that does not happen…
(sorry to share like this, but the forum eats the leading whitespaces in each new line, which can make python code interpretation quite hard)
Save your screenshots as PNG images in subfolder “venv/images” as shown on the first image above. Use alphabetically sorted names, usually screenshots already do that using a format like YYYY_MM_DD_mm_ss.
Run the script: the first time you will be greeted with a board which shows for every member the segmented part of the image for his name, its translation into plain text (OCR applied), the segmented part of the image for his score and its translation into plain text (OCR again). Will look like this one:
All names are red because none of them has been saved yet (this is the first processed image). You’ll have to check that the names and the scores are recognized correctly, and correct the errors as in this case:
I suggest to pay attention to i, l and j mostly. Scores are often correct.
Once you’re done click “Save” and close the window.
If there are other images queued the program will repeat the procedure with the next image, otherwise it will stop and you will be able to restart when you add a new screenshot to your collection.
This time some names will be green (the name is already on the list of names found in previous images), and some red (the name has not appeared yet, maybe a new player). Yellow is for names that are not recognized correctly, but they were already corrected in the same way on a previous image, so the program guesses that correction should be applied again. For example in the following Divine_Dee has been recognized as DivineiDee as it happened for the previous image, so the correction used in the previous image is automatically applied:
Starting from the second image, after doing your corrections you can click the button “Check”, to verify that all the names are correctly matched to the names in previous images (green background), except for new members (red background). A report on old, new and lost members will also appear.
Always remember to click “Save” once after you apply your corrections and to close the window to go to the next image.
The data will be saved in file saved_data.dat. Since I didn’t implement features to verify that you do not corrupt data (e.g. by clicking “Save” more than once on a single image), I suggest to always make a backup copy of saved_data.dat before rerunning the program again on a new batch of images.
- This is not a standalone program, you need a Python 3 interpreter to run it
- The code as it is won’t work with alphabets other than latin
- The code works well on screenshots taken with my phone and I did just small adaptations to make it robust for screenshots taken from a few other sources