自动驾驶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代码直接转换过来的,没有进行任何的优化加速。

测试实现的效果:

相关推荐
地平线开发者9 小时前
J6B vio scenario sample
算法
SelectDB15 小时前
Apache Doris Python UDF:让 SQL 直接调用 Python 生态,支撑 Agent 时代复杂业务逻辑
大数据·数据库·python
BothSavage21 小时前
Trae远程开发中DeepSeek自定义模型4054错误的排查与修复
算法
小林ixn21 小时前
从暴力到KMP:一道题彻底搞懂字符串匹配的前世今生
算法
烬羽1 天前
字符串算法入门:从反转字符串到回文判断,面试不再慌
算法·面试
荣码1 天前
GraphRAG:普通RAG只能回答"点"的问题,我踩了4个坑才搞懂
java·python
金銀銅鐵1 天前
[Python] 基于欧几里得算法,实现分数约分计算器
python·数学
Lyn_Li1 天前
Kaggle Top 5 | 198只股票、200条数据的金融预测——BattleFin高分方案从零复现
python·kaggle·比赛复盘·金融预测
冬奇Lab1 天前
每日一个开源项目(第146篇):openpilot - 开源自动驾驶辅助系统,曾在 Consumer Reports 评测中超过特斯拉 Autopilot
人工智能·开源·自动驾驶