From 065b05f89515417bae5beb1dd89717a03602895c Mon Sep 17 00:00:00 2001 From: bluepulsar Date: Thu, 25 Dec 2025 17:04:11 +0800 Subject: [PATCH] json update --- src/orisys/__init__.py | 2 +- src/orisys/configs/__init__.py | 17 +-------------- src/orisys/configs/prototype.json | 1 + src/orisys/sensor.py | 35 ++++++++++++++++--------------- 4 files changed, 21 insertions(+), 34 deletions(-) diff --git a/src/orisys/__init__.py b/src/orisys/__init__.py index c3cf38a..4f305f3 100644 --- a/src/orisys/__init__.py +++ b/src/orisys/__init__.py @@ -6,7 +6,7 @@ including image stitching, optical flow tracking, and deformation decomposition. """ __version__ = "0.1.0" -__author__ = "Your Name" +__author__ = "Orisys" from .sensor import Sensor diff --git a/src/orisys/configs/__init__.py b/src/orisys/configs/__init__.py index 118737a..dbe4f9a 100644 --- a/src/orisys/configs/__init__.py +++ b/src/orisys/configs/__init__.py @@ -29,19 +29,4 @@ def load_config(config_name: str): with open(config_path, 'r') as f: return json.load(f) - -def save_config(config: dict, config_name: str): - """ - Save sensor configuration to JSON file. - - Args: - config: Dictionary containing the configuration - config_name: Name of the config file (without .json extension) - - Returns: - Path to the saved config file - """ - config_path = CONFIG_DIR / f"{config_name}.json" - with open(config_path, 'w') as f: - json.dump(config, f, indent=4) - return config_path \ No newline at end of file + \ No newline at end of file diff --git a/src/orisys/configs/prototype.json b/src/orisys/configs/prototype.json index 0ac9dc8..0094f99 100644 --- a/src/orisys/configs/prototype.json +++ b/src/orisys/configs/prototype.json @@ -5,6 +5,7 @@ "resolution_raw": [1920, 1080], "fps": 60, "units": 15, + "units_used": 9, "resolution_stitch": [400, 400], "index": [1,2,3,6,7,8,11,12,13], "pos_default": [[260, 56], [577, 62], [897, 69], [1214, 75], [1530, 81], [256, 391], [570, 397], [889, 403], [1208, 409], [1523, 416], [248, 724], [563, 730], [882, 738], [1201, 743], [1516, 751]] diff --git a/src/orisys/sensor.py b/src/orisys/sensor.py index b28f792..1554c76 100644 --- a/src/orisys/sensor.py +++ b/src/orisys/sensor.py @@ -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.