condor-scripts
Mike Lang 3 years ago
parent 14d72759d4
commit 59b0732c2f

@ -26,7 +26,7 @@ def main(output_file, videos, maxlen=900):
subprocess.check_call([
'ffmpeg', '-hide_banner',
'-i', video,
'-r', '1',
'-r', '2',
os.path.join(rowdir, 'frame%08d.png'),
])
for i, frame in enumerate(sorted(os.listdir(rowdir))):
@ -43,10 +43,14 @@ def main(output_file, videos, maxlen=900):
#avg_color = (0, 0, 0)
#count = 0
#for color in frame_im.getdata():
# if color != [0,0,0]:
# if color != (0,0,0):
# avg_color = tuple(a + b for a, b in zip(avg_color, color))
# count += 1
#if count > 0:
# avg_color = tuple(a / count for a in avg_color)
#else:
# avg_color = (0, 0, 0)
#image.putpixel((i, row), tuple(avg_color))
## true avg using numpy
#avg_per_row = numpy.average(cv2.imread(filepath), axis=0)
@ -58,12 +62,12 @@ def main(output_file, videos, maxlen=900):
non_black = im[im.sum(axis=2) != 0]
avg = numpy.average(non_black, axis=0)
try:
color = tuple(map(int, avg))
# note numpy flips the RGB values to BGR for some reason, so flip back
color = tuple(map(int, avg))[::-1]
except ValueError: # avg is NaN because all pixels black
color = (0, 0, 0)
image.putpixel((i, row), color)
#image.putpixel((i, row), tuple(avg_color))
rmtree(rowdir)

@ -142,8 +142,8 @@ def main(match_id, race_number, output_path,
line for line in re.split('[\r\n]', err.strip())
if line.startswith('[blackdetect @ ')
]
if len(lines) == 1:
line, = lines
if len(lines) > 0:
line = lines[0] # take first
black_end = line.split(' ')[4]
assert black_end.startswith('black_end:')
time_offset = float(black_end.split(':')[1])

@ -28,7 +28,7 @@ from uuid import uuid4
import argh
import mysql.connector
def main(league, limit=144,
def main(league, limit=144, max_duration=3600.0,
host='condor.live', user='necrobot-read', password='necrobot-read', database='condor_x2',
):
logging.basicConfig(level=logging.INFO)
@ -50,9 +50,10 @@ def main(league, limit=144,
JOIN race_runs ON (races.race_id = race_runs.race_id)
WHERE race_runs.rank = 1
AND match_info.league_tag = %(league)s
AND race_runs.time < %(max_duration)s
ORDER BY race_runs.time ASC
LIMIT %(limit)s
""", {'limit': limit, 'league': league})
""", {'limit': limit, 'league': league, 'max_duration': int(max_duration * 100)})
data = cur.fetchall()
data = [

Loading…
Cancel
Save