Skip to content

Commit

Permalink
reencoding fix + minor changes
Browse files Browse the repository at this point in the history
  • Loading branch information
bzhang1945 committed Oct 22, 2023
1 parent 7b90668 commit 7c1b049
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/processing/video_render.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
"""
Video Rendering module for courtline detection and video reencoding.
"""
import cv2 as cv
import random
import os
import numpy as np
import subprocess
import sys

# pass in homo matrix + +
# implement video reencoding

class VideoRender:
def __init__(self, homography):
self._TRUE_PATH = os.path.join('data','true_map.png')
Expand Down Expand Up @@ -58,7 +58,7 @@ def render_video(self,states:list,players:dict,filename:str,fps:int=30):
height, width, _ = background.shape

# Initialize the video writer
fourcc = cv.VideoWriter_fourcc(*'H264')
fourcc = cv.VideoWriter_fourcc(*'mp4v')
video_writer = cv.VideoWriter(filename, fourcc, fps, (width,height))

# Define initial positions for each player
Expand Down Expand Up @@ -114,6 +114,7 @@ def render_video(self,states:list,players:dict,filename:str,fps:int=30):
# Release the video writer
video_writer.release()


def _transform_point(self,x:float,y:float):
'''
Applies court homography to single point
Expand Down
3 changes: 3 additions & 0 deletions src/processrunner.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,11 @@ def run(self):
self.run_general_detect()
self.run_team_detect()
self.run_shot_detect()
print('G, T, S detect fine')
self.run_courtline_detect()
print('courtline detect fine')
self.run_video_render()
print('video render fine')


def get_results(self):
Expand Down
6 changes: 6 additions & 0 deletions src/view/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@


def process_video(video_file):
'''
Takes in a mp4 file at video_file and uploads it to the backend, then stores
the processed video name into session state
Temporarily: stores the processed video into tmp/user_upload.mp4
'''
if video_file is None:
return False
response = requests.post(SERVER_URL+"upload",
Expand Down Expand Up @@ -104,6 +109,7 @@ def results_page():

st.button(label='Back to Home', on_click=change_state, args=(0,),type="primary")


def tips_page():
'''
Loads tips page
Expand Down

0 comments on commit 7c1b049

Please sign in to comment.