diff --git a/src/orisys/HHD.py b/src/orisys/HHD.py index f3c301b..8840b70 100644 --- a/src/orisys/HHD.py +++ b/src/orisys/HHD.py @@ -30,9 +30,9 @@ from scipy import signal, spatial # from .UnstructuredGrid import UnstructuredGrid # import matplotlib.pyplot as plt -# Try to import CuPy for GPU acceleration try: import cupy as cp + import cupyx.scipy.signal as cp_signal CUPY_AVAILABLE = True # Try to import CuPy streams for parallel execution @@ -65,6 +65,7 @@ try: except ImportError: cp = None + cp_signal = None CUPY_AVAILABLE = False STREAMS_AVAILABLE = False KERNEL_AVAILABLE = False @@ -130,14 +131,14 @@ class nHHD(object): print( 'div =', self.div.shape, self.div.min(), self.div.max()) print( 'curlw =', self.curlw.shape, self.curlw.min(), self.curlw.max()) - # compute potentials - self.nD = self.psolver.solve_gpu(self.div, verbose > 0) #1) - if verbose > 0: - print( 'nD =', self.nD.shape, self.nD.min(), self.nD.max()) + # # compute potentials + # self.nD = self.psolver.solve_gpu(self.div, verbose > 0) #1) + # if verbose > 0: + # print( 'nD =', self.nD.shape, self.nD.min(), self.nD.max()) - self.nRu = self.psolver.solve_gpu(self.curlw, verbose > 0) #1) - if verbose > 0: - print( 'nR =', self.nRu.shape, self.nRu.min(), self.nRu.max()) + # self.nRu = self.psolver.solve_gpu(self.curlw, verbose > 0) #1) + # if verbose > 0: + # print( 'nR =', self.nRu.shape, self.nRu.min(), self.nRu.max()) # compute fields as gradients of potentials self.d = self.mesh.gradient(self.nD) @@ -398,8 +399,8 @@ class nHHD(object): nRu_gpu = self._nRu_gpu # Use reduction kernels for better performance - # Compute Sn using L1 norm (sum of absolute values) - Sn = float(cp.linalg.norm(d_gpu.ravel(), ord=1)) + # Compute Sn as L1 sum directly on GPU (faster than linalg.norm for this case) + Sn = float(cp.sum(cp.abs(d_gpu))) # Compute Stx, Sty Stx = float(cp.sum(h_gpu[:, :, 0])) @@ -881,19 +882,19 @@ class StructuredGrid(object): # -------------------------------------------------------------------------- -import numpy -from scipy import signal, spatial -# from .timer import Timer +# import numpy +# from scipy import signal, spatial +# # from .timer import Timer -# Try to import CuPy for GPU acceleration -try: - import cupy as cp - import cupyx.scipy.signal as cp_signal - CUPY_AVAILABLE = True -except ImportError: - cp = None - cp_signal = None - CUPY_AVAILABLE = False +# # Try to import CuPy for GPU acceleration +# try: +# import cupy as cp +# import cupyx.scipy.signal as cp_signal +# CUPY_AVAILABLE = True +# except ImportError: +# cp = None +# cp_signal = None +# CUPY_AVAILABLE = False ''' @@ -1322,7 +1323,7 @@ class PoissonSolver(object): p_gpu *= self._gpu_cache['gdx_prod'] return p_gpu # Return CuPy array - + # def solve_gpu_batch(self, f_list, verbose=False): # """ diff --git a/src/orisys/sensor.py b/src/orisys/sensor.py index f5bf5b7..73479f9 100644 --- a/src/orisys/sensor.py +++ b/src/orisys/sensor.py @@ -177,17 +177,17 @@ class Sensor: # Start processing timing t_processing_start = time.perf_counter() - self.frame = frame.copy() - + # self.frame = frame.copy() + self.frame = frame # Extract and stitch tiles - self.stitcher.get_stitch_unit(frame) + # self.stitcher.get_stitch_unit(frame) self._extract_tiles(frame) img = np.ascontiguousarray(self.stitcher.stitch_rt_optimized()) self.img_size_raw = img.shape # Resize - img = cv2.resize(img, tuple(self._config_resolution_stitch), interpolation=cv2.INTER_CUBIC) + img = cv2.resize(img, tuple(self._config_resolution_stitch), interpolation=cv2.INTER_LINEAR) if self.mirror: img = cv2.flip(img, 1) @@ -201,7 +201,7 @@ class Sensor: self._fps = 1.0 / (time.perf_counter() - self.last_log_time) self.last_log_time = time.perf_counter() - return self.img.copy() + return None def detect_motion(self, threshold=4): if self.initial_img is None: