資源簡介
試用過的一種傳統車道檢測方法(里面還有HOUGH變換的車道檢測方法贈送,去掉注釋符號即可使用),已改成vs2015+OPENCV3.3版,絕對好用 。10分是良心價。

代碼片段和文件信息
//?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?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? {
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?>?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\.vs\lanedetect\
?????目錄???????????0??2018-02-10?21:59??lanedetect\.vs\lanedetect\v14\
?????文件???????39936??2018-02-11?19:44??lanedetect\.vs\lanedetect\v14\.suo
?????目錄???????????0??2018-02-10?22:03??lanedetect\Debug\
?????文件???????61440??2018-02-10?22:03??lanedetect\Debug\lanedetect.pdb
?????目錄???????????0??2018-02-10?21:59??lanedetect\ipch\
?????目錄???????????0??2018-02-10?22:20??lanedetect\ipch\LANEDETECT-2a780b78\
?????文件?????3538944??2018-02-10?22:01??lanedetect\ipch\LANEDETECT-2a780b78\LANEDETECT-13cafd85.ipch
?????文件?????3604480??2018-02-10?22:20??lanedetect\ipch\LANEDETECT-2a780b78\LANEDETECT-db0486a3.ipch
?????目錄???????????0??2018-02-11?19:44??lanedetect\lanedetect\
?????目錄???????????0??2018-02-10?22:03??lanedetect\lanedetect\Debug\
?????文件????????2466??2018-02-10?22:03??lanedetect\lanedetect\Debug\lanedetect.log
?????文件???????86719??2018-02-10?22:03??lanedetect\lanedetect\Debug\lanedetect.obj
?????文件?????3407872??2018-02-10?22:02??lanedetect\lanedetect\Debug\lanedetect.pch
?????目錄???????????0??2018-02-10?22:03??lanedetect\lanedetect\Debug\lanedetect.tlog\
?????文件????????1346??2018-02-10?22:03??lanedetect\lanedetect\Debug\lanedetect.tlog\CL.command.1.tlog
?????文件???????22310??2018-02-10?22:03??lanedetect\lanedetect\Debug\lanedetect.tlog\CL.read.1.tlog
?????文件?????????772??2018-02-10?22:03??lanedetect\lanedetect\Debug\lanedetect.tlog\CL.write.1.tlog
?????文件?????????180??2018-02-10?22:03??lanedetect\lanedetect\Debug\lanedetect.tlog\lanedetect.lastbuildstate
?????文件???????????2??2018-02-10?22:03??lanedetect\lanedetect\Debug\lanedetect.tlog\li
?????文件???????????2??2018-02-10?22:03??lanedetect\lanedetect\Debug\lanedetect.tlog\li
?????文件???????????2??2018-02-10?22:03??lanedetect\lanedetect\Debug\lanedetect.tlog\li
?????文件???????????2??2018-02-10?22:03??lanedetect\lanedetect\Debug\lanedetect.tlog\li
?????文件???????????2??2018-02-10?22:03??lanedetect\lanedetect\Debug\lanedetect.tlog\li
?????文件???????????2??2018-02-10?22:03??lanedetect\lanedetect\Debug\lanedetect.tlog\li
?????文件???????????2??2018-02-10?22:03??lanedetect\lanedetect\Debug\lanedetect.tlog\li
?????文件???????????0??2018-02-10?22:03??lanedetect\lanedetect\Debug\lanedetect.tlog\unsuccessfulbuild
?????文件???????11846??2018-02-10?22:02??lanedetect\lanedetect\Debug\stdafx.obj
?????文件??????560128??2018-02-10?22:03??lanedetect\lanedetect\Debug\vc140.idb
............此處省略31個文件信息
- 上一篇:LSM6DS3中文資料
- 下一篇:學校教材訂購系統.rar絕對完整絕對實用
評論
共有 條評論