diff --git a/config/prototype.json b/config/prototype.json index 187a8ea..ff0b9c0 100644 --- a/config/prototype.json +++ b/config/prototype.json @@ -6,14 +6,16 @@ "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]] + "resolution_stitch": [400, 400] }, "stitcher": { "min_area_frac": 0.018, "max_area_frac": 0.035, - "max_aspect_ratio": 20 + "max_aspect_ratio": 20, + "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]], + "margin": 10, + "nominal_ov_pos": 100 }, "contact": { "min_contour_area": 3000, diff --git a/example1_basic.py b/example1_basic.py index 28bb8a3..1ce3a87 100644 --- a/example1_basic.py +++ b/example1_basic.py @@ -28,7 +28,7 @@ def main(): # verbose: 是否打印详细初始化日志 # 方式1: 从视频文件读取 - sensor = orisys.Sensor("./s1.mp4", isstitch=True, cuda=False, verbose=True) + sensor = orisys.Sensor("./s1.mp4", isstitch=True, cuda=False, verbose=True,config_name="prototype") # 方式2: 从摄像头读取(取消注释使用) # sensor = orisys.Sensor(0, isstitch=True, cuda=True, verbose=True) diff --git a/src/orisys/Stitcher.py b/src/orisys/Stitcher.py index b6f0441..3f4d25b 100644 --- a/src/orisys/Stitcher.py +++ b/src/orisys/Stitcher.py @@ -6,11 +6,12 @@ import cv2 class Stitcher: - def __init__(self,isstitch=False, n=[3,3], index=np.array([1,2,3,6,7,8,11,12,13]), config_stitcher=None): + def __init__(self,isstitch=False, n=[3,3], config_stitcher=None,verbose=False): # Settings self.isstitch = isstitch self.config_stitcher = config_stitcher + self.verbose = verbose # Find Boxes Related self.min_area_frac = config_stitcher["min_area_frac"] self.max_area_frac = config_stitcher["max_area_frac"] @@ -19,16 +20,16 @@ class Stitcher: # stitch related self.stitch_valid = False self.boxes = self.units = None - self.index = index + self.index = config_stitcher["index"] self.stitch_calibration = self.tile_list = [] self.ncol = n[0] self.nrow = n[1] - self.nominal_ov_pos=100 - self.margin=10 + self.nominal_ov_pos=config_stitcher["nominal_ov_pos"] + self.margin=config_stitcher["margin"] self.bound=self.nominal_ov_pos - self.margin # for sensor 1 - self.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)] + self.pos_default = config_stitcher["pos_default"] def stitch_rt_optimized(self, change_sv=False, s_mean=28., v_mean=180.): tile_list = self.tile_list diff --git a/src/orisys/configs/prototype.json b/src/orisys/configs/prototype.json index 187a8ea..59e9393 100644 --- a/src/orisys/configs/prototype.json +++ b/src/orisys/configs/prototype.json @@ -1,29 +1,31 @@ { - "name": "prototype", - "version": "1.0", - "camera": { - "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]] - }, - "stitcher": { - "min_area_frac": 0.018, - "max_area_frac": 0.035, - "max_aspect_ratio": 20 - }, - "contact": { - "min_contour_area": 3000, - "flow_threshold":1, - "div_threshold":0.02, - "expansion_threshold": 0.01, - "downsample_factor": 1, - "kernel_size": [5,5], - "denoise_sigma": 15 - } + "name": "prototype", + "version": "1.0", + "camera": { + "resolution_raw": [1920, 1080], + "fps": 60, + "units": 15, + "units_used": 9, + "resolution_stitch": [400, 400] + }, + "stitcher": { + "min_area_frac": 0.018, + "max_area_frac": 0.035, + "max_aspect_ratio": 20, + "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]], + "margin": 10, + "nominal_ov_pos": 100 + }, + "contact": { + "min_contour_area": 3000, + "flow_threshold":1, + "div_threshold":0.02, + "expansion_threshold": 0.01, + "downsample_factor": 1, + "kernel_size": [5,5], + "denoise_sigma": 15 + } } diff --git a/src/orisys/sensor.py b/src/orisys/sensor.py index 460ea66..04c7d61 100644 --- a/src/orisys/sensor.py +++ b/src/orisys/sensor.py @@ -132,8 +132,8 @@ class Sensor: # Initialize components - self._stitcher = Stitcher(isstitch=isstitch, index=self.config_index, config_stitcher=self.config_stitcher) - self.tracker = Tracker(adaptive=True, cuda=cuda) + self._stitcher = Stitcher(isstitch=isstitch, config_stitcher=self.config_stitcher, verbose=self.verbose) + self.tracker = Tracker(adaptive=True, cuda=cuda, verbose=self.verbose) self.contact3d = Contact3D(config_contact=self.config_contact, verbose=self.verbose) self.hhd = None @@ -459,8 +459,8 @@ class Sensor: self.config_fps = cam["fps"] self.config_units = cam["units"] self.config_resolution_stitch = cam["resolution_stitch"] - self.config_index = cam["index"] - self.config_pos_default = cam["pos_default"] + # self.config_index = cam["index"] + # self.config_pos_default = cam["pos_default"] self.config_stitcher = self.config["stitcher"] self.config_contact = self.config["contact"] diff --git a/src/orisys/tracker.py b/src/orisys/tracker.py index 85a7f3a..88dcf27 100644 --- a/src/orisys/tracker.py +++ b/src/orisys/tracker.py @@ -12,13 +12,15 @@ class Tracker: lower_threshold=12.0, upper_threshold=18.0, loop_closure_interval=1, - dis_preset='medium'): + dis_preset='medium', + verbose=False): # Check if OpenCV is built with CUDA support if cuda and not cv2.cuda.getCudaEnabledDeviceCount(): # print("Warning: CUDA requested but OpenCV not built with CUDA support or no CUDA device found. Falling back to CPU.") cuda = False self.cuda = cuda + self.verbose = verbose self.__loop_closure_interval = loop_closure_interval self.__frame_count = 0