Skip to content
This repository was archived by the owner on Aug 10, 2022. It is now read-only.

Commit 3d83ea4

Browse files
authored
Add files via upload
Added rough GUI implementation into lucasKanadeOpticalFlow.py
1 parent d634f4c commit 3d83ea4

File tree

1 file changed

+31
-3
lines changed

1 file changed

+31
-3
lines changed

opticalFlow/lucasKanadeOpticalFlow.py

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,41 @@
1010
The idea is that perhaps the data about how certain pixels/features are moving across the screen could be used to figure out how the player camera / aim was changing.
1111
"""
1212

13+
from tkinter import *
14+
from tkinter import filedialog
1315
import cv2 as cv
1416
import numpy as np
17+
from tkinter.messagebox import showinfo
18+
19+
# GUI FILE BROWSER------------------------------------------------------------
20+
21+
window = Tk()
22+
window.geometry('300x150') # sets the size of the GUI window
23+
window.title('Select a Video File') # creates a title for the window
24+
25+
# function allowing you to find/select video in GUI
26+
def get_file_path():
27+
global file_path
28+
# Open and return file path
29+
file_path = filedialog.askopenfilename(title = "Select a Video File", filetypes = (("mp4", "*.mp4"), ("mov files", "*.mov") ,("wmv", "*.wmv"), ("avi", "*.avi")))
30+
showinfo(title='Selected File', message=file_path)
31+
32+
# function allowing you to select the output path in the GUI
33+
def output():
34+
global savepath
35+
savepath = filedialog.asksaveasfilename(filetypes=[("mp4", '*.mp4')])
36+
window.destroy()
37+
38+
# Creating a button to search for the input file and to select the output destinatio and file name
39+
b1 = Button(window, text = 'Open a File', command = get_file_path).pack()
40+
b2 = Button(window, text = 'Save File Name', command = output).pack()
41+
window.mainloop()
42+
1543

1644
# PARAMETERS------------------------------------------------------------------
1745

1846
# path to input videofile
19-
vidpath = r""
47+
vidpath = file_path
2048

2149
# do you want to save the video?
2250
savevid = True
@@ -83,8 +111,8 @@
83111
# if saving video
84112
if savevid:
85113
# path to save output video
86-
pathparts = vidpath.split('.')
87-
savepath = '.'+ vidpath.split('.')[-2] + '_LK_FLOW' + '.mp4'
114+
#pathparts = vidpath.split('.')
115+
#savepath = vidpath.split('.')[-2] + '_LK_FLOW' + '.mp4'
88116
print(f"Saving Output video to: {savepath}")
89117

90118
# get shape of video frames

0 commit comments

Comments
 (0)