expose flow and hhd for benchmark
This commit is contained in:
+13
-5
@@ -20,7 +20,7 @@ def main():
|
|||||||
# cal_path为校准文件路径, 每一个设备需要创建/使用一个校准文件
|
# cal_path为校准文件路径, 每一个设备需要创建/使用一个校准文件
|
||||||
|
|
||||||
# 方式1: 从视频文件读取
|
# 方式1: 从视频文件读取
|
||||||
sensor = orisys.Sensor("s1.mp4", config_name="./config/prototype_of3.json", cal_path= "./config/dd01a_0.npy", isstitch=True, cuda=False, verbose=True, poisson_backend='opencl')
|
sensor = orisys.Sensor("s1_480p.mp4", config_name="./config/prototype_of3_480p.json", cal_path= "./config/dd01a_0_480p.npy", isstitch=True, cuda=False, verbose=True, poisson_backend='cpu')
|
||||||
|
|
||||||
# 方式2: 从摄像头读取(取消注释使用)
|
# 方式2: 从摄像头读取(取消注释使用)
|
||||||
# sensor = orisys.Sensor(0, config_name="./config/prototype_of3.json", cal_path= "./config/cal.npy", isstitch=True, cuda=True, verbose=True)
|
# sensor = orisys.Sensor(0, config_name="./config/prototype_of3.json", cal_path= "./config/cal.npy", isstitch=True, cuda=True, verbose=True)
|
||||||
@@ -39,9 +39,17 @@ def main():
|
|||||||
# print("motion detected")
|
# print("motion detected")
|
||||||
# 步骤 2.2: 计算形变场 (必要步骤)
|
# 步骤 2.2: 计算形变场 (必要步骤)
|
||||||
start_time = time.perf_counter()
|
start_time = time.perf_counter()
|
||||||
sensor.compute_deformation()
|
sensor.compute_flow()
|
||||||
|
|
||||||
end_time = time.perf_counter()
|
end_time = time.perf_counter()
|
||||||
compute_deformation_time = end_time - start_time
|
compute_flow_time = end_time - start_time
|
||||||
|
|
||||||
|
start_time = time.perf_counter()
|
||||||
|
sensor.compute_hhd()
|
||||||
|
|
||||||
|
end_time = time.perf_counter()
|
||||||
|
compute_hhd_time = end_time - start_time
|
||||||
|
|
||||||
# 步骤 2.3: 计算触碰点
|
# 步骤 2.3: 计算触碰点
|
||||||
start_time = time.perf_counter()
|
start_time = time.perf_counter()
|
||||||
sensor.compute_contact()
|
sensor.compute_contact()
|
||||||
@@ -98,8 +106,8 @@ def main():
|
|||||||
capture_time = sensor._last_capture_time
|
capture_time = sensor._last_capture_time
|
||||||
processing_time = sensor._last_processing_time
|
processing_time = sensor._last_processing_time
|
||||||
|
|
||||||
total_time = get_img_time + compute_deformation_time + compute_contact_time + read_info_time + display_time
|
total_time = get_img_time + compute_flow_time + compute_hhd_time + compute_contact_time + read_info_time + display_time
|
||||||
print(f"get_img: {get_img_time*1000:.2f}ms (capture: {capture_time*1000:.2f}ms, processing: {processing_time*1000:.2f}ms), deformation: {compute_deformation_time*1000:.2f}ms, contact: {compute_contact_time*1000:.2f}ms, read: {read_info_time*1000:.2f}ms, display: {display_time*1000:.2f}ms, total: {total_time*1000:.2f}ms")
|
print(f"get_img: {get_img_time*1000:.2f}ms (capture: {capture_time*1000:.2f}ms, processing: {processing_time*1000:.2f}ms), flow: {compute_flow_time*1000:.2f}ms,hhd: {compute_hhd_time*1000:.2f}ms, contact: {compute_contact_time*1000:.2f}ms, read: {read_info_time*1000:.2f}ms, display: {display_time*1000:.2f}ms, total: {total_time*1000:.2f}ms")
|
||||||
|
|
||||||
#步骤 3.5: 键盘控制
|
#步骤 3.5: 键盘控制
|
||||||
key = cv2.waitKey(1) & 0xFF
|
key = cv2.waitKey(1) & 0xFF
|
||||||
|
|||||||
+2
-2
@@ -1628,7 +1628,7 @@ class PoissonSolver(object):
|
|||||||
Batched OpenCL Poisson solver for two 2D fields.
|
Batched OpenCL Poisson solver for two 2D fields.
|
||||||
Optimized: scatter H2D (~4x smaller transfer), fused multiply
|
Optimized: scatter H2D (~4x smaller transfer), fused multiply
|
||||||
(reads g_fft once), async D2H (one sync instead of two).
|
(reads g_fft once), async D2H (one sync instead of two).
|
||||||
When profile=True, records and optionally prints per-stage timings.
|
When profile=False, records and optionally prints per-stage timings.
|
||||||
"""
|
"""
|
||||||
if not OPENCL_AVAILABLE:
|
if not OPENCL_AVAILABLE:
|
||||||
if verbose:
|
if verbose:
|
||||||
@@ -1818,7 +1818,7 @@ class PoissonSolver(object):
|
|||||||
# """
|
# """
|
||||||
# OpenCL Poisson solver using pyvkfft FFT convolution.
|
# OpenCL Poisson solver using pyvkfft FFT convolution.
|
||||||
# Replaces scipy.signal.fftconvolve(..., mode='same') for structured grids.
|
# Replaces scipy.signal.fftconvolve(..., mode='same') for structured grids.
|
||||||
# When profile=True, records and optionally prints per-stage timings.
|
# When profile=False, records and optionally prints per-stage timings.
|
||||||
# """
|
# """
|
||||||
# if not OPENCL_AVAILABLE:
|
# if not OPENCL_AVAILABLE:
|
||||||
# if verbose:
|
# if verbose:
|
||||||
|
|||||||
@@ -210,13 +210,13 @@ class Sensor:
|
|||||||
if self.img is None:
|
if self.img is None:
|
||||||
raise Exception("Warning: Get image first")
|
raise Exception("Warning: Get image first")
|
||||||
|
|
||||||
self.__compute_flow()
|
self.compute_flow()
|
||||||
if decompose:
|
if decompose:
|
||||||
self.__compute_hhd()
|
self.compute_hhd()
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def __compute_flow(self):
|
def compute_flow(self):
|
||||||
if self.img is None:
|
if self.img is None:
|
||||||
raise Exception("Warning: Get image first")
|
raise Exception("Warning: Get image first")
|
||||||
|
|
||||||
@@ -226,7 +226,7 @@ class Sensor:
|
|||||||
flow = flow.download()
|
flow = flow.download()
|
||||||
self.flow = flow
|
self.flow = flow
|
||||||
|
|
||||||
def __compute_hhd(self):
|
def compute_hhd(self):
|
||||||
|
|
||||||
flow = self.flow
|
flow = self.flow
|
||||||
if flow is None:
|
if flow is None:
|
||||||
|
|||||||
Reference in New Issue
Block a user