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

测试实现的效果:

相关推荐
Dillon Dong1 小时前
【风电控制】TI TMS320F28379D 双CPU架构解析与任务分布设计
嵌入式硬件·算法·变流器·风电控制
花酒锄作田4 小时前
[python]argparse 包在聊天机器人中的应用
python
NiceCloud喜云6 小时前
Opus 4.8 的 Effort Control 怎么选:Low 到 Max 五档策略
android·java·大数据·前端·c++·python·spring
小羊在睡觉6 小时前
力扣84. 柱状图中最大的矩形
后端·算法·leetcode·golang·go
3DVisionary7 小时前
蓝光三维扫描:医疗制造的精度焦虑怎么解
人工智能·算法·制造·蓝光三维扫描·医疗制造·三维检测·义齿检测
AI玫瑰助手7 小时前
Python函数:默认参数的定义与注意事项
开发语言·python·信息可视化
好评笔记7 小时前
机器学习面试八股——常用损失函数
人工智能·深度学习·算法·机器学习·校招
weixin_468466857 小时前
全局与局部注意力机制新手实战指南
人工智能·python·深度学习·算法·自然语言处理·transformer·注意力机制
深蓝学院7 小时前
小米世界模型也来了:重建+生成一体化,实现秒级仿真+实时预测!
自动驾驶·小米·世界模型
小糖学代码7 小时前
LLM系列:环境搭建:5.Python-dotenv 环境变量管理
人工智能·python·深度学习·神经网络