Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
UPLOAD_FOLDER = os.path.join(app.instance_path, 'uploads')
app.config['UPLOAD_FOLDER'] = UPLOAD_FOLDER
app.config['MAX_CONTENT_LENGTH'] = 30 * 1024 * 1024 # 30 MB limit
os.makedirs(UPLOAD_FOLDER, exist_ok=True)
current_df = pd.DataFrame()
# Assert OpenCV version reads videos
SAMPLE_FILE = os.path.join(app.static_folder, "sample.mp4")
ret, _ = cv2.VideoCapture(SAMPLE_FILE).read()
assert ret, "OpenCV installed at {} does not support video".format(
cv2.__file__)
global detector, graph
sns.set()
detector = FER(emotion_model=os.environ.get('EMOTION_API_URL', None))
current_video = None
def read_csv(file):
position_df = pd.read_csv(file, index_col='time_stamps_vec')[['x', 'y']]
position_df *= 100
return position_df
def calc_distance(position_df):
position_df['distance'] = np.sqrt(
np.power(position_df['x'].shift() - position_df['x'], 2) +
np.power(position_df['y'].shift() - position_df['y'], 2))
return position_df