optical flow optimize done and cleaned

This commit is contained in:
unknown
2026-01-14 10:13:19 +08:00
parent 4d6bfb49ae
commit 721dccbab4
11 changed files with 120 additions and 108 deletions
-28
View File
@@ -1,28 +0,0 @@
{
"name": "prototype",
"version": "1.0",
"camera": {
"resolution_raw": [1920, 1080],
"fps": 60,
"units": 15,
"units_used": 9,
"resolution_stitch": [400, 400],
"index": [1,2,3,6,7,8,11,12,13],
"pos_default": [[260, 56], [577, 62], [897, 69], [1214, 75], [1530, 81], [256, 391], [570, 397], [889, 403], [1208, 409], [1523, 416], [248, 724], [563, 730], [882, 738], [1201, 743], [1516, 751]]
},
"stitcher": {
"min_area_frac": 0.01,
"max_area_frac": 0.05,
"max_aspect_ratio": 100
},
"contact": {
"min_contour_area": 3000,
"min_magnitude": 1.0,
"expansion_threshold": 0.01,
"contact_ds_factor": 10,
"kernel_size": [5,5],
"denoise_sigma": 15
}
}
+3 -1
View File
@@ -160,11 +160,13 @@ class Sensor:
Returns:
np.ndarray: Processed grayscale image
"""
t0 = time.perf_counter()
ret, frame = self.cap.read()
if not ret:
print("Failed to get_img from video source.")
return None
t1 = time.perf_counter()
print(f"read frame time: {t1 - t0} seconds")
# Convert to grayscale
gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
-6
View File
@@ -1,8 +1,5 @@
import cv2
import numpy as np
import cupy as cp
import time
class Tracker:
def __init__(self,
@@ -146,12 +143,9 @@ class Tracker:
self.__checkLoopClosure(frame)
# CPU optical flow computation
start_time = time.perf_counter()
self.__prev_fine_flow = self.__tracking_inst.calc(
self.__fine_base_frame_queue[-1], frame,
self.__prev_fine_flow)
end_time = time.perf_counter()
print(f"CPU optical flow computation time: {end_time - start_time} seconds")
# Direct numpy addition is faster than cv2.add
final_flow = self.__fine_flow_queue[-1] + self.__prev_fine_flow