json update
This commit is contained in:
@@ -6,7 +6,7 @@ including image stitching, optical flow tracking, and deformation decomposition.
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
__version__ = "0.1.0"
|
__version__ = "0.1.0"
|
||||||
__author__ = "Your Name"
|
__author__ = "Orisys"
|
||||||
|
|
||||||
from .sensor import Sensor
|
from .sensor import Sensor
|
||||||
|
|
||||||
|
|||||||
@@ -29,19 +29,4 @@ def load_config(config_name: str):
|
|||||||
|
|
||||||
with open(config_path, 'r') as f:
|
with open(config_path, 'r') as f:
|
||||||
return json.load(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
|
|
||||||
@@ -5,6 +5,7 @@
|
|||||||
"resolution_raw": [1920, 1080],
|
"resolution_raw": [1920, 1080],
|
||||||
"fps": 60,
|
"fps": 60,
|
||||||
"units": 15,
|
"units": 15,
|
||||||
|
"units_used": 9,
|
||||||
"resolution_stitch": [400, 400],
|
"resolution_stitch": [400, 400],
|
||||||
"index": [1,2,3,6,7,8,11,12,13],
|
"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]]
|
"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]]
|
||||||
|
|||||||
+18
-17
@@ -3,7 +3,6 @@
|
|||||||
"""
|
"""
|
||||||
import os
|
import os
|
||||||
import numpy as np
|
import numpy as np
|
||||||
from scipy import ndimage
|
|
||||||
import cv2
|
import cv2
|
||||||
from .Stitcher import Stitcher
|
from .Stitcher import Stitcher
|
||||||
from .tracker import Tracker
|
from .tracker import Tracker
|
||||||
@@ -25,7 +24,7 @@ class Sensor:
|
|||||||
Initialize Sensor with video source and configuration.
|
Initialize Sensor with video source and configuration.
|
||||||
|
|
||||||
Args:
|
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)
|
isstitch: Whether to use stitching mode for multi-tile sensor (default: False)
|
||||||
verbose: Whether to print initialization logs (default: True)
|
verbose: Whether to print initialization logs (default: True)
|
||||||
cuda: Whether to use CUDA acceleration for optical flow & decomposition (default: True)
|
cuda: Whether to use CUDA acceleration for optical flow & decomposition (default: True)
|
||||||
@@ -38,12 +37,10 @@ class Sensor:
|
|||||||
self.CUPY_AVAILABLE = False
|
self.CUPY_AVAILABLE = False
|
||||||
|
|
||||||
# Initialize settings
|
# Initialize settings
|
||||||
if vid_src is not None:
|
if vid_src is None:
|
||||||
vid_src = vid_src
|
raise ValueError("User must specify a video source.")
|
||||||
else:
|
|
||||||
print("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
|
||||||
self.vid_src, self.isstitch, self.cuda, self.verbose = vid_src, isstitch, cuda, verbose
|
|
||||||
self.config_name = config_name
|
|
||||||
|
|
||||||
# Initialize Sensor Configuration
|
# Initialize Sensor Configuration
|
||||||
self.get_config()
|
self.get_config()
|
||||||
@@ -71,8 +68,6 @@ class Sensor:
|
|||||||
ret, frame = self.cap.read()
|
ret, frame = self.cap.read()
|
||||||
if not ret:
|
if not ret:
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
if self.verbose:
|
|
||||||
print("Video source connected.")
|
|
||||||
|
|
||||||
# Initialize and calibrate
|
# Initialize and calibrate
|
||||||
self.__find_stitch_boxes(frame, show=False)
|
self.__find_stitch_boxes(frame, show=False)
|
||||||
@@ -82,23 +77,20 @@ class Sensor:
|
|||||||
print("Sensor initialized and calibrated.")
|
print("Sensor initialized and calibrated.")
|
||||||
|
|
||||||
# Initialize state variables
|
# Initialize state variables
|
||||||
self.stitch_valid = False
|
self.stitch_valid = self.imgupdate = self.vupdate = False
|
||||||
self.n_boxes = None
|
|
||||||
self.stitch_calibration = []
|
self.stitch_calibration = []
|
||||||
self.img = self.flow = self.normal = self.shear = self.force = self.depth = None
|
self.img = self.flow = self.normal = self.shear = self.force = self.depth = self.n_boxes = self.img_filtered = None
|
||||||
self.img_filtered = None # For temporal noise reduction
|
|
||||||
self.fnormal=self.fshearx=self.fsheary=self.ftor=0.0
|
self.fnormal=self.fshearx=self.fsheary=self.ftor=0.0
|
||||||
self.imgupdate = self.vupdate = False
|
|
||||||
|
|
||||||
# Logging state
|
# Logging state
|
||||||
self.last_log_time = time.time()
|
self.last_log_time = time.time()
|
||||||
self.fps = 0
|
self.fps = 0
|
||||||
|
|
||||||
if self.verbose:
|
if self.verbose:
|
||||||
print("Settings:")
|
print("Settings:" {self.config_name})
|
||||||
print(f" Video source: {vid_src}")
|
print(f" Video source: {vid_src}")
|
||||||
print(f" Stitch mode: {isstitch}")
|
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" Cupy available: {self.CUPY_AVAILABLE}")
|
||||||
print(f" OpenCV CUDA devices: {cv2.cuda.getCudaEnabledDeviceCount()}")
|
print(f" OpenCV CUDA devices: {cv2.cuda.getCudaEnabledDeviceCount()}")
|
||||||
|
|
||||||
@@ -128,6 +120,15 @@ class Sensor:
|
|||||||
self.config_index = self.config["camera"]["index"]
|
self.config_index = self.config["camera"]["index"]
|
||||||
self.config_pos_default = self.config["camera"]["pos_default"]
|
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):
|
def get_img(self):
|
||||||
"""
|
"""
|
||||||
Capture frame from video source, convert to grayscale, and perform stitching.
|
Capture frame from video source, convert to grayscale, and perform stitching.
|
||||||
|
|||||||
Reference in New Issue
Block a user