fix import
This commit is contained in:
+23
-22
@@ -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
|
||||
|
||||
|
||||
'''
|
||||
|
||||
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user