freescale解决办法--起跑线识别

void startline(uchar hang_begin,uchar hang_end)  
{
    int i,j,point_field=0,count,cycle=0,sum;
    for(i=rows-1;i>=1;i--)
    {
        point_field+=path_mid-path_mid[i-1];
    }
    point_field/=rows;
    if(point_field>-10&&point_field<10)
    {
        for(i=hang_begin;i>=hang_end;i--)
        {
            count=sum=0;
            for(j=0;j<cols-3;j++)
            {
                if(image[j]<threshold&&image[j+1]<threshold&&image[j+2]>=threshold&&image[j+3]>=threshold)
                {
                    if(j-sum>5)
                    {
                        sum=j;
                        count++;
                    }
                }
                if(image[j]>=threshold&&image[j+1]>=threshold&&image[j+2]<threshold&&image[j+3]<threshold)
                {
                    if(j-sum>5)
                    {
                        sum=j;
                        count++;
                    }
                }
            }
            if(count>=5)
            cycle++;
        }
        if(cycle>3)
        motor_braking();
    }
}


你可能感兴趣的:(freescale解决办法--起跑线识别)