update
This commit is contained in:
+29
-11
@@ -4,7 +4,7 @@ import cv2
|
||||
import orisys
|
||||
import numpy as np
|
||||
import time
|
||||
|
||||
import argparse
|
||||
import pyqtgraph as pg
|
||||
|
||||
def create_plot():
|
||||
@@ -90,22 +90,40 @@ for i in range(3):
|
||||
|
||||
def main():
|
||||
global start_time
|
||||
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument("--video","-v", type=str, default="0", help="Camera ID / Video file path")
|
||||
parser.add_argument("--config","-c", type=str, default="./config/ddjx01.json", help="Configuration file path")
|
||||
parser.add_argument("--cal","-cal", type=str, default="./config/ddjx01.npy", help="Calibration file path")
|
||||
parser.add_argument("--verbose","-verbose", type=bool, default=True, help="Print detailed information")
|
||||
args = parser.parse_args()
|
||||
|
||||
# 步骤1:创建传感器对象 (必要步骤),
|
||||
# config_name为配置文件名(内置配置文件名)或路径(自定义配置文件路径)
|
||||
# cal_path为校准文件路径, 每一个设备需要创建/使用一个校准文件
|
||||
|
||||
# 方式1: 从视频文件读取
|
||||
try:
|
||||
input = int(args.video)
|
||||
is_camera = True
|
||||
sensor = orisys.Sensor(input, config_name=args.config, cal_path= args.cal, verbose=args.verbose)
|
||||
except:
|
||||
is_camera = False
|
||||
sensor = orisys.Sensor(args.video, config_name=args.config, cal_path= args.cal, verbose=args.verbose)
|
||||
# 打开视频
|
||||
# sensor1 = Sensor("./s1.mp4",isstitch=True,cuda = True,verbose = True)
|
||||
# 方式1: 从视频文件读取
|
||||
sensor1 = orisys.Sensor(8, config_name="./config/ddjx01.json", cal_path= "./config/ddjx01.npy", cuda=False, verbose=True)
|
||||
# sensor1 = orisys.Sensor("./s1.mp4", config_name="./config/ddjx01.json", cal_path= "./config/ddjx01.npy", cuda=False, verbose=True)
|
||||
|
||||
start_time = time.time()
|
||||
is_save = False
|
||||
frame_count = 0
|
||||
writer = None
|
||||
while True:
|
||||
sensor1.get_img() # 提取并拼接复眼图像
|
||||
sensor.get_img() # 提取并拼接复眼图像
|
||||
|
||||
if is_save and writer is not None and sensor1.frame is not None:
|
||||
if is_save and writer is not None and sensor.frame is not None:
|
||||
frame_count += 1
|
||||
save_img = sensor1.frame
|
||||
save_img = sensor.frame
|
||||
|
||||
# Convert grayscale (1 channel) to BGR (3 channels) if needed
|
||||
if len(save_img.shape) == 2 or (len(save_img.shape) == 3 and save_img.shape[2] == 1):
|
||||
@@ -115,15 +133,15 @@ def main():
|
||||
|
||||
writer.write(save_img)
|
||||
|
||||
sensor1.compute_deformation(check_motion=False) # 计算形变和分解
|
||||
sensor.compute_deformation(check_motion=False) # 计算形变和分解
|
||||
# 提取信息:
|
||||
# 向量场: VRAW, VNORMAL, VSHEAR: 原始,法向,切向
|
||||
# 帧率,时间戳: FPS, TIMESTAMP
|
||||
# 变形量总和: FNORMAL , FSHEARX, FSHEARY : 法向,切向(X),切向(Y)
|
||||
fps, fn, fx, fy, flow = sensor1.read_info(sensor1.info.FPS, sensor1.info.FNORMAL, sensor1.info.FSHEARX, sensor1.info.FSHEARY, sensor1.info.VRAW)
|
||||
fps, fn, fx, fy, flow, vnormal, vshear = sensor.read_info(sensor.info.FPS, sensor.info.FNORMAL, sensor.info.FSHEARX, sensor.info.FSHEARY, sensor.info.VRAW, sensor.info.VNORMAL,sensor.info.VSHEAR)
|
||||
print(fps,fn,fx,fy)
|
||||
# 显示向量场
|
||||
arrows = orisys.util.draw_arrows(sensor1.img, flow, threshold=5, grid_spacing=10, arrow_scale=1.0)
|
||||
arrows = orisys.util.draw_arrows(sensor.img, flow, threshold=5, grid_spacing=10, arrow_scale=1.0)
|
||||
cv2.imshow("Deformation", arrows)
|
||||
# 显示深度图
|
||||
mag = draw_magnitude_map(flow)
|
||||
@@ -149,7 +167,7 @@ def main():
|
||||
# Ensure directory exists
|
||||
os.makedirs(os.path.dirname(save_path), exist_ok=True)
|
||||
# Get frame dimensions from the actual frame
|
||||
save_img = sensor1.frame
|
||||
save_img = sensor.frame
|
||||
|
||||
if save_img is not None:
|
||||
# Convert grayscale (1 channel) to BGR (3 channels) if needed for dimension check
|
||||
@@ -180,7 +198,7 @@ def main():
|
||||
print(f"Stop writing, total frames: {frame_count}")
|
||||
frame_count = 0
|
||||
|
||||
sensor1.disconnect() # 断开传感器连接
|
||||
sensor.disconnect() # 断开传感器连接
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user