add debug option

This commit is contained in:
bluepulsar
2026-03-01 20:42:12 +08:00
parent 1e3751c388
commit c95e810e87
5 changed files with 27 additions and 317 deletions
+5 -4
View File
@@ -51,7 +51,8 @@ class nHHD(object):
backend = 'cpu'
elif backend == 'opencl' and not OPENCL_AVAILABLE:
backend = 'cpu'
self.debug = kwargs.get('debug', False)
self.poisson_backend = backend
# Initialize CUDA streams for cupy backend
@@ -103,7 +104,7 @@ class nHHD(object):
Dispatch Poisson solve using the selected backend.
"""
if self.poisson_backend == 'opencl':
return self.psolver.solve_opencl(field, verbose, profile=True)
return self.psolver.solve_opencl(field, verbose, profile=self.debug)
if self.poisson_backend == 'cupy':
return self.psolver.solve_gpu(field, verbose)
@@ -136,7 +137,7 @@ class nHHD(object):
# compute potentials
if self.poisson_backend == 'opencl' and ('OPENCL_AVAILABLE' in globals() and OPENCL_AVAILABLE):
self.nD, self.nRu = self.psolver.solve_opencl_batch2(self.div, self.curlw, verbose > 0, profile=True)
self.nD, self.nRu = self.psolver.solve_opencl_batch2(self.div, self.curlw, verbose > 0, profile=self.debug)
else:
self.nD = self._solve_poisson_backend(self.div, verbose > 0)
self.nRu = self._solve_poisson_backend(self.curlw, verbose > 0)
@@ -1655,7 +1656,7 @@ class PoissonSolver(object):
return full_conv[slices]
def solve_opencl_batch2(self, f1, f2, verbose=False, profile=True):
def solve_opencl_batch2(self, f1, f2, verbose=False, profile=False):
"""
Batched OpenCL Poisson solver for two 2D fields.
Optimized: scatter H2D (~4x smaller transfer), fused multiply
+4 -3
View File
@@ -59,7 +59,7 @@ class Sensor:
# Initialization
# =========================================================================
def __init__(self, vid_src, cuda=True, isstitch=True, verbose=True,
def __init__(self, vid_src, cuda=True, isstitch=True, verbose=True, debug=False,
config_name="prototype", cal_path=None, override=False, box=None, mirror=True, poisson_backend='auto'):
"""
Initialize Sensor with video source and configuration.
@@ -86,6 +86,7 @@ class Sensor:
self.isstitch = isstitch
self.cuda = cuda
self.verbose = verbose
self.debug = debug
self.config_name = config_name
self.cal_path = cal_path
self.mirror = mirror
@@ -130,7 +131,7 @@ class Sensor:
# Initialize components
self.stitcher = Stitcher(isstitch=isstitch, config_stitcher=self.__config_stitcher, verbose=self.verbose)
self.__tracker = Tracker(adaptive=True, cuda=cuda, verbose=self.verbose, dis_preset=self._config_dis_preset, config_tracker=self.__config_tracker)
self.__tracker = Tracker(adaptive=True, cuda=cuda, verbose=self.verbose, config_tracker=self.__config_tracker)
self.__contact3d = Contact3D(config_contact=self.__config_contact, verbose=self.verbose)
self.__hhd = None
self.poisson_backend = poisson_backend
@@ -252,7 +253,7 @@ class Sensor:
# Initialize HHD solver
if self.__hhd is None:
self.__hhd = nHHD(cuda=self.cuda, grid=flow.shape[:2], spacings=(18, 18), poisson_backend=self.poisson_backend)
self.__hhd = nHHD(cuda=self.cuda, grid=flow.shape[:2], spacings=(18, 18), poisson_backend=self.poisson_backend, debug=self.debug)
# Force computation
# When OpenCL backend is selected, use host force path to ensure
+1 -1
View File
@@ -11,7 +11,7 @@ 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():