智能车制作

 找回密码
 注册

扫一扫,访问微社区

查看: 1095|回复: 2
打印 上一主题 下一主题

开始看程序了。。

[复制链接]

2

主题

12

帖子

0

精华

中级会员

Rank: 3Rank: 3

积分
307
威望
159
贡献
78
兑换币
87
注册时间
2015-3-25
在线时间
35 小时
跳转到指定楼层
1#
发表于 2015-5-16 11:51:38 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
想学一下调试车模。。可是程序看不懂。不知道从何下手。。求大神给点意见吧。。感谢!!!!
回复

使用道具 举报

2

主题

12

帖子

0

精华

中级会员

Rank: 3Rank: 3

积分
307
威望
159
贡献
78
兑换币
87
注册时间
2015-3-25
在线时间
35 小时
2#
 楼主| 发表于 2015-5-16 11:53:17 | 只看该作者
:'(:'(:'(真的不晓得从哪里看起走。
回复 支持 反对

使用道具 举报

1

主题

2

帖子

0

精华

注册会员

Rank: 2

积分
34
威望
30
贡献
4
兑换币
5
注册时间
2016-2-25
在线时间
0 小时
毕业学校
皖西学院
3#
发表于 2016-3-3 17:01:56 | 只看该作者
同感啊,我有一份K60的程序,看不懂,求大神解读


#include  "common.h"
#include  "image.h"
#include  "gpio.h"
#include  "exti.h"
#include  "uart.h"
#include  "FTM.h"
#include  "delay.h"
#include  "isr.h"

unsigned char threshold=135;         
unsigned char Is_SendPhoto=0;  
unsigned char Pix_data[V][H]={0},Bina_data[V][H]={0};
int  LeftBorder[V]={0},RightBorder[V]={0}, CenterLine[V]={0};
u16 CCD_V,CCD_H;
s8 Sumleft,Sumright;
unsigned char top_line=40,top_line1=50,top_line2=48;
long count,WhiteNum;
unsigned char width_count=50;
unsigned char width_min=50;
unsigned char V_count=0;         
unsigned char jump_point;

unsigned char last_top;
unsigned char top_top_line=49;

unsigned char THRE[20];
long  thre_sum=0;
unsigned char thread_count;
unsigned char center_min=30;
unsigned char left_line,right_line;

unsigned int left_count,right_count;


unsigned char Bina_Data[H]={0};
u32 S_count=0;
extern u32 start4s;
void CameraInit()
{  
    exti_init(PORTE,1,rising_down);           
    disable_irq(91);                        
exti_init(PORTE,0,falling_down);           
}
void Binarization(void)
{
  u16 i;
  for(i=0;i<280;i++)
  {
   if(Pix_data[32][i]>threshold)
   {
     Bina_Data[i] = 1;
   }
   else
   {
     Bina_Data[i] = 0;
   }
  }
}

void Get_Center(void)
{
    for(CCD_H=155;CCD_H>1;CCD_H--)
    {
      if((Bina_Data[CCD_H]) && (Bina_Data[CCD_H-1]==0) && (Bina_Data[CCD_H-2]==0))      {
        RightBorder[CCD_V]=CCD_H;
        break;
      }
      else   RightBorder[CCD_V]=0;      
    }
     
    for(CCD_H=125;CCD_H<H-2;CCD_H++)
    {
      if((Bina_Data[CCD_H]==0) && (Bina_Data[CCD_H+1]==0) && (Bina_Data[CCD_H+2]==0))   
      {
        LeftBorder[CCD_V]=CCD_H;
        break;
      }
      else   LeftBorder[CCD_V]=280;
     
    }
    CenterLine[CCD_V]=(LeftBorder[CCD_V]+RightBorder[CCD_V])/2;
}

void BinaData()
{
  int i=0,j=0;
  unsigned char *p;
  for(i=0;i<V;i++)
  {
    p=Pix_data[i];
    for(j=0;j<H;j++)
    {
      if(*(p+j)>=threshold)     
      {
        Bina_data[i][j]=1;
      }
      else  
        Bina_data[i][j]=0;
    }
  }
}
void AllFilt()
{
  count=0;
  for(CCD_V=1;CCD_V<V-1;CCD_V++)
  {
    for(CCD_H=1;CCD_H<H-1;CCD_H++)
    {
      if(Bina_data[CCD_V][CCD_H]==1)
      {  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))
          {
               Bina_data[CCD_V][CCD_H]=1;  
               count++;
          }
         else  
               Bina_data[CCD_V][CCD_H]=0;

      }
      else if(Bina_data[CCD_V][CCD_H]==0)
      {
         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))
          {
               Bina_data[CCD_V][CCD_H]=0;
          }
         else  
         {
               Bina_data[CCD_V][CCD_H]=1;
               count++;
         }
      }
    }
  }
}
void get_center()
{
  
  unsigned char *p;
  static unsigned char last_center=140;
  for(CCD_V=0;CCD_V<LINE;CCD_V++)
  {
    p=Bina_data[CCD_V];
    for(CCD_H=140;CCD_H>1;CCD_H--)
    {
      if((*(p+CCD_H)==0) && (*(p+CCD_H-1)==0) && (*(p+CCD_H-2)==0))
      {
        RightBorder[CCD_V]=CCD_H;
        break;
      }
      else     RightBorder[CCD_V]=18;     
     
    }
      
   for(CCD_H=140;CCD_H<H-2;CCD_H++)     
{
      if((*(p+CCD_H)==0) && (*(p+CCD_H+1)==0) && (*(p+CCD_H+2)==0))         
{
        LeftBorder[CCD_V]=CCD_H;
        break;
       }
      else    LeftBorder[CCD_V]=262;   
     
   }
    CenterLine[CCD_V]=(LeftBorder[CCD_V]+RightBorder[CCD_V])/2;
   
    if(fabsf(CenterLine[4]-last_center)>=8)
      CenterLine[4]=last_center;
    last_center=CenterLine[4];         
   
//    if((LeftBorder[CCD_V]-RightBorder[CCD_V])>width_count)
//       width_count=LeftBorder[CCD_V]-RightBorder[CCD_V];
   
  }  
  
  for(CCD_V=LINE;CCD_V<V;CCD_V++)
  {
    p=Bina_data[CCD_V];
    for(CCD_H=(unsigned char )CenterLine[CCD_V-1];CCD_H>1;CCD_H--)
    {
      if((*(p+CCD_H)==0) && (*(p+CCD_H-1)==0) && (*(p+CCD_H-2)==0))
      {
        RightBorder[CCD_V]=CCD_H;
        break;
      }
      else   RightBorder[CCD_V]=18;      
      
    }
     
    for(CCD_H=(unsigned char )CenterLine[CCD_V-1];CCD_H<H-2;CCD_H++)
    {
      if((*(p+CCD_H)==0) && (*(p+CCD_H+1)==0) && (*(p+CCD_H+2)==0))   
      {
        LeftBorder[CCD_V]=CCD_H;
        break;
      }
      else   LeftBorder[CCD_V]=262;
     
    }
    CenterLine[CCD_V]=(LeftBorder[CCD_V]+RightBorder[CCD_V])/2;
      
   
    //if((LeftBorder[CCD_V]-RightBorder[CCD_V])>width_count)
    //   width_count=LeftBorder[CCD_V]-RightBorder[CCD_V];
   
  }
}



回复 支持 反对

使用道具 举报

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

本版积分规则

关于我们|联系我们|小黑屋|智能车制作 ( 黑ICP备2022002344号

GMT+8, 2024-10-2 06:32 , Processed in 0.066093 second(s), 31 queries , Gzip On.

Powered by Discuz! X3.2

© 2001-2013 Comsenz Inc.

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