add override option
This commit is contained in:
Binary file not shown.
|
Before Width: | Height: | Size: 2.1 MiB After Width: | Height: | Size: 2.0 MiB |
+8
-1
@@ -8,10 +8,17 @@ import numpy as np
|
|||||||
def main():
|
def main():
|
||||||
global start_time
|
global start_time
|
||||||
|
|
||||||
|
box = []
|
||||||
|
dx = 90
|
||||||
|
dy = -95
|
||||||
|
for i in range(15):
|
||||||
|
box.append((410+dx, 900+dy, 620+dx, 1110+dy))
|
||||||
# 打开视频
|
# 打开视频
|
||||||
sensor1 = Sensor("./s1.mp4",isstitch=True,cuda = True,verbose = True)
|
sensor1 = Sensor("./uv_2.mp4",isstitch=False,cuda = True,verbose = True, override=True, box=box)
|
||||||
# 打开摄像头
|
# 打开摄像头
|
||||||
# sensor1 = Sensor(0,isstitch=True,cuda = True,verbose = True)
|
# sensor1 = Sensor(0,isstitch=True,cuda = True,verbose = True)
|
||||||
|
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
sensor1.get_img() # 提取并拼接复眼图像
|
sensor1.get_img() # 提取并拼接复眼图像
|
||||||
sensor1.compute_deformation() # 计算形变和分解
|
sensor1.compute_deformation() # 计算形变和分解
|
||||||
|
|||||||
@@ -473,7 +473,7 @@ class Stitcher:
|
|||||||
n_boxes = len(boxes)
|
n_boxes = len(boxes)
|
||||||
bk_thresh += bk_thresh_step
|
bk_thresh += bk_thresh_step
|
||||||
|
|
||||||
# print("Detected {} candidate boxes with bk_thresh={}".format(n_boxes, bk_thresh - bk_thresh_step))
|
print("Detected {} candidate boxes with bk_thresh={}".format(n_boxes, bk_thresh - bk_thresh_step))
|
||||||
if n_boxes == 0:
|
if n_boxes == 0:
|
||||||
self.boxes = []
|
self.boxes = []
|
||||||
return n_boxes
|
return n_boxes
|
||||||
|
|||||||
+14
-5
@@ -19,7 +19,7 @@ class Sensor:
|
|||||||
Sensor helper that can decompose optical flow via Fourier methods.
|
Sensor helper that can decompose optical flow via Fourier methods.
|
||||||
Stores the decomposed components and global norms as attributes after compute().
|
Stores the decomposed components and global norms as attributes after compute().
|
||||||
"""
|
"""
|
||||||
def __init__(self, vid_src, isstitch=False, verbose=True, cuda=True):
|
def __init__(self, vid_src, isstitch=False, verbose=True, cuda=True, override=False, box=None):
|
||||||
"""
|
"""
|
||||||
Initialize Sensor with video source and configuration.
|
Initialize Sensor with video source and configuration.
|
||||||
|
|
||||||
@@ -70,13 +70,22 @@ class Sensor:
|
|||||||
if self.verbose:
|
if self.verbose:
|
||||||
print("Video source connected.")
|
print("Video source connected.")
|
||||||
|
|
||||||
# Initialize and calibrate
|
if override:
|
||||||
self.__find_stitch_boxes(frame, show=False)
|
if box is not None:
|
||||||
self.__get_tiles(frame)
|
self.__stitcher.boxes = box
|
||||||
self.stitch_cal()
|
else:
|
||||||
|
print("Override is True but no box provided.")
|
||||||
|
else:
|
||||||
|
# Initialize and calibrate
|
||||||
|
self.__find_stitch_boxes(frame, show=False)
|
||||||
|
self.__get_tiles(frame)
|
||||||
|
self.stitch_cal()
|
||||||
if self.verbose:
|
if self.verbose:
|
||||||
print("Sensor initialized and calibrated.")
|
print("Sensor initialized and calibrated.")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Initialize state variables
|
# Initialize state variables
|
||||||
self.stitch_valid = False
|
self.stitch_valid = False
|
||||||
self.n_boxes = None
|
self.n_boxes = None
|
||||||
|
|||||||
Reference in New Issue
Block a user