试用过的一种传统车道检测方法(里面还有HOUGH变换的车道检测方法赠送,去掉注释符号即可使用),已改成vs2015+OPENCV3.3版,绝对好用 。10分是良心价。
代码片段和文件信息
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2018-02-11 19:44 lanedetect
目录 0 2018-02-10 21:59 lanedetect.vs
目录 0 2018-02-10 21:59 lanedetect.vslanedetect
目录 0 2018-02-10 21:59 lanedetect.vslanedetectv14
文件 39936 2018-02-11 19:44 lanedetect.vslanedetectv14.suo
目录 0 2018-02-10 22:03 lanedetectDebug
文件 61440 2018-02-10 22:03 lanedetectDebuglanedetect.pdb
目录 0 2018-02-10 21:59 lanedetectipch
目录 0 2018-02-10 22:20 lanedetectipchLANEDETECT-2a780b78
文件 3538944 2018-02-10 22:01 lanedetectipchLANEDETECT-2a780b78LANEDETECT-13cafd85.ipch
文件 3604480 2018-02-10 22:20 lanedetectipchLANEDETECT-2a780b78LANEDETECT-db0486a3.ipch
目录 0 2018-02-11 19:44 lanedetectlanedetect
目录 0 2018-02-10 22:03 lanedetectlanedetectDebug
文件 2466 2018-02-10 22:03 lanedetectlanedetectDebuglanedetect.log
文件 86719 2018-02-10 22:03 lanedetectlanedetectDebuglanedetect.obj
文件 3407872 2018-02-10 22:02 lanedetectlanedetectDebuglanedetect.pch
目录 0 2018-02-10 22:03 lanedetectlanedetectDebuglanedetect.tlog
文件 1346 2018-02-10 22:03 lanedetectlanedetectDebuglanedetect.tlogCL.command.1.tlog
文件 22310 2018-02-10 22:03 lanedetectlanedetectDebuglanedetect.tlogCL.read.1.tlog
文件 772 2018-02-10 22:03 lanedetectlanedetectDebuglanedetect.tlogCL.write.1.tlog
文件 180 2018-02-10 22:03 lanedetectlanedetectDebuglanedetect.tloglanedetect.lastbuildstate
文件 2 2018-02-10 22:03 lanedetectlanedetectDebuglanedetect.tloglink-cvtres.read.1.tlog
文件 2 2018-02-10 22:03 lanedetectlanedetectDebuglanedetect.tloglink-cvtres.write.1.tlog
文件 2 2018-02-10 22:03 lanedetectlanedetectDebuglanedetect.tloglink-rc.read.1.tlog
文件 2 2018-02-10 22:03 lanedetectlanedetectDebuglanedetect.tloglink-rc.write.1.tlog
文件 2 2018-02-10 22:03 lanedetectlanedetectDebuglanedetect.tloglink.command.1.tlog
文件 2 2018-02-10 22:03 lanedetectlanedetectDebuglanedetect.tloglink.read.1.tlog
文件 2 2018-02-10 22:03 lanedetectlanedetectDebuglanedetect.tloglink.write.1.tlog
文件 0 2018-02-10 22:03 lanedetectlanedetectDebuglanedetect.tlogunsuccessfulbuild
文件 11846 2018-02-10 22:02 lanedetectlanedetectDebugstdafx.obj
文件 560128 2018-02-10 22:03 lanedetectlanedetectDebugvc140.idb
............此处省略31个文件信息
// lanedetect.cpp : 定义控制台应用程序的入口点。
#include “stdafx.h“
#include
#include
#include
using namespace cv;
using namespace std;
/*
#define INF 99999999
CvCapture* g_capture = NULL;
int g_slider_pos = 0;
int frame_count = 0;
CvSeq* lines;
int main(int argc char* argv[])
{
cvNamedWindow(“show“);
g_capture = cvCreateFileCapture(“D:\shipin/2--2018-2-4--15-36-23-999.avi“);
IplImage* frame;
while (1)
{
CvMemStorage* storage = cvCreateMemStorage();
frame = cvQueryframe(g_capture);
//set the ROI of the original image
int x = 0 y = frame->height / 2;
int width = frame->width height = frame->height / 2;
if (!frame)
break;
cvSetImageROI(frame cvRect(x y width height));
IplImage* gray = cvCreateImage(cvGetSize(frame) 8 1);
cvCvtColor(frame gray CV_BGR2GRAY);
cvCanny(gray gray 50 100);
cvShowImage(“canny“ gray);
cvSmooth(gray gray CV_GAUSSIAN 3 1 0);
//Hough
lines = cvHoughLines2(gray storage CV_HOUGH_PROBABILISTIC 1 CV_PI / 180 50 90 50);
//select approprivate lines acoording to the slope
for (int i = 0; i < lines->total; i++)
{
double k = INF;
CvPoint* line = (CvPoint*)cvGetSeqElem(lines i);
int dx = line[1].x - line[0].x;
int dy = line[1].x - line[0].y;
double angle = atan2(dy dx) * 180 / CV_PI;
if (abs(angle) <= 10)
continue;
if (line[0].y > line[1].y + 50 || line[0].y < line[1].y - 50)
{
cvLine(frame line[0] line[1] CV_RGB(255 0 0) 2 CV_AA);
}
}
cvResetImageROI(frame);
cvShowImage(“show“ frame);
char c = cvWaitKey(33);
if (c == 27)
break;
}
cvReleaseCapture(&g_capture);
cvDestroyWindow(“show“);
return 0;
}
*/
/*TODO
* improve edge linking
* remove blobs whose axis direction doesnt point towards vanishing pt
* Parallelisation
* lane prediction
*/
#include
#include “opencv2/imgproc/imgproc.hpp“
#include
#include
#include
#include
#include
#include
using namespace std;
using namespace cv;
clock_t start stop;
class LaneDetect
{
public:
Mat currframe; //stores the upcoming frame
Mat temp; //stores intermediate results
Mat temp2; //stores the final lane segments
int diff diffL diffR;
int laneWidth;
int diffThreshTop;
int diffThreshLow;
int ROIrows;
int vertical_left;
int vertical_right;
int vertical_top;
int smallLaneArea;
int longLane;
int vanishingPt;
float maxLaneWidth;
//to store various blob properties
Mat binary_image; //used for blob removal
int minSize;
int ratio;
float contour_area;
float blob_angle_deg;
float bounding_width;
float bounding_length;
Size2f sz;
vector< vector > contours;
vector hierarchy;
RotatedRect rotated_rect;
LaneDetect(Mat startframe)
{
//currframe = startFram
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2018-02-11 19:44 lanedetect
目录 0 2018-02-10 21:59 lanedetect.vs
目录 0 2018-02-10 21:59 lanedetect.vslanedetect
目录 0 2018-02-10 21:59 lanedetect.vslanedetectv14
文件 39936 2018-02-11 19:44 lanedetect.vslanedetectv14.suo
目录 0 2018-02-10 22:03 lanedetectDebug
文件 61440 2018-02-10 22:03 lanedetectDebuglanedetect.pdb
目录 0 2018-02-10 21:59 lanedetectipch
目录 0 2018-02-10 22:20 lanedetectipchLANEDETECT-2a780b78
文件 3538944 2018-02-10 22:01 lanedetectipchLANEDETECT-2a780b78LANEDETECT-13cafd85.ipch
文件 3604480 2018-02-10 22:20 lanedetectipchLANEDETECT-2a780b78LANEDETECT-db0486a3.ipch
目录 0 2018-02-11 19:44 lanedetectlanedetect
目录 0 2018-02-10 22:03 lanedetectlanedetectDebug
文件 2466 2018-02-10 22:03 lanedetectlanedetectDebuglanedetect.log
文件 86719 2018-02-10 22:03 lanedetectlanedetectDebuglanedetect.obj
文件 3407872 2018-02-10 22:02 lanedetectlanedetectDebuglanedetect.pch
目录 0 2018-02-10 22:03 lanedetectlanedetectDebuglanedetect.tlog
文件 1346 2018-02-10 22:03 lanedetectlanedetectDebuglanedetect.tlogCL.command.1.tlog
文件 22310 2018-02-10 22:03 lanedetectlanedetectDebuglanedetect.tlogCL.read.1.tlog
文件 772 2018-02-10 22:03 lanedetectlanedetectDebuglanedetect.tlogCL.write.1.tlog
文件 180 2018-02-10 22:03 lanedetectlanedetectDebuglanedetect.tloglanedetect.lastbuildstate
文件 2 2018-02-10 22:03 lanedetectlanedetectDebuglanedetect.tlogli
文件 2 2018-02-10 22:03 lanedetectlanedetectDebuglanedetect.tlogli
文件 2 2018-02-10 22:03 lanedetectlanedetectDebuglanedetect.tlogli
文件 2 2018-02-10 22:03 lanedetectlanedetectDebuglanedetect.tlogli
文件 2 2018-02-10 22:03 lanedetectlanedetectDebuglanedetect.tlogli
文件 2 2018-02-10 22:03 lanedetectlanedetectDebuglanedetect.tlogli
文件 2 2018-02-10 22:03 lanedetectlanedetectDebuglanedetect.tlogli
文件 0 2018-02-10 22:03 lanedetectlanedetectDebuglanedetect.tlogunsuccessfulbuild
文件 11846 2018-02-10 22:02 lanedetectlanedetectDebugstdafx.obj
文件 560128 2018-02-10 22:03 lanedetectlanedetectDebugvc140.idb
............此处省略31个文件信息
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件举报,一经查实,本站将立刻删除。
评论列表(条)