注册

自动驾驶AVM环视算法–超广角模式/转向模式/3D碗型投影模式/窄边模式/车轮模式等的实现

全功能展示

截图

视频

https://www.bilibili.com/video/BV12t421P77X?t=3.2

AVM全景的多视图模式–各功能合集

1、AVM全景的多视图模式–碗型投影任意角度旋转展示

算法的原理:主要是是根据四个相机内外参数拼接图像,并将显示的结果图像投影到3D的碗型投影曲面。

主要的实现代码如下所示

    //设置输出显示的视频分辨率
	IplImage* img_AVM_WAN = cvCreateImage(cvSize(1280, 1440), 8, 3);
	//读取测试图片
	IplImage* img_F = cvLoadImage("Front.png");
	IplImage* img_B = cvLoadImage("Back.png");
	IplImage* img_L = cvLoadImage("Left.png");
	IplImage* img_R = cvLoadImage("Right.png");
	//设置输出视频分辨率和帧率
	CvVideoWriter* writer = cvCreateVideoWriter("G:\\CSDN\\AVM\\Video1\\Wan_Angle.avi", CV_FOURCC('X', 'V', 'I', 'D'), 25, cvSize(1280, 1440));
	//定义参数结构体
	js_AVM_obj AVMData_WAN;
	//初始化虚拟相机的角度参数
	AVMData_WAN.A_rx = 120; //[72 114]
	AVMData_WAN.A_ry = 0;//[0 360]
	AVMData_WAN.A_rz = 0;//[-20 20]
	//设置当前的运行步骤
	int stept_index = 0;
	while (1)
	{
		//初始化
		js_init_avm_pic(&AVMData_WAN, img_AVM_WAN->width, img_AVM_WAN->height, 1);
		//运行函数
		js_getAVM_TOP(&AVMData_WAN, img_AVM_WAN->imageData, img_F->imageData, img_B->imageData, img_L->imageData, img_R->imageData, img_F->width, img_F->height, img_AVM_WAN->width, img_AVM_WAN->height, img_AVM_WAN->nChannels, 1);
 
		//角度调整实现输出任意角度的视图
		switch (stept_index)
		{
		case 0://x轴
			AVMData_WAN.A_rx = AVMData_WAN.A_rx - 1;
			if (AVMData_WAN.A_rx == 70)
			{
				stept_index = 1;
				AVMData_WAN.A_ry = 0;
			}
			break;
		case 1://y轴
			AVMData_WAN.A_ry = AVMData_WAN.A_ry + 1;
			if (AVMData_WAN.A_ry == 450)
			{
				stept_index = 2;
				AVMData_WAN.A_rx = 90;
				AVMData_WAN.A_rz = -20;
			}
			break;
		case 2://z轴
			AVMData_WAN.A_rz = AVMData_WAN.A_rz + 1;
			if (AVMData_WAN.A_rz == 20)
			{
				stept_index = 3;
			}
			break;
		default:
			break;
		}
		if (stept_index == 3)break;
 
 
		cvShowImage("img", img_AVM_WAN);
 
		cvWriteFrame(writer, img_AVM_WAN);
		cvWaitKey(10);
 
		free(AVMData_WAN.Ftable);
		free(AVMData_WAN.Btable);
		free(AVMData_WAN.Ltable);
		free(AVMData_WAN.Rtable);
 
	}
 
	cvReleaseVideoWriter(&writer);
	cvWaitKey(0);

测试结果视频

https://www.bilibili.com/video/BV1Xm421j7hF?t=2.0

2、AVM全景的后视模式–倒车模式

主要的功能:在启动倒车后输出后视的视图,用观察车辆后方是否安全。

主函数的测试代码

//设置输出显示的视频分辨率
	IplImage* img_AVM_FBLR = cvCreateImage(cvSize(1280, 1440), 8, 3);
	//设置输出视频分辨率和帧率
	CvVideoWriter* writer = cvCreateVideoWriter("G:\\CSDN\\AVM\\Video1\\FBLR_B.avi", CV_FOURCC('X', 'V', 'I', 'D'), 25, cvSize(1280, 1440));
	cvNamedWindow("视频播放", CV_WINDOW_AUTOSIZE);
	//读取测试视频
	CvCapture* C_img_F = cvCreateFileCapture("G:\\CSDN\\AVM\\Video1\\Front.avi");
	CvCapture* C_img_B = cvCreateFileCapture("G:\\CSDN\\AVM\\Video1\\Back.avi");
	CvCapture* C_img_L = cvCreateFileCapture("G:\\CSDN\\AVM\\Video1\\Left.avi");
	CvCapture* C_img_R = cvCreateFileCapture("G:\\CSDN\\AVM\\Video1\\Right.avi");
	IplImage* img_F, * img_B, * img_L, * img_R;
	//定义参数结构体
	js_AVM_obj  AVMData_FBLR;
	//初始化
	js_init_avm_FBLR(&AVMData_FBLR, img_AVM_FBLR->width, img_AVM_FBLR->height, 1);//B
 
	img_F = cvQueryFrame(C_img_F);
	img_B = cvQueryFrame(C_img_B);
	img_L = cvQueryFrame(C_img_L);
	img_R = cvQueryFrame(C_img_R);
	int num = 0;
	while (img_F = cvQueryFrame(C_img_F))
	{
		img_B = cvQueryFrame(C_img_B);
		img_L = cvQueryFrame(C_img_L);
		img_R = cvQueryFrame(C_img_R);
		//运行函数
		js_getAVM_FBLR(&AVMData_FBLR, img_AVM_FBLR->imageData, img_F->imageData, img_B->imageData, img_L->imageData, img_R->imageData, img_F->width, img_F->height, img_AVM_FBLR->width, img_AVM_FBLR->height, img_AVM_FBLR->nChannels, 1);
		
		cvWriteFrame(writer, img_AVM_FBLR);
 
 
		cvShowImage("视频播放", img_AVM_FBLR);
		char c = cvWaitKey(1);
		if (c == 27)break;
		num++;
	}
	cvReleaseVideoWriter(&writer);
	cvReleaseCapture(&C_img_F);
	cvReleaseCapture(&C_img_B);
	cvReleaseCapture(&C_img_L);
	cvReleaseCapture(&C_img_R);
	cvDestroyWindow("视频播放");

测试结果视频(由于当前的测试视频不是倒车的视频,所以视频及用于展示视角)

https://www.bilibili.com/video/BV1LJ4m1W7fZ?t=102.9

3、AVM全景的左转弯模式–左转向模式

主要的功能:在启动转向后输出转向左视的视图,用观察车辆左方是否安全。

主函数的测试代码

IplImage* img_AVM_FBLR = cvCreateImage(cvSize(1280, 1440), 8, 3);
	CvVideoWriter* writer = cvCreateVideoWriter("G:\\CSDN\\AVM\\Video1\\FBLR_L.avi", CV_FOURCC('X', 'V', 'I', 'D'), 25, cvSize(1280, 1440));
	cvNamedWindow("视频播放", CV_WINDOW_AUTOSIZE);
	CvCapture* C_img_F = cvCreateFileCapture("G:\\CSDN\\AVM\\Video1\\Front.avi");
	CvCapture* C_img_B = cvCreateFileCapture("G:\\CSDN\\AVM\\Video1\\Back.avi");
	CvCapture* C_img_L = cvCreateFileCapture("G:\\CSDN\\AVM\\Video1\\Left.avi");
	CvCapture* C_img_R = cvCreateFileCapture("G:\\CSDN\\AVM\\Video1\\Right.avi");
	IplImage* img_F, * img_B, * img_L, * img_R;
	js_AVM_obj AVMData_FBLR;
 
	js_init_avm_FBLR(&AVMData_FBLR, img_AVM_FBLR->width, img_AVM_FBLR->height, 2);//L
 
	img_F = cvQueryFrame(C_img_F);
	img_B = cvQueryFrame(C_img_B);
	img_L = cvQueryFrame(C_img_L);
	img_R = cvQueryFrame(C_img_R);
	int num = 0;
	while (img_F = cvQueryFrame(C_img_F))
	{
		img_B = cvQueryFrame(C_img_B);
		img_L = cvQueryFrame(C_img_L);
		img_R = cvQueryFrame(C_img_R);
		js_getAVM_FBLR(&AVMData_FBLR, img_AVM_FBLR->imageData, img_F->imageData, img_B->imageData, img_L->imageData, img_R->imageData, img_F->width, img_F->height, img_AVM_FBLR->width, img_AVM_FBLR->height, img_AVM_FBLR->nChannels, 1);
 
		cvWriteFrame(writer, img_AVM_FBLR);
 
 
		cvShowImage("视频播放", img_AVM_FBLR);
		char c = cvWaitKey(1);
		if (c == 27)break;
		num++;
	}
	cvReleaseVideoWriter(&writer);
	cvReleaseCapture(&C_img_F);
	cvReleaseCapture(&C_img_B);
	cvReleaseCapture(&C_img_L);
	cvReleaseCapture(&C_img_R);
	cvDestroyWindow("视频播放");

测试结果视频

https://www.bilibili.com/video/BV1AM4m1Q71n?t=1.3

4、AVM全景的后视模式–行车模式

主要的功能:在行车状态下的前视的视图,用观察车辆前方是否安全。

主函数的测试代码

IplImage* img_AVM_FBLR = cvCreateImage(cvSize(1280, 1440), 8, 3);
	CvVideoWriter* writer = cvCreateVideoWriter("G:\\CSDN\\AVM\\Video1\\FBLR_F.avi", CV_FOURCC('X', 'V', 'I', 'D'), 25, cvSize(1280, 1440));
	cvNamedWindow("视频播放", CV_WINDOW_AUTOSIZE);
	CvCapture* C_img_F = cvCreateFileCapture("G:\\CSDN\\AVM\\Video1\\Front.avi");
	CvCapture* C_img_B = cvCreateFileCapture("G:\\CSDN\\AVM\\Video1\\Back.avi");
	CvCapture* C_img_L = cvCreateFileCapture("G:\\CSDN\\AVM\\Video1\\Left.avi");
	CvCapture* C_img_R = cvCreateFileCapture("G:\\CSDN\\AVM\\Video1\\Right.avi");
	IplImage* img_F, * img_B, * img_L, * img_R;
	js_AVM_obj AVMData_FBLR;
 
	js_init_avm_FBLR(&AVMData_FBLR, img_AVM_FBLR->width, img_AVM_FBLR->height, 0);//F
 
	img_F = cvQueryFrame(C_img_F);
	img_B = cvQueryFrame(C_img_B);
	img_L = cvQueryFrame(C_img_L);
	img_R = cvQueryFrame(C_img_R);
	int num = 0;
	while (img_F = cvQueryFrame(C_img_F))
	{
		img_B = cvQueryFrame(C_img_B);
		img_L = cvQueryFrame(C_img_L);
		img_R = cvQueryFrame(C_img_R);
		js_getAVM_FBLR(&AVMData_FBLR, img_AVM_FBLR->imageData, img_F->imageData, img_B->imageData, img_L->imageData, img_R->imageData, img_F->width, img_F->height, img_AVM_FBLR->width, img_AVM_FBLR->height, img_AVM_FBLR->nChannels, 1);
 
		cvWriteFrame(writer, img_AVM_FBLR);
 
 
		cvShowImage("视频播放", img_AVM_FBLR);
		char c = cvWaitKey(1);
		if (c == 27)break;
		num++;
	}
	cvReleaseVideoWriter(&writer);
	cvReleaseCapture(&C_img_F);
	cvReleaseCapture(&C_img_B);
	cvReleaseCapture(&C_img_L);
	cvReleaseCapture(&C_img_R);
	cvDestroyWindow("视频播放");

测试结果视频

https://www.bilibili.com/video/BV1fp421X7k2?t=0.8

5、AVM全景的转弯模式–右转模式

主要的功能:在启动转向后输出转向右视的视图,用观察车辆右方是否安全。

主函数的测试代码

    IplImage* img_AVM_FBLR = cvCreateImage(cvSize(1280, 1440), 8, 3);
	CvVideoWriter* writer = cvCreateVideoWriter("G:\\CSDN\\AVM\\Video1\\FBLR_R.avi", CV_FOURCC('X', 'V', 'I', 'D'), 25, cvSize(1280, 1440));
	cvNamedWindow("视频播放", CV_WINDOW_AUTOSIZE);
	CvCapture* C_img_F = cvCreateFileCapture("G:\\CSDN\\AVM\\Video1\\Front.avi");
	CvCapture* C_img_B = cvCreateFileCapture("G:\\CSDN\\AVM\\Video1\\Back.avi");
	CvCapture* C_img_L = cvCreateFileCapture("G:\\CSDN\\AVM\\Video1\\Left.avi");
	CvCapture* C_img_R = cvCreateFileCapture("G:\\CSDN\\AVM\\Video1\\Right.avi");
	IplImage* img_F, * img_B, * img_L, * img_R;
	js_AVM_obj AVMData_FBLR;
	js_init_avm_FBLR(&AVMData_FBLR, img_AVM_FBLR->width, img_AVM_FBLR->height, 3);//R
 
	img_F = cvQueryFrame(C_img_F);
	img_B = cvQueryFrame(C_img_B);
	img_L = cvQueryFrame(C_img_L);
	img_R = cvQueryFrame(C_img_R);
	int num = 0;
	while (img_F = cvQueryFrame(C_img_F))
	{
		img_B = cvQueryFrame(C_img_B);
		img_L = cvQueryFrame(C_img_L);
		img_R = cvQueryFrame(C_img_R);
		js_getAVM_FBLR(&AVMData_FBLR, img_AVM_FBLR->imageData, img_F->imageData, img_B->imageData, img_L->imageData, img_R->imageData, img_F->width, img_F->height, img_AVM_FBLR->width, img_AVM_FBLR->height, img_AVM_FBLR->nChannels, 1);
		cvWriteFrame(writer, img_AVM_FBLR);
 
 
		cvShowImage("视频播放", img_AVM_FBLR);
		char c = cvWaitKey(1);
		if (c == 27)break;
		num++;
	}
	cvReleaseVideoWriter(&writer);
	cvReleaseCapture(&C_img_F);
	cvReleaseCapture(&C_img_B);
	cvReleaseCapture(&C_img_L);
	cvReleaseCapture(&C_img_R);
	cvDestroyWindow("视频播放");

测试结果视频

https://www.bilibili.com/video/BV1im421x7Mr?t=1.2

6、AVM全景的多视角模式–全景俯视模式模式

主要的功能:全景的俯视图主要用于观察车辆周围是否安全和盲区的监测。

主函数的测试代码

IplImage* img_AVM_TOP = cvCreateImage(cvSize(1280, 1440), 8, 3);
	CvVideoWriter* writer = cvCreateVideoWriter("G:\\CSDN\\AVM\\Video1\\TOP.avi", CV_FOURCC('X', 'V', 'I', 'D'), 25, cvSize(1280, 1440));
	cvNamedWindow("视频播放", CV_WINDOW_AUTOSIZE);
	CvCapture* C_img_F = cvCreateFileCapture("G:\\CSDN\\AVM\\Video1\\Front.avi");
	CvCapture* C_img_B = cvCreateFileCapture("G:\\CSDN\\AVM\\Video1\\Back.avi");
	CvCapture* C_img_L = cvCreateFileCapture("G:\\CSDN\\AVM\\Video1\\Left.avi");
	CvCapture* C_img_R = cvCreateFileCapture("G:\\CSDN\\AVM\\Video1\\Right.avi");
	IplImage* img_F, * img_B, * img_L, * img_R;
	js_AVM_obj AVMData_TOP;
	
	js_init_avm(&AVMData_TOP, img_AVM_TOP->width, img_AVM_TOP->height, 0);
	
	img_F = cvQueryFrame(C_img_F);
	img_B = cvQueryFrame(C_img_B);
	img_L = cvQueryFrame(C_img_L);
	img_R = cvQueryFrame(C_img_R);
	int num = 0;
	while (img_F = cvQueryFrame(C_img_F))
	{
		img_B = cvQueryFrame(C_img_B);
		img_L = cvQueryFrame(C_img_L);
		img_R = cvQueryFrame(C_img_R);
		js_getAVM_TOP(&AVMData_TOP, img_AVM_TOP->imageData, img_F->imageData, img_B->imageData, img_L->imageData, img_R->imageData, img_F->width, img_F->height, img_AVM_TOP->width, img_AVM_TOP->height, img_AVM_TOP->nChannels, 0);
 
		cvWriteFrame(writer, img_AVM_TOP);
 
 
		cvShowImage("视频播放", img_AVM_TOP);
		char c = cvWaitKey(1);
		if (c == 27)break;
		num++;
	}
	cvReleaseVideoWriter(&writer);
	cvReleaseCapture(&C_img_F);
	cvReleaseCapture(&C_img_B);
	cvReleaseCapture(&C_img_L);
	cvReleaseCapture(&C_img_R);
	cvDestroyWindow("视频播放");

测试结果视频

https://www.bilibili.com/video/BV1Jm411U7QF?t=0.8

7、AVM全景的超广角模式–右视超广角模式(当前拼接位置对齐存在问题,暂未解决)

主要的功能:超广角就是用观察正前方和左右两侧是否存在快速接近的物体,主要是视角大可以近视看到180度的视角。

主函数的测试代码

IplImage* img_AVM_WideAngle = cvCreateImage(cvSize(1280, 720), 8, 3);
 
	CvVideoWriter* writer = cvCreateVideoWriter("G:\\CSDN\\AVM\\Video1\\WideAngle_R.avi", CV_FOURCC('X', 'V', 'I', 'D'), 25, cvSize(1280, 720));
	cvNamedWindow("视频播放", CV_WINDOW_AUTOSIZE);
	CvCapture* C_img_F = cvCreateFileCapture("G:\\CSDN\\AVM\\Video1\\Front.avi");
	CvCapture* C_img_B = cvCreateFileCapture("G:\\CSDN\\AVM\\Video1\\Back.avi");
	CvCapture* C_img_L = cvCreateFileCapture("G:\\CSDN\\AVM\\Video1\\Left.avi");
	CvCapture* C_img_R = cvCreateFileCapture("G:\\CSDN\\AVM\\Video1\\Right.avi");
	IplImage* img_F, * img_B, * img_L, * img_R;
	js_AVM_obj AVMData_WideAngle;
	js_init_avm_WideAngle(&AVMData_WideAngle, img_AVM_WideAngle->width, img_AVM_WideAngle->height, 1, 0);//0:F 1:B 
 
 
 
	img_F = cvQueryFrame(C_img_F);
	img_B = cvQueryFrame(C_img_B);
	img_L = cvQueryFrame(C_img_L);
	img_R = cvQueryFrame(C_img_R);
	int num = 0;
	while (img_F = cvQueryFrame(C_img_F))
	{
		img_B = cvQueryFrame(C_img_B);
		img_L = cvQueryFrame(C_img_L);
		img_R = cvQueryFrame(C_img_R);
		js_getAVM_WideAngle(&AVMData_WideAngle, img_AVM_WideAngle->imageData, img_R->imageData, img_F->width, img_F->height, img_AVM_WideAngle->width, img_AVM_WideAngle->height, img_AVM_WideAngle->nChannels, 1, 0);
 
		cvLine(img_AVM_WideAngle, cvPoint(276, 0), cvPoint(276, 720), CV_RGB(0, 0, 0), 3);
		cvLine(img_AVM_WideAngle, cvPoint(1003, 0), cvPoint(1003, 720), CV_RGB(0, 0, 0), 3);
 
		cvWriteFrame(writer, img_AVM_WideAngle);
 
 
		cvShowImage("视频播放", img_AVM_WideAngle);
		char c = cvWaitKey(1);
		if (c == 27)break;
		num++;
	}
	cvReleaseVideoWriter(&writer);
	cvReleaseCapture(&C_img_F);
	cvReleaseCapture(&C_img_B);
	cvReleaseCapture(&C_img_L);
	cvReleaseCapture(&C_img_R);
	cvDestroyWindow("视频播放");

测试结果视频

https://www.bilibili.com/video/BV1nH4y1N7i5?t=1.0

8、AVM全景的超广角模式–后视超广角模式(当前拼接位置对齐存在问题,暂未解决)

主要的功能:超广角就是用观察正前方和左右两侧是否存在快速接近的物体,主要是视角大可以近视看到180度的视角。

主函数的测试代码

	IplImage* img_AVM_WideAngle = cvCreateImage(cvSize(1280, 720), 8, 3);
 
	CvVideoWriter* writer = cvCreateVideoWriter("G:\\CSDN\\AVM\\Video1\\WideAngle_B.avi", CV_FOURCC('X', 'V', 'I', 'D'), 25, cvSize(1280, 720));
	cvNamedWindow("视频播放", CV_WINDOW_AUTOSIZE);
	CvCapture* C_img_F = cvCreateFileCapture("G:\\CSDN\\AVM\\Video1\\Front.avi");
	CvCapture* C_img_B = cvCreateFileCapture("G:\\CSDN\\AVM\\Video1\\Back.avi");
	CvCapture* C_img_L = cvCreateFileCapture("G:\\CSDN\\AVM\\Video1\\Left.avi");
	CvCapture* C_img_R = cvCreateFileCapture("G:\\CSDN\\AVM\\Video1\\Right.avi");
	IplImage* img_F, * img_B, * img_L, * img_R;
	js_AVM_obj AVMData_WideAngle;
	js_init_avm_WideAngle(&AVMData_WideAngle, img_AVM_WideAngle->width, img_AVM_WideAngle->height, 1, 0);//0:F 1:B 
 
	img_F = cvQueryFrame(C_img_F);
	img_B = cvQueryFrame(C_img_B);
	img_L = cvQueryFrame(C_img_L);
	img_R = cvQueryFrame(C_img_R);
	int num = 0;
	while (img_F = cvQueryFrame(C_img_F))
	{
		img_B = cvQueryFrame(C_img_B);
		img_L = cvQueryFrame(C_img_L);
		img_R = cvQueryFrame(C_img_R);
		js_getAVM_WideAngle(&AVMData_WideAngle, img_AVM_WideAngle->imageData, img_B->imageData,img_F->width, img_F->height, img_AVM_WideAngle->width, img_AVM_WideAngle->height, img_AVM_WideAngle->nChannels, 1, 0);
 
		cvLine(img_AVM_WideAngle, cvPoint(276, 0), cvPoint(276, 720), CV_RGB(0, 0, 0), 3);
		cvLine(img_AVM_WideAngle, cvPoint(1003, 0), cvPoint(1003, 720), CV_RGB(0, 0, 0), 3);
 
		cvWriteFrame(writer, img_AVM_WideAngle);
 
 
		cvShowImage("视频播放", img_AVM_WideAngle);
		char c = cvWaitKey(1);
		if (c == 27)break;
		num++;
	}
	cvReleaseVideoWriter(&writer);
	cvReleaseCapture(&C_img_F);
	cvReleaseCapture(&C_img_B);
	cvReleaseCapture(&C_img_L);
	cvReleaseCapture(&C_img_R);
	cvDestroyWindow("视频播放");

测试结果视频

https://www.bilibili.com/video/BV1hx4y1h72H?t=0.2

9、AVM全景的超广角模式–前视超广角模式(当前拼接位置对齐存在问题,暂未解决)

主要的功能:超广角就是用观察正前方和左右两侧是否存在快速接近的物体,主要是视角大可以近视看到180度的视角。

主函数的测试代码

IplImage* img_AVM_WideAngle  = cvCreateImage(cvSize(1280, 720), 8, 3);
 
	CvVideoWriter* writer = cvCreateVideoWriter("G:\\CSDN\\AVM\\Video1\\WideAngle_F.avi", CV_FOURCC('X', 'V', 'I', 'D'), 25, cvSize(1280, 720));
	cvNamedWindow("视频播放", CV_WINDOW_AUTOSIZE);
	CvCapture* C_img_F = cvCreateFileCapture("G:\\CSDN\\AVM\\Video1\\Front.avi");
	CvCapture* C_img_B = cvCreateFileCapture("G:\\CSDN\\AVM\\Video1\\Back.avi");
	CvCapture* C_img_L = cvCreateFileCapture("G:\\CSDN\\AVM\\Video1\\Left.avi");
	CvCapture* C_img_R = cvCreateFileCapture("G:\\CSDN\\AVM\\Video1\\Right.avi");
	IplImage* img_F, *img_B, *img_L, *img_R;
	js_AVM_obj AVMData_WideAngle;
	js_init_avm_WideAngle(&AVMData_WideAngle, img_AVM_WideAngle->width, img_AVM_WideAngle->height, 1,0);//0:F 1:B 
 
	img_F = cvQueryFrame(C_img_F);
	img_B = cvQueryFrame(C_img_B);
	img_L = cvQueryFrame(C_img_L);
	img_R = cvQueryFrame(C_img_R);
	int num = 0;
	while (img_F = cvQueryFrame(C_img_F))
	{
 
		js_getAVM_WideAngle(&AVMData_WideAngle, img_AVM_WideAngle->imageData, img_F->imageData, img_F->width, img_F->height, img_AVM_WideAngle->width, img_AVM_WideAngle->height, img_AVM_WideAngle->nChannels, 1, 0);
 
		cvLine(img_AVM_WideAngle, cvPoint(276, 0), cvPoint(276, 720), CV_RGB(0, 0, 0), 3);
		cvLine(img_AVM_WideAngle, cvPoint(1003, 0), cvPoint(1003, 720), CV_RGB(0, 0, 0), 3);
 
 		cvWriteFrame(writer, img_AVM_WideAngle);
 
 
		cvShowImage("视频播放", img_AVM_WideAngle);
		char c = cvWaitKey(1);
		if (c == 27)break;
		num++;
	}
	cvReleaseVideoWriter(&writer);
	cvReleaseCapture(&C_img_F);
	cvReleaseCapture(&C_img_B);
	cvReleaseCapture(&C_img_L);
	cvReleaseCapture(&C_img_R);
	cvDestroyWindow("视频播放");

测试结果视频

https://www.bilibili.com/video/BV1St421P7ay?t=0.5

10、AVM全景的超广角模式–左视超广角模式(当前拼接位置对齐存在问题,暂未解决)

主要的功能:超广角就是用观察正前方和左右两侧是否存在快速接近的物体,主要是视角大可以近视看到180度的视角。

主函数的测试代码

	IplImage* img_AVM_WideAngle = cvCreateImage(cvSize(1280, 720), 8, 3);
 
	CvVideoWriter* writer = cvCreateVideoWriter("G:\\CSDN\\AVM\\Video1\\WideAngle_L.avi", CV_FOURCC('X', 'V', 'I', 'D'), 25, cvSize(1280, 720));
	cvNamedWindow("视频播放", CV_WINDOW_AUTOSIZE);
	CvCapture* C_img_F = cvCreateFileCapture("G:\\CSDN\\AVM\\Video1\\Front.avi");
	CvCapture* C_img_B = cvCreateFileCapture("G:\\CSDN\\AVM\\Video1\\Back.avi");
	CvCapture* C_img_L = cvCreateFileCapture("G:\\CSDN\\AVM\\Video1\\Left.avi");
	CvCapture* C_img_R = cvCreateFileCapture("G:\\CSDN\\AVM\\Video1\\Right.avi");
	IplImage* img_F, * img_B, * img_L, * img_R;
	js_AVM_obj AVMData_WideAngle;
 
	js_init_avm_WideAngle(&AVMData_WideAngle, img_AVM_WideAngle->width, img_AVM_WideAngle->height, 1, 0);//0:F 1:B 
 
 
	img_F = cvQueryFrame(C_img_F);
	img_B = cvQueryFrame(C_img_B);
	img_L = cvQueryFrame(C_img_L);
	img_R = cvQueryFrame(C_img_R);
	int num = 0;
	while (img_F = cvQueryFrame(C_img_F))
	{
		img_B = cvQueryFrame(C_img_B);
		img_L = cvQueryFrame(C_img_L);
		img_R = cvQueryFrame(C_img_R);
		js_getAVM_WideAngle(&AVMData_WideAngle, img_AVM_WideAngle->imageData, img_L->imageData, img_F->width, img_F->height, img_AVM_WideAngle->width, img_AVM_WideAngle->height, img_AVM_WideAngle->nChannels, 1, 0);
 
		cvLine(img_AVM_WideAngle, cvPoint(276, 0), cvPoint(276, 720), CV_RGB(0, 0, 0), 3);
		cvLine(img_AVM_WideAngle, cvPoint(1003, 0), cvPoint(1003, 720), CV_RGB(0, 0, 0), 3);
 
		cvWriteFrame(writer, img_AVM_WideAngle);
 
 
		cvShowImage("视频播放", img_AVM_WideAngle);
		char c = cvWaitKey(1);
		if (c == 27)break;
		num++;
	}
	cvReleaseVideoWriter(&writer);
	cvReleaseCapture(&C_img_F);
	cvReleaseCapture(&C_img_B);
	cvReleaseCapture(&C_img_L);
	cvReleaseCapture(&C_img_R);
	cvDestroyWindow("视频播放");

测试结果视频

https://www.bilibili.com/video/BV1Ni4212766?t=0.8

11、AVM全景的车轮模式–行车左前车轮模式

主要的功能:在行车状态是左转时用于观察车辆左侧的近处是否存在刮碰车辆的风险。

主函数的测试代码

IplImage* img_AVM_Wheel = cvCreateImage(cvSize(1280, 1440), 8, 3);
 
	CvVideoWriter* writer = cvCreateVideoWriter("G:\\CSDN\\AVM\\Video1\\Wheel_FL.avi", CV_FOURCC('X', 'V', 'I', 'D'), 25, cvSize(1280, 1440));
	cvNamedWindow("视频播放", CV_WINDOW_AUTOSIZE);
	CvCapture* C_img_F = cvCreateFileCapture("G:\\CSDN\\AVM\\Video1\\Front.avi");
	CvCapture* C_img_B = cvCreateFileCapture("G:\\CSDN\\AVM\\Video1\\Back.avi");
	CvCapture* C_img_L = cvCreateFileCapture("G:\\CSDN\\AVM\\Video1\\Left.avi");
	CvCapture* C_img_R = cvCreateFileCapture("G:\\CSDN\\AVM\\Video1\\Right.avi");
	IplImage* img_F, * img_B, * img_L, * img_R;
	js_AVM_obj AVMData_Wheel;
	
	js_init_avm_Wheel(&AVMData_Wheel, img_AVM_Wheel->width, img_AVM_Wheel->height,0);//FL:0 FR:1 BL:2 BR:3 
 
	img_F = cvQueryFrame(C_img_F);
	img_B = cvQueryFrame(C_img_B);
	img_L = cvQueryFrame(C_img_L);
	img_R = cvQueryFrame(C_img_R);
	int num = 0;
	while (img_F = cvQueryFrame(C_img_F))
	{
		img_B = cvQueryFrame(C_img_B);
		img_L = cvQueryFrame(C_img_L);
		img_R = cvQueryFrame(C_img_R);
		js_getAVM_Wheel(&AVMData_Wheel, img_AVM_Wheel->imageData, img_F->imageData, img_B->imageData, img_L->imageData, img_R->imageData, img_F->width, img_F->height, img_AVM_Wheel->width, img_AVM_Wheel->height, img_AVM_Wheel->nChannels, 1,0);
		
		cvWriteFrame(writer, img_AVM_Wheel);
 
 
		cvShowImage("视频播放", img_AVM_Wheel);
		char c = cvWaitKey(1);
		if (c == 27)break;
		num++;
	}
	cvReleaseVideoWriter(&writer);
	cvReleaseCapture(&C_img_F);
	cvReleaseCapture(&C_img_B);
	cvReleaseCapture(&C_img_L);
	cvReleaseCapture(&C_img_R);
	cvDestroyWindow("视频播放");

测试结果视频

https://www.bilibili.com/video/BV1M1421d7KZ?t=0.6

12、AVM全景的车轮模式–行车右前车轮模式

主要的功能:在行车状态是右转时用于观察车辆右侧的近处是否存在刮碰车辆的风险。

主函数的测试代码

	IplImage* img_AVM_Wheel = cvCreateImage(cvSize(1280, 1440), 8, 3);
 
	CvVideoWriter* writer = cvCreateVideoWriter("G:\\CSDN\\AVM\\Video1\\Wheel_FR.avi", CV_FOURCC('X', 'V', 'I', 'D'), 25, cvSize(1280, 1440));
	cvNamedWindow("视频播放", CV_WINDOW_AUTOSIZE);
	CvCapture* C_img_F = cvCreateFileCapture("G:\\CSDN\\AVM\\Video1\\Front.avi");
	CvCapture* C_img_B = cvCreateFileCapture("G:\\CSDN\\AVM\\Video1\\Back.avi");
	CvCapture* C_img_L = cvCreateFileCapture("G:\\CSDN\\AVM\\Video1\\Left.avi");
	CvCapture* C_img_R = cvCreateFileCapture("G:\\CSDN\\AVM\\Video1\\Right.avi");
	IplImage* img_F, * img_B, * img_L, * img_R;
	js_AVM_obj AVMData_Wheel;
 
	js_init_avm_Wheel(&AVMData_Wheel, img_AVM_Wheel->width, img_AVM_Wheel->height, 1);//FL:0 FR:1 BL:2 BR:3 
	
	img_F = cvQueryFrame(C_img_F);
	img_B = cvQueryFrame(C_img_B);
	img_L = cvQueryFrame(C_img_L);
	img_R = cvQueryFrame(C_img_R);
	int num = 0;
	while (img_F = cvQueryFrame(C_img_F))
	{
		img_B = cvQueryFrame(C_img_B);
		img_L = cvQueryFrame(C_img_L);
		img_R = cvQueryFrame(C_img_R);
		js_getAVM_Wheel(&AVMData_Wheel, img_AVM_Wheel->imageData, img_F->imageData, img_B->imageData, img_L->imageData, img_R->imageData, img_F->width, img_F->height, img_AVM_Wheel->width, img_AVM_Wheel->height, img_AVM_Wheel->nChannels, 1, 1);
		
		cvWriteFrame(writer, img_AVM_Wheel);
 
 
		cvShowImage("视频播放", img_AVM_Wheel);
		char c = cvWaitKey(1);
		if (c == 27)break;
		num++;
	}
	cvReleaseVideoWriter(&writer);
	cvReleaseCapture(&C_img_F);
	cvReleaseCapture(&C_img_B);
	cvReleaseCapture(&C_img_L);
	cvReleaseCapture(&C_img_R);
	cvDestroyWindow("视频播放");

测试结果视频

https://www.bilibili.com/video/BV1pT42127uR?t=0.5

13、AVM全景的车轮模式–倒车右后车轮模式

主要的功能:在倒车状态是左转时用于观察车辆左侧的近处是否存在刮碰车辆的风险。

主函数的测试代码

	IplImage* img_AVM_Wheel = cvCreateImage(cvSize(1280, 1440), 8, 3);
 
	CvVideoWriter* writer = cvCreateVideoWriter("G:\\CSDN\\AVM\\Video1\\Wheel_BR.avi", CV_FOURCC('X', 'V', 'I', 'D'), 25, cvSize(1280, 1440));
	cvNamedWindow("视频播放", CV_WINDOW_AUTOSIZE);
	CvCapture* C_img_F = cvCreateFileCapture("G:\\CSDN\\AVM\\Video1\\Front.avi");
	CvCapture* C_img_B = cvCreateFileCapture("G:\\CSDN\\AVM\\Video1\\Back.avi");
	CvCapture* C_img_L = cvCreateFileCapture("G:\\CSDN\\AVM\\Video1\\Left.avi");
	CvCapture* C_img_R = cvCreateFileCapture("G:\\CSDN\\AVM\\Video1\\Right.avi");
	IplImage* img_F, * img_B, * img_L, * img_R;
	js_AVM_obj AVMData_Wheel;
	
	js_init_avm_Wheel(&AVMData_Wheel, img_AVM_Wheel->width, img_AVM_Wheel->height, 3);//FL:0 FR:1 BL:2 BR:3 
 
	img_F = cvQueryFrame(C_img_F);
	img_B = cvQueryFrame(C_img_B);
	img_L = cvQueryFrame(C_img_L);
	img_R = cvQueryFrame(C_img_R);
	int num = 0;
	while (img_F = cvQueryFrame(C_img_F))
	{
		img_B = cvQueryFrame(C_img_B);
		img_L = cvQueryFrame(C_img_L);
		img_R = cvQueryFrame(C_img_R);
		js_getAVM_Wheel(&AVMData_Wheel, img_AVM_Wheel->imageData, img_F->imageData, img_B->imageData, img_L->imageData, img_R->imageData, img_F->width, img_F->height, img_AVM_Wheel->width, img_AVM_Wheel->height, img_AVM_Wheel->nChannels, 1, 3);
		cvWriteFrame(writer, img_AVM_Wheel);
 
 
		cvShowImage("视频播放", img_AVM_Wheel);
		char c = cvWaitKey(1);
		if (c == 27)break;
		num++;
	}
	cvReleaseVideoWriter(&writer);
	cvReleaseCapture(&C_img_F);
	cvReleaseCapture(&C_img_B);
	cvReleaseCapture(&C_img_L);
	cvReleaseCapture(&C_img_R);
	cvDestroyWindow("视频播放");

测试结果视频

https://www.bilibili.com/video/BV1FZ421e7nJ?t=0.0

14、AVM全景的车轮模式–倒车左后车轮模式

主要的功能:在到车状态是右转时用于观察车辆右侧的近处是否存在刮碰车辆的风险。

主函数的测试代码

	IplImage* img_AVM_Wheel = cvCreateImage(cvSize(1280, 1440), 8, 3);
 
	CvVideoWriter* writer = cvCreateVideoWriter("G:\\CSDN\\AVM\\Video1\\Wheel_BL.avi", CV_FOURCC('X', 'V', 'I', 'D'), 25, cvSize(1280, 1440));
	cvNamedWindow("视频播放", CV_WINDOW_AUTOSIZE);
	CvCapture* C_img_F = cvCreateFileCapture("G:\\CSDN\\AVM\\Video1\\Front.avi");
	CvCapture* C_img_B = cvCreateFileCapture("G:\\CSDN\\AVM\\Video1\\Back.avi");
	CvCapture* C_img_L = cvCreateFileCapture("G:\\CSDN\\AVM\\Video1\\Left.avi");
	CvCapture* C_img_R = cvCreateFileCapture("G:\\CSDN\\AVM\\Video1\\Right.avi");
	IplImage* img_F, * img_B, * img_L, * img_R;
	js_AVM_obj  AVMData_Wheel;
 
	js_init_avm_Wheel(&AVMData_Wheel, img_AVM_Wheel->width, img_AVM_Wheel->height, 2);//FL:0 FR:1 BL:2 BR:3 
 
	img_F = cvQueryFrame(C_img_F);
	img_B = cvQueryFrame(C_img_B);
	img_L = cvQueryFrame(C_img_L);
	img_R = cvQueryFrame(C_img_R);
	int num = 0;
	while (img_F = cvQueryFrame(C_img_F))
	{
		img_B = cvQueryFrame(C_img_B);
		img_L = cvQueryFrame(C_img_L);
		img_R = cvQueryFrame(C_img_R);
		js_getAVM_Wheel(&AVMData_Wheel, img_AVM_Wheel->imageData, img_F->imageData, img_B->imageData, img_L->imageData, img_R->imageData, img_F->width, img_F->height, img_AVM_Wheel->width, img_AVM_Wheel->height, img_AVM_Wheel->nChannels, 1, 2);
		
 
		cvWriteFrame(writer, img_AVM_Wheel);
 
 
		cvShowImage("视频播放", img_AVM_Wheel);
		char c = cvWaitKey(1);
		if (c == 27)break;
		num++;
	}
	cvReleaseVideoWriter(&writer);
	cvReleaseCapture(&C_img_F);
	cvReleaseCapture(&C_img_B);
	cvReleaseCapture(&C_img_L);
	cvReleaseCapture(&C_img_R);
	cvDestroyWindow("视频播放");

测试结果视频

https://www.bilibili.com/video/BV1vm421x7gd?t=1.0

15、AVM全景的窄边模式–倒车窄边模式

主要的功能:在倒车时通过比较窄的路段用于观察车辆两侧是否安全。

主函数的测试代码

IplImage* img_AVM_NarrowEdge = cvCreateImage(cvSize(1280, 1440), 8, 3);
 
 
	CvVideoWriter* writer = cvCreateVideoWriter("G:\\CSDN\\AVM\\Video1\\NarrowEdge_B.avi", CV_FOURCC('X', 'V', 'I', 'D'), 25, cvSize(1280, 1440));
	cvNamedWindow("视频播放", CV_WINDOW_AUTOSIZE);
	CvCapture* C_img_F = cvCreateFileCapture("G:\\CSDN\\AVM\\Video1\\Front.avi");
	CvCapture* C_img_B = cvCreateFileCapture("G:\\CSDN\\AVM\\Video1\\Back.avi");
	CvCapture* C_img_L = cvCreateFileCapture("G:\\CSDN\\AVM\\Video1\\Left.avi");
	CvCapture* C_img_R = cvCreateFileCapture("G:\\CSDN\\AVM\\Video1\\Right.avi");
	IplImage* img_F, * img_B, * img_L, * img_R;
	js_AVM_obj  AVMData_NarrowEdge;
	
	js_init_avm_NarrowEdge(&AVMData_NarrowEdge, img_AVM_NarrowEdge->width, img_AVM_NarrowEdge->height, 1);//0F 
 
	img_F = cvQueryFrame(C_img_F);
	img_B = cvQueryFrame(C_img_B);
	img_L = cvQueryFrame(C_img_L);
	img_R = cvQueryFrame(C_img_R);
	int num = 0;
	while (img_F = cvQueryFrame(C_img_F))
	{
		img_B = cvQueryFrame(C_img_B);
		img_L = cvQueryFrame(C_img_L);
		img_R = cvQueryFrame(C_img_R);
		js_getAVM_NarrowEdge(&AVMData_NarrowEdge, img_AVM_NarrowEdge->imageData, img_F->imageData, img_B->imageData, img_L->imageData, img_R->imageData, img_F->width, img_F->height, img_AVM_NarrowEdge->width, img_AVM_NarrowEdge->height, img_AVM_NarrowEdge->nChannels, 0);
		
		cvLine(img_AVM_NarrowEdge, cvPoint(AVMData_NarrowEdge.LFsrc.x, AVMData_NarrowEdge.LFsrc.y), cvPoint(AVMData_NarrowEdge.LBsrc.x, AVMData_NarrowEdge.LBsrc.y), CV_RGB(255, 255, 0), 3);
		cvLine(img_AVM_NarrowEdge, cvPoint(AVMData_NarrowEdge.RFsrc.x, AVMData_NarrowEdge.RFsrc.y), cvPoint(AVMData_NarrowEdge.RBsrc.x, AVMData_NarrowEdge.RBsrc.y), CV_RGB(255, 255, 0), 3);
		cvLine(img_AVM_NarrowEdge, cvPoint(AVMData_NarrowEdge.LBsrc.x, AVMData_NarrowEdge.LBsrc.y), cvPoint(AVMData_NarrowEdge.LBsrc.x + 50, AVMData_NarrowEdge.LBsrc.y), CV_RGB(255, 255, 0), 3);
		cvLine(img_AVM_NarrowEdge, cvPoint(AVMData_NarrowEdge.RBsrc.x - 50, AVMData_NarrowEdge.RBsrc.y), cvPoint(AVMData_NarrowEdge.RBsrc.x, AVMData_NarrowEdge.RBsrc.y), CV_RGB(255, 255, 0), 3);
 
 
		cvWriteFrame(writer, img_AVM_NarrowEdge);
 
 
		cvShowImage("视频播放", img_AVM_NarrowEdge);
		char c = cvWaitKey(1);
		if (c == 27)break;
		num++;
	}
	cvReleaseVideoWriter(&writer);
	cvReleaseCapture(&C_img_F);
	cvReleaseCapture(&C_img_B);
	cvReleaseCapture(&C_img_L);
	cvReleaseCapture(&C_img_R);
	cvDestroyWindow("视频播放");

测试结果视频

https://www.bilibili.com/video/BV1TH4y1N7o5?t=0.6

16、AVM全景的窄边模式–行车窄边模式

主要的功能:在行车时通过比较窄的路段用于观察车辆两侧是否安全。

主函数的测试代码

	IplImage* img_AVM_NarrowEdge = cvCreateImage(cvSize(1280, 1440), 8, 3);
 
	CvVideoWriter* writer = cvCreateVideoWriter("G:\\CSDN\\AVM\\Video1\\NarrowEdge_F.avi", CV_FOURCC('X', 'V', 'I', 'D'), 25, cvSize(1280, 1440));
	cvNamedWindow("视频播放", CV_WINDOW_AUTOSIZE);
	CvCapture* C_img_F = cvCreateFileCapture("G:\\CSDN\\AVM\\Video1\\Front.avi");
	CvCapture* C_img_B = cvCreateFileCapture("G:\\CSDN\\AVM\\Video1\\Back.avi");
	CvCapture* C_img_L = cvCreateFileCapture("G:\\CSDN\\AVM\\Video1\\Left.avi");
	CvCapture* C_img_R = cvCreateFileCapture("G:\\CSDN\\AVM\\Video1\\Right.avi");
	IplImage* img_F, * img_B, * img_L, * img_R;
	js_AVM_obj AVMData_NarrowEdge;
 
	js_init_avm_NarrowEdge(&AVMData_NarrowEdge, img_AVM_NarrowEdge->width, img_AVM_NarrowEdge->height,0);//0F 
	img_F = cvQueryFrame(C_img_F);
	img_B = cvQueryFrame(C_img_B);
	img_L = cvQueryFrame(C_img_L);
	img_R = cvQueryFrame(C_img_R);
	int num = 0;
	while (img_F = cvQueryFrame(C_img_F))
	{
		img_B = cvQueryFrame(C_img_B);
		img_L = cvQueryFrame(C_img_L);
		img_R = cvQueryFrame(C_img_R);
		js_getAVM_NarrowEdge(&AVMData_NarrowEdge, img_AVM_NarrowEdge->imageData, img_F->imageData, img_B->imageData, img_L->imageData, img_R->imageData, img_F->width, img_F->height, img_AVM_NarrowEdge->width, img_AVM_NarrowEdge->height, img_AVM_NarrowEdge->nChannels, 0);
		cvLine(img_AVM_NarrowEdge, cvPoint(AVMData_NarrowEdge.LFsrc.x, AVMData_NarrowEdge.LFsrc.y), cvPoint(AVMData_NarrowEdge.LBsrc.x, AVMData_NarrowEdge.LBsrc.y), CV_RGB(255, 255, 0), 3);
		cvLine(img_AVM_NarrowEdge, cvPoint(AVMData_NarrowEdge.RFsrc.x, AVMData_NarrowEdge.RFsrc.y), cvPoint(AVMData_NarrowEdge.RBsrc.x, AVMData_NarrowEdge.RBsrc.y), CV_RGB(255, 255, 0), 3);
		cvLine(img_AVM_NarrowEdge, cvPoint(AVMData_NarrowEdge.LFsrc.x, AVMData_NarrowEdge.LFsrc.y), cvPoint(AVMData_NarrowEdge.LFsrc.x+ 50, AVMData_NarrowEdge.LFsrc.y), CV_RGB(255, 255, 0), 3);
		cvLine(img_AVM_NarrowEdge, cvPoint(AVMData_NarrowEdge.RFsrc.x-50, AVMData_NarrowEdge.RFsrc.y), cvPoint(AVMData_NarrowEdge.RFsrc.x, AVMData_NarrowEdge.RFsrc.y), CV_RGB(255, 255, 0), 3);
 
 
		cvWriteFrame(writer, img_AVM_NarrowEdge);
 
 
		cvShowImage("视频播放", img_AVM_NarrowEdge);
		char c = cvWaitKey(1);
		if (c == 27)break;
		num++;
	}
	cvReleaseVideoWriter(&writer);
	cvReleaseCapture(&C_img_F);
	cvReleaseCapture(&C_img_B);
	cvReleaseCapture(&C_img_L);
	cvReleaseCapture(&C_img_R);
	cvDestroyWindow("视频播放");

测试结果视频

https://www.bilibili.com/video/BV13H4y1T7s5?t=0.5

-=||=-赞 (2)
未经允许不得转载:金书世界 » 自动驾驶AVM环视算法–超广角模式/转向模式/3D碗型投影模式/窄边模式/车轮模式等的实现

相关文章

评论 (0)