找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
查看: 4553|回复: 0
打印 上一主题 下一主题
收起左侧

K60项目设计智能车最终代码

[复制链接]
跳转到指定楼层
楼主
项目设计智能车最终代码

单片机源程序如下:
  1. #include  "common.h"
  2. #include  "camera.h"
  3. #include  "gpio.h"
  4. #include  "exti.h"
  5. #include  "uart.h"
  6. #include  "roadJudge.h"
  7. #include  "arm_math.h"
  8. #include  "FTM.h"
  9. #include  "delay.h"
  10. #include  "isr.h"

  11. //变量定义
  12. unsigned char threshold;
  13. unsigned char Is_SendPhoto=0;  
  14. unsigned char Pix_data[V][H]={0},Bina_data[V][H]={0};// int   *p=new   int[len];V=50;H=150;
  15. int  LeftBorder[V]={0},RightBorder[V]={0}, CenterLine[V]={0};//记录左右边界,和中间线
  16. unsigned char CCD_V,CCD_H;//
  17. unsigned char top_line=40,top_line1=50,top_line2=48;//为什么用char型
  18. long count,WhiteNum;
  19. unsigned char width_count=50;
  20. unsigned char width_min=50;
  21. unsigned char V_count=0;          //采集行计数
  22. unsigned char jump_point;

  23. unsigned char last_top;//unsigned char到底是数还是字符啊?
  24. unsigned char top_top_line=49;

  25. unsigned char THRE[20];
  26. long  thre_sum=0;
  27. unsigned char thread_count;
  28. unsigned char center_min=30;
  29. unsigned char left_line,right_line;

  30. unsigned int left_count,right_count;

  31. /*    unsigned char left_tiaobian=0;
  32.     unsigned char  right_tiaobian=0;
  33.     unsigned char left_guaidian=0;
  34.     unsigned char  right_guaidian=0;
  35.      unsigned char left_tiaobian_row=0;
  36.      unsigned char right_tiaobian_row=0;
  37.     unsigned char left_guaidian_row=0;
  38.     unsigned char right_guaidian_row=0;
  39. */
  40. //摄像头初始化
  41. void CameraInit()
  42. {  
  43.     exti_init(PORTC,1,rising_down);  //行中断,PORTC1 端口外部中断初始化 ,上升沿触发中断,内部下拉,,,初始化外部中断,内部函数,设定外部中断(IO),
  44.     disable_irq(89);                 //行中断关闭,,,89表示irq中断向量号
  45.     disable_irq(90);                 //场中断关闭,,,新的一幅图像,下降沿有效
  46.     exti_init(PORTD,1,falling_down); //场中断,PORTD1 端口外部中断初始化 ,下降沿触发中断,内部下拉
  47. }

  48. //二值化函数
  49. void BinaData()
  50. {
  51.   int i=0,j=0;
  52.   //count=0;
  53.   unsigned char *p;
  54.   for(i=0;i<V;i++)
  55.   {
  56.     p=Pix_data[i];
  57.     for(j=0;j<H;j++)
  58.     {
  59.       if(*(p+j)>=threshold)     
  60.       {
  61.         Bina_data[i][j]=1;
  62.       //  count++;
  63.       }
  64.       else                            Bina_data[i][j]=0;
  65.     }
  66.   }
  67. }


  68. //整场去燥
  69. void AllFilt()
  70. {
  71.   count=0;
  72.   //unsigned char sum;
  73.   for(CCD_V=1;CCD_V<V-1;CCD_V++)
  74.   {
  75.     for(CCD_H=1;CCD_H<H-1;CCD_H++)
  76.     {
  77.       if(Bina_data[CCD_V][CCD_H]==1)
  78.       {  if((Bina_data[CCD_V-1][CCD_H]==1 || Bina_data[CCD_V+1][CCD_H]==1) && (Bina_data[CCD_V][CCD_H-1]==1 || Bina_data[CCD_V][CCD_H+1]==1))
  79.           {
  80.                Bina_data[CCD_V][CCD_H]=1;  
  81.                count++;
  82.           }
  83.          else  
  84.                Bina_data[CCD_V][CCD_H]=0;
  85.      /*   sum=0;
  86.         sum=sum + Bina_data[CCD_V-1][CCD_H] + Bina_data[CCD_V-1][CCD_H-1] + Bina_data[CCD_V-1][CCD_H+1]
  87.              + Bina_data[CCD_V][CCD_H-1] + Bina_data[CCD_V][CCD_H+1] + Bina_data[CCD_V+1][CCD_H+1]
  88.              + Bina_data[CCD_V+1][CCD_H-1] + Bina_data[CCD_V+1][CCD_H];
  89.         if(sum>=4)        Bina_data[CCD_V][CCD_H]=1;
  90.         else              Bina_data[CCD_V][CCD_H]=0;
  91.         */
  92.       }
  93.       else if(Bina_data[CCD_V][CCD_H]==0)
  94.       {
  95.          if((Bina_data[CCD_V-1][CCD_H]==0 || Bina_data[CCD_V+1][CCD_H]==0) && (Bina_data[CCD_V][CCD_H-1]==0 || Bina_data[CCD_V][CCD_H+1]==0))
  96.           {
  97.                Bina_data[CCD_V][CCD_H]=0;
  98.           }
  99.          else  
  100.          {
  101.                Bina_data[CCD_V][CCD_H]=1;
  102.                count++;
  103.          }
  104.         /*sum=0;
  105.         sum=sum + Bina_data[CCD_V-1][CCD_H] + Bina_data[CCD_V-1][CCD_H-1] + Bina_data[CCD_V-1][CCD_H+1]
  106.              + Bina_data[CCD_V][CCD_H-1] + Bina_data[CCD_V][CCD_H+1] + Bina_data[CCD_V+1][CCD_H+1]
  107.              + Bina_data[CCD_V+1][CCD_H-1] + Bina_data[CCD_V+1][CCD_H];
  108.         if(sum<=6)        Bina_data[CCD_V][CCD_H]=0;
  109.         else              Bina_data[CCD_V][CCD_H]=1;*/
  110.       }
  111.     }
  112.   }
  113. }

  114. //统计图像下半部分白点数
  115. void WhiteCount()
  116. {
  117.   WhiteNum=0;
  118.   for(CCD_V=0;CCD_V<25;CCD_V++)
  119.     for(CCD_H=0;CCD_H<H;CCD_H++)
  120.       if(Bina_data[CCD_V][CCD_H]==1)
  121.         WhiteNum++;
  122. }


  123. //中心线提取,,,480*640,LINE去除掉起始行
  124. void get_center()
  125. {
  126.   
  127.   unsigned char *p;
  128.   static unsigned char last_center=75;
  129.   for(CCD_V=0;CCD_V<LINE;CCD_V++)//,,,为什么是前五行,视野最前方提取有何意义
  130.   {
  131.     p=Bina_data[CCD_V];
  132.     for(CCD_H=75;CCD_H>1;CCD_H--)//中间往右
  133.     {
  134.       if((*(p+CCD_H)==0) && (*(p+CCD_H-1)==0) && (*(p+CCD_H-2)==0)) //右边黑线检测,,,连续三列为黑
  135.       {
  136.         RightBorder[CCD_V]=CCD_H;//记录列数
  137.         break;//找到该行的左边界
  138.       }
  139.       else     RightBorder[CCD_V]=0;      //如果右边没有检测到有黑线
  140.      
  141.     }
  142.       
  143.    for(CCD_H=75;CCD_H<H-2;CCD_H++)  //中间往左
  144.    {
  145.       if((*(p+CCD_H)==0) && (*(p+CCD_H+1)==0) && (*(p+CCD_H+2)==0))    //左边黑线检测
  146.       {
  147.         LeftBorder[CCD_V]=CCD_H;
  148.         break;
  149.        }
  150.       else    LeftBorder[CCD_V]=149;    //如果左边没有检测到有黑线
  151.      
  152.    }
  153.     CenterLine[CCD_V]=(LeftBorder[CCD_V]+RightBorder[CCD_V])/2; //计算中心线
  154.    
  155.     if(fabsf(CenterLine[4]-last_center)>=8)  //基准,,,第五行有什么用?
  156.       CenterLine[4]=last_center;
  157.     last_center=CenterLine[4];         
  158.    
  159.     if((LeftBorder[CCD_V]-RightBorder[CCD_V])>width_count)  //判断赛道宽度,CCD_V=4
  160.        width_count=LeftBorder[CCD_V]-RightBorder[CCD_V];//width_count最大值,  CenterLine记录中间线, CenterLine[4]有什么特殊的?
  161.    
  162.   }  
  163.   
  164.   for(CCD_V=LINE;CCD_V<V;CCD_V++)
  165.   {
  166.     p=Bina_data[CCD_V];
  167.     for(CCD_H=(unsigned char )CenterLine[CCD_V-1];CCD_H>1;CCD_H--)//中间往右,,,为什么是四行的中间点,而不是75?
  168.     {
  169.       if((*(p+CCD_H)==0) && (*(p+CCD_H-1)==0) && (*(p+CCD_H-2)==0)) //右边黑线检测
  170.       {
  171.         RightBorder[CCD_V]=CCD_H;
  172.         break;
  173.       }
  174.       else   RightBorder[CCD_V]=0;      
  175.       
  176.     }
  177.      
  178.     for(CCD_H=(unsigned char )CenterLine[CCD_V-1];CCD_H<H-2;CCD_H++)  //中间往左,,,,能增加运算速度
  179.     {
  180.       if((*(p+CCD_H)==0) && (*(p+CCD_H+1)==0) && (*(p+CCD_H+2)==0))    //左边黑线检测
  181.       {
  182.         LeftBorder[CCD_V]=CCD_H;
  183.         break;
  184.       }
  185.       else   LeftBorder[CCD_V]=149;
  186.      
  187.     }
  188.     CenterLine[CCD_V]=(LeftBorder[CCD_V]+RightBorder[CCD_V])/2;
  189.       
  190.    
  191.     if((LeftBorder[CCD_V]-RightBorder[CCD_V])>width_count) ////判断赛道宽度
  192.        width_count=LeftBorder[CCD_V]-RightBorder[CCD_V];//这真的是判断赛道宽度嘛?这简直在找最宽的赛道嘛?
  193.    
  194.   }
  195. }

  196. //
  197. void centeradjust()
  198. {
  199.   for(CCD_V=top_line-1;CCD_V<V;CCD_V++)//四十行开始往上
  200.   {
  201.     if(LeftBorder[top_line-2]>=145 || LeftBorder[top_line-3]>=145)//如果上两行的左边界有一个大于145,(其实右边界),调整思路是什么?
  202.     {
  203.       CenterLine[CCD_V]= (int)((147-left_offset_row)*1.0/(V-1-top_line)*(CCD_V+2-top_line)+0.5)+
  204.         left_offset_row;                                       //这一堆可能在矫正些什么
  205.       if(CenterLine[CCD_V]>=147)    CenterLine[CCD_V]=147;//左边界最大到147,
  206.     }
  207.    
  208.     if(RightBorder[top_line-2]<=5 || RightBorder[top_line-3]<=5)
  209.     {
  210.       CenterLine[CCD_V]=(int)((2-right_offset_row)*1.0/(V-1-top_line)*(CCD_V+2-top_line)+0.5)+right_offset_row;//右边界的矫正
  211.       if(CenterLine[CCD_V]<=3)      CenterLine[CCD_V]=2;
  212.     }
  213.   }
  214.   
  215.         
  216. }

  217. //起跑线,有点迷?
  218. void stop_line()
  219. {
  220.   Right_dot=0;
  221.   left_dot=0;
  222.   
  223.   if(stop_flag==1)
  224.   {
  225.       for(CCD_V=10;CCD_V<15;CCD_V++)
  226.       {
  227.         for(CCD_H=RightBorder[20];CCD_H<=CenterLine[20];CCD_H++)
  228.         {
  229.           if(Bina_data[CCD_V][CCD_H]==0)//为何不统计宽度?统计劳什子的黑点数
  230.           Right_dot++;   
  231.         }
  232.         for(CCD_H=CenterLine[20];CCD_H<=LeftBorder[20];CCD_H++)
  233.         {
  234.           if(Bina_data[CCD_V][CCD_H]==0)
  235.           left_dot++;   
  236.         }
  237.       if((LeftBorder[CCD_V]-RightBorder[CCD_V])<width_min)
  238.              width_min=LeftBorder[CCD_V]-RightBorder[CCD_V]; //有点蒙了
  239.       }
  240.       if(Right_dot>=30 && Right_dot<=90 && left_dot<=90 && left_dot>=30 && top_line1>=45)
  241.       {
  242.          FTM_PWM_Duty(FTM0,CH4,1000);//要减速嘛?4,5通道是干嘛的?
  243.          FTM_PWM_Duty(FTM0,CH5,0);
  244.          if(gpio_get(PORTA,13)==0)    delayms(50);//PORTA是干啥的?
  245.          if(gpio_get(PORTA,14)==0)    delayms(50);
  246.          if(gpio_get(PORTA,15)==0)    delayms(50);
  247.          if(gpio_get(PORTA,16)==0)    delayms(50);
  248.          if(gpio_get(PORTA,12)==0)    delayms(50);
  249.          gpio_set(PORTC,19,0);
  250.       }
  251.   }
  252. }


  253. //中心线判断与矫正  顶端行求取,,,图像的模糊
  254. void TopGet()
  255. {
  256.   
  257.   for(CCD_V=8;CCD_V<V-2;CCD_V++)//又从第八行开始干啥?
  258.   {
  259.     if((CenterLine[CCD_V]-CenterLine[CCD_V+1])>center_error || (CenterLine[CCD_V+1]-CenterLine[CCD_V])>center_error)    //中线误差三?突变嘛?
  260.     {
  261.       if((CenterLine[CCD_V+1]-CenterLine[CCD_V+2])>center_error || (CenterLine[CCD_V+2]-CenterLine[CCD_V+1])>center_error)//连续两行突变?
  262.       {
  263.         top_line1=CCD_V;//又干啥呀?
  264.         break;
  265.       }
  266.       else ;
  267.     }
  268.     else
  269.        top_line1=48;//这样啊
  270.     if(LeftBorder[CCD_V]-RightBorder[CCD_V]<=30)
  271.     {
  272.       if(LeftBorder[CCD_V+1]-RightBorder[CCD_V+1]<=30)
  273.       {
  274.         top_line2=CCD_V;//30是允许通过行驶的宽度嘛?
  275.         break;
  276.       }
  277.       else ;
  278.     }
  279.   }
  280.   if(top_line1>=30 && top_line2>=30)
  281.         top_line=(top_line2 < top_line1) ? top_line2 : top_line1;//找个最小的
  282.   
  283.   /*
  284.   if(count>=5100)
  285.      last_top=top_line;*/
  286. }

  287. void line_count()
  288. {
  289.   left_line=0;
  290.   right_line=0;
  291.   for(CCD_V=0;CCD_V<49;CCD_V++)
  292.   {
  293.       if(LeftBorder[CCD_V]==149)
  294.         left_line++;
  295.       if(RightBorder[CCD_V]==0)
  296.         right_line++;
  297.   }
  298. }

  299. //十字交叉,,,没看太明白
  300. void CrossJudge()
  301. {
  302.   if(count>=5000 && count<=5800 && right_line>=10 && left_line>=10)// && right_line<=18 && left_line<=18),,,count什么呀?
  303.   {   
  304.     for(CCD_V=8;CCD_V<49;CCD_V++)
  305.     {
  306.       if(CenterLine[8]+CenterLine[7]-CenterLine[1]-CenterLine[0]<0)
  307.       {
  308.         if(LeftBorder[CCD_V] - LeftBorder[CCD_V-1]>= 3)
  309.         {
  310.           LeftBorder[CCD_V]=LeftBorder[CCD_V-1]-1;
  311.           RightBorder[CCD_V]=RightBorder[5];
  312.         }
  313.         else if(LeftBorder[CCD_V]>=145)
  314.           LeftBorder[CCD_V]=LeftBorder[CCD_V-1];
  315.         else;
  316.       }
  317.       
  318.       else if(CenterLine[8]+CenterLine[7]-CenterLine[1]-CenterLine[0]>0)
  319.       {
  320.         if(RightBorder[CCD_V] - RightBorder[CCD_V-1]<= -3)
  321.         {
  322.           RightBorder[CCD_V]=RightBorder[CCD_V-1]+1;
  323.           LeftBorder[CCD_V]=LeftBorder[5];
  324.         }
  325.         else if(RightBorder[CCD_V]<= 5)
  326.           RightBorder[CCD_V]=RightBorder[CCD_V-1];
  327.         else;
  328.       }
  329.       CenterLine[CCD_V]=(LeftBorder[CCD_V]+RightBorder[CCD_V])/2;
  330.     }
  331.    
  332.     for(CCD_V=49;CCD_V>top_line;CCD_V--)
  333.       {
  334.         for(CCD_H=CenterLine[top_line];CCD_H>RightBorder[top_line];CCD_H--)
  335.         {
  336.           if(Bina_data[CCD_V][CCD_H+1]==1  && Bina_data[CCD_V][CCD_H]==1)
  337.           {
  338.            if(Bina_data[CCD_V][CCD_H-1]==0 && Bina_data[CCD_V][CCD_H-2]==0)
  339.             {
  340.               RightBorder[CCD_V]=CCD_H;
  341.               break;
  342.             }
  343.           }
  344.          else     RightBorder[CCD_V]=RightBorder[top_line];  
  345.         }
  346.         for(CCD_H=CenterLine[top_line];CCD_H<LeftBorder[top_line];CCD_H++)
  347.         {
  348.           if(Bina_data[CCD_V][CCD_H+1]==1  && Bina_data[CCD_V][CCD_H]==1)
  349.           {
  350.             if(Bina_data[CCD_V][CCD_H+3]==0 && Bina_data[CCD_V][CCD_H+2]==0)
  351.             {
  352.               LeftBorder[CCD_V]=CCD_H;
  353.               break;
  354.             }
  355.           }
  356.                 else     LeftBorder[CCD_V]=LeftBorder[top_line];   
  357.         }
  358.         CenterLine[CCD_V]=(LeftBorder[CCD_V]+RightBorder[CCD_V])/2;  
  359.       }
  360.    
  361.    for(CCD_V=48;CCD_V>=top_line;CCD_V--)
  362.    {
  363.     if((CenterLine[CCD_V]-CenterLine[CCD_V-1])>center_error || (CenterLine[CCD_V-1]-CenterLine[CCD_V])>center_error)
  364.     {
  365.       if((CenterLine[CCD_V]-CenterLine[CCD_V-2])>center_error || (CenterLine[CCD_V-2]-CenterLine[CCD_V])>center_error)
  366.       {
  367.         top_top_line=CCD_V;
  368.         break;
  369.       }
  370.       else ;
  371.     }     
  372.    }
  373.    
  374.    //中心线修正
  375.    
  376.   }
  377. }


  378.   
  379. //=====================================
  380. //||                                 ||
  381. //||          十字道处理             ||
  382. //||                                 ||
  383. //=====================================
  384. /* crossJudge()
  385. {
  386.     char i,j;
  387.     char left_tiaobian=0;
  388.     char right_tiaobian=0;
  389.     char left_guaidian=0;
  390.     char right_guaidian=0;
  391.     char left_tiaobian_row=0;
  392.     char right_tiaobian_row=0;
  393.     char left_guaidian_row=0;
  394.     char right_guaidian_row=0;
  395.    
  396.    
  397.     if(count>=5000 && count<=5800 && right_line>=10 && left_line>=10)  //十字道判断条件1,整场黑点数2,白条宽度  3,斜十字能否准确判断!
  398.     {
  399.   
  400.        //==========十字道处理==========  //搜索左下边沿
  401.        for(i=1;i<V;i++) //注意不要让数组溢出
  402.        {
  403.           //====左边线处理==
  404.              //搜索拐点  //&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&7?
  405.              //左右要写的一样
  406.           if(LeftBorder[i]>LeftBorder[i-1] || LeftBorder[i]>140)  //抓住十字边界的延生特点左突变
  407.               {
  408.                 left_guaidian= LeftBorder[i-3];
  409.                 left_guaidian_row=i-3;
  410.                 break;
  411.               }
  412.          
  413.        }
  414.           //搜索跳变点  //搜索左上边沿
  415.        for(i=1;i<V;i++)
  416.        {   
  417.          if(LeftBorder[i]-LeftBorder[i-1]<-10)  
  418.                  {
  419.             
  420.               left_tiaobian= LeftBorder[i+2];
  421.               left_tiaobian_row=i+2;
  422.               break;
  423.           }
  424.        }
  425.             //搜索完后再补线。
  426.          //边线补线
  427.          if((left_guaidian!=0)&&(left_tiaobian!=0))   //通过直线去补线效果更好
  428.             {
  429.                for(i=left_guaidian_row;i<=left_tiaobian_row;i++)
  430.                   LeftBorder[i]=(char)((left_tiaobian- left_guaidian)*1.0/( left_tiaobian_row-left_guaidian_row)*(i-left_guaidian_row)+0.5)+ left_guaidian;
  431.                  
  432.                
  433.              }
  434.       
  435.       //====右边线处理==
  436.          //搜索拐点
  437.         for(i=1;i<V;i++) //注意不要让数组溢出
  438.        {
  439.           //====右边线处理==
  440.              //搜索拐点  //&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&7?
  441.              //左右要写的一样
  442.           if(RighttBorder[i]<RightBorder[i-1] || RightBorder[i]<10)  //抓住十字边界的延生特点左突变
  443.              {
  444.                                 right_guaidian= RightBorder[i-3];
  445.                 right_guaidian_row=i-3;
  446.                 break;
  447.               }
  448.          
  449.        }
  450.           //搜索跳变点  //搜索右上边沿
  451.        for(i=1;i<V;i++)
  452.        {   
  453.          if( RightBorder[i]- RightBorderr[i-1]>10)  
  454.                  {
  455.             
  456.               right_tiaobian= RightBorder[i+2];
  457.               right_tiaobian_row=i+2;
  458.               break;
  459.           }
  460.        }
  461.         //边线补线
  462.        if((right_guaidian!=0)&&(right_tiaobian!=0))  
  463.          {
  464.                for(i=right_guaidian_row;i<right_tiaobian_row-1;i++)
  465.                   RightBorder[i]=(char)(( right_tiaobian-right_guaidian)*1.0/( right_tiaobian_row- right_guaidian_row)*(i-right_guaidian_row)+0.5)+right_guaidian;
  466.          }
  467.             
  468.          
  469.       
  470.         }
  471.                   //=================中心线重提取============
  472.                                    
  473.       
  474.                           for(i=0;i<V;i++)
  475.         
  476.                           CenterLine[i]=(LeftBorder[i]+RightBorder[i])/2;
  477.                         
  478. }*/


  479. //小S
  480. void S_road()
  481. {
  482.   long center_sum=0;
  483.   //long left_sum=0,right_sum=0;
  484. // unsigned char left_ave=0,right_ave=0;
  485.   if(count>5800)
  486.   {
  487.     for(CCD_V=5;CCD_V<=40;CCD_V++)
  488.     {
  489.       if(fabsf((LeftBorder[CCD_V]-LeftBorder[CCD_V+1])>=3))    LeftBorder[CCD_V]=LeftBorder[CCD_V-1];
  490.       if(fabsf(RightBorder[CCD_V]-RightBorder[CCD_V+1])>=3)    RightBorder[CCD_V]=RightBorder[CCD_V-1];
  491.       CenterLine[CCD_V]=(LeftBorder[CCD_V]+RightBorder[CCD_V])/2;
  492.       center_sum+=CenterLine[CCD_V];
  493.       //right_sum+=RightBorder[CCD_V];
  494.       //left_sum+=LeftBorder[CCD_V];
  495.     }
  496.     //left_ave=left_sum/19;
  497.     //right_ave=right_sum/19;
  498.    
  499.    
  500.     for(CCD_V=5;CCD_V<=44;CCD_V++)
  501.     {
  502.       CenterLine[CCD_V]=center_sum/35;//好吧,中线变直线了,完美
  503.      /* if((right_line-left_line)>5)
  504.         CenterLine[CCD_V]=CenterLine[CCD_V]-10;
  505.       if((left_line-right_line)>5)
  506.         CenterLine[CCD_V]=CenterLine[CCD_V]+10;*/
  507.     }
  508.       
  509.   }
  510.   
  511. }

  512. //发送图像到上位机
  513. void send_photo()
  514. {     
  515.   int i=0,j=0;
  516.   //以下四句话是固定格式,是串口和上位机软件之间的协议
  517.   uart_putchar(UART2,0);
  518.   uart_putchar(UART2,255);
  519.   uart_putchar(UART2,1);
  520.   uart_putchar(UART2,0);
  521.   for(i=V-1;i>=0;i--)
  522.     for(j=H-1;j>=0;j--)
  523.     {
  524.       if(j==CenterLine[i])     uart_putchar(UART2,0);              //中心线
  525.       else if(j==RightBorder[i])     uart_putchar(UART2,0);
  526.       else if(j==LeftBorder[i])     uart_putchar(UART2,0);
  527.       else                     uart_putchar(UART2,Bina_data[i][j]);
  528.     }
  529. }

  530. void SendImg()
  531. {
  532.   disable_irq(89);
  533.   disable_irq(90);                     //关闭场中断,防止串口发送图像数据进程被打乱            
  534.   if(gpio_get(PORTA,11)==0)    thread();
  535.   else     threshold=135;
  536.   BinaData();
  537.   
  538. ……………………

  539. …………限于本文篇幅 余下代码请从51黑下载附件…………
复制代码

所有资料51hei提供下载:
K60 smartcar最终代码.rar (1.83 MB, 下载次数: 33)


分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏1 分享淘帖 顶 踩
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

手机版|小黑屋|51黑电子论坛 |51黑电子论坛6群 QQ 管理员QQ:125739409;技术交流QQ群281945664

Powered by 单片机教程网

快速回复 返回顶部 返回列表