自动驾驶AVM环视算法--python版本的俯视TOP投影模式

c语言版本和算法原理的可以查看本人的其他文档。《自动驾驶AVM环视算法--全景的俯视图像和原图》本文档进用于展示部分代码的视线,获取方式网盘自行获取(非免费介意勿下载):链接: https://pan.baidu.com/s/1MJa8ZCEfNyLc5x0uVegtog 提取码: vskn 。

测试的环境:

以下是主运行函数的部分代码(仅供参考):

复制代码
import cv2 
from runTOP import * 

# 导入 MyClass 类  
from runTOP import avmobjData  

# 创建类的实例  
runTOP = avmobjData()  



F_open=True
B_open=True
L_open=True
R_open=True
F_video=cv2.VideoCapture("video/Front.avi")
if F_video.isOpened():
    F_ocpn,F_frame=F_video.read()
else:
    F_open=False
B_video=cv2.VideoCapture("video/Back.avi")
if B_video.isOpened():
    B_ocpn,B_frame=B_video.read()
else:
    B_open=False
L_video=cv2.VideoCapture("video/Left.avi")
if L_video.isOpened():
    L_ocpn,L_frame=L_video.read()
else:
    L_open=False
R_video=cv2.VideoCapture("video/Right.avi")
if R_video.isOpened():
    R_ocpn,R_frame=R_video.read()
else:
    R_open=False

CarImage = cv2.imread("top.png")  
print(F_open,B_open,L_open,R_open)
#初始化函数
new_width,new_height=runTOP.init(0)  
print("new_width,new_height",new_width,new_height)
resize_CarImage = cv2.resize(CarImage, (new_width, new_height))
cv2.imshow("resize_CarImage",resize_CarImage)
# 创建一个三通道的彩色图像(RGB),初始值为 0(黑色)  
Dstimg = np.zeros((JS_AVM_IMGH, JS_AVM_IMGW, 3), dtype=np.uint8) 
while F_open and B_open and L_open and R_open:
    F_ret,F_frame=F_video.read()
    B_ret,B_frame=B_video.read()
    L_ret,L_frame=L_video.read()
    R_ret,R_frame=R_video.read()
    if F_frame is None  or B_frame is None or L_frame is None or R_frame is None is None:
        break
    if F_ret==True and B_ret==True and L_ret==True and R_ret==True:
        runTOP.run(F_frame,B_frame,L_frame,R_frame,Dstimg,0)  
        runTOP.js_DrawCar(Dstimg,resize_CarImage,1)
        Dstimg=runTOP.drawTxt(Dstimg)
        cv2.imshow("avmTOP",Dstimg)
        if cv2.waitKey(25) & 0xFF==27:
            break
F_video.release()
B_video.release()
L_video.release()
R_video.release()
cv2.destroyAllWindows()

注:当前python的版本效率比较低,需要加速的可以自行优化加速代码,实现的过程是从C代码直接转换过来的,没有进行任何的优化加速。

测试实现的效果:

相关推荐
for_ever_love__26 分钟前
函数——参数、lambda、*args与作用域
python·函数·大模型开发·编程基础
东莞市云毅网络有限公司29 分钟前
企业资料时效性判定:Last-Modified、正文日期与版本字段三路交叉
python·sqlite·自动化运维·geo·数据监测
Query*29 分钟前
深入浅出LangGraph【一】_基础篇
python·ai·langchain
XiaoMaqqqq1 小时前
市面上正规的IP驱动产业新场景新工具哪家强
运维·python·网络协议·tcp/ip
ShyanZh2 小时前
【Python3基础】19-Socket 与 TCP、UDP 编程
python·网络协议·tcp/ip·udp
念何架构之路2 小时前
zap采样器与性能优化内幕
算法·性能优化·哈希算法
惊讶的猫2 小时前
工具选对之后还不够:商城 Agent 的参数与权限治理
开发语言·python
天赐范式2 小时前
天赐范式第186天:让方差开始自洽——Bulmer效应的闭式验证
python·数字生命·天赐范式·动态运行时·遗传方差·bulmer效应
泡茶喝茶写代码2 小时前
A股量化数据工程:从 REST 接口到策略信号(第 8 篇):成长能力因子:营收与利润增速
java·python·股票数据api·股票数据api接口·股票量化数据api·股票量化数据接口·股票数据api数据
晒太羊的猫3 小时前
hot100动态规划刷题
算法·动态规划