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