#include<iostream>#include<opencv/cv.hpp>usingnamespace std;usingnamespace cv;intmain(int argc,char**argv){
Mat img =imread(argv[1]);if(img.empty())return0;resize(img,img,Size(416,416));imshow("img",img);
Mat gray,binary,sobel;cvtColor(img,gray,COLOR_BGR2GRAY);//大津法阈值分割threshold(gray,binary,0,255,CV_THRESH_OTSU);imshow("thresh",binary);//提取水平边缘信息Sobel(gray,sobel,CV_8UC1,1,0,3);threshold(sobel,sobel,32,255,THRESH_BINARY);imshow("sobel",sobel);//合并两个分支的结果,获得车道线区域bitwise_and(binary,sobel,binary);//均值滤波+二值化,代替膨胀,减少长线出现锯齿、中断等现象blur(binary,binary,Size(3,3));threshold(binary,binary,32,255,THRESH_BINARY);imshow("result",binary);waitKey(0);return0;}