久久久久久久999_99精品久久精品一区二区爱城_成人欧美一区二区三区在线播放_国产精品日本一区二区不卡视频_国产午夜视频_欧美精品在线观看免费

 找回密碼
 立即注冊

QQ登錄

只需一步,快速開始

搜索
查看: 5492|回復: 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 單片機教程網

快速回復 返回頂部 返回列表
主站蜘蛛池模板: 免费观看黄色片视频 | 在线欧美日韩 | 成人欧美一区二区三区在线观看 | 久久久精品一区二区 | 91天堂| 久久免费资源 | 无码日韩精品一区二区免费 | 久久伊人亚洲 | 一区二视频 | 久久精品成人一区 | 亚洲欧美日韩在线 | 色桃网 | 国产精品久久av | 97色伦网| 天堂综合网久久 | 欧美日韩久久 | 久久精品欧美一区二区三区不卡 | 亚洲天堂影院 | 日本黄色免费大片 | 一区二区三区欧美 | 精品久久精品 | 久久婷婷麻豆国产91天堂 | 日韩欧美一区二区三区免费看 | 亚洲国产精品久久久 | 国产欧美日韩久久久 | 九九亚洲| 9久久精品 | 色综合99| 中文字幕国产一区 | 日韩精品视频一区二区三区 | 日韩亚洲欧美一区 | 成人片在线看 | 欧洲一区二区三区 | 午夜一区二区三区在线观看 | 男人天堂网址 | av在线播放网站 | 欧美日韩精品一区二区三区四区 | 亚洲日日操| 成人综合久久 | 久久久女女女女999久久 | 国产精品久久久久久久久久 |