Skip to content

Commit

Permalink
Completed Readme
Browse files Browse the repository at this point in the history
  • Loading branch information
Fran314 committed Jan 1, 2021
1 parent c2934b4 commit c66d4b6
Show file tree
Hide file tree
Showing 8 changed files with 30 additions and 27 deletions.
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,13 @@ If you too are an occasional Smash player and a stats nerd, this is for you!
First, download the script. You CAN download the whole repository, but I'd suggest to download the latest release (whcih you can find [here](https://github.com/Fran314/SmashDataCollector/releases)), as it has only the stuff that you need to run the script and not the bunch of stuff that I needed and need to make the character faces database.
### What to do when you're Smashing
In order to save a match for collecting the data later, you'll have to take two screenshots (using the screenshot button on the Switch, and not any other screenshot function that your monitor/television might have) for every match you play. In particular, you'll have to take a screenshot of the result screen where the "Out at" time is displayed (and we'll call it first screenshot), and a screenshot of the result screen where the kills, falls, damage taken and damage given are displayed. An example of what the first and second screenshot should look like is this:
![first screenshot](data/2020121110511900_c.jpg)
![second screenshot](data/2020121110513400_c.jpg)
![first screenshot](readme_images/2021010119113300_c.jpg)
![second screenshot](readme_images/2021010119115300_c.jpg)
Taking the first screenshot is just pressing the screenshot button, it's as easy as it gets.
For the second screenshot you have to be a bit more precise, because the menu is a scrolling menu and not all the necessary stats are displayed before scrolling the menu. When you take the second screenshot you have to make sure that the scroll menu is not too high (which means the right side of the "Falls" row should be fully visible) and not too low (the right side of the "Taken damage" row should be fully visible). It is a bit annoying to have to check out for this, but the range of positions for the scroll menu for it to be a valid screenshot is very wide, so it's not as annoying as it sounds.
For the second screenshot you have to be a bit more precise, because the menu is a scrolling menu and not all the necessary stats are displayed before scrolling the menu. When you take the second screenshot you have to make sure that the scroll menu is not too high (which means the left side of the "Falls" row should be fully visible) and not too low (the right side of the "Taken damage" row should be fully visible). It is a bit annoying to have to check out for this, but the range of positions for the scroll menu for it to be a valid screenshot is very wide, so it's not as annoying as it sounds.
Here's examples of valid and invalid positions of the scroll menu:
![top limit](readme_images/top_limit.png)
![bottom limit](readme_images/bottm_limit.png)
After these two screenshot you can go for the next match. That's all it takes, and once you get used to it, it really just takes you away a couple of seconds per match!

### How to transfer the screenshots
Expand Down
14 changes: 7 additions & 7 deletions SmashDataCollector.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
sys.exit(0)

#--- FIND MATCHES ---#
dirs = fun.mergeSort(os.listdir(custom.data_path))
dirs = fun.mergeSort(os.listdir(custom.DATA_PATH))
if(len(dirs) % 2 != 0):
print("Odd number of images present in data. Ignoring the last image.")
dirs = dirs[:-1]
Expand All @@ -28,8 +28,8 @@
problematic_matches = []
for match_index in range(tot_matches):
print(f'Match #{match_index+1} out of {tot_matches}')
first_data = cv2.imread(os.path.join(custom.data_path, dirs[2*match_index]))
second_data = cv2.imread(os.path.join(custom.data_path, dirs[2*match_index+1]))
first_data = cv2.imread(os.path.join(custom.DATA_PATH, dirs[2*match_index]))
second_data = cv2.imread(os.path.join(custom.DATA_PATH, dirs[2*match_index+1]))

try:
#--- FIRST IMAGE ---#
Expand Down Expand Up @@ -216,7 +216,7 @@
print(f'elapsed time: {(time.time() - t):.3f} s')

#--- WRITE TEMPORARY OUTPUT ---#
output_file = open(custom.output_path, 'w')
output_file = open(custom.OUTPUT_PATH, 'w')
for match in output_strings[:-1]:
output_file.write(match)
output_file.write("\n")
Expand All @@ -231,8 +231,8 @@
print(f'Problematic match #{match_counter+1} of {len(problematic_matches)} (match #{problematic_match[0]+1})')
print(f'Problem: {problematic_match[1]}')

first_data = cv2.imread(os.path.join(custom.data_path, dirs[2*problematic_match[0]]))
second_data = cv2.imread(os.path.join(custom.data_path, dirs[2*problematic_match[0]+1]))
first_data = cv2.imread(os.path.join(custom.DATA_PATH, dirs[2*problematic_match[0]]))
second_data = cv2.imread(os.path.join(custom.DATA_PATH, dirs[2*problematic_match[0]+1]))
valid_data = False
while(valid_data == False):
valid_data = True
Expand Down Expand Up @@ -340,7 +340,7 @@
pass

#--- WRITE OUTPUT ---#
output_file = open(custom.output_path, 'w')
output_file = open(custom.OUTPUT_PATH, 'w')
for match in output_strings[:-1]:
output_file.write(match)
output_file.write("\n")
Expand Down
9 changes: 5 additions & 4 deletions customizable.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
data_path = r'C:\Users\franc\Documents\VSCode\SmashDataCollector\data'
res_path = r'C:\Users\franc\Documents\VSCode\SmashDataCollector\res'
output_path = r'C:\Users\franc\Documents\VSCode\SmashDataCollector\output.tsv'
DATA_PATH = r'C:\Users\franc\Documents\VSCode\SmashDataCollector\data'
RES_PATH = r'C:\Users\franc\Documents\VSCode\SmashDataCollector\res'
OUTPUT_PATH = r'C:\Users\franc\Documents\VSCode\SmashDataCollector\output.tsv'

# Set the language variable to 0, 1 or 2 according to the following:
# 0 for Japanese or Korean
# 1 for English, Italian, Dutch or Russian
# 2 for French, Spanish or German
# 3 for Chinese (traditional or simplified)
LANGUAGE = 1

LIVES = 3


TAKEN_GIVEN_DMG_THRESHOLD = 30
Binary file added readme_images/2021010119113300_c.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added readme_images/2021010119115300_c.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added readme_images/bottom_limit.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added readme_images/top_limit.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
26 changes: 13 additions & 13 deletions resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@
import numpy
import sys
from cv2 import cv2
from customizable import res_path, LANGUAGE
from customizable import RES_PATH, LANGUAGE
from functions import readTSV, addBackground


MAX_PLAYERS = 4 # Max number of players


CHARACTER_INFOS = readTSV(os.path.join(res_path, "character_references", "characters_info.tsv"))
CHARACTER_INFOS = readTSV(os.path.join(RES_PATH, "character_references", "characters_info.tsv"))
CHARACTER_CLOSEUPS = []
# 2 and 3 players closeups
characters_tile = cv2.cvtColor(cv2.imread(os.path.join(res_path, "character_references", "23-closeups.png"), flags=cv2.IMREAD_UNCHANGED), cv2.COLOR_BGR2BGRA)
characters_tile = cv2.cvtColor(cv2.imread(os.path.join(RES_PATH, "character_references", "23-closeups.png"), flags=cv2.IMREAD_UNCHANGED), cv2.COLOR_BGR2BGRA)
tile_height = int(characters_tile.shape[0] / len(CHARACTER_INFOS))
tile_width = int(characters_tile.shape[1] / 8)
main_list = []
Expand All @@ -29,7 +29,7 @@
CHARACTER_CLOSEUPS.append(main_list)
CHARACTER_CLOSEUPS.append(main_list)
# 4 players closeups
characters_tile = cv2.cvtColor(cv2.imread(os.path.join(res_path, "character_references", "4-closeups.png"), flags=cv2.IMREAD_UNCHANGED), cv2.COLOR_BGR2BGRA)
characters_tile = cv2.cvtColor(cv2.imread(os.path.join(RES_PATH, "character_references", "4-closeups.png"), flags=cv2.IMREAD_UNCHANGED), cv2.COLOR_BGR2BGRA)
tile_height = int(characters_tile.shape[0] / len(CHARACTER_INFOS))
tile_width = int(characters_tile.shape[1] / 8)
main_list = []
Expand All @@ -40,15 +40,15 @@
main_list.append(skins_list)
CHARACTER_CLOSEUPS.append(main_list)

CHARACTER_CLOSEUPS_MASKS = [[(cv2.imread(os.path.join(res_path, "character_references", "23-lose_mask.png")) / 255).astype(numpy.uint8),
(cv2.imread(os.path.join(res_path, "character_references", "23-win_mask.png")) / 255).astype(numpy.uint8)],
[(cv2.imread(os.path.join(res_path, "character_references", "23-lose_mask.png")) / 255).astype(numpy.uint8),
(cv2.imread(os.path.join(res_path, "character_references", "23-win_mask.png")) / 255).astype(numpy.uint8)],
[(cv2.imread(os.path.join(res_path, "character_references", "4-lose_mask.png")) / 255).astype(numpy.uint8),
(cv2.imread(os.path.join(res_path, "character_references", "4-win_mask.png")) / 255).astype(numpy.uint8)]]
CHARACTER_CLOSEUPS_MASKS = [[(cv2.imread(os.path.join(RES_PATH, "character_references", "23-lose_mask.png")) / 255).astype(numpy.uint8),
(cv2.imread(os.path.join(RES_PATH, "character_references", "23-win_mask.png")) / 255).astype(numpy.uint8)],
[(cv2.imread(os.path.join(RES_PATH, "character_references", "23-lose_mask.png")) / 255).astype(numpy.uint8),
(cv2.imread(os.path.join(RES_PATH, "character_references", "23-win_mask.png")) / 255).astype(numpy.uint8)],
[(cv2.imread(os.path.join(RES_PATH, "character_references", "4-lose_mask.png")) / 255).astype(numpy.uint8),
(cv2.imread(os.path.join(RES_PATH, "character_references", "4-win_mask.png")) / 255).astype(numpy.uint8)]]

CHARACTER_ICONS = []
characters_tile = cv2.cvtColor(cv2.imread(os.path.join(res_path, "character_references", "icons.png"), flags=cv2.IMREAD_UNCHANGED), cv2.COLOR_BGR2BGRA)
characters_tile = cv2.cvtColor(cv2.imread(os.path.join(RES_PATH, "character_references", "icons.png"), flags=cv2.IMREAD_UNCHANGED), cv2.COLOR_BGR2BGRA)
tile_height = int(characters_tile.shape[0] / len(CHARACTER_INFOS))
tile_width = int(characters_tile.shape[1] / 8)
for i in range(len(CHARACTER_INFOS)):
Expand Down Expand Up @@ -96,14 +96,14 @@
SMALL_DIGIT_HEIGHT = 21
SMALL_DIGIT_SEP = 19.5
SMALL_DIGIT_IMAGES = []
digits_tile = cv2.cvtColor(cv2.imread(os.path.join(res_path, "digits", "small_digits.png")), cv2.COLOR_BGR2GRAY)
digits_tile = cv2.cvtColor(cv2.imread(os.path.join(RES_PATH, "digits", "small_digits.png")), cv2.COLOR_BGR2GRAY)
for i in range(11):
SMALL_DIGIT_IMAGES.append(digits_tile[:, i*SMALL_DIGIT_WIDTH : (i+1)*SMALL_DIGIT_WIDTH].copy())

BIG_DIGIT_WIDTH = 44
BIG_DIGIT_HEIGHT = 63
BIG_DIGIT_IMAGES = []
digits_tile = cv2.cvtColor(cv2.imread(os.path.join(res_path, "digits", "big_digits.png")), cv2.COLOR_BGR2GRAY)
digits_tile = cv2.cvtColor(cv2.imread(os.path.join(RES_PATH, "digits", "big_digits.png")), cv2.COLOR_BGR2GRAY)
for i in range(12):
BIG_DIGIT_IMAGES.append(digits_tile[:, i*BIG_DIGIT_WIDTH : (i+1)*BIG_DIGIT_WIDTH].copy())

Expand Down

0 comments on commit c66d4b6

Please sign in to comment.