update dd02 3d viewer v1

This commit is contained in:
ykcheungab
2026-06-02 12:15:36 +08:00
parent 7224fea411
commit 8a50492465
16 changed files with 2269 additions and 252 deletions
+36
View File
@@ -0,0 +1,36 @@
import cv2
import numpy as np
class CompoundEyeFrameProcessor:
"""Convert a raw compound-eye frame into one stitched BGR tactile image."""
def __init__(self, stitcher):
self.stitcher = stitcher
def process(self, frame):
self.stitcher.get_stitch_unit(frame)
self.stitcher.extract_tiles()
return self.stitcher.stitch_rt_optimized(blend=False)
class SingleCameraFrameProcessor:
"""Convert a normal camera frame into one BGR tactile image."""
def process(self, frame):
if frame.ndim == 2:
return cv2.cvtColor(frame, cv2.COLOR_GRAY2BGR)
if frame.shape[2] == 1:
return cv2.cvtColor(frame[:, :, 0], cv2.COLOR_GRAY2BGR)
return frame
def create_frame_processor(sensor_type, stitcher=None):
sensor_type = (sensor_type or "compound_eye").lower()
if sensor_type in ("compound_eye", "compound-eye", "compound"):
if stitcher is None:
raise ValueError("Compound-eye sensor requires a Stitcher instance.")
return CompoundEyeFrameProcessor(stitcher)
if sensor_type in ("single_camera", "camera", "mono"):
return SingleCameraFrameProcessor()
raise ValueError(f"Unsupported sensor type: {sensor_type}")