Exemplo n.º 1
0
//Cambio***************
static int filtro_gestos_buscar_limites(lua_State *L)
{
 dato_t *in = (filtro_gestos_in_imagen_t *)lua_touserdata(L, 1);
 int op = luaL_checkint(L, 2);
 special_colour_t *sc = (special_colour_t *)lua_touserdata(L, 3);
 bounds_t* out = (bounds_t*)malloc(sizeof(bounds_t));
 coord_t c1= Corner1(in,sc);
 coord_t c2= Corner2(in,sc);
 coord_t c3= Corner3(in,sc);
 coord_t c4= Corner4(in,sc);
 int b, a, d, c;
double divis,divis2;
 double angulo, angulo2;
 int grados1, grados2;
 if(op){
   Identify(in,out,c1);
   Identify(in,out,c2);
   Identify(in,out,c3);
   Identify(in,out,c4);
 }
 else Identify2(out,c1,c2,c3,c4);
 //Cambio********************************+
 b= out->ii.y-out->id.y;
  a= out->id.x-out->ii.x;
  d= out->ii.y-out->si.y;
  c= out->ii.x-out->si.x;
 
 
 // Tenías esto, el compilador da un warning
 // se suele usar sólo para asignaciones como te lo he puesto
 // Carlos
 // (a==0)?divis=0:divis=(double)b/a;
 //(c==0)?divis2=0:divis2=(double)d/c;
 // hasta aquí
 divis = (a == 0) ? 0 : (double)b / a;
 divis2 = (c == 0) ? 0 : (double)d / c;
 // esto de antes es lo nuevo, así no se queja
  angulo= atan(divis);
  angulo2= atan(divis2);
 out->grados= (angulo*180)/M_PI;
  grados1= abs(out->grados);
  grados2= abs((angulo2*180)/M_PI);
 /*lua_pushlightuserdata(L, grados1+grados2>80 && grados1+grados2<100 ? 
   out : 0);*/
 lua_pushlightuserdata(L, out);
 ///*if((*/grados1+grados2>80 && grados1+grados2<100;/*) || !op)*/
 return 1;
// else return 0;
}
Exemplo n.º 2
0
///////////////////////////////////////////////////////////////////////
/// \brief Measure the line in pixels
/////////////////////////////////////////////////////////////////////////
void vfn_calibrateLine(void)
{
	//Create the pattern.
//	vfn_binarize();
//	
//	//Is a black line?
//	if( pat_info.value ==  BLACK_LINE && pat_info.valid == 3 )
//	{
//		ub_Left_Corner = pat_info.width[0];
//		ub_Right_Corner = pat_info.width[1] - 1;
//	
//		sb_BLACK_STRIP_WIDTH_MEASU = ub_Black_Strip_Width = pat_info.width[1] - pat_info.width[0];
//		ub_Black_Strip_Center = ub_Black_Strip_Width / 2 + pat_info.width[0];
//	}
	
	CalculateCentralDifferentials(NUM_PIXELS);
	CalculateCentralDifferentials2(NUM_PIXELS);
		
	switch (Identify(NUM_PIXELS)) {
	
		case 1:
			
			sb_BLACK_STRIP_WIDTH_MEASU = ub_Black_Strip_Width = lineWidth;
			ub_Line_Average[0] = ub_Black_Strip_Center = lineCenter;
			
			//TERMINAL_PRINTF( "%d\r\n",1 );
			
			break;
			
		default:
			break;
	}
	
	switch (Identify2(NUM_PIXELS)) {
		
			case 1:
				
				sb_BLACK_STRIP_WIDTH_MEASU2 = ub_Black_Strip_Width2 = lineWidth2;
				ub_Line_Average2[0] = ub_Black_Strip_Center2 = lineCenter2;
				
				//TERMINAL_PRINTF( "%d\r\n",1 );
				
				break;
				
			default:
				break;
		}
}
Exemplo n.º 3
0
//Cambio********************
static int filtro_gestos_on_border(lua_State *L)
{
 dato_t *in = (filtro_gestos_in_imagen_t *)lua_touserdata(L, 1);
 special_colour_t *sc = (special_colour_t *)lua_touserdata(L, 2);
 //bounds_t* out = (bounds_t*)malloc(sizeof(bounds_t));
 bounds_t out;
 coord_t c1= Corner1(in,sc);
 coord_t c2= Corner2(in,sc);
 coord_t c3= Corner3(in,sc);
 coord_t c4= Corner4(in,sc);
 Identify2(&out,c1,c2,c3,c4);
 if(out.ii.y>in->m_alto-BORDER || out.si.y<BORDER ||
    out.ii.x<BORDER || out.id.x>in->m_ancho-BORDER){
   //free(out);   
   //   return 1;
   lua_pushboolean(L, 1);
 }
 else{
   //free(out);
   //return 0;
   lua_pushboolean(L, 0);
 }
 return 1;
}