diff --git a/src/autofocus.py b/src/autofocus.py index cbee136..89ccfff 100644 --- a/src/autofocus.py +++ b/src/autofocus.py @@ -1,7 +1,3 @@ -""" -Autofocus module - handles focus detection and autofocus routines. -""" - import time import threading from vision import calculate_focus_score_sobel @@ -12,12 +8,12 @@ class AutofocusController: # Default timing settings DEFAULT_SETTINGS = { - 'sweep_move_time': 2.0, - 'sweep_settle_time': 0.25, + 'sweep_move_time': 0.5, + 'sweep_settle_time': 0.05, 'sweep_samples': 10, - 'sweep_steps': 15, + 'sweep_steps': 30, 'fine_move_time': 0.15, - 'fine_settle_time': 0.25, + 'fine_settle_time': 0.1, 'fine_samples': 10, 'fine_max_no_improvement': 5, } diff --git a/src/gui.py b/src/gui.py index 09d2e35..262253f 100644 --- a/src/gui.py +++ b/src/gui.py @@ -1,8 +1,3 @@ -""" -AutoScope GUI - Pure UI layer. -Delegates logic to controllers. -""" - import tkinter as tk from tkinter import ttk, scrolledtext from PIL import Image, ImageTk @@ -322,6 +317,7 @@ class AppGUI: score = self.autofocus.get_focus_score() self.focus_score_label.config(text=f"Focus: {score:.1f}") + frame = self._draw_crosshair(frame) frame = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB) h, w = frame.shape[:2] @@ -338,6 +334,33 @@ class AppGUI: except Exception as e: print(f"Camera error: {e}") + def _draw_crosshair(self, frame, color=(0, 0, 255), thickness=1, gap=0, size=40): + """ + Draw a crosshair at the center of the frame. + + Args: + frame: OpenCV image + color: BGR color tuple (default green) + thickness: Line thickness + gap: Gap in center of crosshair + size: Length of crosshair arms from center + """ + h, w = frame.shape[:2] + cx, cy = w // 2, h // 2 + + # Horizontal lines (left and right of center gap) + cv2.line(frame, (cx - size, cy), (cx - gap, cy), color, thickness) + cv2.line(frame, (cx + gap, cy), (cx + size, cy), color, thickness) + + # Vertical lines (above and below center gap) + cv2.line(frame, (cx, cy - size), (cx, cy - gap), color, thickness) + cv2.line(frame, (cx, cy + gap), (cx, cy + size), color, thickness) + + # Optional: center dot + # cv2.circle(frame, (cx, cy), 2, color, -1) + + return frame + # === Main Loop === def run(self): diff --git a/src/motion_controller.py b/src/motion_controller.py index a979699..8e2f919 100644 --- a/src/motion_controller.py +++ b/src/motion_controller.py @@ -1,8 +1,3 @@ -""" -Motion controller - manages axis movement state and commands. -Abstracts the command protocol from the GUI. -""" - class MotionController: # Command mapping for each axis AXIS_COMMANDS = {