reveresed X axis

This commit is contained in:
Shaiv Kamat 2025-12-29 15:46:12 -08:00
parent 8bed3511a9
commit 65bc86eb52
3 changed files with 32 additions and 18 deletions

View file

@ -1,7 +1,3 @@
"""
Autofocus module - handles focus detection and autofocus routines.
"""
import time import time
import threading import threading
from vision import calculate_focus_score_sobel from vision import calculate_focus_score_sobel
@ -12,12 +8,12 @@ class AutofocusController:
# Default timing settings # Default timing settings
DEFAULT_SETTINGS = { DEFAULT_SETTINGS = {
'sweep_move_time': 2.0, 'sweep_move_time': 0.5,
'sweep_settle_time': 0.25, 'sweep_settle_time': 0.05,
'sweep_samples': 10, 'sweep_samples': 10,
'sweep_steps': 15, 'sweep_steps': 30,
'fine_move_time': 0.15, 'fine_move_time': 0.15,
'fine_settle_time': 0.25, 'fine_settle_time': 0.1,
'fine_samples': 10, 'fine_samples': 10,
'fine_max_no_improvement': 5, 'fine_max_no_improvement': 5,
} }

View file

@ -1,8 +1,3 @@
"""
AutoScope GUI - Pure UI layer.
Delegates logic to controllers.
"""
import tkinter as tk import tkinter as tk
from tkinter import ttk, scrolledtext from tkinter import ttk, scrolledtext
from PIL import Image, ImageTk from PIL import Image, ImageTk
@ -322,6 +317,7 @@ class AppGUI:
score = self.autofocus.get_focus_score() score = self.autofocus.get_focus_score()
self.focus_score_label.config(text=f"Focus: {score:.1f}") self.focus_score_label.config(text=f"Focus: {score:.1f}")
frame = self._draw_crosshair(frame)
frame = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB) frame = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)
h, w = frame.shape[:2] h, w = frame.shape[:2]
@ -338,6 +334,33 @@ class AppGUI:
except Exception as e: except Exception as e:
print(f"Camera error: {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 === # === Main Loop ===
def run(self): def run(self):

View file

@ -1,8 +1,3 @@
"""
Motion controller - manages axis movement state and commands.
Abstracts the command protocol from the GUI.
"""
class MotionController: class MotionController:
# Command mapping for each axis # Command mapping for each axis
AXIS_COMMANDS = { AXIS_COMMANDS = {