46 lines
1.6 KiB
Python
46 lines
1.6 KiB
Python
import os
|
|
os.environ["OPENCV_VIDEOIO_MSMF_ENABLE_HW_TRANSFORMS"] = "0"
|
|
import cv2
|
|
import orisys
|
|
|
|
def main():
|
|
global start_time
|
|
|
|
box = []
|
|
dx = 90
|
|
dy = -95
|
|
for i in range(15):
|
|
box.append((410+dx, 900+dy, 620+dx, 1110+dy))
|
|
# 打开视频,手动设置box 的坐标
|
|
sensor1 = orisys.Sensor("./s1.mp4",isstitch=False,cuda = True,verbose = True, override=True, box=box)
|
|
# sensor1 = orisys.Sensor("./uv_2.mp4",isstitch=True,cuda = True,verbose = True, override=True, box=box)
|
|
# 打开摄像头
|
|
# sensor1 = Sensor(0,isstitch=True,cuda = True,verbose = True)
|
|
|
|
|
|
while True:
|
|
sensor1.get_img() # 提取并拼接复眼图像
|
|
sensor1.compute_deformation() # 计算形变和分解
|
|
# 提取信息:
|
|
# 向量场: 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)
|
|
print(fps,fn,fx,fy)
|
|
# 显示向量场
|
|
arrows = orisys.util.draw_arrows(sensor1.img, flow, threshold=5, grid_spacing=40, arrow_scale=1.0)
|
|
cv2.imshow("Deformation", arrows)
|
|
|
|
key = cv2.waitKey(1)
|
|
if key & 0xFF == ord("q"):
|
|
print("\n 停止程序")
|
|
break
|
|
if key & 0xFF == ord("r"):
|
|
sensor1.reset()
|
|
|
|
sensor1.disconnect() # 断开传感器连接
|
|
|
|
|
|
if __name__ == '__main__':
|
|
main()
|