程序是基于MFC的,所以只有部分,必须修改下才能运行;
这是做车道识别最原始的想法
效果很一般的,不实际,霍夫变换相当耗时ddd
float keytheta=0.0,keyrho=0.0;
vector<Vec2f> GetThreeLineEx(Mat line,int colhaf)
{
/*if (line.cols<=3)
{
return line;
}*/
vector<Vec2f> threeline;
int idx=0;
float distance=0.0;
Vec2f tempVec;
Vec2f VEC;
VEC[0]=0;
VEC[1]=CV_PI/2;
float theta2;
float rho;
float theta;
double sum;
for(int i=1;i<=5;i++)
{
sum=CV_PI;
tempVec[0]=0;
tempVec[1]=0;
for (int k=0;k<line.cols;k++)
{
rho=line.at<Vec2f>(k)[0];
theta=line.at<Vec2f>(k)[1];
if (theta>(CV_PI/3.0)&&theta<(CV_PI*2/3.0))
{
continue;
}
if (theta<(CV_PI/36.0)||((CV_PI-theta)<CV_PI/36.0))
{
if (abs(rho-colhaf)>20)
{
continue;
}
}
distance=abs(rho-keyrho*cos(theta-keytheta));
if (distance>50)