Pineapple (CH3)
+ Better µScan
+ BmpV!
This commit is contained in:
@@ -373,7 +373,7 @@ class PfandCalculator:
|
|||||||
label = tk.Label(
|
label = tk.Label(
|
||||||
about_window,
|
about_window,
|
||||||
text=(
|
text=(
|
||||||
"PfandApp V.8.05.501 - 'Pineapple'\n"
|
"PfandApp V.8.15.000 - 'Pineapple'\n"
|
||||||
"PaketVersion 1.1 ( PKG1.1 )\n\n"
|
"PaketVersion 1.1 ( PKG1.1 )\n\n"
|
||||||
"Erstellt mit TKinter, CV2, Numpy, PyZbar, TGTG-API, TKCalendar, Datetime\n"
|
"Erstellt mit TKinter, CV2, Numpy, PyZbar, TGTG-API, TKCalendar, Datetime\n"
|
||||||
),
|
),
|
||||||
@@ -550,7 +550,7 @@ class PfandCalculator:
|
|||||||
about_uscan,
|
about_uscan,
|
||||||
text=(
|
text=(
|
||||||
"µScan - Der bessere Barcode Scanner\n"
|
"µ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 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"
|
"µ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
|
import tkinter as tk
|
||||||
from tkinter import ttk, simpledialog, messagebox
|
from tkinter import ttk, simpledialog, messagebox
|
||||||
import cv2
|
import cv2
|
||||||
@@ -126,6 +125,7 @@ class PfandScanner:
|
|||||||
return binary
|
return binary
|
||||||
|
|
||||||
def process_video(self):
|
def process_video(self):
|
||||||
|
try:
|
||||||
ret, frame = self.cap.read()
|
ret, frame = self.cap.read()
|
||||||
if ret:
|
if ret:
|
||||||
if not self.autofocus_var.get():
|
if not self.autofocus_var.get():
|
||||||
@@ -138,7 +138,7 @@ class PfandScanner:
|
|||||||
points = barcode.polygon
|
points = barcode.polygon
|
||||||
if len(points) == 4:
|
if len(points) == 4:
|
||||||
pts = [(p.x, p.y) for p in points]
|
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')
|
barcode_data = barcode.data.decode('utf-8')
|
||||||
self.queue.put(barcode_data)
|
self.queue.put(barcode_data)
|
||||||
|
|
||||||
@@ -147,12 +147,14 @@ class PfandScanner:
|
|||||||
imgtk = ImageTk.PhotoImage(image=img)
|
imgtk = ImageTk.PhotoImage(image=img)
|
||||||
self.camera_label.imgtk = imgtk
|
self.camera_label.imgtk = imgtk
|
||||||
self.camera_label.configure(image=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):
|
def show_product_selection(self, barcode_data):
|
||||||
if hasattr(self, 'product_win') and self.product_win.winfo_exists():
|
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 = tk.Toplevel(self.window)
|
||||||
self.product_win.title("Produktwahl")
|
self.product_win.title("Produktwahl")
|
||||||
@@ -176,15 +178,15 @@ class PfandScanner:
|
|||||||
|
|
||||||
def process_queue(self):
|
def process_queue(self):
|
||||||
try:
|
try:
|
||||||
while True:
|
barcode_data = self.queue.get(timeout=0.1)
|
||||||
barcode_data = self.queue.get_nowait()
|
|
||||||
now = datetime.now()
|
now = datetime.now()
|
||||||
|
|
||||||
if barcode_data in self.barcode_times:
|
if barcode_data in self.barcode_times:
|
||||||
timestamps = self.barcode_times[barcode_data]
|
timestamps = self.barcode_times[barcode_data]
|
||||||
timestamps = [t for t in timestamps if now - t <= timedelta(seconds=20)]
|
timestamps = [t for t in timestamps if now - t <= timedelta(seconds=5)]
|
||||||
if len(timestamps) >= 10:
|
if len(timestamps) >= 3:
|
||||||
continue
|
return
|
||||||
timestamps.append(now)
|
timestamps.append(now)
|
||||||
self.barcode_times[barcode_data] = timestamps
|
self.barcode_times[barcode_data] = timestamps
|
||||||
else:
|
else:
|
||||||
@@ -206,8 +208,10 @@ class PfandScanner:
|
|||||||
|
|
||||||
except queue.Empty:
|
except queue.Empty:
|
||||||
pass
|
pass
|
||||||
|
except Exception as e:
|
||||||
|
print(f"Error in queue processing: {e}")
|
||||||
finally:
|
finally:
|
||||||
self.window.after(100, self.process_queue)
|
self.window.after(100, self.process_queue) # freez delay
|
||||||
|
|
||||||
def on_closing(self):
|
def on_closing(self):
|
||||||
if self.cap.isOpened():
|
if self.cap.isOpened():
|
||||||
@@ -217,4 +221,4 @@ class PfandScanner:
|
|||||||
if __name__ != "__main__":
|
if __name__ != "__main__":
|
||||||
def launch_pfand_scanner():
|
def launch_pfand_scanner():
|
||||||
scanner_window = tk.Toplevel()
|
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