⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 find.c

📁 合众达的DM642示例工程
💻 C
字号:

//从一副图像576×720的一行中找到低于threshold的点


void find(unsigned maddr,unsigned  address,unsigned char threshold,int * x,int * y,int * n,int line_num)
{
int i;
int m;
int temp;
int over;
int line;
int num,start,startnum;
int b,flagn;
unsigned short a;
unsigned t3_t2_t1_t0; //threshold
unsigned p3_p2_p1_p0;
unsigned c3_c2_c1_c0; //comparison results

int qq;
unsigned char limit;

limit = 20;
temp =_pack2(threshold,threshold);//threshold<<8;

//temp = _packl4(temp,0x00800080);
t3_t2_t1_t0 =  _packl4(temp,temp);//threshold+temp;// | 0x80008000;
line=0;
a=0;
b=0;
flagn=0;
qq=0;
num = 0;
start = 0;
over = 0;



startnum=0;
for(i=0; i<360; i++)
{
	if(!(i%2))
	p3_p2_p1_p0 = *(unsigned *)(address+2*i);

	c3_c2_c1_c0 = _cmpgtu4(p3_p2_p1_p0,t3_t2_t1_t0);
	p3_p2_p1_p0=p3_p2_p1_p0>>16;
	
	if(start == 0)
	{
		if(c3_c2_c1_c0 & 0x000000001)  //the first dot is  
		{
			start = 1;
			startnum = 2*i;
			num++;
		}
		else if(c3_c2_c1_c0 & 0x00000002) //the second dot is
		{
			start = 1;
			startnum = 2*i+1;
			num++;
		}
		else if(c3_c2_c1_c0 & 0x00000003) //both
		{
			start = 1;
			startnum = 2*i;
			num+=2;
		}

	}
	else
	{
		if((c3_c2_c1_c0 & 0x00000001)==0)  //the first dot is  
		{
			over = 1;
		}
		else if((c3_c2_c1_c0 & 0x00000002)==0)  //the second dot is
		{
			num++;
			over = 1;
		}	
		else
		{ 
			num+=2;
			
		}	
					
		
			if(over)
			{

		if(num >2 && num < 60)
			{

					b = startnum + num/2;
					if(!(line_num%2)) 	a = 0x00ff & *(unsigned short *)((line_num/2)*720+b+0x32a00 + maddr);
					else 			a = 0x00ff & *(unsigned short *)((line_num/2)*720+b + maddr);
					
					flagn = 0;
					if(num < 4)
					{
					for( m=-3;m<4;m++ )
					{
						line = line_num + m;
						if(!(line_num%2)) 	temp = 0x00ff & *(unsigned short *)((line/2)*720+b+3+0x32a00+ maddr);
						else 			temp = 0x00ff & *(unsigned short *)((line/2)*720+b+3+ maddr);					
						
						
						qq=a-temp;
						if(qq > limit) flagn++;
						
						if(!(line_num%2)) 	temp = 0x00ff & *(unsigned short *)((line/2)*720+b-3+0x32a00+ maddr);
						else 			temp = 0x00ff & *(unsigned short *)((line/2)*720+b-3+ maddr);						
						qq=a-temp;
						if(qq > limit) flagn++;
												
						line = line_num + 3;
						if(!(line_num%2)) 	temp = 0x00ff & *(unsigned short *)((line/2)*720+b+m+0x32a00+ maddr);
						else 			temp = 0x00ff & *(unsigned short *)((line/2)*720+b+m+ maddr);																	
						qq=a-temp;
						if(qq > limit) flagn++;
						
						line = line_num - 3;
						if(!(line_num%2)) 	temp = 0x00ff & *(unsigned short *)((line/2)*720+b-m+0x32a00+ maddr);
						else 			temp = 0x00ff & *(unsigned short *)((line/2)*720+b-m+ maddr);						
						qq=a-temp;
						if(qq > limit) flagn++;
					}




					if(flagn==28) 
					{
						x[(*n)]=line_num;
						y[(*n)]=b;
						(*n)++;
					}
					}

					else if(num < 8)
					{
					for( m=-7;m<8;m++ )
					{
						line = line_num + m;
						if(!(line_num%2)) 	temp = 0x00ff & *(unsigned short *)((line/2)*720+b+7+0x32a00+ maddr);
						else 			temp = 0x00ff & *(unsigned short *)((line/2)*720+b+7+ maddr);					
						
						
						qq=a-temp;
						if(qq > limit) flagn++;
						
						if(!(line_num%2)) 	temp = 0x00ff & *(unsigned short *)((line/2)*720+b-7+0x32a00+ maddr);
						else 			temp = 0x00ff & *(unsigned short *)((line/2)*720+b-7+ maddr);						
						qq=a-temp;
						if(qq > limit) flagn++;
												
						line = line_num + 7;
						if(!(line_num%2)) 	temp = 0x00ff & *(unsigned short *)((line/2)*720+b+m+0x32a00+ maddr);
						else 			temp = 0x00ff & *(unsigned short *)((line/2)*720+b+m+ maddr);																	
						qq=a-temp;
						if(qq > limit) flagn++;
						
						line = line_num - 7;
						if(!(line_num%2)) 	temp = 0x00ff & *(unsigned short *)((line/2)*720+b-m+0x32a00+ maddr);
						else 			temp = 0x00ff & *(unsigned short *)((line/2)*720+b-m+ maddr);						
						qq=a-temp;
						if(qq > limit) flagn++;
					}

					if(flagn==60) 
					{
						x[(*n)]=line_num;
						y[(*n)]=b;
						(*n)++;
					}
					}




					else if(num < 15)
					{
					for( m=-15;m<16;m++ )
					{
						line = line_num + m;
						if(!(line_num%2)) 	temp = 0x00ff & *(unsigned short *)((line/2)*720+b+15+0x32a00+ maddr);
						else 			temp = 0x00ff & *(unsigned short *)((line/2)*720+b+15+ maddr);					
						
						
						qq=a-temp;
						if(qq > limit) flagn++;
						
						if(!(line_num%2)) 	temp = 0x00ff & *(unsigned short *)((line/2)*720+b-15+0x32a00+ maddr);
						else 			temp = 0x00ff & *(unsigned short *)((line/2)*720+b-15+ maddr);						
						qq=a-temp;
						if(qq > limit) flagn++;
												
						line = line_num + 15;

						if(!(line_num%2)) 	temp = 0x00ff & *(unsigned short *)((line/2)*720+b+m+0x32a00+ maddr);
						else 			temp = 0x00ff & *(unsigned short *)((line/2)*720+b+m+ maddr);																	
						qq=a-temp;
						if(qq > limit) flagn++;
						
						line = line_num - 15;
						if(!(line_num%2)) 	temp = 0x00ff & *(unsigned short *)((line/2)*720+b-m+0x32a00+ maddr);
						else 			temp = 0x00ff & *(unsigned short *)((line/2)*720+b-m+ maddr);						
						qq=a-temp;
						if(qq > limit) flagn++;
					}

					if(flagn==124) 
					{
						x[(*n)]=line_num;
						y[(*n)]=b;
						(*n)++;
					}
					}
					
					
					
					
					
				/*	else if(num < 60)
					{
					for( m=-60;m<61;m++ )
					{
						line = line_num + m;
						if(!(line_num%2)) 	temp = 0x00ff & *(unsigned short *)((line/2)*720+b+60+0x32a00+ maddr);
						else 			temp = 0x00ff & *(unsigned short *)((line/2)*720+b+60+ maddr);					
						
						
						qq=a-temp;
						if(qq > limit) flagn++;
						
						if(!(line_num%2)) 	temp = 0x00ff & *(unsigned short *)((line/2)*720+b-60+0x32a00+ maddr);
						else 			temp = 0x00ff & *(unsigned short *)((line/2)*720+b-60+ maddr);						
						qq=a-temp;
						if(qq > limit) flagn++;
												
						line = line_num + 60;

						if(!(line_num%2)) 	temp = 0x00ff & *(unsigned short *)((line/2)*720+b+m+0x32a00+ maddr);
						else 			temp = 0x00ff & *(unsigned short *)((line/2)*720+b+m+ maddr);																	
						qq=a-temp;
						if(qq > limit) flagn++;
						
						line = line_num - 60;
						if(!(line_num%2)) 	temp = 0x00ff & *(unsigned short *)((line/2)*720+b-m+0x32a00+ maddr);
						else 			temp = 0x00ff & *(unsigned short *)((line/2)*720+b-m+ maddr);						
						qq=a-temp;
						if(qq > limit) flagn++;
					}

					if((flagn>180)) 
					{
						x[(*n)]=line_num;
						y[(*n)]=b;
						(*n)++;
					}
					}*/
					
					//(hGpio,GPIO_PIN0,GPIO_OUTPUT);
					
					}
			over = 0;
			start=0;
			num=0;
		}
		
		
		
		
		
		
		
		
		
		

	}
}




}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -