-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathgui_stitcher.py
76 lines (52 loc) · 2.12 KB
/
gui_stitcher.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
import tkinter as tk
from tkinter import filedialog
from panorama import Stitcher
from video_reader import frame_generator
import cv2
root = tk.Tk()
root.title("HyperMapStitcher")
root.wm_iconbitmap("hms.ico")
stitcher = Stitcher()
frame = tk.Frame(root, width=300, height=250, padx=15, pady=15)
input_filename = ""
input_hint_label = tk.Label(frame, text="Must specify an input file")
output_filename = ""
output_hint_label = tk.Label(frame, text="Must specify an output file")
manual_checkbox = tk.IntVar()
def input_file():
global input_filename
input_filename = filedialog.askopenfilename(initialdir=".", title="Select input video",
filetypes=[["video files", ["*.mp4", "*.avi"]], ["all files", "*.*"]])
def output_file():
global output_filename
output_filename = filedialog.asksaveasfilename(initialdir=".", title="Select output filename", initialfile="out.png")
def call_stitch():
input_hint_label.pack_forget()
output_hint_label.pack_forget()
frames = int(frame_entry.get())
width = int(width_entry.get())
manual = bool(manual_checkbox.get())
if input_filename == "":
input_hint_label.pack()
if output_filename == "":
output_hint_label.pack()
if (input_filename != "") & (output_filename != ""):
images = frame_generator(input_filename, frames=frames, width=width)
result = stitcher.multistitch(images, manual=manual, os="win")
cv2.imwrite(output_filename, result)
root.destroy()
tk.Label(frame, text="Frame count").pack()
frame_entry = tk.Entry(frame)
frame_entry.insert(0, "10")
frame_entry.pack()
tk.Label(frame, text="Scale to width").pack()
width_entry = tk.Entry(frame)
width_entry.insert(0, "477")
width_entry.pack()
tk.Checkbutton(frame, text="Manual mode?", variable=manual_checkbox).pack()
tk.Button(frame, text="Input file", command=input_file, width=10).pack()
tk.Button(frame, text="Output file", command=output_file, width=10).pack()
tk.Button(frame, text="Stitch!", command=call_stitch, width=10).pack()
frame.pack(expand=True, fill='both')
frame.pack_propagate(0)
root.mainloop()