常驻嘉宾
- 积分
- 3091
- 威望
- 2551
- 贡献
- 482
- 兑换币
- 0
- 注册时间
- 2012-5-28
- 在线时间
- 29 小时
- 毕业学校
- 湖北
|
unsigned int hang,hang1,hang2;
unsigned char *p,*q,*o;
unsigned int Get_Image[]={
17,20,23,26,29,31,34,37,40,43,46,49,53,57,
61,65,69,73,77,81,85,89,94,99,105,111,117,123,
129,135,141,147,153,159,166,173,180,187,194
}; //定每场采哪几行。
unsigned int Get_Image1[]={
18,21,24,27,30,32,35,38,42,44,47,50,54,58,
62,66,70,74,78,82,86,90,95,100,106,112,118,124,
130,136,142,148,154,160,167,174,181,188,195
};
unsigned int Get_Image2[]={
19,22,25,28,31,33,36,39,43,45,48,51,55,59,
63,67,71,75,79,83,87,91,96,101,107,113,117,125,
131,137,143,149,155,161,168,175,182,189,196
};
/*************************************************************/
/* 行中断处理函数 */
/*************************************************************/
#pragma CODE_SEG __NEAR_SEG NON_BANKED
void interrupt 8 PT0_Interrupt()
{
TFLG1_C0F=1; //行中断标志位清除,以便于下次行中断进行
Line++; //行中断计数变量
if ( SampleFlag == 0 || Line<ROW_START || Line>ROW_MAX )
{
return; //不是要采集图像的有效行,返回
}
if( Line==Get_Image[hang])
{
delays(8);
Buffer[m][0]=PORTA;_asm();Buffer[m][1]=PORTA;_asm();Buffer[m][2]=PORTA;_asm();Buffer[m][3]=PORTA;_asm();Buffer[m][4]=PORTA;_asm();
Buffer[m][5]=PORTA;_asm();Buffer[m][6]=PORTA;_asm();Buffer[m][7]=PORTA;_asm();Buffer[m][8]=PORTA;_asm();Buffer[m][9]=PORTA;_asm();
Buffer[m][10]=PORTA;_asm();Buffer[m][11]=PORTA;_asm();Buffer[m][12]=PORTA;_asm();Buffer[m][13]=PORTA;_asm();Buffer[m][14]=PORTA;_asm();
Buffer[m][15]=PORTA;_asm();Buffer[m][16]=PORTA;_asm();Buffer[m][17]=PORTA;_asm();Buffer[m][18]=PORTA;_asm();Buffer[m][19]=PORTA;_asm();
Buffer[m][20]=PORTA;_asm();Buffer[m][21]=PORTA;_asm();Buffer[m][22]=PORTA;_asm();Buffer[m][23]=PORTA;_asm();Buffer[m][24]=PORTA;_asm();
Buffer[m][25]=PORTA;_asm();Buffer[m][26]=PORTA;_asm();Buffer[m][27]=PORTA;_asm();Buffer[m][28]=PORTA;_asm();Buffer[m][29]=PORTA;_asm();
Buffer[m][30]=PORTA;_asm();Buffer[m][31]=PORTA;_asm();Buffer[m][32]=PORTA;_asm();Buffer[m][33]=PORTA;_asm();Buffer[m][34]=PORTA;_asm();
Buffer[m][35]=PORTA;_asm();Buffer[m][36]=PORTA;_asm();Buffer[m][37]=PORTA;_asm();Buffer[m][38]=PORTA;_asm();Buffer[m][39]=PORTA;_asm();
Buffer[m][40]=PORTA;_asm();Buffer[m][41]=PORTA;_asm();Buffer[m][42]=PORTA;_asm();Buffer[m][43]=PORTA;_asm();Buffer[m][44]=PORTA;_asm();
Buffer[m][45]=PORTA;_asm();Buffer[m][46]=PORTA;_asm();Buffer[m][47]=PORTA;_asm();Buffer[m][48]=PORTA;_asm();Buffer[m][49]=PORTA;_asm();
Buffer[m][50]=PORTA;_asm();Buffer[m][51]=PORTA;_asm();Buffer[m][52]=PORTA;_asm();Buffer[m][53]=PORTA;_asm();Buffer[m][54]=PORTA;_asm();
Buffer[m][55]=PORTA;_asm();Buffer[m][56]=PORTA;_asm();Buffer[m][57]=PORTA;_asm();Buffer[m][58]=PORTA;_asm();Buffer[m][59]=PORTA;_asm();
Buffer[m][60]=PORTA;_asm();Buffer[m][61]=PORTA;_asm();Buffer[m][62]=PORTA;_asm();Buffer[m][63]=PORTA;_asm();Buffer[m][64]=PORTA;_asm();
Buffer[m][65]=PORTA;_asm();Buffer[m][66]=PORTA;_asm();Buffer[m][67]=PORTA;_asm();Buffer[m][68]=PORTA;_asm();Buffer[m][69]=PORTA;_asm();
Buffer[m][70]=PORTA;_asm();Buffer[m][71]=PORTA;_asm();Buffer[m][72]=PORTA;_asm();Buffer[m][73]=PORTA;_asm();Buffer[m][74]=PORTA;_asm();
Buffer[m][75]=PORTA;_asm();Buffer[m][76]=PORTA;_asm();Buffer[m][77]=PORTA;_asm();Buffer[m][78]=PORTA;_asm();Buffer[m][79]=PORTA;_asm();
Buffer[m][80]=PORTA;_asm();Buffer[m][81]=PORTA;_asm();Buffer[m][82]=PORTA;_asm();Buffer[m][83]=PORTA;_asm();Buffer[m][84]=PORTA;_asm();
Buffer[m][85]=PORTA;_asm();Buffer[m][86]=PORTA;_asm();Buffer[m][87]=PORTA;_asm();Buffer[m][88]=PORTA;_asm();Buffer[m][89]=PORTA;_asm();
Buffer[m][90]=PORTA;_asm();Buffer[m][91]=PORTA;_asm();Buffer[m][92]=PORTA;_asm();Buffer[m][93]=PORTA;_asm();Buffer[m][94]=PORTA;_asm();
Buffer[m][95]=PORTA;_asm();Buffer[m][96]=PORTA;_asm();Buffer[m][97]=PORTA;_asm();Buffer[m][98]=PORTA;_asm();Buffer[m][99]=PORTA;_asm();
Buffer[m][100]=PORTA;_asm();Buffer[m][101]=PORTA;_asm();Buffer[m][102]=PORTA;_asm();Buffer[m][103]=PORTA;_asm();Buffer[m][104]=PORTA;_asm();
Buffer[m][105]=PORTA;_asm();Buffer[m][106]=PORTA;_asm();Buffer[m][107]=PORTA;_asm();Buffer[m][108]=PORTA;_asm();Buffer[m][109]=PORTA;_asm();
Buffer[m][110]=PORTA;_asm();Buffer[m][111]=PORTA;_asm();Buffer[m][112]=PORTA;_asm();Buffer[m][113]=PORTA;_asm();Buffer[m][114]=PORTA;_asm();
Buffer[m][115]=PORTA;_asm();Buffer[m][116]=PORTA;_asm();Buffer[m][117]=PORTA;_asm();Buffer[m][118]=PORTA;_asm();Buffer[m][119]=PORTA;_asm();
Buffer[m][120]=PORTA;
hang++;
m++;
}
if(Line==Get_Image1[hang1])
{
if(*(p-1)-2)
{
for(j=*p+10;j>2;j--)
if((Buffer[m-1][j-2]<=THRESHOLD)&&(Buffer[m-1][j-1]<=THRESHOLD)&&(Buffer[m-1][j]<=THRESHOLD)&&(Buffer[m-1][j+1]>=THRESHOLD)&&(Buffer[m-1][j+2]>=THRESHOLD))
{
*p=j;
break;
}
} else
for(j=60;j>2;j--)
if((Buffer[m-1][j-2]<=THRESHOLD)&&(Buffer[m-1][j-1]<=THRESHOLD)&&(Buffer[m-1][j]<=THRESHOLD)&&(Buffer[m-1][j+1]>=THRESHOLD)&&(Buffer[m-1][j+2]>=THRESHOLD))
{
*p=j;
break;
}
if(*(q-1)-118)
{
for(j=*q-10;j<118;j++)
if((Buffer[m-1][j-2]>=THRESHOLD)&&(Buffer[m-1][j-1]>=THRESHOLD)&&(Buffer[m-1][j]<=THRESHOLD)&&(Buffer[m-1][j+1]<=THRESHOLD)&&(Buffer[m-1][j+2]<=THRESHOLD))
{
*q=j;
break;
} else
for(j=60;j<118;j++)
if((Buffer[m-1][j-2]>=THRESHOLD)&&(Buffer[m-1][j-1]>=THRESHOLD)&&(Buffer[m-1][j]<=THRESHOLD)&&(Buffer[m-1][j+1]<=THRESHOLD)&&(Buffer[m-1][j+2]<=THRESHOLD))
{
*q=j;
break;
}
}
hang1++;
}
if(Line==Get_Image2[hang2])
{
if((*p-2)&&(*q-118))
*o=(unsigned char)(*p+*q)/2;
else if(*p-2)
*o=*p+60;
else if(*q-118)
*o=*q-60;
else
*o=*(o-1)*2-*(o-2);
}
}
/*************************************************************/
/* 场中断处理函数 */
/*************************************************************/
#pragma CODE_SEG __NEAR_SEG NON_BANKED
void interrupt 9 PT1_Interrupt()
{
TFLG1_C1F=1; //场中断清楚,以便于下次的场中断的正常进行
TFLG1_C0F=1; //行中断清除,以便于开始采集图像数据
m=0; //行中间变量清零,以便于开始从把采集的图像放到数组的第一行
Line=0; //行中断临时变量清零
hang=0;
hang1=0;
hang2=0; //行临时变量清除
SampleFlag=~SampleFlag; //场中断标记取反,这样只采集奇数场的图像
Left[0]=Left[ROW-1];
Right[0]=Right[ROW-1];
Center[0]=Center[ROW-1];
p=&Left[0];
q=&Right[0];
o=&Center[0];
}
|
|