|
10 | 10 | 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. |
11 | 11 | """ |
12 | 12 |
|
| 13 | +from tkinter import * |
| 14 | +from tkinter import filedialog |
13 | 15 | import cv2 as cv |
14 | 16 | 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 | + |
15 | 43 |
|
16 | 44 | # PARAMETERS------------------------------------------------------------------ |
17 | 45 |
|
18 | 46 | # path to input videofile |
19 | | -vidpath = r"" |
| 47 | +vidpath = file_path |
20 | 48 |
|
21 | 49 | # do you want to save the video? |
22 | 50 | savevid = True |
|
83 | 111 | # if saving video |
84 | 112 | if savevid: |
85 | 113 | # 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' |
88 | 116 | print(f"Saving Output video to: {savepath}") |
89 | 117 |
|
90 | 118 | # get shape of video frames |
|
0 commit comments