Skip to content

Commit 5d917df

Browse files
authored
More
last update for a while the exe for this will be 1.2 well i make it!!
1 parent cb2548c commit 5d917df

File tree

5 files changed

+260
-36
lines changed

5 files changed

+260
-36
lines changed

README.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,8 +131,10 @@ Action dictionary fields (as used across sequences and failsafe steps):
131131
## How Matching and Actions Work
132132

133133
- Template matching uses OpenCV (`cv2.matchTemplate`). Confidence threshold is adjustable per step.
134-
- Feature matching uses ORB descriptors and BF matcher with Lowe's ratio filtering.
135-
- Homography via RANSAC estimates rotation/scale; center of the matched polygon is used.
134+
- Feature matching supports multiple detectors and safe fallbacks:
135+
- Detectors: `ORB` (fast), `AKAZE` (scale-robust), `SIFT` (strong features; requires `opencv-contrib-python`).
136+
- Pipeline: KNN + Lowe’s ratio → RANSAC homography → sanity check (area ratio) → center of detected polygon.
137+
- Fallbacks: If detector fails, automatically tries `AKAZE`, then `SIFT`. If all fail, a multi‑scale template match runs.
136138
- Provide `strategy: "feature"` and optional `min_inliers`, `ratio_thresh`, `ransac_thresh` per step.
137139
- If a step has no `find` template, its actions run directly.
138140
- `move_to` can target the detected position or a random point inside a selected region.
@@ -185,6 +187,9 @@ Action dictionary fields (as used across sequences and failsafe steps):
185187

186188
- Strategy Dropdown: Default (template) or Feature (scale/rotation).
187189
- Parameters: Min Inliers, Ratio, RANSAC thresholds.
190+
- Visualizer controls:
191+
- Detector: choose `ORB`, `AKAZE`, or `SIFT` for the feature preview.
192+
- Show Keypoints: toggle overlay of scene keypoints for visual debugging (off by default for performance).
188193
- Debug Panel shows:
189194
- Target screen index, geometry, local capture rect
190195
- Frame size and bytes-per-line, DPI ratio, pixmap state

bot_gui.py

Lines changed: 35 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2087,6 +2087,18 @@ def init_ui(self):
20872087
params_layout.addWidget(self.ransac_spin)
20882088
form_layout.addRow("Params:", params_layout)
20892089

2090+
# Visualizer controls (performance-friendly toggles)
2091+
viz_layout = QHBoxLayout()
2092+
self.keypoints_check = QCheckBox("Show Keypoints")
2093+
self.keypoints_check.setChecked(False)
2094+
viz_layout.addWidget(self.keypoints_check)
2095+
viz_layout.addWidget(QLabel("Detector"))
2096+
self.detector_combo = QComboBox()
2097+
self.detector_combo.addItems(["ORB", "AKAZE", "SIFT"])
2098+
viz_layout.addWidget(self.detector_combo)
2099+
viz_layout.addStretch()
2100+
form_layout.addRow("Visualizer:", viz_layout)
2101+
20902102
# Metrics display (move overlay metrics into GUI)
20912103
metrics_layout = QHBoxLayout()
20922104
self.metric_inliers = QLabel("Inliers: -")
@@ -2289,12 +2301,31 @@ def capture_region_bgr(x: int, y: int, w: int, h: int) -> np.ndarray:
22892301
if strategy == "feature":
22902302
# Feature-based preview: draw inlier matches and polygon
22912303
try:
2292-
orb = cv2.ORB_create(nfeatures=1500)
2304+
# Choose detector based on UI (ORB or AKAZE)
2305+
use_alg = self.detector_combo.currentText() if hasattr(self, 'detector_combo') else "ORB"
2306+
if use_alg == "AKAZE":
2307+
detector = cv2.AKAZE_create()
2308+
norm = cv2.NORM_HAMMING
2309+
elif use_alg == "SIFT":
2310+
detector = cv2.SIFT_create()
2311+
norm = cv2.NORM_L2
2312+
else:
2313+
detector = cv2.ORB_create(nfeatures=1500)
2314+
norm = cv2.NORM_HAMMING
22932315
gray_screen = cv2.cvtColor(screenshot, cv2.COLOR_BGR2GRAY)
22942316
gray_template = cv2.cvtColor(template, cv2.COLOR_BGR2GRAY)
2295-
kps1, des1 = orb.detectAndCompute(gray_template, None)
2296-
kps2, des2 = orb.detectAndCompute(gray_screen, None)
2297-
bf = cv2.BFMatcher(cv2.NORM_HAMMING, crossCheck=False)
2317+
kps1, des1 = detector.detectAndCompute(gray_template, None)
2318+
kps2, des2 = detector.detectAndCompute(gray_screen, None)
2319+
# Draw scene keypoints on the preview for visual debugging (optional)
2320+
if getattr(self, 'keypoints_check', None) and self.keypoints_check.isChecked():
2321+
try:
2322+
keypoint_img = cv2.drawKeypoints(display_img, kps2 if kps2 is not None else [], None,
2323+
color=(255, 255, 0), flags=cv2.DRAW_MATCHES_FLAGS_DEFAULT)
2324+
if keypoint_img is not None:
2325+
display_img = keypoint_img
2326+
except Exception:
2327+
pass
2328+
bf = cv2.BFMatcher(norm, crossCheck=False)
22982329
matches = bf.knnMatch(des1, des2, k=2) if des1 is not None and des2 is not None else []
22992330
good = []
23002331
ratio_thresh = float(self.ratio_spin.value())

0 commit comments

Comments
 (0)