json update

This commit is contained in:
bluepulsar
2025-12-25 17:04:11 +08:00
parent eab0294f5b
commit 065b05f895
4 changed files with 21 additions and 34 deletions
+18 -17
View File
@@ -3,7 +3,6 @@
"""
import os
import numpy as np
from scipy import ndimage
import cv2
from .Stitcher import Stitcher
from .tracker import Tracker
@@ -25,7 +24,7 @@ class Sensor:
Initialize Sensor with video source and configuration.
Args:
vid_src: Video source (int for camera ID, str for file path, None for default camera)
vid_src: Video source (int for camera ID, str for file path)
isstitch: Whether to use stitching mode for multi-tile sensor (default: False)
verbose: Whether to print initialization logs (default: True)
cuda: Whether to use CUDA acceleration for optical flow & decomposition (default: True)
@@ -38,12 +37,10 @@ class Sensor:
self.CUPY_AVAILABLE = False
# Initialize settings
if vid_src is not None:
vid_src = vid_src
else:
print("User must specify a video source.")
self.vid_src, self.isstitch, self.cuda, self.verbose = vid_src, isstitch, cuda, verbose
self.config_name = config_name
if vid_src is None:
raise ValueError("User must specify a video source.")
self.vid_src, self.isstitch, self.cuda, self.verbose, self.config_name = vid_src, isstitch, cuda, verbose, config_name
# Initialize Sensor Configuration
self.get_config()
@@ -71,8 +68,6 @@ class Sensor:
ret, frame = self.cap.read()
if not ret:
time.sleep(1)
if self.verbose:
print("Video source connected.")
# Initialize and calibrate
self.__find_stitch_boxes(frame, show=False)
@@ -82,23 +77,20 @@ class Sensor:
print("Sensor initialized and calibrated.")
# Initialize state variables
self.stitch_valid = False
self.n_boxes = None
self.stitch_valid = self.imgupdate = self.vupdate = False
self.stitch_calibration = []
self.img = self.flow = self.normal = self.shear = self.force = self.depth = None
self.img_filtered = None # For temporal noise reduction
self.img = self.flow = self.normal = self.shear = self.force = self.depth = self.n_boxes = self.img_filtered = None
self.fnormal=self.fshearx=self.fsheary=self.ftor=0.0
self.imgupdate = self.vupdate = False
# Logging state
self.last_log_time = time.time()
self.fps = 0
if self.verbose:
print("Settings:")
print("Settings:" {self.config_name})
print(f" Video source: {vid_src}")
print(f" Stitch mode: {isstitch}")
print(f" CUDA acceleration: {cuda}")
print(f" CUDA acceleration: {self.cuda}")
print(f" Cupy available: {self.CUPY_AVAILABLE}")
print(f" OpenCV CUDA devices: {cv2.cuda.getCudaEnabledDeviceCount()}")
@@ -128,6 +120,15 @@ class Sensor:
self.config_index = self.config["camera"]["index"]
self.config_pos_default = self.config["camera"]["pos_default"]
if self.verbose:
print("Config loaded: ", str(self.config_name))
print(" Resolution raw: ", str(self.config_resolution_raw))
print(" FPS: ", str(self.config_fps))
print(" Units: ", str(self.config_units))
print(" Resolution stitch: ", str(self.config_resolution_stitch))
print(" Index: ", str(self.config_index))
print(" Pos default: ", str(self.config_pos_default))
def get_img(self):
"""
Capture frame from video source, convert to grayscale, and perform stitching.