-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutils.py
More file actions
71 lines (58 loc) · 2.3 KB
/
utils.py
File metadata and controls
71 lines (58 loc) · 2.3 KB
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
#!/usr/bin/env python3
from loguru import logger
import tkinter as tk
from PIL import Image, ImageTk
Config = {
"DEBUG_MODE": False
}
def setup_logging(log_lvl="DEBUG", options={}):
file = options.get("file", False)
function = options.get("function", False)
process = options.get("process", False)
thread = options.get("thread", False)
log_fmt = (u"<n><d><level>{time:HH:mm:ss.SSS} | " +
f"{'{file:>15.15}' if file else ''}" +
f"{'{function:>15.15}' if function else ''}" +
f"{':{line:<4} | ' if file or function else ''}" +
f"{'{process.name:>12.12} | ' if process else ''}" +
f"{'{thread.name:<11.11} | ' if thread else ''}" +
u"{level:1.1} | </level></d></n><level>{message}</level>")
logger.configure(
handlers=[{
"sink": lambda x: print(x, end=""),
"level": log_lvl,
"format": log_fmt,
"colorize": True,
"backtrace": True,
"diagnose": True
}],
levels=[
{"name": "TRACE", "color": "<white><dim>"},
{"name": "DEBUG", "color": "<cyan><dim>"},
{"name": "INFO", "color": "<white>"}
]
) # type: ignore # yapf: disable
# Function to display images in debug mode
def display_images(new_image, merged_image):
root = tk.Tk(sync=False)
root.title("Debug Images")
# Create frames for layout
frame_new = tk.Frame(root)
frame_new.pack(side="left", padx=10, pady=10)
frame_merged = tk.Frame(root)
frame_merged.pack(side="right", padx=10, pady=10)
# New Captured Image
new_image_tk = ImageTk.PhotoImage(new_image)
new_image_label = tk.Label(frame_new, image=new_image_tk) # type: ignore
new_image_label.pack()
new_image_title = tk.Label(frame_new, text="New Captured Image")
new_image_title.pack()
# Merged Image
if merged_image is not None:
merged_image_tk = ImageTk.PhotoImage(merged_image)
merged_image_label = tk.Label(frame_merged, image=merged_image_tk) # type: ignore
merged_image_label.pack()
merged_image_title = tk.Label(frame_merged, text="Current Merged Image")
merged_image_title.pack()
# Keep a reference to the images to prevent garbage collection
root.mainloop()