代码拉取完成,页面将自动刷新
同步操作将从 zhanghao/surround-view-system-introduction 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
import os
import cv2
from surround_view import CaptureThread, CameraProcessingThread
from surround_view import FisheyeCameraModel, BirdView
from surround_view import MultiBufferManager, ProjectedImageBuffer
import surround_view.param_settings as settings
yamls_dir = os.path.join(os.getcwd(), "yaml")
camera_ids = [4, 3, 5, 6]
flip_methods = [0, 2, 0, 2]
names = settings.camera_names
cameras_files = [os.path.join(yamls_dir, name + ".yaml") for name in names]
camera_models = [FisheyeCameraModel(camera_file, name) for camera_file, name in zip(cameras_files, names)]
def main():
capture_tds = [CaptureThread(camera_id, flip_method)
for camera_id, flip_method in zip(camera_ids, flip_methods)]
capture_buffer_manager = MultiBufferManager()
for td in capture_tds:
capture_buffer_manager.bind_thread(td, buffer_size=8)
if (td.connect_camera()):
td.start()
proc_buffer_manager = ProjectedImageBuffer()
process_tds = [CameraProcessingThread(capture_buffer_manager,
camera_id,
camera_model)
for camera_id, camera_model in zip(camera_ids, camera_models)]
for td in process_tds:
proc_buffer_manager.bind_thread(td)
td.start()
birdview = BirdView(proc_buffer_manager)
birdview.load_weights_and_masks("./weights.png", "./masks.png")
birdview.start()
while True:
img = cv2.resize(birdview.get(), (300, 400))
cv2.imshow("birdview", img)
key = cv2.waitKey(1) & 0xFF
if key == ord("q"):
break
for td in capture_tds:
print("camera {} fps: {}\n".format(td.device_id, td.stat_data.average_fps), end="\r")
for td in process_tds:
print("process {} fps: {}\n".format(td.device_id, td.stat_data.average_fps), end="\r")
print("birdview fps: {}".format(birdview.stat_data.average_fps))
for td in process_tds:
td.stop()
for td in capture_tds:
td.stop()
td.disconnect_camera()
if __name__ == "__main__":
main()
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。