Compare commits

...

2 commits

Author SHA1 Message Date
ae4f2317f9 fix:保全代理报错
All checks were successful
ci/woodpecker/push/check_format Pipeline was successful
2024-12-29 11:09:10 +08:00
f9da770bb1 拼接图片适配灰度图 2024-12-29 11:07:58 +08:00
2 changed files with 13 additions and 4 deletions

View file

@ -2,6 +2,7 @@ from mower.utils import config
from mower.utils.graph import SceneGraphSolver from mower.utils.graph import SceneGraphSolver
from mower.utils.recognize import Scene from mower.utils.recognize import Scene
from .sss_navi import SSSNaviSolver
from .utils import is_full from .utils import is_full
@ -45,4 +46,4 @@ class SSSOpeSolver(SceneGraphSolver):
return return
self.tap("sss/ope/use") self.tap("sss/ope/use")
else: else:
self.scene_graph_step(Scene.SSS_START) SSSNaviSolver().run()

View file

@ -243,7 +243,7 @@ def template(
cv2.rectangle( cv2.rectangle(
disp, max_loc, (max_loc[0] + w, max_loc[1] + h), (0, 255, 0), 3 disp, max_loc, (max_loc[0] + w, max_loc[1] + h), (0, 255, 0), 3
) )
plt.imshow(disp) plt.imshow(disp, cmap="gray", vmin=0, vmax=255)
plt.show() plt.show()
return score, scope return score, scope
except Exception as e: except Exception as e:
@ -312,8 +312,16 @@ def horizontal_stitch(images: list) -> np.ndarray:
prev_img = stitched_image prev_img = stitched_image
curr_img = images[i] curr_img = images[i]
# 转为灰度图,用于计算重叠区域 # 转为灰度图,用于计算重叠区域
gray_prev = cv2.cvtColor(prev_img, cv2.COLOR_RGB2GRAY) gray_prev = (
gray_curr = cv2.cvtColor(curr_img, cv2.COLOR_RGB2GRAY) prev_img
if len(prev_img.shape) == 2
else cv2.cvtColor(prev_img, cv2.COLOR_RGB2GRAY)
)
gray_curr = (
curr_img
if len(curr_img.shape) == 2
else cv2.cvtColor(curr_img, cv2.COLOR_RGB2GRAY)
)
# 匹配 prev_img 的右侧区域和 curr_img 的左侧区域 # 匹配 prev_img 的右侧区域和 curr_img 的左侧区域
match_width = min(800, gray_prev.shape[1]) # 假设重叠区域宽度最大为 800 像素 match_width = min(800, gray_prev.shape[1]) # 假设重叠区域宽度最大为 800 像素
prev_region = gray_prev[:, -match_width:] # 取 prev_img 的右侧区域 prev_region = gray_prev[:, -match_width:] # 取 prev_img 的右侧区域