Skip to content

Commit c646133

Browse files
committed
1.1.0 update
1 parent 4a9da9a commit c646133

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+65
-37
lines changed

README.md

Lines changed: 1 addition & 1 deletion

SmashDataCollector.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,17 @@
3939
times = []
4040

4141
#--- GET NUMBER OF PLAYERS ---#
42-
players_colour = first_data[res.PLAYER_PIXEL]
43-
players_amount = numpy.argmin([numpy.linalg.norm(players_colour - colour) for colour in res.PLAYER_COLOURS])+2
42+
# players_colour = first_data[res.PLAYER_PIXEL]
43+
# players_amount = numpy.argmin([numpy.linalg.norm(players_colour - colour) for colour in res.PLAYER_COLOURS])+2
44+
players_amount = 0
45+
for i in range(3):
46+
if(all([numpy.linalg.norm(first_data[pixel]) < 20 for pixel in res.PLAYER_PIXELS[i]])):
47+
players_amount = i+2
48+
break
49+
if(players_amount == 0):
50+
error_message = f'unable to tell how many players'
51+
raise fun.InvalidData
52+
4453

4554
for curr_player_index in range(players_amount):
4655
#--- GET PLAYER TYPE ---#
@@ -197,7 +206,7 @@
197206
taken_given_dmg_difference = 0
198207
for curr_player_index in range(players_amount):
199208
taken_given_dmg_difference += taken_damages[curr_player_index] - given_damages[curr_player_index]
200-
if(taken_given_dmg_difference < 0 or taken_given_dmg_difference >= custom.TAKEN_GIVEN_DMG_THRESHOLD):
209+
if(taken_given_dmg_difference <= -custom.TAKEN_GIVEN_DMG_THRESHOLD or taken_given_dmg_difference >= custom.TAKEN_GIVEN_DMG_THRESHOLD):
201210
error_message = f'too big of a difference between total taken damage and total given damage ({taken_given_dmg_difference})'
202211
raise fun.InvalidData
203212

customizable.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
DATA_PATH = r'C:\Users\franc\Documents\VSCode\SmashDataCollector\data'
1+
DATA_PATH = r'C:\Users\franc\Documents\VSCode\SmashDataCollector\data\demo-4'
22
RES_PATH = r'C:\Users\franc\Documents\VSCode\SmashDataCollector\res'
3-
OUTPUT_PATH = r'C:\Users\franc\Documents\VSCode\SmashDataCollector\output.tsv'
3+
OUTPUT_PATH = r'C:\Users\franc\Documents\VSCode\SmashDataCollector\output\output-4.tsv'
44

55
# Set the language variable to 0, 1 or 2 according to the following:
66
# 0 for Japanese or Korean
77
# 1 for English, Italian, Dutch or Russian
88
# 2 for French, Spanish or German
99
# 3 for Chinese (traditional or simplified)
1010
LANGUAGE = 1
11-
LIVES = 3
11+
LIVES = 1
1212

1313

1414
TAKEN_GIVEN_DMG_THRESHOLD = 30

data/demo-0/2020123112040000_c.jpg

237 KB

data/demo-0/2020123112041500_c.jpg

235 KB

data/demo-0/2020123112050500_c.jpg

261 KB

data/demo-0/2020123112050900_c.jpg

262 KB

data/demo-0/2020123112070900_c.jpg

255 KB

data/demo-0/2020123112071800_c.jpg

254 KB

data/demo-0/2020123112080300_c.jpg

209 KB

data/demo-0/2020123112081100_c.jpg

200 KB

data/demo-0/2020123112220700_c.jpg

249 KB

data/demo-0/2020123112221100_c.jpg

231 KB
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

data/demo-1/2020123112014300_c.jpg

249 KB

data/demo-1/2020123112015500_c.jpg

246 KB

data/demo-2/2020123112100700_c.jpg

246 KB

data/demo-2/2020123112101400_c.jpg

227 KB

data/demo-2/2020123112141000_c.jpg

247 KB

data/demo-2/2020123112141500_c.jpg

241 KB

data/demo-2/2020123112270300_c.jpg

250 KB

data/demo-2/2020123112270800_c.jpg

239 KB

data/demo-3/2020123112164100_c.jpg

250 KB

data/demo-3/2020123112164900_c.jpg

227 KB

data/demo-3/2020123112183500_c.jpg

246 KB

data/demo-3/2020123112184100_c.jpg

224 KB

data/demo-4/2020123112120400_c.jpg

264 KB

data/demo-4/2020123112120900_c.jpg

241 KB

data/demo-4/2020123112245800_c.jpg

252 KB

data/demo-4/2020123112250200_c.jpg

241 KB

functions.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -207,10 +207,10 @@ def convertMatchToString(file_name, characters, positions, times, falls, given_d
207207
for i in range(players):
208208
match_string += characters[i] + "\t"
209209
match_string += str(positions[i]) + "\t"
210+
match_string += time2string(times[i]) + "\t"
210211
match_string += ','.join(map(str, falls[i])) + "\t"
211212
match_string += str(given_damages[i]) + "\t"
212-
match_string += str(taken_damages[i]) + "\t"
213-
match_string += time2string(times[i])
213+
match_string += str(taken_damages[i])
214214
if(i < players - 1):
215215
match_string += "\t"
216216

output.tsv

Lines changed: 0 additions & 3 deletions
This file was deleted.

output/output-0.tsv

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
31/12/2020 3 Toon Link 1 28 0 Sonic 2 3 1 0 13 Little Mac 3 1 1 0 14
2+
31/12/2020 4 Toon Link 1 31 0 Marth 2 5 1 0 14 Ike 3 3 1 0 8 Shulk 3 3 1 0 8
3+
31/12/2020 4 Toon Link 2 9 1 21 0 Mr. Game & Watch 4 0 1 0 13 Samus 1 0 0 Bayonetta 3 5 1 0 7
4+
31/12/2020 2 Toon Link 1 10 0 Roy 2 2 1 0 10
5+
31/12/2020 3 Toon Link 1 22 0 Richter 2 3 1 0 8 Zelda 3 1 1 0 13

output/output-1.tsv

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
11/12/2020 2 Ganondorf 2 67 2,2,2 84 131 Kirby 1 1,1 130 88
2+
11/12/2020 4 Palutena 3 99 2,2,2 147 87 Luigi 1 1,3 146 88 Inkling 2 130 1,2,2 41 73 Pac-Man 4 70 1,1,2 0 91
3+
11/12/2020 3 Donkey Kong 2 83 3,2,2 69 69 Meta Knight 1 1,3 76 72 Young Link 3 77 1,2,2 57 63
4+
31/12/2020 3 Toon Link 1 3 627 47 Duck Hunt 2 152 1,1,1 41 346 Cloud 3 119 1,1,1 18 297

output/output-2.tsv

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
31/12/2020 3 Toon Link 1 22 0 Robin 2 4 1 0 8 R.O.B. 3 0 1 0 13
2+
31/12/2020 3 Toon Link 1 22 0 Chrom 2 3 1 0 13 Meta Knight 3 1 1 0 8
3+
31/12/2020 3 Toon Link 1 25 0 Roy 3 2 1 0 13 Zero Suit Samus 2 4 1 0 11

output/output-3.tsv

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
31/12/2020 3 Toon Link 1 17 0 Captain Falcon 3 2 1 0 9 Cloud 2 5 1 0 8
2+
31/12/2020 3 Toon Link 1 23 0 Donkey Kong 2 5 1 0 14 Peach 3 1 1 0 8

output/output-4.tsv

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
31/12/2020 3 Toon Link 1 23 0 Lucario 3 3 1 0 14 Dark Samus 2 6 1 0 8
2+
31/12/2020 3 Toon Link 1 23 0 Dark Pit 3 2 1 0 8 Ice Climbers 2 6 1 0 7

resources.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,10 @@
113113
# "Player pixel" = the pixel sampled used to determine the number of players based on its colour
114114
PLAYER_PIXEL = (657, 972)
115115

116+
PLAYER_PIXELS = [[(409, 179), (409, 705)],
117+
[(409, 23), (409, 442), (409, 861)],
118+
[(397, 4), (397, 324), (397, 644), (397, 964)]]
119+
116120
# PLAYERS_COLS[i] = The colour of the player pixel if there are [i+2] players
117121
PLAYER_COLOURS = [numpy.array([150, 61, 0]),
118122
numpy.array([0, 114, 144]),

useful_code/test.py

Lines changed: 27 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -14,30 +14,32 @@
1414
# [0, 125, 166],
1515
# [22, 131, 22]]
1616

17-
RIGHT_EDGE = [423, 842, 1261]
18-
LEFT_EDGE = [19, 438, 857]
17+
print(numpy.linalg.norm([0, 4, 0]))
1918

20-
screenshots = os.listdir(r'C:\Users\franc\Desktop\aptest')
21-
template_source = cv2.imread(r'C:\Users\franc\Documents\VSCode\SmashDataCollector\res\temp\template.png')
22-
templates = [template_source[:, 0:8].copy(), template_source[:, 8:16].copy(), template_source[:, 16:24].copy()]
23-
height = templates[0].shape[0]
24-
span_range = int(height * 3.0 / 4.0)
19+
# RIGHT_EDGE = [423, 842, 1261]
20+
# LEFT_EDGE = [19, 438, 857]
2521

26-
for screenshot_file in screenshots:
27-
screenshot_image = cv2.imread(os.path.join(r'C:\Users\franc\Desktop\aptest', screenshot_file))
28-
for i in range(3):
29-
subimage = screenshot_image[172 : 443, RIGHT_EDGE[i] - 19 : RIGHT_EDGE[i] - 11].copy()
30-
distances = cv2.matchTemplate(subimage, templates[i], cv2.TM_CCOEFF_NORMED)
31-
found = False
32-
for j in range(distances.shape[0]):
33-
upper_span = min(j, span_range)
34-
lower_span = min(distances.shape[0] - j - 1, span_range)
35-
region = distances[j - upper_span : j + lower_span]
36-
if(numpy.argmax(region) == upper_span and
37-
numpy.sum(fun.polarizeImage(screenshot_image[174 + j : 172 + j + height - 2, RIGHT_EDGE[i] - 19 - 20 : RIGHT_EDGE[i] - 19], 100)) == 0 and
38-
numpy.sum(fun.polarizeImage(screenshot_image[174 + j + 74 : 172 + j + height - 2 + 74, RIGHT_EDGE[i] - 19 - 20 : RIGHT_EDGE[i] - 19], 100)) > 0):
39-
fun.showImage(screenshot_image[172 + j : 172 + j + height, LEFT_EDGE[i] : RIGHT_EDGE[i]])
40-
found = True
41-
break
42-
if(found == False):
43-
print('Errr... couldn\'t find it...')
22+
# screenshots = os.listdir(r'C:\Users\franc\Desktop\aptest')
23+
# template_source = cv2.imread(r'C:\Users\franc\Documents\VSCode\SmashDataCollector\res\temp\template.png')
24+
# templates = [template_source[:, 0:8].copy(), template_source[:, 8:16].copy(), template_source[:, 16:24].copy()]
25+
# height = templates[0].shape[0]
26+
# span_range = int(height * 3.0 / 4.0)
27+
28+
# for screenshot_file in screenshots:
29+
# screenshot_image = cv2.imread(os.path.join(r'C:\Users\franc\Desktop\aptest', screenshot_file))
30+
# for i in range(3):
31+
# subimage = screenshot_image[172 : 443, RIGHT_EDGE[i] - 19 : RIGHT_EDGE[i] - 11].copy()
32+
# distances = cv2.matchTemplate(subimage, templates[i], cv2.TM_CCOEFF_NORMED)
33+
# found = False
34+
# for j in range(distances.shape[0]):
35+
# upper_span = min(j, span_range)
36+
# lower_span = min(distances.shape[0] - j - 1, span_range)
37+
# region = distances[j - upper_span : j + lower_span]
38+
# if(numpy.argmax(region) == upper_span and
39+
# numpy.sum(fun.polarizeImage(screenshot_image[174 + j : 172 + j + height - 2, RIGHT_EDGE[i] - 19 - 20 : RIGHT_EDGE[i] - 19], 100)) == 0 and
40+
# numpy.sum(fun.polarizeImage(screenshot_image[174 + j + 74 : 172 + j + height - 2 + 74, RIGHT_EDGE[i] - 19 - 20 : RIGHT_EDGE[i] - 19], 100)) > 0):
41+
# fun.showImage(screenshot_image[172 + j : 172 + j + height, LEFT_EDGE[i] : RIGHT_EDGE[i]])
42+
# found = True
43+
# break
44+
# if(found == False):
45+
# print('Errr... couldn\'t find it...')

0 commit comments

Comments
 (0)