Pineapple (CH3)
+ Better µScan
+ BmpV!
This commit is contained in:
@@ -373,7 +373,7 @@ class PfandCalculator:
|
||||
label = tk.Label(
|
||||
about_window,
|
||||
text=(
|
||||
"PfandApp V.8.05.501 - 'Pineapple'\n"
|
||||
"PfandApp V.8.15.000 - 'Pineapple'\n"
|
||||
"PaketVersion 1.1 ( PKG1.1 )\n\n"
|
||||
"Erstellt mit TKinter, CV2, Numpy, PyZbar, TGTG-API, TKCalendar, Datetime\n"
|
||||
),
|
||||
@@ -550,7 +550,7 @@ class PfandCalculator:
|
||||
about_uscan,
|
||||
text=(
|
||||
"µScan - Der bessere Barcode Scanner\n"
|
||||
"Version 1.1.0\n"
|
||||
"Version 2.1.0\n"
|
||||
"µScan erfordert einen UI Reload (Strg+R) in der Root Anwendung\n"
|
||||
"µScan ist für mehrere Barcodes gemacht, die in einer kurzen Zeit gescannt werden sollten\n"
|
||||
),
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
# µScan
|
||||
|
||||
# µScan V2.1.0
|
||||
import tkinter as tk
|
||||
from tkinter import ttk, simpledialog, messagebox
|
||||
import cv2
|
||||
@@ -126,6 +125,7 @@ class PfandScanner:
|
||||
return binary
|
||||
|
||||
def process_video(self):
|
||||
try:
|
||||
ret, frame = self.cap.read()
|
||||
if ret:
|
||||
if not self.autofocus_var.get():
|
||||
@@ -138,7 +138,7 @@ class PfandScanner:
|
||||
points = barcode.polygon
|
||||
if len(points) == 4:
|
||||
pts = [(p.x, p.y) for p in points]
|
||||
cv2.polylines(frame, [cv2.convexHull(cv2.UMat(cv2.Mat(pts))).get()], True, (0, 255, 0), 2)
|
||||
cv2.polylines(frame, [cv2.convexHull(cv2.UMat(cv2.Mat(pts))).get()], True, (0, 0, 255), 2)
|
||||
barcode_data = barcode.data.decode('utf-8')
|
||||
self.queue.put(barcode_data)
|
||||
|
||||
@@ -147,12 +147,14 @@ class PfandScanner:
|
||||
imgtk = ImageTk.PhotoImage(image=img)
|
||||
self.camera_label.imgtk = imgtk
|
||||
self.camera_label.configure(image=imgtk)
|
||||
except Exception as e:
|
||||
print(f"Error in processing video: {e}")
|
||||
|
||||
self.window.after(10, self.process_video)
|
||||
self.window.after(100, self.process_video)
|
||||
|
||||
def show_product_selection(self, barcode_data):
|
||||
if hasattr(self, 'product_win') and self.product_win.winfo_exists():
|
||||
return # prevent multiple dialogs
|
||||
return
|
||||
|
||||
self.product_win = tk.Toplevel(self.window)
|
||||
self.product_win.title("Produktwahl")
|
||||
@@ -176,15 +178,15 @@ class PfandScanner:
|
||||
|
||||
def process_queue(self):
|
||||
try:
|
||||
while True:
|
||||
barcode_data = self.queue.get_nowait()
|
||||
barcode_data = self.queue.get(timeout=0.1)
|
||||
|
||||
now = datetime.now()
|
||||
|
||||
if barcode_data in self.barcode_times:
|
||||
timestamps = self.barcode_times[barcode_data]
|
||||
timestamps = [t for t in timestamps if now - t <= timedelta(seconds=20)]
|
||||
if len(timestamps) >= 10:
|
||||
continue
|
||||
timestamps = [t for t in timestamps if now - t <= timedelta(seconds=5)]
|
||||
if len(timestamps) >= 3:
|
||||
return
|
||||
timestamps.append(now)
|
||||
self.barcode_times[barcode_data] = timestamps
|
||||
else:
|
||||
@@ -206,8 +208,10 @@ class PfandScanner:
|
||||
|
||||
except queue.Empty:
|
||||
pass
|
||||
except Exception as e:
|
||||
print(f"Error in queue processing: {e}")
|
||||
finally:
|
||||
self.window.after(100, self.process_queue)
|
||||
self.window.after(100, self.process_queue) # freez delay
|
||||
|
||||
def on_closing(self):
|
||||
if self.cap.isOpened():
|
||||
@@ -217,4 +221,4 @@ class PfandScanner:
|
||||
if __name__ != "__main__":
|
||||
def launch_pfand_scanner():
|
||||
scanner_window = tk.Toplevel()
|
||||
PfandScanner(scanner_window, "µScan V1.1.0")
|
||||
PfandScanner(scanner_window, "µScan V2.1.0")
|
||||
Reference in New Issue
Block a user