Skip to content

Commit fa2ce5e

Browse files
authored
Add files via upload
1 parent 54628c2 commit fa2ce5e

File tree

4 files changed

+381
-347
lines changed

4 files changed

+381
-347
lines changed

checkgpu.py

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import torch
2+
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
3+
4+
print(torch.cuda.is_available())
5+

confirmRegion.py

+99-88
Original file line numberDiff line numberDiff line change
@@ -1,89 +1,100 @@
1-
import time
2-
import tkinter as tk
3-
from PIL import Image, ImageTk
4-
5-
import videoprocess
6-
7-
file_path = ""
8-
region = None
9-
root = None
10-
11-
intervalEntry = None
12-
similarityEntry = None
13-
14-
def button1_action():
15-
global intervalEntry,similarityEntry,root
16-
17-
interval = float(intervalEntry.get())
18-
similarityEntry = float(similarityEntry.get())
19-
20-
root.destroy()
21-
start_time = time.time() # 获取当前时间戳
22-
text_groups = videoprocess.process_video(file_path,region,interval,similarityEntry)
23-
24-
25-
if "/" in file_path:
26-
file_name = file_path[file_path.rindex("/") + 1:]
27-
else:
28-
file_name = file_path
29-
videoprocess.write_to_script(file_name,text_groups,"start.vgs")
30-
31-
end_time = time.time() # 获取当前时间戳
32-
elapsed_time = end_time - start_time # 计算耗时
33-
print("处理完成")
34-
print(f"耗时: {elapsed_time:.4f} 秒")
35-
36-
def reset_action():
37-
exit()
38-
39-
40-
def show_confirmWindow(tknode,crop_area,file):
41-
global file_path,region,root,similarityEntry,intervalEntry
42-
region = crop_area
43-
file_path = file
44-
root = tk.Toplevel(tknode)
45-
root.title("区域确认")
46-
47-
# 加载图片对象
48-
49-
image_path = "current_frame.jpg" # 替换为你的图片路径
50-
pil_image = Image.open(image_path)
51-
cropped_image = pil_image.crop(crop_area)
52-
tk_image = ImageTk.PhotoImage(cropped_image)
53-
#
54-
# # 创建标签显示图片
55-
image_label = tk.Label(root, image=tk_image)
56-
image_label.grid(row=0, column=0, columnspan=2, padx=20, pady=20)
57-
58-
label = tk.Label(root, text="处理间隔(单位:秒):")
59-
label.grid(row=1, column=0, pady=10 ) # 添加一些垂直间距
60-
61-
# 创建一个输入框
62-
default_value = tk.StringVar()
63-
default_value.set("0.5") # 设置默认值
64-
intervalEntry = tk.Entry(root,textvariable=default_value)
65-
intervalEntry.grid(row=1, column=1, pady=10)
66-
67-
68-
label2 = tk.Label(root, text="文本相似度:")
69-
label2.grid(row=2, column=0, pady=10 ) # 添加一些垂直间距
70-
71-
default_value = tk.StringVar()
72-
default_value.set("0.6") # 设置默认值
73-
# 创建一个输入框
74-
similarityEntry = tk.Entry(root,textvariable=default_value)
75-
similarityEntry.grid(row=2, column=1, pady=10 )
76-
77-
# 创建按钮
78-
button1 = tk.Button(root, text="确定",command=button1_action)
79-
button1.grid(row=3, column=0, pady=10 )
80-
81-
button2 = tk.Button(root, text="取消", command=reset_action)
82-
button2.grid(row=3, column=1, pady=10)
83-
84-
# 调整行和列的权重,使组件能够在水平和垂直方向上平均分布
85-
root.rowconfigure(0, weight=1)
86-
root.columnconfigure(0, weight=1)
87-
root.columnconfigure(1, weight=1)
88-
1+
import time
2+
import tkinter as tk
3+
from PIL import Image, ImageTk
4+
5+
import videoprocess
6+
7+
file_path = ""
8+
region = None
9+
root = None
10+
11+
intervalEntry = None
12+
similarityEntry = None
13+
threadEntry = None
14+
15+
def button1_action():
16+
global intervalEntry,similarityEntry,root
17+
18+
interval = float(intervalEntry.get())
19+
similarity = float(similarityEntry.get())
20+
thread = int(threadEntry.get())
21+
22+
root.destroy()
23+
start_time = time.time() # 获取当前时间戳
24+
text_groups = videoprocess.process_video(file_path,region,interval,similarity,thread)
25+
26+
27+
if "/" in file_path:
28+
file_name = file_path[file_path.rindex("/") + 1:]
29+
else:
30+
file_name = file_path
31+
videoprocess.write_to_script(file_name,text_groups,"start.vgs")
32+
33+
end_time = time.time() # 获取当前时间戳
34+
elapsed_time = end_time - start_time # 计算耗时
35+
print("处理完成")
36+
print(f"耗时: {elapsed_time:.4f} 秒")
37+
38+
def reset_action():
39+
exit()
40+
41+
42+
def show_confirmWindow(tknode,crop_area,file):
43+
global file_path,region,root,similarityEntry,intervalEntry,threadEntry
44+
region = crop_area
45+
file_path = file
46+
root = tk.Toplevel(tknode)
47+
root.title("区域确认")
48+
49+
# 加载图片对象
50+
51+
image_path = "current_frame.jpg" # 替换为你的图片路径
52+
pil_image = Image.open(image_path)
53+
cropped_image = pil_image.crop(crop_area)
54+
tk_image = ImageTk.PhotoImage(cropped_image)
55+
#
56+
# # 创建标签显示图片
57+
image_label = tk.Label(root, image=tk_image)
58+
image_label.grid(row=0, column=0, columnspan=2, padx=20, pady=20)
59+
60+
label = tk.Label(root, text="处理间隔(单位:秒):")
61+
label.grid(row=1, column=0, pady=10 ) # 添加一些垂直间距
62+
63+
# 创建一个输入框
64+
default_value = tk.StringVar()
65+
default_value.set("0.5") # 设置默认值
66+
intervalEntry = tk.Entry(root,textvariable=default_value)
67+
intervalEntry.grid(row=1, column=1, pady=10)
68+
69+
70+
label2 = tk.Label(root, text="文本相似度:")
71+
label2.grid(row=2, column=0, pady=10 ) # 添加一些垂直间距
72+
73+
default_value = tk.StringVar()
74+
default_value.set("0.6") # 设置默认值
75+
# 创建一个输入框
76+
similarityEntry = tk.Entry(root,textvariable=default_value)
77+
similarityEntry.grid(row=2, column=1, pady=10 )
78+
79+
label3 = tk.Label(root, text="多线程:")
80+
label3.grid(row=3, column=0, pady=10 ) # 添加一些垂直间距
81+
82+
default_value = tk.StringVar()
83+
default_value.set("1") # 设置默认值
84+
# 创建一个输入框
85+
threadEntry = tk.Entry(root,textvariable=default_value)
86+
threadEntry.grid(row=3, column=1, pady=10 )
87+
88+
# 创建按钮
89+
button1 = tk.Button(root, text="确定",command=button1_action)
90+
button1.grid(row=4, column=0, pady=10 )
91+
92+
button2 = tk.Button(root, text="取消", command=reset_action)
93+
button2.grid(row=4, column=1, pady=10)
94+
95+
# 调整行和列的权重,使组件能够在水平和垂直方向上平均分布
96+
root.rowconfigure(0, weight=1)
97+
root.columnconfigure(0, weight=1)
98+
root.columnconfigure(1, weight=1)
99+
89100
root.mainloop()

0 commit comments

Comments
 (0)