update hex test video

This commit is contained in:
bluepulsar
2026-03-29 20:10:15 +08:00
parent 97d7d55838
commit 7609791aff
6 changed files with 271 additions and 1678 deletions
+32 -26
View File
@@ -108,7 +108,7 @@ class Sensor:
self.compute_contact_valid = False
# Image Data Variables (public)
self.stitch_calibration = []
# self.stitch_calibration = []
self.frame = self.img = None
self.initial_img = None
shape = (self.__config_cam["resolution_stitch"][1], self.__config_cam["resolution_stitch"][0])
@@ -402,7 +402,9 @@ class Sensor:
def reset(self):
"""Reset optical flow tracker."""
self.__tracker.reset()
self.initial_img = self.img.copy()
if self.img is not None:
self.initial_img = self.img.copy()
def disconnect(self):
"""Release resources and stop async threads."""
@@ -438,31 +440,31 @@ class Sensor:
def stitch_cal(self):
"""
Load or create stitch calibration.
# def stitch_cal(self):
# """
# Load or create stitch calibration.
Returns:
np.ndarray: Stitched calibration image
"""
if self.cal_path is None:
self.cal_path = "./config/cal.npy"
# Returns:
# np.ndarray: Stitched calibration image
# """
# if self.cal_path is None:
# self.cal_path = "./config/cal.npy"
if os.path.exists(self.cal_path):
if self.verbose:
print("Loading calibration from", self.cal_path)
self.stitch_calibration = np.load(self.cal_path, allow_pickle=True)
self.stitcher.stitch_calibration = self.stitch_calibration
return self.stitcher.stitch_rt_optimized()
else:
if self.verbose:
print("Creating new calibration...")
img, self.stitch_calibration = self.stitcher.stitch_cal()
os.makedirs("./config", exist_ok=True)
np.save(self.cal_path, self.stitch_calibration)
if self.verbose:
print("Calibration saved to", self.cal_path)
return img
# if os.path.exists(self.cal_path):
# if self.verbose:
# print("Loading calibration from", self.cal_path)
# self.stitch_calibration = np.load(self.cal_path, allow_pickle=True)
# self.stitcher.stitch_calibration = self.stitch_calibration
# return self.stitcher.stitch_rt_optimized()
# else:
# if self.verbose:
# print("Creating new calibration...")
# img, self.stitch_calibration = self.stitcher.stitch_cal()
# os.makedirs("./config", exist_ok=True)
# np.save(self.cal_path, self.stitch_calibration)
# if self.verbose:
# print("Calibration saved to", self.cal_path)
# return img
# =========================================================================
# Private - Initialization Helpers
@@ -575,7 +577,11 @@ class Sensor:
else:
self._find_stitch_boxes(frame)
self._extract_tiles(frame)
img = self.stitch_cal()
# Feature-based stitching no longer needs eager overlap calibration here.
# Keep stitch_cal() as a fallback so older overlap-based stitching still works.
img = self.stitcher.stitch_rt_optimized()
# if img is None:
# img = self.stitch_cal()
img = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
self.resolution_stitch = img.shape
self.initial_img = cv2.resize(img, tuple(self._config_resolution_stitch), interpolation=cv2.INTER_CUBIC)