diff --git a/README.md b/README.md index bf18a38..a869832 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/SmashDataCollector.py b/SmashDataCollector.py index ba18140..7880c72 100644 --- a/SmashDataCollector.py +++ b/SmashDataCollector.py @@ -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] @@ -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 ---# @@ -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") @@ -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 @@ -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") diff --git a/customizable.py b/customizable.py index 9eb351a..789e31d 100644 --- a/customizable.py +++ b/customizable.py @@ -1,6 +1,6 @@ -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 @@ -8,6 +8,7 @@ # 2 for French, Spanish or German # 3 for Chinese (traditional or simplified) LANGUAGE = 1 - LIVES = 3 + + TAKEN_GIVEN_DMG_THRESHOLD = 30 \ No newline at end of file diff --git a/readme_images/2021010119113300_c.jpg b/readme_images/2021010119113300_c.jpg new file mode 100644 index 0000000..045ff88 Binary files /dev/null and b/readme_images/2021010119113300_c.jpg differ diff --git a/readme_images/2021010119115300_c.jpg b/readme_images/2021010119115300_c.jpg new file mode 100644 index 0000000..81537bf Binary files /dev/null and b/readme_images/2021010119115300_c.jpg differ diff --git a/readme_images/bottom_limit.png b/readme_images/bottom_limit.png new file mode 100644 index 0000000..cbfe727 Binary files /dev/null and b/readme_images/bottom_limit.png differ diff --git a/readme_images/top_limit.png b/readme_images/top_limit.png new file mode 100644 index 0000000..309652a Binary files /dev/null and b/readme_images/top_limit.png differ diff --git a/resources.py b/resources.py index 29cd196..81cf47d 100644 --- a/resources.py +++ b/resources.py @@ -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 = [] @@ -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 = [] @@ -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)): @@ -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())