[Jderobot-admin] jderobot-r1027 - in trunk/src/stable/libs/visionlib: . imgAnalyze

eperdices en jderobot.org eperdices en jderobot.org
Mie Oct 9 17:12:57 CEST 2013


Author: eperdices
Date: 2013-10-09 17:11:57 +0200 (Wed, 09 Oct 2013)
New Revision: 1027

Added:
   trunk/src/stable/libs/visionlib/imgAnalyze/
   trunk/src/stable/libs/visionlib/imgAnalyze/CMakeLists.txt
   trunk/src/stable/libs/visionlib/imgAnalyze/geometry.cpp
   trunk/src/stable/libs/visionlib/imgAnalyze/geometry.h
   trunk/src/stable/libs/visionlib/imgAnalyze/image.cpp
   trunk/src/stable/libs/visionlib/imgAnalyze/image.h
   trunk/src/stable/libs/visionlib/imgAnalyze/linesDetection.cpp
   trunk/src/stable/libs/visionlib/imgAnalyze/linesDetection.h
   trunk/src/stable/libs/visionlib/imgAnalyze/structs.h
Removed:
   trunk/src/stable/libs/visionlib/geometry.cpp
   trunk/src/stable/libs/visionlib/geometry.h
   trunk/src/stable/libs/visionlib/image.cpp
   trunk/src/stable/libs/visionlib/image.h
   trunk/src/stable/libs/visionlib/linesDetection.cpp
   trunk/src/stable/libs/visionlib/linesDetection.h
   trunk/src/stable/libs/visionlib/structs.h
Modified:
   trunk/src/stable/libs/visionlib/CMakeLists.txt
   trunk/src/stable/libs/visionlib/visionlib.h
Log:
#58 Visionlib structure changed



Modified: trunk/src/stable/libs/visionlib/CMakeLists.txt
===================================================================
--- trunk/src/stable/libs/visionlib/CMakeLists.txt	2013-10-09 14:41:27 UTC (rev 1026)
+++ trunk/src/stable/libs/visionlib/CMakeLists.txt	2013-10-09 15:11:57 UTC (rev 1027)
@@ -4,10 +4,5 @@
         ADD_SUBDIRECTORY (${libs})
 ENDFOREACH()
 
-SET( SOURCE_FILES geometry.cpp image.cpp linesDetection.cpp)
-include_directories( ${LIBS_DIR}/)
-add_library (visionlib  SHARED ${SOURCE_FILES})
-TARGET_LINK_LIBRARIES(visionlib progeo cvfast)
 
 
-

Deleted: trunk/src/stable/libs/visionlib/geometry.cpp
===================================================================
--- trunk/src/stable/libs/visionlib/geometry.cpp	2013-10-09 14:41:27 UTC (rev 1026)
+++ trunk/src/stable/libs/visionlib/geometry.cpp	2013-10-09 15:11:57 UTC (rev 1027)
@@ -1,668 +0,0 @@
- /*
- *  Copyright (C) 2010 Julio Vega Pérez
- *
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2 of the License, or
- *  (at your option) any later version.
- *
- *  This program is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU Library General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *
- * 	Author : Julio Vega Pérez (julio [dot] vega [at] urjc [dot] es)
- *           Eduardo Perdices (eperdices [at] gsyc [dot] es)
- *
- *  This library was programed for RobotVision Project http://jderobot.org/index.php/robotvision
- *
- */
-
-#include "geometry.h"
-
-namespace visionLibrary {
-
-	const double geometry::GEOMETRY_PI = 3.1415926535897932384626433832795;
-	const double geometry::GEOMETRY_PI_2 = 1.570796327;
-	const double geometry::GEOMETRY_SQRT_2 = 1.414213562;
-	const double geometry::GEOMETRY_INFINITE = 123456789.123456789;
-
-	geometry::geometry () {}
-
-	geometry::~geometry () {}
-
-	double geometry::distanceBetweenPoints2D(int x1, int y1, int x2, int y2)
-	{
-		return sqrt(G_SQUARE(x2-x1) + G_SQUARE(y2-y1));
-	}
-
-	double geometry::distanceBetweenPoints2D(double x1, double y1, double x2, double y2)
-	{
-		return sqrt(G_SQUARE(x2-x1) + G_SQUARE(y2-y1));
-	}
-
-	double geometry::distanceBetweenPoints2D(HPoint2D p1, HPoint2D p2)
-	{
-		return sqrt(G_SQUARE(p2.x-p1.x) + G_SQUARE(p2.y-p1.y));
-	}
-
-	double geometry::distanceBetweenPoints3D(HPoint3D p1, HPoint3D p2)
-	{
-		return sqrt(G_SQUARE(p2.X-p1.X) + G_SQUARE(p2.Y-p1.Y) + G_SQUARE(p2.Z-p1.Z));
-	}
-
-	double geometry::calcDistanceAxis(double x1, double y1, double x2, double y2, double alpha)
-	{
-		double dist;
-
-		dist = (x2 - x1)*cos(alpha) + (y2 - y1)*sin(alpha);
-
-		return fabs(dist);
-	}
-
-	double geometry::calcDistanceAxis(HPoint2D p1, HPoint2D p2, double alpha)
-	{
-		double dist;
-
-		dist = (p2.x - p1.x)*cos(alpha) + (p2.y - p1.y)*sin(alpha);
-
-		return fabs(dist);
-	}
-
-	double geometry::calcDistanceAxis(HPoint2D p1, HPoint2D p2, double cosa, double sina)
-	{
-		double dist;
-
-		dist = (p2.x - p1.x)*cosa + (p2.y - p1.y)*sina;
-
-		return fabs(dist);
-	}
-
-	double geometry::calcDistanceAxis(HPoint3D p1, HPoint3D p2, double alpha)
-	{
-		double dist;
-
-		dist = (p2.X - p1.X)*cos(alpha) + (p2.Y - p1.Y)*sin(alpha);
-
-		return fabs(dist);
-	}
-
-	double geometry::calcDistanceAxis(HPoint3D p1, HPoint3D p2, double cosa, double sina)
-	{
-		double dist;
-
-		dist = (p2.X - p1.X)*cosa + (p2.Y - p1.Y)*sina;
-
-		return fabs(dist);
-	}
-
-	double geometry::calcVectorAngle(double x1, double y1, double x2, double y2)
-	{
-		double diffx, diffy;
-		double alpha;
-
-		diffx = x2 - x1;
-		diffy = y2 - y1;
-
-		if(diffx == 0.0)
-			return GEOMETRY_PI_2;
-
-		alpha = atan(diffy/diffx);
-
-		/*Normalize*/
-		if(alpha < 0)
-			alpha += GEOMETRY_PI;
-		if(alpha > GEOMETRY_PI)
-			alpha -= GEOMETRY_PI;	
-
-		return alpha;		
-	}
-
-	double geometry::calcVectorAngle(HPoint3D line)
-	{
-		double alpha;
-
-		if(line.Y == 0.0)
-			return GEOMETRY_PI_2;
-
-		alpha = atan(-line.X/line.Y);
-
-		/*Normalize*/
-		if(alpha < 0)
-			alpha += GEOMETRY_PI;
-		if(alpha > GEOMETRY_PI)
-			alpha -= GEOMETRY_PI;	
-
-		return alpha;		
-	}
-
-	double geometry::calcVectorGradient(double x1, double y1, double x2, double y2)
-	{
-		double diffx, diffy;
-
-		diffx = x2 - x1;
-		diffy = y2 - y1;
-
-		if(diffx == 0.0)
-			return GEOMETRY_INFINITE;
-
-		return diffy/diffx;
-	}
-
-	double geometry::calcVectorGradient(HPoint3D line)
-	{
-		if(line.Y == 0.0)
-			return GEOMETRY_INFINITE;
-
-		return -line.X/line.Y;
-	}
-
-	void geometry::calcVector2D(HPoint2D p1, HPoint2D p2, HPoint3D &v)
-	{
-		/*Get the Ax + By + C = 0 parameters*/
-		v.X = p1.y - p2.y; 				//y1*z2 - z1*y2
-		v.Y = p2.x - p1.x; 				//z1*x2 - x1*z2
-		v.Z = p1.x*p2.y - p1.y*p2.x; 	//x1*y2 - y1*x2
-		v.H = 1.0;
-	}
-
-	void geometry::calcVector2D(HPoint3D p1, HPoint3D p2, HPoint3D &v)
-	{
-		/*Get the Ax + By + C = 0 parameters*/
-		v.X = p1.Y - p2.Y; 				//y1*z2 - z1*y2
-		v.Y = p2.X - p1.X; 				//z1*x2 - x1*z2
-		v.Z = p1.X*p2.Y - p1.Y*p2.X; 	//x1*y2 - y1*x2
-		v.H = 1.0;
-	}
-
-	void geometry::calcNormalVector2D(HPoint2D p1, HPoint2D p2, HPoint2D p3, HPoint3D &v)
-	{
-		HPoint3D vtmp;
-		double nA, nB, nC;
-
-		/*Get the vector p1-p2*/
-		calcVector2D(p1, p2, vtmp);
-
-		/*Calc the normal*/
-		nA = vtmp.Y;
-		nB = -vtmp.X;
-		nC = -(p3.x*nA + p3.y*nB); //Solve equation Ax+By+C with central point
-
-		v.X = nA;
-		v.Y = nB;
-		v.Z = nC;	
-		v.H = 1.0;
-	}
-
-	void geometry::calcNormalVector2D(HPoint3D p1, HPoint3D p2, HPoint3D p3, HPoint3D &v)
-	{
-		HPoint3D vtmp;
-		double nA, nB, nC;
-
-		/*Get the vector p1-p2*/
-		calcVector2D(p1, p2, vtmp);
-
-		/*Calc the normal*/
-		nA = vtmp.Y;
-		nB = -vtmp.X;
-		nC = -(p3.X*nA + p3.Y*nB); //Solve equation Ax+By+C with central point
-
-		v.X = nA;
-		v.Y = nB;
-		v.Z = nC;	
-		v.H = 1.0;
-	}
-
-	void geometry::calcIntersection2D(HPoint3D v1, HPoint3D v2, HPoint2D &p)
-	{
-		double h;
-
-		h = v1.X*v2.Y - v1.Y*v2.X; 		/*x1*y2 - y1*x2*/
-
-		/*Are parallel*/	
-		if(h==0)
-			p.h = 0.0;
-
-		p.x = (v1.Y*v2.Z - v2.Y*v1.Z)/h; /*y1*z2 - z1*y2*/
-		p.y = (v1.Z*v2.X - v1.X*v2.Z)/h; /*z1*x2 - x1*z2*/
-		p.h = 1.0;
-	}
-
-	void geometry::calcIntersection2D(HPoint3D v1, HPoint3D v2, HPoint3D &p)
-	{
-		double h;
-
-		h = v1.X*v2.Y - v1.Y*v2.X; 		/*x1*y2 - y1*x2*/
-
-		/*Are parallel*/	
-		if(h==0)
-			p.H = 0.0;
-
-		p.X = (v1.Y*v2.Z - v2.Y*v1.Z)/h; /*y1*z2 - z1*y2*/
-		p.Y = (v1.Z*v2.X - v1.X*v2.Z)/h; /*z1*x2 - x1*z2*/
-		p.Z = 0.0;
-		p.H = 1.0;
-	}
-
-	bool geometry::areVectorsParallel(double alpha1, double alpha2, double threshold)
-	{
-		double diff;
-
-		diff = alpha2 - alpha1;
-
-		/*Normalize*/
-		while(diff < -GEOMETRY_PI_2)
-			diff += GEOMETRY_PI;
-		while(diff > GEOMETRY_PI_2)
-			diff -= GEOMETRY_PI;
-
-		return fabs(diff) < threshold;
-	}
-
-	bool geometry::isPointInsideLine(HPoint2D p, HPoint2D a, HPoint2D b)
-	{
-		return isPointInsideLine(p.x, p.y, a.x, a.y, b.x, b.y);
-	}
-
-	bool geometry::isPointInsideLine(double px, double py, double ax, double ay, double bx, double by)
-	{
-
-		double tmp;
-
-		/*Get the u parameter in the equation P = A+u(B-A)*/
-		/*	(Px-Ax)(Bx-Ax) + (Py-Ay)(By-Ay)
-		u = -------------------------------
-				(Bx-Ax)^2 + (By-Ay)^2*/
-
-		/*Check if the line is a point*/
-		if(ax == bx && ay == by)
-			return false;
-
-		tmp = (px-ax)*(bx-ax) + (py-ay)*(by-ay);
-		tmp = tmp /(pow(bx-ax,2) + pow(by-ay,2));
-
-		if(tmp >=0 && tmp <=1)
-			return true;
-
-		return false;	
-	}
-
-	double geometry::getPositionInLine(HPoint2D p, HPoint2D a, HPoint2D b)
-	{
-		return getPositionInLine(p.x, p.y, a.x, a.y, b.x, b.y);
-	}
-
-	double geometry::getPositionInLine(double px, double py, double ax, double ay, double bx, double by)
-	{
-		/*	(Px-Ax)(Bx-Ax) + (Py-Ay)(By-Ay)
-		u = -------------------------------
-				(Bx-Ax)^2 + (By-Ay)^2*/
-
-		double tmp;
-	
-		/*Check if the line is a point*/
-		if(ax == bx && ay == by)
-			return 0;
-
-		tmp = (px-ax)*(bx-ax) + (py-ay)*(by-ay);
-		tmp = tmp /(pow(bx-ax,2) + pow(by-ay,2));
-
-		return tmp;
-	}
-
-	void geometry::getPointFromVector(int &px, int &py, int ax, int ay, int bx, int by, double u)
-	{
-		/*Get P from the equation P = A+u(B-A)*/
-		px = (int)((double)ax + u*(double)(bx-ax));
-		py = (int)((double)ay + u*(double)(by-ay));
-	}
-
-	void geometry::getPointFromVector(double &px, double &py, double ax, double ay, double bx, double by, double u)
-	{
-		/*Get P from the equation P = A+u(B-A)*/
-		px = ax + u*(bx-ax);
-		py = ay + u*(by-ay);
-	}
-
-	void geometry::calIntersectionCircleVector(HPoint3D v, HPoint3D p_c, double r, HPoint3D &int1, HPoint3D &int2)
-	{
-		/*Solve equations:
-		(x-px)^2 + (y - py)^2 = r^2
-		Ax + By + C = 0*/
-
-		double i,j,k, A_2;
-		double a,b,c;
-		double tmp;
-
-		if(v.X == 0.0) {
-			/*Avoid div by 0*/
-			v.X = 0.000001;
-		}
-
-		i = -2*p_c.X;
-		j = -2*p_c.Y;
-		k = G_SQUARE(p_c.X) + G_SQUARE(p_c.Y) - G_SQUARE(r);
-
-		A_2 = G_SQUARE(v.X);
-		a = G_SQUARE(-v.Y)/A_2 + 1;
-		b = -2*v.Z*-v.Y/A_2  - v.Y*i/v.X + j;
-		c = G_SQUARE(v.Z)/A_2 - v.Z*i/v.X + k;	
-
-		/*Solve a*Y^2 + b+Y + c = 0*/
-		tmp = G_SQUARE(b) - 4*a*c;
-		if(tmp<0) {
-			/*No intersection*/
-			int1.H = 0.0;
-			int2.H = 0.0;	
-			return;	
-		}
-
-		tmp = sqrt(tmp);
-		int1.Y = (-b + tmp)/(2*a);
-		int2.Y = (-b - tmp)/(2*a);
-
-		/*Get X Coordinate*/
-		int1.X = (-v.Y*int1.Y - v.Z)/v.X;
-		int2.X = (-v.Y*int2.Y - v.Z)/v.X;	
-
-		int1.H = 1.0;
-		int2.H = 1.0;
-	}
-
-	void geometry::lineGroundIntersection (HPoint3D A, HPoint3D B, HPoint3D &intersectionPoint) {
-		HPoint3D v;	// Line director vector: it the same to take A or B as origin or destination extrem...
-		double t;
-
-		A.X = A.X;
-		A.Y = A.Y;
-		A.Z = A.Z;
-
-		B.X = B.X;
-		B.Y = B.Y;
-		B.Z = B.Z;
-
-		v.X = (B.X - A.X);
-		v.Y = (B.Y - A.Y);
-		v.Z = (B.Z - A.Z);
-
-		// We'll calculate the ground intersection (Z = 0) on our robot system. Parametric equations:
-		intersectionPoint.Z = 0.; // intersectionPoint.Z = A.Z + t*v.Z => t = (-A.Z / v.Z)
-		t = (-A.Z) / (v.Z);
-
-		intersectionPoint.X = A.X + (t*v.X);
-		intersectionPoint.Y = A.Y + (t*v.Y);
-		intersectionPoint.H = 1.;
-	}
-
-	bool geometry::intersectSegments(double p1x, double p1y, double p2x, double p2y, double p3x, double p3y, double p4x, double p4y, HPoint2D& pres) {
-		HPoint3D v1, v2;
-		HPoint2D s1, s2, s3, s4;
-
-		s1.x = p1x; s1.y = p1y;
-		s2.x = p2x; s2.y = p2y;		
-		s3.x = p3x; s3.y = p3y;	
-		s4.x = p4x; s4.y = p4y;
-
-		/*Get vectors*/
-		geometry::calcVector2D(s1, s2, v1);
-		geometry::calcVector2D(s3, s4, v2);
-
-		/*Get intersection*/
-		geometry::calcIntersection2D(v1, v2, pres);
-
-		/*H is 0 if are parallel*/
-		if(pres.h == 0)
-			return false;
-
-		/*Check extremes*/
-		if(geometry::isPointInsideLine(pres, s1, s2) && geometry::isPointInsideLine(pres, s3, s4))
-			return true;
-
-		return false;
-	}
-
-	bool geometry::mergeSegments(Segment2D &segment1, Segment2D segment2, double max_parallel, double max_distance, double max_normal_distance) {
-		double dist1, dist2, dist3, dist4, l1dist, l2dist;
-		double cent_x1, cent_y1, cent_x2, cent_y2;
-		double disty1, disty2;
-		double max_dist;
-		bool mix1, mix2;
-		double angle1, angle2;
-
-		/*Get angles*/
-		angle1 = calcVectorAngle(segment1.start.x, segment1.start.y, segment1.end.x, segment1.end.y);
-		angle2 = calcVectorAngle(segment2.start.x, segment2.start.y, segment2.end.x, segment2.end.y);
-
-		/*They have to be almost parallel*/
-		if(!areVectorsParallel(angle1, angle2, max_parallel))
-			return false;
-
-		/*Check parallel distance*/
-		cent_x1 = (segment1.start.x + segment1.end.x)/2.0;
-		cent_y1 = (segment1.start.y + segment1.end.y)/2.0;
-		cent_x2 = (segment2.start.x + segment2.end.x)/2.0;
-		cent_y2 = (segment2.start.y + segment2.end.y)/2.0;
-
-		disty1 = calcDistanceAxis(cent_x1, cent_y1, cent_x2, cent_y2, angle1+(GEOMETRY_PI_2));
-		disty2 = calcDistanceAxis(cent_x1, cent_y1, cent_x2, cent_y2, angle2+(GEOMETRY_PI_2));
-		if(disty1 > max_normal_distance && disty2 > max_normal_distance)
-			return false;
-
-		/*Distance between segments*/
-		dist1 = distanceBetweenPoints2D(segment1.start, segment2.start);
-		dist2 = distanceBetweenPoints2D(segment1.start, segment2.end);
-		dist3 = distanceBetweenPoints2D(segment1.end, segment2.start);
-		dist4 = distanceBetweenPoints2D(segment1.end, segment2.end);
-		l1dist = distanceBetweenPoints2D(segment1.start, segment1.end);
-		l2dist = distanceBetweenPoints2D(segment2.start, segment2.end);
-
-		/*Line 2 in the middle of line 1*/
-		if(dist1 <= l1dist && dist2 <= l1dist && dist3 <= l1dist && dist4 <= l1dist)
-			return true;
-
-		/*Line 1 in the middle of line 2*/
-		if(dist1 <= l2dist && dist2 <= l2dist && dist3 <= l2dist && dist4 <= l2dist) {	
-			segment1.start = segment2.start;
-			segment1.end = segment2.end;
-			return true;
-		}
-
-		/*Check if lines are not mixed*/
-		mix1 = isPointInsideLine(segment2.start.x, segment2.start.y, segment1.start.x, segment1.start.y, segment1.end.x, segment1.end.y);
-		mix2 = isPointInsideLine(segment2.end.x, segment2.end.y, segment1.start.x, segment1.start.y, segment1.end.x, segment1.end.y);
-
-		if(!mix1 && !mix2) {
-			/*if not mixed, check distance*/
-			if(dist1 > max_distance && dist2 > max_distance && dist3 > max_distance && dist4 > max_distance)
-				return false;
-		}
-
-		max_dist = dist1;	
-		if(dist2 > max_dist) max_dist = dist2;
-		if(dist3 > max_dist) max_dist = dist3;
-		if(dist4 > max_dist) max_dist = dist4;
-		
-		/*Lines mixed, change one extreme*/
-		if(max_dist == dist1)
-			segment1.end = segment2.start;
-		if(max_dist == dist2)
-			segment1.end = segment2.end;
-		if(max_dist == dist3)
-			segment1.start = segment2.start;
-		if(max_dist == dist4)
-			segment1.start = segment2.end;
-
-		return true;
-	}
-
-	void geometry::getMaximizedSegment (HPoint3D seg1Start, HPoint3D seg1End, HPoint3D seg2Start, HPoint3D seg2End, HPoint3D &startPoint, HPoint3D &endPoint) {
-
-		HPoint3D myArray[4] = {seg1Start, seg1End, seg2Start, seg2End};
-		double max = 0;
-		int i, j;
-		double value;
-
-		for (i = 0; i < 4; i ++) {
-			for (j = i+1; j < 4; j ++) {
-				value = abs(distanceBetweenPoints3D (myArray[i], myArray[j]));
-				if (value > max) {
-					max = value;
-					startPoint = myArray[i];
-					endPoint = myArray[j];
-				}
-			}
-		}
-		// Finally, we'll get two points in order to maximize distance between them
-	}
-
-	double geometry::segmentLength(Segment3D segment) {
-		return distanceBetweenPoints3D(segment.start, segment.end);
-	}
-
-	double geometry::distancePointLine(HPoint3D point, Segment3D segment, HPoint3D &intersection, int &isInside) {
-		return distancePointSegment(point, segment, intersection, isInside);
-	}
-
-	double geometry::distancePointSegment(HPoint3D point, Segment3D segment, HPoint3D &intersection, int &isInside) {
-		double LineMag;
-		double U;
-
-		LineMag = segmentLength(segment);
-
-		U = ( ( ( point.X - segment.start.X ) * ( segment.end.X - segment.start.X ) ) +
-				  ( ( point.Y - segment.start.Y ) * ( segment.end.Y - segment.start.Y ) ) +
-				  ( ( point.Z - segment.start.Z ) * ( segment.end.Z - segment.start.Z ) ) ) /
-					( LineMag * LineMag );
-
-		intersection.X = segment.start.X + U * ( segment.end.X - segment.start.X );
-		intersection.Y = segment.start.Y + U * ( segment.end.Y - segment.start.Y );
-		intersection.Z = segment.start.Z + U * ( segment.end.Z - segment.start.Z );
-
-		if( U >= 0.0f || U <= 1.0f ) {
-			isInside = 0;
-		} else {
-			if (U < 0.) { // Intersection will be after segment
-				isInside = -1;
-			} else { // Intersection will be before segment
-				isInside = +1;
-			}
-		}
-
-		return distanceBetweenPoints3D(point, intersection);
-	}
-
-	double geometry::distancePointLine(HPoint2D point, HPoint3D line) {
-		/*dist = |A*x + B*y + C|
-						---------------
-						sqrt(A^2 + B^2)*/
-
-		if(line.X == 0.0 && line.Y == 0.0)
-			return GEOMETRY_INFINITE;
-		
-		return abs(line.X*point.x + line.Y*point.y + line.Z)/(sqrt(G_SQUARE(line.X) + G_SQUARE(line.Y)));
-	}
-
-	double geometry::distanceOriginLine(HPoint3D line) {
-		/*dist = 			|C|
-						---------------
-						sqrt(A^2 + B^2)*/
-		if(line.X == 0.0 && line.Y == 0.0)
-			return GEOMETRY_INFINITE;
-
-		return abs(line.Z)/(sqrt(G_SQUARE(line.X) + G_SQUARE(line.Y)));
-	}
-
-	bool geometry::areTheSameSegment (Segment3D s1, Segment3D s2) {
-		bool areTheSame = false;
-		if ((((double)s1.start.X==(double)s2.start.X) && 
-				 ((double)s1.start.Y==(double)s2.start.Y) && 
-				 ((double)s1.start.Z==(double)s2.start.Z) && 
-				 ((double)s1.end.X==(double)s2.end.X) &&
-				 ((double)s1.end.Y==(double)s2.end.Y) && 
-				 ((double)s1.end.Z==(double)s2.end.Z))	|| 
-				(((double)s1.start.X==(double)s2.end.X) && 
-				 ((double)s1.start.Y==(double)s2.end.Y) && 
-				 ((double)s1.start.Z==(double)s2.end.Z) && 
-				 ((double)s1.end.X==(double)s2.start.X) &&
-				 ((double)s1.end.Y==(double)s2.start.Y) && 
-				 ((double)s1.end.Z==(double)s2.start.Z))) { // they're the same segment
-			areTheSame = true;
-		}
-
-		return areTheSame;
-	}
-
-	bool geometry::areTheSameParallelogram (Parallelogram3D par1, Parallelogram3D par2) {
-		HPoint3D* myArray1[4] = {&(par1.p1), &(par1.p2), &(par1.p3), &(par1.p4)};
-		HPoint3D* myArray2[4] = {&(par2.p1), &(par2.p2), &(par2.p3), &(par2.p4)};
-		int i, j, found;
-		double value;
-		int equalPointsCounter = 0;
-
-		for (i = 0; i < 4; i ++) {
-			j = 0;
-			found = false;
-			while ((j < 4) && (!found)) {
-				value = abs(distanceBetweenPoints3D (*myArray1[i], *myArray2[j]));
-				if (value < 20.) {
-					equalPointsCounter ++;
-					found = true;
-				}
-				j ++;
-			}
-		}
-
-		return (equalPointsCounter == 4);
-	}
-
-	void geometry::getPolygonCentroid (Parallelogram3D &parallelogram) {
-		HPoint3D vertexList[5]; // Remember: Counter Clockwise Winding in order to get the centroid
-		int i, j;
-		double sum = 0.;
-		double area = 0.;
-		HPoint3D centroid;
-
-		vertexList[0] = parallelogram.p2;
-		vertexList[1] = parallelogram.p1;
-		vertexList[2] = parallelogram.p3;
-		vertexList[3] = parallelogram.p4;
-		vertexList[4] = vertexList[0];
-
-		centroid.X = 0.;
-		centroid.Y = 0.;
-		centroid.Z = 0.;
-		centroid.H = 1.;
-
-		for (i = 0; i < 5; i++) {
-			j = (i+1)%5;
-		  area = vertexList[i].X * vertexList[j].Y - vertexList[i].Y * vertexList[j].X;
-		  sum += area;
-		  centroid.X += (vertexList[i].X + vertexList[j].X) * area;
-		  centroid.Y += (vertexList[i].Y + vertexList[j].Y) * area;
-		}
-		sum *= 3.;
-		centroid.X /= sum;
-		centroid.Y /= sum;
-
-		parallelogram.centroid = centroid;
-	}
-
-	void geometry::printMatrix(gsl_matrix * m) {
-		unsigned int i, j;
-
-		std::cout << "-------------" << std::endl;
-
-		for(i=0;i<m->size1;i++) {
-			std::cout << "|\t";
-			for(j=0;j<m->size2;j++) {
-				std::cout << gsl_matrix_get(m,i,j) << "\t|\t";
-			}
-			std::cout << std::endl;
-		} 
-	}
-}
-

Deleted: trunk/src/stable/libs/visionlib/geometry.h
===================================================================
--- trunk/src/stable/libs/visionlib/geometry.h	2013-10-09 14:41:27 UTC (rev 1026)
+++ trunk/src/stable/libs/visionlib/geometry.h	2013-10-09 15:11:57 UTC (rev 1027)
@@ -1,147 +0,0 @@
-/*
- *  Copyright (C) 2011 Julio Vega Pérez
- *
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2 of the License, or
- *  (at your option) any later version.
- *
- *  This program is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU Library General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *
- * 	Author : Julio Vega Pérez (julio [dot] vega [at] urjc [dot] es)
- *           Eduardo Perdices (eperdices [at] gsyc [dot] es)
- *
- *  This library was programed for RobotVision Project http://jderobot.org/index.php/robotvision
- *
- */
-
-#ifndef VISIONLIBRARY_GEOMETRY_H
-#define VISIONLIBRARY_GEOMETRY_H
-
-#include <iostream>
-#include <opencv/cv.h>
-#include <opencv/highgui.h>
-#include "structs.h"
-/*GSL*/
-#include <gsl/gsl_linalg.h>
-#include <gsl/gsl_blas.h>
-#include <gsl/gsl_rng.h>
-#include <gsl/gsl_eigen.h>
-
-#ifndef G_SQUARE
-#define G_SQUARE(a) ( (a) * (a) )
-#endif
-
-namespace visionLibrary {
-  class geometry {
-
-		public:
-			geometry ();
-		  virtual ~geometry ();
-
-			/*Distance between two points in 2D*/
-			static double distanceBetweenPoints2D(int x1, int y1, int x2, int y2);
-			static double distanceBetweenPoints2D(double x1, double y1, double x2, double y2);
-			static double distanceBetweenPoints2D(HPoint2D p1, HPoint2D p2);
-
-			/*Distance between two points in 3D*/
-			static double distanceBetweenPoints3D(HPoint3D p1, HPoint3D p2);
-
-			/*Distance between two points in 2D in a concrete axis*/
-			static double calcDistanceAxis(double x1, double y1, double x2, double y2, double alpha);
-			static double calcDistanceAxis(HPoint2D p1, HPoint2D p2, double alpha);
-			static double calcDistanceAxis(HPoint2D p1, HPoint2D p2, double cosa, double sina);
-			static double calcDistanceAxis(HPoint3D p1, HPoint3D p2, double alpha);
-			static double calcDistanceAxis(HPoint3D p1, HPoint3D p2, double cosa, double sina);
-
-			/*Calc the positive angle of a vector*/
-			static double calcVectorAngle(double x1, double y1, double x2, double y2);
-			static double calcVectorAngle(HPoint3D line);
-			/*Calc gradient of a vector*/
-			static double calcVectorGradient(double x1, double y1, double x2, double y2);			
-			static double calcVectorGradient(HPoint3D line);	
-
-			/*Calc a 2D vector from 2 2D points*/
-			static void calcVector2D(HPoint2D p1, HPoint2D p2, HPoint3D &v);
-			static void calcVector2D(HPoint3D p1, HPoint3D p2, HPoint3D &v);
-
-			/*Calc a 2D normal vector from 3 2D points (normal vector of p1-p2 in p3)*/
-			static void calcNormalVector2D(HPoint2D p1, HPoint2D p2, HPoint2D p3, HPoint3D &v);
-			static void calcNormalVector2D(HPoint3D p1, HPoint3D p2, HPoint3D p3, HPoint3D &v);
-
-			/*Calc intersection between 2 2D vectors in a 2D point*/
-			static void calcIntersection2D(HPoint3D v1, HPoint3D v2, HPoint2D &p);
-			static void calcIntersection2D(HPoint3D v1, HPoint3D v2, HPoint3D &p);
-
-			/*Return true if the angles of two vectors can be considerated parallel*/
-			static bool areVectorsParallel(double alpha1, double alpha2, double threshold);
-
-			/*Return true if the projection of the point P is "inside" the segment A-B*/
-			static bool isPointInsideLine(HPoint2D p, HPoint2D a, HPoint2D b);
-			static bool isPointInsideLine(double px, double py, double ax, double ay, double bx, double by);
-
-			/*Get the u parameter in the equation P = A+u(B-A)*/
-			static double getPositionInLine(HPoint2D p, HPoint2D a, HPoint2D b);
-			static double getPositionInLine(double px, double py, double ax, double ay, double bx, double by);
-
-			/*Return a point belonging to the vector A-B*/
-			static void getPointFromVector(int &px, int &py, int ax, int ay, int bx, int by, double u);
-			static void getPointFromVector(double &px, double &py, double ax, double ay, double bx, double by, double u);
-
-			/*Return the intersection between a circle (radius and P_central) and a vector*/
-			static void calIntersectionCircleVector(HPoint3D v, HPoint3D p_c, double r, HPoint3D &int1, HPoint3D &int2);
-
-			/*Return the intersection between two points (A and B) on 3D, and the ground*/
-			static void lineGroundIntersection (HPoint3D A, HPoint3D B, HPoint3D &intersectionPoint);
-
-			/*Return true if two segments P1-P2 and P3-P4 intersect each other*/
-			static bool intersectSegments(double p1x, double p1y, double p2x, double p2y, double p3x, double p3y, double p4x, double p4y, HPoint2D& pres);
-
-			/*Try to merge two segments, return true if merged and update segment1.
-			Params: max parallel angle (rads), max horizontal distance (pixs), max perpendicular distance (pixs)*/
-			static bool mergeSegments(Segment2D &segment1, Segment2D segment2, double max_parallel = 0.3, double max_distance = 10.0, double max_normal_distance = 10.0);
-
-			/*Merge two segments to obtain the longest one*/
-			static void getMaximizedSegment(HPoint3D seg1Start, HPoint3D seg1End, HPoint3D seg2Start, HPoint3D seg2End, HPoint3D &startPoint, HPoint3D &endPoint);
-
-			/*Length of a segment*/
-			static double segmentLength(Segment3D segment);
-
-			/*Distance between a point and a segment. Check if the points is inside the line in "isInside" parameter*/
-			static double distancePointLine(HPoint3D point, Segment3D segment, HPoint3D &intersection, int &isInside); /*Deprecated*/
-			static double distancePointSegment(HPoint3D point, Segment3D segment, HPoint3D &intersection, int &isInside);
-
-			/*Distance between a point and a line*/
-			static double distancePointLine(HPoint2D point, HPoint3D line);
-
-			/*Distance between the origin (0,0) and a line*/
-			static double distanceOriginLine(HPoint3D line);			
-
-			/*Check if two segments are equal*/
-			static bool areTheSameSegment (Segment3D s1, Segment3D s2);
-
-			/*Check if two parallelograms are equal*/
-			static bool areTheSameParallelogram (Parallelogram3D par1, Parallelogram3D par2);
-
-			/*Calculate centroid of a polygon*/
-			static void getPolygonCentroid (Parallelogram3D &parallelogram);
-
-			/*Print matrix*/
-			static void printMatrix(gsl_matrix * m);
-
-		private:
-			static const double GEOMETRY_PI;
-			static const double GEOMETRY_PI_2;
-			static const double GEOMETRY_SQRT_2;
-			static const double GEOMETRY_INFINITE;
-	};
-}
-
-#endif

Deleted: trunk/src/stable/libs/visionlib/image.cpp
===================================================================
--- trunk/src/stable/libs/visionlib/image.cpp	2013-10-09 14:41:27 UTC (rev 1026)
+++ trunk/src/stable/libs/visionlib/image.cpp	2013-10-09 15:11:57 UTC (rev 1027)
@@ -1,354 +0,0 @@
- /*
- *  Copyright (C) 2010 Julio Vega Pérez
- *
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2 of the License, or
- *  (at your option) any later version.
- *
- *  This program is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU Library General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *
- * 	Author : Julio Vega Pérez (julio [dot] vega [at] urjc [dot] es)
- *           Eduardo Perdices (eperdices [at] gsyc [dot] es)
- *
- *  This library was programed for RobotVision Project http://jderobot.org/index.php/robotvision
- *
- */
-
-#include "image.h"
-
-namespace visionLibrary {
-
-	const int image::IMAGE_WIDTH = 320;
-	const int image::IMAGE_HEIGHT = 240;
-	const double image::MIN_DISTANCE_CORNERS = 30.0;
-	const double image::MIN_PERCENTAGE_VALID = 0.95;
-	const double image::MIN_DISTANCE_UNIQUE_CORNERS = 15.0;
-
-	cv::Mat *image::current_src = NULL;
-	double image::sobel_threshold = 0.0;
-	bool * image::calThreshold = new bool[IMAGE_WIDTH*IMAGE_HEIGHT];
-	bool * image::thresholds = new bool[IMAGE_WIDTH*IMAGE_HEIGHT];
-	bool * image::calPixel = new bool[IMAGE_WIDTH*IMAGE_HEIGHT];
-	bool * image::pixels = new bool[IMAGE_WIDTH*IMAGE_HEIGHT];
-	std::vector<HPoint2D> * image::unique_corners = new std::vector<HPoint2D>();
-
-	image::image () {}
-
-	image::~image () {}
-
-	std::vector<HPoint2D> * image::getSegments(cv::Mat &src, std::vector<Segment2D> * segments, double threshold_fast, double threshold_sobel) {
-		CvPoint * corners;
-		Segment2D segment;
-		HPoint2D new_corner;
-		int * scores;
-		int numCorners;
-
-		image::current_src = &src;
-		image::sobel_threshold = threshold_sobel;
-
-		/*Reset parameters*/
-		memset(image::calThreshold, 0, sizeof(bool)*IMAGE_WIDTH*IMAGE_HEIGHT);
-		memset(image::thresholds, 0, sizeof(bool)*IMAGE_WIDTH*IMAGE_HEIGHT);
-		memset(image::calPixel, 0, sizeof(bool)*IMAGE_WIDTH*IMAGE_HEIGHT);
-		memset(image::pixels, 0, sizeof(bool)*IMAGE_WIDTH*IMAGE_HEIGHT);
-		segments->clear();
-		image::unique_corners->clear();
-
-		/*Get corners fast*/
-		cvCornerFast(src, threshold_fast, 9, false, &numCorners, &corners, &scores);
-
-		/*Check unique corners*/
-		for(int i=0;i<numCorners;i++) {
-			/*Save unique corners*/
-			if(is_unique_corner(corners[i].x, corners[i].y, scores[i])) {
-				new_corner.x = (float) corners[i].x;
-				new_corner.y = (float) corners[i].y;
-				new_corner.h = (float) scores[i];				
-				image::unique_corners->push_back(new_corner);
-			}
-		}
-
-		/*Free memory*/
-		if(corners != NULL)	free(corners);
-		if(scores != NULL) free(scores);
-
-		/*Select lines*/
-		for(std::vector<HPoint2D>::iterator p1=image::unique_corners->begin(); p1 != image::unique_corners->end(); p1++)
-			for(std::vector<HPoint2D>::iterator p2=p1+1; p2 != image::unique_corners->end(); p2++) {
-				/*Check distance between corners*/
-				if(!(geometry::distanceBetweenPoints2D((*p1).x, (*p1).y, (*p2).x, (*p2).y) > MIN_DISTANCE_CORNERS))
-					continue;
-			
-				/*Check line (fast way)*/
-				if(!isLineFast((*p1).x, (*p1).y, (*p2).x, (*p2).y))
-					continue;
-
-				/*Check line (slow way)*/
-				if(!isLineSlow((*p1).x, (*p1).y, (*p2).x, (*p2).y))
-					continue;
-
-				/*Save line*/
-				segment.start.x = (float) (*p1).x;
-				segment.start.y = (float) (*p1).y;
-				segment.end.x = (float) (*p2).x;
-				segment.end.y = (float) (*p2).y;
-				segment.isValid = true;
-				segments->push_back(segment);
-			}
-
-		return image::unique_corners;
-	}
-
-/*	int image::multiplyFFT (const CvArr* srcAarr, const CvArr* srcBarr, CvArr* dstarr) {
-		CvMat *srcA = (CvMat*)srcAarr;
-		CvMat *srcB = (CvMat*)srcBarr;
-		CvMat *dst = (CvMat*)dstarr;
-
-		int i,j, rows, cols;
-		rows = srcA->rows;
-		cols = srcA->cols;
-		double c_re,c_im;
-
-		for( i=0; i<rows; i++ )	{
-			for( j = 0; j < cols; j ++ ) {
-				c_re = ((double*)(srcA->data.ptr + srcA->step*i))[j*2]*((double*)(srcB->data.ptr + srcB->step*i))[j*2] -
-				((double*)(srcA->data.ptr + srcA->step*i))[j*2+1]*((double*)(srcB->data.ptr + srcB->step*i))[j*2+1];
-				c_im = ((double*)(srcA->data.ptr + srcA->step*i))[j*2]*((double*)(srcB->data.ptr + srcB->step*i))[j*2+1] +
-				((double*)(srcA->data.ptr + srcA->step*i))[j*2+1]*((double*)(srcB->data.ptr + srcB->step*i))[j*2];
-				((double*)(dst->data.ptr + dst->step*i))[j*2]	= c_re;
-				((double*)(dst->data.ptr + dst->step*i))[j*2+1]	= c_im;
-			}
-		}
-
-		return 1;
-	}*/
-
-	bool image::isLineFast(int x1, int y1, int x2, int y2) {
-		HPoint2D v;
-		int cx, cy;
-
-		/*Get vector*/
-		v.x = x2-x1;
-		v.y = y2-y1;
-			
-		/*Center*/
-		cx = x1 + 0.5*v.x;
-		cy = y1 + 0.5*v.y;
-
-		if(!isEdge(cx, cy))
-			return false;
-
-		/*1st cuarter*/
-		cx = x1 + 0.25*v.x;
-		cy = y1 + 0.25*v.y;
-
-		if(!isEdge(cx, cy))
-			return false;
-
-		/*3rd cuarter*/
-		cx = x1 + 0.75*v.x;
-		cy = y1 + 0.75*v.y;
-
-		if(!isEdge(cx, cy))
-			return false;
-
-		return true;
-	}
-
-	bool image::isLineSlow(int x1, int y1, int x2, int y2) {
-		HPoint2D v;
-		int cx, cy;
-		int dist, num_steps, max_nvalid, step = 2;
-		double frac, frac_step;
-		int n_nvalid = 0;
-
-		/*Get vector*/
-		v.x = x2-x1;
-		v.y = y2-y1;
-
-		/*Distance between points*/
-		dist = geometry::distanceBetweenPoints2D(x1, y1, x2, y2);
-		frac_step = (double)step/(double)dist;
-		num_steps = dist/step;
-
-		/*Calculate max non valid*/
-		max_nvalid = (int) ((double)num_steps*(1.0-MIN_PERCENTAGE_VALID) + 1.0);
-
-		/*Cover line*/
-		frac = frac_step;
-		while(frac <= 1.0) {
-			cx = x1 + frac*v.x;
-			cy = y1 + frac*v.y;
-
-			if(!isEdge(cx, cy))
-				n_nvalid++;
-
-			/*Max non valid reached, it's not a valid line*/
-			if(n_nvalid >= max_nvalid)
-				return false;
-
-			frac += frac_step;
-		}
-	
-		return true;
-	}
-
-	bool image::isEdge(int x, int y) {
-		int pos;
-
-		pos = y*IMAGE_WIDTH + x;	
-
-		/*Check if its already calculated*/
-		if(image::calThreshold[pos])
-			return image::thresholds[pos];
-
-		/*Calculate new point*/
-		if(image::getEdgeThresholed(x, y))
-			image::thresholds[pos] = true;
-		else
-			image::thresholds[pos] = false;
-
-		image::calThreshold[pos] = true;
-		return image::thresholds[pos];
-	}
-
-	bool image::getEdgeThresholed(int x, int y) {
-		int threshold = 2;
-		int ti, tj;
-
-		/*Check basic point*/
-		if(getEdge(x, y))
-			return true;
-
-		/*Check neighbors*/
-		for(int i=2;i<=threshold;i++) {
-			/*Top*/
-			ti = x;
-			tj = y-i;
-			if(tj>=0) {
-				if(getEdge(ti, tj))
-					return true;
-			}
-
-			/*Bottom*/
-			ti = x;
-			tj = y+i;
-			if(tj<IMAGE_HEIGHT) {
-				if(getEdge(ti, tj))
-					return true;
-			}
-
-			/*Left*/
-			ti = x-i;
-			tj = y;
-			if(ti>=0) {
-				if(getEdge(ti, tj))
-					return true;
-			}
-
-			/*Right*/
-			ti = x+i;
-			tj = y;
-			if(ti<IMAGE_WIDTH) {
-				if(getEdge(ti, tj))
-					return true;
-			}
-		}
-
-		return false;
-	}
-
-	bool image::getEdge(int x, int y) {
-		int pos;
-		int gx, gy, sum;
-		int posc1, posc2, posc3;
-
-		pos = y*IMAGE_WIDTH + x;
-
-		/*Check if its already calculated*/
-		if(image::calPixel[pos])
-			return image::pixels[pos];
-
-		/*Check borders*/
-		if(x==0 || y==0 || x==IMAGE_WIDTH-1 || y==IMAGE_WIDTH-1) {
-			image::pixels[pos] = false;
-			image::calPixel[pos] = true;
-			return false;
-		}
-
-		posc1 = (y-1)*IMAGE_WIDTH + x;
-		posc2 = pos;
-		posc3 = (y+1)*IMAGE_WIDTH + x;
-
-		/*Sobel filter: Sum = abs(Gx) + abs(Gy):
-
-					-1	0	+1					+1	+2	+1	
-		Gx = 	-2	0	+2		Gy = 	0		0		0
-					-1	0	+1					-1	-2	-1*/
-
-		gx = 	-(unsigned int)image::current_src->data[posc1-1] + (unsigned int)image::current_src->data[posc1+1] +
-					-2*(unsigned int)image::current_src->data[posc2-1] + 2*(unsigned int)image::current_src->data[posc2+1] +
-					-(unsigned int)image::current_src->data[posc3-1] + (int)image::current_src->data[posc3+1];
-
-		gy = 	1*(unsigned int)image::current_src->data[posc1-1] + 2*(unsigned int)image::current_src->data[posc1] + 1*(unsigned int)image::current_src->data[posc1+1] +
-					-1*(unsigned int)image::current_src->data[posc3-1] + -2*(unsigned int)image::current_src->data[posc3] + -1*(unsigned int)image::current_src->data[posc3+1];
-
-		sum = abs(gx) + abs(gy);
-		
-		/*Calculate new point*/
-		if(sum > image::sobel_threshold)
-			image::pixels[pos] = true;
-		else
-			image::pixels[pos] = false;
-
-		image::calPixel[pos] = true;
-		return image::pixels[pos];
-			
-	}
-
-	void image::getSegmentsDebug(cv::Mat &src) {
-
-		for(int ti=0;ti<IMAGE_WIDTH;ti++)
-			for(int tj=0;tj<IMAGE_HEIGHT;tj++)
-				isEdge(ti, tj);
-
-		for(int ti=0;ti<IMAGE_WIDTH;ti++)
-			for(int tj=0;tj<IMAGE_HEIGHT;tj++) {
-				int pos = tj*IMAGE_WIDTH + ti;
-				if(image::thresholds[pos])
-					src.data[pos] = 255;
-				else
-					src.data[pos] = 0;
-			}
-	}
-
-	bool image::is_unique_corner(int x, int y, int score) {
-		double dist;
-
-		for(std::vector<HPoint2D>::iterator p1=image::unique_corners->begin(); p1 != image::unique_corners->end(); p1++) {
-			dist = geometry::distanceBetweenPoints2D((double)(*p1).x, (double)(*p1).y, (double)x, (double)y);
-
-			/*Check distance in pixels*/
-			if(dist <= MIN_DISTANCE_UNIQUE_CORNERS) {
-				/*Check score*/
-				if((float) score > (*p1).h) {
-					(*p1).x = (float) x;
-					(*p1).y = (float) y;
-					(*p1).h = (float) score;
-				}
-				return false;
-			}
-		}
-
-		return true;
-	}
-}
-

Deleted: trunk/src/stable/libs/visionlib/image.h
===================================================================
--- trunk/src/stable/libs/visionlib/image.h	2013-10-09 14:41:27 UTC (rev 1026)
+++ trunk/src/stable/libs/visionlib/image.h	2013-10-09 15:11:57 UTC (rev 1027)
@@ -1,86 +0,0 @@
-/*
- *  Copyright (C) 2010 Julio Vega Pérez
- *
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2 of the License, or
- *  (at your option) any later version.
- *
- *  This program is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU Library General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *
- * 	Author : Julio Vega Pérez (julio [dot] vega [at] urjc [dot] es)
- *           Eduardo Perdices (eperdices [at] gsyc [dot] es)
- *
- *  This library was programed for RobotVision Project http://jderobot.org/index.php/robotvision
- *
- */
-
-#ifndef VISIONLIBRARY_IMAGE_H
-#define VISIONLIBRARY_IMAGE_H
-
-#include <iostream>
-#include <opencv/cv.h>
-#include <opencv/highgui.h>
-#include "structs.h"
-#include <visionlib/cvFast/cvfast.h>
-#include "geometry.h"
-
-#ifndef I_SQUARE
-#define I_SQUARE(a) ( (a) * (a) )
-#endif
-
-namespace visionLibrary {
-  class image {
-
-		public:
-			image ();
-		  virtual ~image ();
-
-			/*Get segments from the image src. Return corners*/
-			static std::vector<HPoint2D> * getSegments(cv::Mat &src, std::vector<Segment2D> * segments, double threshold_fast = 50.0, double threshold_sobel = 100.0);
-
-			/*Multiply fast fourier transform*/
-			//static int multiplyFFT (const CvArr* srcAarr, const CvArr* srcBarr, CvArr* dstarr);
-
-			/*Debug function*/
-			static void getSegmentsDebug(cv::Mat &src);
-		
-		private:
-
-			static const int IMAGE_WIDTH;
-			static const int IMAGE_HEIGHT;
-			static const double MIN_DISTANCE_CORNERS;
-			static const double MIN_PERCENTAGE_VALID;
-			static const double MIN_DISTANCE_UNIQUE_CORNERS;
-
-			/*Check line fast*/
-			static bool isLineFast(int x1, int y1, int x2, int y2);
-			/*Check line slow*/
-			static bool isLineSlow(int x1, int y1, int x2, int y2);
-			/*Check edge filter*/
-			static bool isEdge(int x, int y);
-			/*Calculate edge in a concrete pixel*/
-			static bool getEdge(int x, int y);
-			/*Calculate edge in a concrete pixel with a threshold*/
-			static bool getEdgeThresholed(int x, int y);
-			/*Check if a corner is unique*/
-			static bool is_unique_corner(int x, int y, int score);
-
-			static cv::Mat *current_src;
-			static double sobel_threshold;
-			static bool * calThreshold;
-			static bool * thresholds;
-			static bool * calPixel;
-			static bool * pixels;
-			static std::vector<HPoint2D> * unique_corners;
-	};
-}
-
-#endif

Added: trunk/src/stable/libs/visionlib/imgAnalyze/CMakeLists.txt
===================================================================
--- trunk/src/stable/libs/visionlib/imgAnalyze/CMakeLists.txt	                        (rev 0)
+++ trunk/src/stable/libs/visionlib/imgAnalyze/CMakeLists.txt	2013-10-09 15:11:57 UTC (rev 1027)
@@ -0,0 +1,7 @@
+SET( SOURCE_FILES geometry.cpp image.cpp linesDetection.cpp)
+include_directories( ${LIBS_DIR}/)
+add_library (imgAnalyze SHARED ${SOURCE_FILES})
+TARGET_LINK_LIBRARIES(imgAnalyze progeo cvfast)
+
+
+

Copied: trunk/src/stable/libs/visionlib/imgAnalyze/geometry.cpp (from rev 1023, trunk/src/stable/libs/visionlib/geometry.cpp)
===================================================================
--- trunk/src/stable/libs/visionlib/imgAnalyze/geometry.cpp	                        (rev 0)
+++ trunk/src/stable/libs/visionlib/imgAnalyze/geometry.cpp	2013-10-09 15:11:57 UTC (rev 1027)
@@ -0,0 +1,668 @@
+ /*
+ *  Copyright (C) 2010 Julio Vega Pérez
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU Library General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * 	Author : Julio Vega Pérez (julio [dot] vega [at] urjc [dot] es)
+ *           Eduardo Perdices (eperdices [at] gsyc [dot] es)
+ *
+ *  This library was programed for RobotVision Project http://jderobot.org/index.php/robotvision
+ *
+ */
+
+#include "geometry.h"
+
+namespace visionLibrary {
+
+	const double geometry::GEOMETRY_PI = 3.1415926535897932384626433832795;
+	const double geometry::GEOMETRY_PI_2 = 1.570796327;
+	const double geometry::GEOMETRY_SQRT_2 = 1.414213562;
+	const double geometry::GEOMETRY_INFINITE = 123456789.123456789;
+
+	geometry::geometry () {}
+
+	geometry::~geometry () {}
+
+	double geometry::distanceBetweenPoints2D(int x1, int y1, int x2, int y2)
+	{
+		return sqrt(G_SQUARE(x2-x1) + G_SQUARE(y2-y1));
+	}
+
+	double geometry::distanceBetweenPoints2D(double x1, double y1, double x2, double y2)
+	{
+		return sqrt(G_SQUARE(x2-x1) + G_SQUARE(y2-y1));
+	}
+
+	double geometry::distanceBetweenPoints2D(HPoint2D p1, HPoint2D p2)
+	{
+		return sqrt(G_SQUARE(p2.x-p1.x) + G_SQUARE(p2.y-p1.y));
+	}
+
+	double geometry::distanceBetweenPoints3D(HPoint3D p1, HPoint3D p2)
+	{
+		return sqrt(G_SQUARE(p2.X-p1.X) + G_SQUARE(p2.Y-p1.Y) + G_SQUARE(p2.Z-p1.Z));
+	}
+
+	double geometry::calcDistanceAxis(double x1, double y1, double x2, double y2, double alpha)
+	{
+		double dist;
+
+		dist = (x2 - x1)*cos(alpha) + (y2 - y1)*sin(alpha);
+
+		return fabs(dist);
+	}
+
+	double geometry::calcDistanceAxis(HPoint2D p1, HPoint2D p2, double alpha)
+	{
+		double dist;
+
+		dist = (p2.x - p1.x)*cos(alpha) + (p2.y - p1.y)*sin(alpha);
+
+		return fabs(dist);
+	}
+
+	double geometry::calcDistanceAxis(HPoint2D p1, HPoint2D p2, double cosa, double sina)
+	{
+		double dist;
+
+		dist = (p2.x - p1.x)*cosa + (p2.y - p1.y)*sina;
+
+		return fabs(dist);
+	}
+
+	double geometry::calcDistanceAxis(HPoint3D p1, HPoint3D p2, double alpha)
+	{
+		double dist;
+
+		dist = (p2.X - p1.X)*cos(alpha) + (p2.Y - p1.Y)*sin(alpha);
+
+		return fabs(dist);
+	}
+
+	double geometry::calcDistanceAxis(HPoint3D p1, HPoint3D p2, double cosa, double sina)
+	{
+		double dist;
+
+		dist = (p2.X - p1.X)*cosa + (p2.Y - p1.Y)*sina;
+
+		return fabs(dist);
+	}
+
+	double geometry::calcVectorAngle(double x1, double y1, double x2, double y2)
+	{
+		double diffx, diffy;
+		double alpha;
+
+		diffx = x2 - x1;
+		diffy = y2 - y1;
+
+		if(diffx == 0.0)
+			return GEOMETRY_PI_2;
+
+		alpha = atan(diffy/diffx);
+
+		/*Normalize*/
+		if(alpha < 0)
+			alpha += GEOMETRY_PI;
+		if(alpha > GEOMETRY_PI)
+			alpha -= GEOMETRY_PI;	
+
+		return alpha;		
+	}
+
+	double geometry::calcVectorAngle(HPoint3D line)
+	{
+		double alpha;
+
+		if(line.Y == 0.0)
+			return GEOMETRY_PI_2;
+
+		alpha = atan(-line.X/line.Y);
+
+		/*Normalize*/
+		if(alpha < 0)
+			alpha += GEOMETRY_PI;
+		if(alpha > GEOMETRY_PI)
+			alpha -= GEOMETRY_PI;	
+
+		return alpha;		
+	}
+
+	double geometry::calcVectorGradient(double x1, double y1, double x2, double y2)
+	{
+		double diffx, diffy;
+
+		diffx = x2 - x1;
+		diffy = y2 - y1;
+
+		if(diffx == 0.0)
+			return GEOMETRY_INFINITE;
+
+		return diffy/diffx;
+	}
+
+	double geometry::calcVectorGradient(HPoint3D line)
+	{
+		if(line.Y == 0.0)
+			return GEOMETRY_INFINITE;
+
+		return -line.X/line.Y;
+	}
+
+	void geometry::calcVector2D(HPoint2D p1, HPoint2D p2, HPoint3D &v)
+	{
+		/*Get the Ax + By + C = 0 parameters*/
+		v.X = p1.y - p2.y; 				//y1*z2 - z1*y2
+		v.Y = p2.x - p1.x; 				//z1*x2 - x1*z2
+		v.Z = p1.x*p2.y - p1.y*p2.x; 	//x1*y2 - y1*x2
+		v.H = 1.0;
+	}
+
+	void geometry::calcVector2D(HPoint3D p1, HPoint3D p2, HPoint3D &v)
+	{
+		/*Get the Ax + By + C = 0 parameters*/
+		v.X = p1.Y - p2.Y; 				//y1*z2 - z1*y2
+		v.Y = p2.X - p1.X; 				//z1*x2 - x1*z2
+		v.Z = p1.X*p2.Y - p1.Y*p2.X; 	//x1*y2 - y1*x2
+		v.H = 1.0;
+	}
+
+	void geometry::calcNormalVector2D(HPoint2D p1, HPoint2D p2, HPoint2D p3, HPoint3D &v)
+	{
+		HPoint3D vtmp;
+		double nA, nB, nC;
+
+		/*Get the vector p1-p2*/
+		calcVector2D(p1, p2, vtmp);
+
+		/*Calc the normal*/
+		nA = vtmp.Y;
+		nB = -vtmp.X;
+		nC = -(p3.x*nA + p3.y*nB); //Solve equation Ax+By+C with central point
+
+		v.X = nA;
+		v.Y = nB;
+		v.Z = nC;	
+		v.H = 1.0;
+	}
+
+	void geometry::calcNormalVector2D(HPoint3D p1, HPoint3D p2, HPoint3D p3, HPoint3D &v)
+	{
+		HPoint3D vtmp;
+		double nA, nB, nC;
+
+		/*Get the vector p1-p2*/
+		calcVector2D(p1, p2, vtmp);
+
+		/*Calc the normal*/
+		nA = vtmp.Y;
+		nB = -vtmp.X;
+		nC = -(p3.X*nA + p3.Y*nB); //Solve equation Ax+By+C with central point
+
+		v.X = nA;
+		v.Y = nB;
+		v.Z = nC;	
+		v.H = 1.0;
+	}
+
+	void geometry::calcIntersection2D(HPoint3D v1, HPoint3D v2, HPoint2D &p)
+	{
+		double h;
+
+		h = v1.X*v2.Y - v1.Y*v2.X; 		/*x1*y2 - y1*x2*/
+
+		/*Are parallel*/	
+		if(h==0)
+			p.h = 0.0;
+
+		p.x = (v1.Y*v2.Z - v2.Y*v1.Z)/h; /*y1*z2 - z1*y2*/
+		p.y = (v1.Z*v2.X - v1.X*v2.Z)/h; /*z1*x2 - x1*z2*/
+		p.h = 1.0;
+	}
+
+	void geometry::calcIntersection2D(HPoint3D v1, HPoint3D v2, HPoint3D &p)
+	{
+		double h;
+
+		h = v1.X*v2.Y - v1.Y*v2.X; 		/*x1*y2 - y1*x2*/
+
+		/*Are parallel*/	
+		if(h==0)
+			p.H = 0.0;
+
+		p.X = (v1.Y*v2.Z - v2.Y*v1.Z)/h; /*y1*z2 - z1*y2*/
+		p.Y = (v1.Z*v2.X - v1.X*v2.Z)/h; /*z1*x2 - x1*z2*/
+		p.Z = 0.0;
+		p.H = 1.0;
+	}
+
+	bool geometry::areVectorsParallel(double alpha1, double alpha2, double threshold)
+	{
+		double diff;
+
+		diff = alpha2 - alpha1;
+
+		/*Normalize*/
+		while(diff < -GEOMETRY_PI_2)
+			diff += GEOMETRY_PI;
+		while(diff > GEOMETRY_PI_2)
+			diff -= GEOMETRY_PI;
+
+		return fabs(diff) < threshold;
+	}
+
+	bool geometry::isPointInsideLine(HPoint2D p, HPoint2D a, HPoint2D b)
+	{
+		return isPointInsideLine(p.x, p.y, a.x, a.y, b.x, b.y);
+	}
+
+	bool geometry::isPointInsideLine(double px, double py, double ax, double ay, double bx, double by)
+	{
+
+		double tmp;
+
+		/*Get the u parameter in the equation P = A+u(B-A)*/
+		/*	(Px-Ax)(Bx-Ax) + (Py-Ay)(By-Ay)
+		u = -------------------------------
+				(Bx-Ax)^2 + (By-Ay)^2*/
+
+		/*Check if the line is a point*/
+		if(ax == bx && ay == by)
+			return false;
+
+		tmp = (px-ax)*(bx-ax) + (py-ay)*(by-ay);
+		tmp = tmp /(pow(bx-ax,2) + pow(by-ay,2));
+
+		if(tmp >=0 && tmp <=1)
+			return true;
+
+		return false;	
+	}
+
+	double geometry::getPositionInLine(HPoint2D p, HPoint2D a, HPoint2D b)
+	{
+		return getPositionInLine(p.x, p.y, a.x, a.y, b.x, b.y);
+	}
+
+	double geometry::getPositionInLine(double px, double py, double ax, double ay, double bx, double by)
+	{
+		/*	(Px-Ax)(Bx-Ax) + (Py-Ay)(By-Ay)
+		u = -------------------------------
+				(Bx-Ax)^2 + (By-Ay)^2*/
+
+		double tmp;
+	
+		/*Check if the line is a point*/
+		if(ax == bx && ay == by)
+			return 0;
+
+		tmp = (px-ax)*(bx-ax) + (py-ay)*(by-ay);
+		tmp = tmp /(pow(bx-ax,2) + pow(by-ay,2));
+
+		return tmp;
+	}
+
+	void geometry::getPointFromVector(int &px, int &py, int ax, int ay, int bx, int by, double u)
+	{
+		/*Get P from the equation P = A+u(B-A)*/
+		px = (int)((double)ax + u*(double)(bx-ax));
+		py = (int)((double)ay + u*(double)(by-ay));
+	}
+
+	void geometry::getPointFromVector(double &px, double &py, double ax, double ay, double bx, double by, double u)
+	{
+		/*Get P from the equation P = A+u(B-A)*/
+		px = ax + u*(bx-ax);
+		py = ay + u*(by-ay);
+	}
+
+	void geometry::calIntersectionCircleVector(HPoint3D v, HPoint3D p_c, double r, HPoint3D &int1, HPoint3D &int2)
+	{
+		/*Solve equations:
+		(x-px)^2 + (y - py)^2 = r^2
+		Ax + By + C = 0*/
+
+		double i,j,k, A_2;
+		double a,b,c;
+		double tmp;
+
+		if(v.X == 0.0) {
+			/*Avoid div by 0*/
+			v.X = 0.000001;
+		}
+
+		i = -2*p_c.X;
+		j = -2*p_c.Y;
+		k = G_SQUARE(p_c.X) + G_SQUARE(p_c.Y) - G_SQUARE(r);
+
+		A_2 = G_SQUARE(v.X);
+		a = G_SQUARE(-v.Y)/A_2 + 1;
+		b = -2*v.Z*-v.Y/A_2  - v.Y*i/v.X + j;
+		c = G_SQUARE(v.Z)/A_2 - v.Z*i/v.X + k;	
+
+		/*Solve a*Y^2 + b+Y + c = 0*/
+		tmp = G_SQUARE(b) - 4*a*c;
+		if(tmp<0) {
+			/*No intersection*/
+			int1.H = 0.0;
+			int2.H = 0.0;	
+			return;	
+		}
+
+		tmp = sqrt(tmp);
+		int1.Y = (-b + tmp)/(2*a);
+		int2.Y = (-b - tmp)/(2*a);
+
+		/*Get X Coordinate*/
+		int1.X = (-v.Y*int1.Y - v.Z)/v.X;
+		int2.X = (-v.Y*int2.Y - v.Z)/v.X;	
+
+		int1.H = 1.0;
+		int2.H = 1.0;
+	}
+
+	void geometry::lineGroundIntersection (HPoint3D A, HPoint3D B, HPoint3D &intersectionPoint) {
+		HPoint3D v;	// Line director vector: it the same to take A or B as origin or destination extrem...
+		double t;
+
+		A.X = A.X;
+		A.Y = A.Y;
+		A.Z = A.Z;
+
+		B.X = B.X;
+		B.Y = B.Y;
+		B.Z = B.Z;
+
+		v.X = (B.X - A.X);
+		v.Y = (B.Y - A.Y);
+		v.Z = (B.Z - A.Z);
+
+		// We'll calculate the ground intersection (Z = 0) on our robot system. Parametric equations:
+		intersectionPoint.Z = 0.; // intersectionPoint.Z = A.Z + t*v.Z => t = (-A.Z / v.Z)
+		t = (-A.Z) / (v.Z);
+
+		intersectionPoint.X = A.X + (t*v.X);
+		intersectionPoint.Y = A.Y + (t*v.Y);
+		intersectionPoint.H = 1.;
+	}
+
+	bool geometry::intersectSegments(double p1x, double p1y, double p2x, double p2y, double p3x, double p3y, double p4x, double p4y, HPoint2D& pres) {
+		HPoint3D v1, v2;
+		HPoint2D s1, s2, s3, s4;
+
+		s1.x = p1x; s1.y = p1y;
+		s2.x = p2x; s2.y = p2y;		
+		s3.x = p3x; s3.y = p3y;	
+		s4.x = p4x; s4.y = p4y;
+
+		/*Get vectors*/
+		geometry::calcVector2D(s1, s2, v1);
+		geometry::calcVector2D(s3, s4, v2);
+
+		/*Get intersection*/
+		geometry::calcIntersection2D(v1, v2, pres);
+
+		/*H is 0 if are parallel*/
+		if(pres.h == 0)
+			return false;
+
+		/*Check extremes*/
+		if(geometry::isPointInsideLine(pres, s1, s2) && geometry::isPointInsideLine(pres, s3, s4))
+			return true;
+
+		return false;
+	}
+
+	bool geometry::mergeSegments(Segment2D &segment1, Segment2D segment2, double max_parallel, double max_distance, double max_normal_distance) {
+		double dist1, dist2, dist3, dist4, l1dist, l2dist;
+		double cent_x1, cent_y1, cent_x2, cent_y2;
+		double disty1, disty2;
+		double max_dist;
+		bool mix1, mix2;
+		double angle1, angle2;
+
+		/*Get angles*/
+		angle1 = calcVectorAngle(segment1.start.x, segment1.start.y, segment1.end.x, segment1.end.y);
+		angle2 = calcVectorAngle(segment2.start.x, segment2.start.y, segment2.end.x, segment2.end.y);
+
+		/*They have to be almost parallel*/
+		if(!areVectorsParallel(angle1, angle2, max_parallel))
+			return false;
+
+		/*Check parallel distance*/
+		cent_x1 = (segment1.start.x + segment1.end.x)/2.0;
+		cent_y1 = (segment1.start.y + segment1.end.y)/2.0;
+		cent_x2 = (segment2.start.x + segment2.end.x)/2.0;
+		cent_y2 = (segment2.start.y + segment2.end.y)/2.0;
+
+		disty1 = calcDistanceAxis(cent_x1, cent_y1, cent_x2, cent_y2, angle1+(GEOMETRY_PI_2));
+		disty2 = calcDistanceAxis(cent_x1, cent_y1, cent_x2, cent_y2, angle2+(GEOMETRY_PI_2));
+		if(disty1 > max_normal_distance && disty2 > max_normal_distance)
+			return false;
+
+		/*Distance between segments*/
+		dist1 = distanceBetweenPoints2D(segment1.start, segment2.start);
+		dist2 = distanceBetweenPoints2D(segment1.start, segment2.end);
+		dist3 = distanceBetweenPoints2D(segment1.end, segment2.start);
+		dist4 = distanceBetweenPoints2D(segment1.end, segment2.end);
+		l1dist = distanceBetweenPoints2D(segment1.start, segment1.end);
+		l2dist = distanceBetweenPoints2D(segment2.start, segment2.end);
+
+		/*Line 2 in the middle of line 1*/
+		if(dist1 <= l1dist && dist2 <= l1dist && dist3 <= l1dist && dist4 <= l1dist)
+			return true;
+
+		/*Line 1 in the middle of line 2*/
+		if(dist1 <= l2dist && dist2 <= l2dist && dist3 <= l2dist && dist4 <= l2dist) {	
+			segment1.start = segment2.start;
+			segment1.end = segment2.end;
+			return true;
+		}
+
+		/*Check if lines are not mixed*/
+		mix1 = isPointInsideLine(segment2.start.x, segment2.start.y, segment1.start.x, segment1.start.y, segment1.end.x, segment1.end.y);
+		mix2 = isPointInsideLine(segment2.end.x, segment2.end.y, segment1.start.x, segment1.start.y, segment1.end.x, segment1.end.y);
+
+		if(!mix1 && !mix2) {
+			/*if not mixed, check distance*/
+			if(dist1 > max_distance && dist2 > max_distance && dist3 > max_distance && dist4 > max_distance)
+				return false;
+		}
+
+		max_dist = dist1;	
+		if(dist2 > max_dist) max_dist = dist2;
+		if(dist3 > max_dist) max_dist = dist3;
+		if(dist4 > max_dist) max_dist = dist4;
+		
+		/*Lines mixed, change one extreme*/
+		if(max_dist == dist1)
+			segment1.end = segment2.start;
+		if(max_dist == dist2)
+			segment1.end = segment2.end;
+		if(max_dist == dist3)
+			segment1.start = segment2.start;
+		if(max_dist == dist4)
+			segment1.start = segment2.end;
+
+		return true;
+	}
+
+	void geometry::getMaximizedSegment (HPoint3D seg1Start, HPoint3D seg1End, HPoint3D seg2Start, HPoint3D seg2End, HPoint3D &startPoint, HPoint3D &endPoint) {
+
+		HPoint3D myArray[4] = {seg1Start, seg1End, seg2Start, seg2End};
+		double max = 0;
+		int i, j;
+		double value;
+
+		for (i = 0; i < 4; i ++) {
+			for (j = i+1; j < 4; j ++) {
+				value = abs(distanceBetweenPoints3D (myArray[i], myArray[j]));
+				if (value > max) {
+					max = value;
+					startPoint = myArray[i];
+					endPoint = myArray[j];
+				}
+			}
+		}
+		// Finally, we'll get two points in order to maximize distance between them
+	}
+
+	double geometry::segmentLength(Segment3D segment) {
+		return distanceBetweenPoints3D(segment.start, segment.end);
+	}
+
+	double geometry::distancePointLine(HPoint3D point, Segment3D segment, HPoint3D &intersection, int &isInside) {
+		return distancePointSegment(point, segment, intersection, isInside);
+	}
+
+	double geometry::distancePointSegment(HPoint3D point, Segment3D segment, HPoint3D &intersection, int &isInside) {
+		double LineMag;
+		double U;
+
+		LineMag = segmentLength(segment);
+
+		U = ( ( ( point.X - segment.start.X ) * ( segment.end.X - segment.start.X ) ) +
+				  ( ( point.Y - segment.start.Y ) * ( segment.end.Y - segment.start.Y ) ) +
+				  ( ( point.Z - segment.start.Z ) * ( segment.end.Z - segment.start.Z ) ) ) /
+					( LineMag * LineMag );
+
+		intersection.X = segment.start.X + U * ( segment.end.X - segment.start.X );
+		intersection.Y = segment.start.Y + U * ( segment.end.Y - segment.start.Y );
+		intersection.Z = segment.start.Z + U * ( segment.end.Z - segment.start.Z );
+
+		if( U >= 0.0f || U <= 1.0f ) {
+			isInside = 0;
+		} else {
+			if (U < 0.) { // Intersection will be after segment
+				isInside = -1;
+			} else { // Intersection will be before segment
+				isInside = +1;
+			}
+		}
+
+		return distanceBetweenPoints3D(point, intersection);
+	}
+
+	double geometry::distancePointLine(HPoint2D point, HPoint3D line) {
+		/*dist = |A*x + B*y + C|
+						---------------
+						sqrt(A^2 + B^2)*/
+
+		if(line.X == 0.0 && line.Y == 0.0)
+			return GEOMETRY_INFINITE;
+		
+		return abs(line.X*point.x + line.Y*point.y + line.Z)/(sqrt(G_SQUARE(line.X) + G_SQUARE(line.Y)));
+	}
+
+	double geometry::distanceOriginLine(HPoint3D line) {
+		/*dist = 			|C|
+						---------------
+						sqrt(A^2 + B^2)*/
+		if(line.X == 0.0 && line.Y == 0.0)
+			return GEOMETRY_INFINITE;
+
+		return abs(line.Z)/(sqrt(G_SQUARE(line.X) + G_SQUARE(line.Y)));
+	}
+
+	bool geometry::areTheSameSegment (Segment3D s1, Segment3D s2) {
+		bool areTheSame = false;
+		if ((((double)s1.start.X==(double)s2.start.X) && 
+				 ((double)s1.start.Y==(double)s2.start.Y) && 
+				 ((double)s1.start.Z==(double)s2.start.Z) && 
+				 ((double)s1.end.X==(double)s2.end.X) &&
+				 ((double)s1.end.Y==(double)s2.end.Y) && 
+				 ((double)s1.end.Z==(double)s2.end.Z))	|| 
+				(((double)s1.start.X==(double)s2.end.X) && 
+				 ((double)s1.start.Y==(double)s2.end.Y) && 
+				 ((double)s1.start.Z==(double)s2.end.Z) && 
+				 ((double)s1.end.X==(double)s2.start.X) &&
+				 ((double)s1.end.Y==(double)s2.start.Y) && 
+				 ((double)s1.end.Z==(double)s2.start.Z))) { // they're the same segment
+			areTheSame = true;
+		}
+
+		return areTheSame;
+	}
+
+	bool geometry::areTheSameParallelogram (Parallelogram3D par1, Parallelogram3D par2) {
+		HPoint3D* myArray1[4] = {&(par1.p1), &(par1.p2), &(par1.p3), &(par1.p4)};
+		HPoint3D* myArray2[4] = {&(par2.p1), &(par2.p2), &(par2.p3), &(par2.p4)};
+		int i, j, found;
+		double value;
+		int equalPointsCounter = 0;
+
+		for (i = 0; i < 4; i ++) {
+			j = 0;
+			found = false;
+			while ((j < 4) && (!found)) {
+				value = abs(distanceBetweenPoints3D (*myArray1[i], *myArray2[j]));
+				if (value < 20.) {
+					equalPointsCounter ++;
+					found = true;
+				}
+				j ++;
+			}
+		}
+
+		return (equalPointsCounter == 4);
+	}
+
+	void geometry::getPolygonCentroid (Parallelogram3D &parallelogram) {
+		HPoint3D vertexList[5]; // Remember: Counter Clockwise Winding in order to get the centroid
+		int i, j;
+		double sum = 0.;
+		double area = 0.;
+		HPoint3D centroid;
+
+		vertexList[0] = parallelogram.p2;
+		vertexList[1] = parallelogram.p1;
+		vertexList[2] = parallelogram.p3;
+		vertexList[3] = parallelogram.p4;
+		vertexList[4] = vertexList[0];
+
+		centroid.X = 0.;
+		centroid.Y = 0.;
+		centroid.Z = 0.;
+		centroid.H = 1.;
+
+		for (i = 0; i < 5; i++) {
+			j = (i+1)%5;
+		  area = vertexList[i].X * vertexList[j].Y - vertexList[i].Y * vertexList[j].X;
+		  sum += area;
+		  centroid.X += (vertexList[i].X + vertexList[j].X) * area;
+		  centroid.Y += (vertexList[i].Y + vertexList[j].Y) * area;
+		}
+		sum *= 3.;
+		centroid.X /= sum;
+		centroid.Y /= sum;
+
+		parallelogram.centroid = centroid;
+	}
+
+	void geometry::printMatrix(gsl_matrix * m) {
+		unsigned int i, j;
+
+		std::cout << "-------------" << std::endl;
+
+		for(i=0;i<m->size1;i++) {
+			std::cout << "|\t";
+			for(j=0;j<m->size2;j++) {
+				std::cout << gsl_matrix_get(m,i,j) << "\t|\t";
+			}
+			std::cout << std::endl;
+		} 
+	}
+}
+

Copied: trunk/src/stable/libs/visionlib/imgAnalyze/geometry.h (from rev 1023, trunk/src/stable/libs/visionlib/geometry.h)
===================================================================
--- trunk/src/stable/libs/visionlib/imgAnalyze/geometry.h	                        (rev 0)
+++ trunk/src/stable/libs/visionlib/imgAnalyze/geometry.h	2013-10-09 15:11:57 UTC (rev 1027)
@@ -0,0 +1,147 @@
+/*
+ *  Copyright (C) 2011 Julio Vega Pérez
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU Library General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * 	Author : Julio Vega Pérez (julio [dot] vega [at] urjc [dot] es)
+ *           Eduardo Perdices (eperdices [at] gsyc [dot] es)
+ *
+ *  This library was programed for RobotVision Project http://jderobot.org/index.php/robotvision
+ *
+ */
+
+#ifndef VISIONLIBRARY_GEOMETRY_H
+#define VISIONLIBRARY_GEOMETRY_H
+
+#include <iostream>
+#include <opencv/cv.h>
+#include <opencv/highgui.h>
+#include "structs.h"
+/*GSL*/
+#include <gsl/gsl_linalg.h>
+#include <gsl/gsl_blas.h>
+#include <gsl/gsl_rng.h>
+#include <gsl/gsl_eigen.h>
+
+#ifndef G_SQUARE
+#define G_SQUARE(a) ( (a) * (a) )
+#endif
+
+namespace visionLibrary {
+  class geometry {
+
+		public:
+			geometry ();
+		  virtual ~geometry ();
+
+			/*Distance between two points in 2D*/
+			static double distanceBetweenPoints2D(int x1, int y1, int x2, int y2);
+			static double distanceBetweenPoints2D(double x1, double y1, double x2, double y2);
+			static double distanceBetweenPoints2D(HPoint2D p1, HPoint2D p2);
+
+			/*Distance between two points in 3D*/
+			static double distanceBetweenPoints3D(HPoint3D p1, HPoint3D p2);
+
+			/*Distance between two points in 2D in a concrete axis*/
+			static double calcDistanceAxis(double x1, double y1, double x2, double y2, double alpha);
+			static double calcDistanceAxis(HPoint2D p1, HPoint2D p2, double alpha);
+			static double calcDistanceAxis(HPoint2D p1, HPoint2D p2, double cosa, double sina);
+			static double calcDistanceAxis(HPoint3D p1, HPoint3D p2, double alpha);
+			static double calcDistanceAxis(HPoint3D p1, HPoint3D p2, double cosa, double sina);
+
+			/*Calc the positive angle of a vector*/
+			static double calcVectorAngle(double x1, double y1, double x2, double y2);
+			static double calcVectorAngle(HPoint3D line);
+			/*Calc gradient of a vector*/
+			static double calcVectorGradient(double x1, double y1, double x2, double y2);			
+			static double calcVectorGradient(HPoint3D line);	
+
+			/*Calc a 2D vector from 2 2D points*/
+			static void calcVector2D(HPoint2D p1, HPoint2D p2, HPoint3D &v);
+			static void calcVector2D(HPoint3D p1, HPoint3D p2, HPoint3D &v);
+
+			/*Calc a 2D normal vector from 3 2D points (normal vector of p1-p2 in p3)*/
+			static void calcNormalVector2D(HPoint2D p1, HPoint2D p2, HPoint2D p3, HPoint3D &v);
+			static void calcNormalVector2D(HPoint3D p1, HPoint3D p2, HPoint3D p3, HPoint3D &v);
+
+			/*Calc intersection between 2 2D vectors in a 2D point*/
+			static void calcIntersection2D(HPoint3D v1, HPoint3D v2, HPoint2D &p);
+			static void calcIntersection2D(HPoint3D v1, HPoint3D v2, HPoint3D &p);
+
+			/*Return true if the angles of two vectors can be considerated parallel*/
+			static bool areVectorsParallel(double alpha1, double alpha2, double threshold);
+
+			/*Return true if the projection of the point P is "inside" the segment A-B*/
+			static bool isPointInsideLine(HPoint2D p, HPoint2D a, HPoint2D b);
+			static bool isPointInsideLine(double px, double py, double ax, double ay, double bx, double by);
+
+			/*Get the u parameter in the equation P = A+u(B-A)*/
+			static double getPositionInLine(HPoint2D p, HPoint2D a, HPoint2D b);
+			static double getPositionInLine(double px, double py, double ax, double ay, double bx, double by);
+
+			/*Return a point belonging to the vector A-B*/
+			static void getPointFromVector(int &px, int &py, int ax, int ay, int bx, int by, double u);
+			static void getPointFromVector(double &px, double &py, double ax, double ay, double bx, double by, double u);
+
+			/*Return the intersection between a circle (radius and P_central) and a vector*/
+			static void calIntersectionCircleVector(HPoint3D v, HPoint3D p_c, double r, HPoint3D &int1, HPoint3D &int2);
+
+			/*Return the intersection between two points (A and B) on 3D, and the ground*/
+			static void lineGroundIntersection (HPoint3D A, HPoint3D B, HPoint3D &intersectionPoint);
+
+			/*Return true if two segments P1-P2 and P3-P4 intersect each other*/
+			static bool intersectSegments(double p1x, double p1y, double p2x, double p2y, double p3x, double p3y, double p4x, double p4y, HPoint2D& pres);
+
+			/*Try to merge two segments, return true if merged and update segment1.
+			Params: max parallel angle (rads), max horizontal distance (pixs), max perpendicular distance (pixs)*/
+			static bool mergeSegments(Segment2D &segment1, Segment2D segment2, double max_parallel = 0.3, double max_distance = 10.0, double max_normal_distance = 10.0);
+
+			/*Merge two segments to obtain the longest one*/
+			static void getMaximizedSegment(HPoint3D seg1Start, HPoint3D seg1End, HPoint3D seg2Start, HPoint3D seg2End, HPoint3D &startPoint, HPoint3D &endPoint);
+
+			/*Length of a segment*/
+			static double segmentLength(Segment3D segment);
+
+			/*Distance between a point and a segment. Check if the points is inside the line in "isInside" parameter*/
+			static double distancePointLine(HPoint3D point, Segment3D segment, HPoint3D &intersection, int &isInside); /*Deprecated*/
+			static double distancePointSegment(HPoint3D point, Segment3D segment, HPoint3D &intersection, int &isInside);
+
+			/*Distance between a point and a line*/
+			static double distancePointLine(HPoint2D point, HPoint3D line);
+
+			/*Distance between the origin (0,0) and a line*/
+			static double distanceOriginLine(HPoint3D line);			
+
+			/*Check if two segments are equal*/
+			static bool areTheSameSegment (Segment3D s1, Segment3D s2);
+
+			/*Check if two parallelograms are equal*/
+			static bool areTheSameParallelogram (Parallelogram3D par1, Parallelogram3D par2);
+
+			/*Calculate centroid of a polygon*/
+			static void getPolygonCentroid (Parallelogram3D &parallelogram);
+
+			/*Print matrix*/
+			static void printMatrix(gsl_matrix * m);
+
+		private:
+			static const double GEOMETRY_PI;
+			static const double GEOMETRY_PI_2;
+			static const double GEOMETRY_SQRT_2;
+			static const double GEOMETRY_INFINITE;
+	};
+}
+
+#endif

Copied: trunk/src/stable/libs/visionlib/imgAnalyze/image.cpp (from rev 1023, trunk/src/stable/libs/visionlib/image.cpp)
===================================================================
--- trunk/src/stable/libs/visionlib/imgAnalyze/image.cpp	                        (rev 0)
+++ trunk/src/stable/libs/visionlib/imgAnalyze/image.cpp	2013-10-09 15:11:57 UTC (rev 1027)
@@ -0,0 +1,354 @@
+ /*
+ *  Copyright (C) 2010 Julio Vega Pérez
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU Library General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * 	Author : Julio Vega Pérez (julio [dot] vega [at] urjc [dot] es)
+ *           Eduardo Perdices (eperdices [at] gsyc [dot] es)
+ *
+ *  This library was programed for RobotVision Project http://jderobot.org/index.php/robotvision
+ *
+ */
+
+#include "image.h"
+
+namespace visionLibrary {
+
+	const int image::IMAGE_WIDTH = 320;
+	const int image::IMAGE_HEIGHT = 240;
+	const double image::MIN_DISTANCE_CORNERS = 30.0;
+	const double image::MIN_PERCENTAGE_VALID = 0.95;
+	const double image::MIN_DISTANCE_UNIQUE_CORNERS = 15.0;
+
+	cv::Mat *image::current_src = NULL;
+	double image::sobel_threshold = 0.0;
+	bool * image::calThreshold = new bool[IMAGE_WIDTH*IMAGE_HEIGHT];
+	bool * image::thresholds = new bool[IMAGE_WIDTH*IMAGE_HEIGHT];
+	bool * image::calPixel = new bool[IMAGE_WIDTH*IMAGE_HEIGHT];
+	bool * image::pixels = new bool[IMAGE_WIDTH*IMAGE_HEIGHT];
+	std::vector<HPoint2D> * image::unique_corners = new std::vector<HPoint2D>();
+
+	image::image () {}
+
+	image::~image () {}
+
+	std::vector<HPoint2D> * image::getSegments(cv::Mat &src, std::vector<Segment2D> * segments, double threshold_fast, double threshold_sobel) {
+		CvPoint * corners;
+		Segment2D segment;
+		HPoint2D new_corner;
+		int * scores;
+		int numCorners;
+
+		image::current_src = &src;
+		image::sobel_threshold = threshold_sobel;
+
+		/*Reset parameters*/
+		memset(image::calThreshold, 0, sizeof(bool)*IMAGE_WIDTH*IMAGE_HEIGHT);
+		memset(image::thresholds, 0, sizeof(bool)*IMAGE_WIDTH*IMAGE_HEIGHT);
+		memset(image::calPixel, 0, sizeof(bool)*IMAGE_WIDTH*IMAGE_HEIGHT);
+		memset(image::pixels, 0, sizeof(bool)*IMAGE_WIDTH*IMAGE_HEIGHT);
+		segments->clear();
+		image::unique_corners->clear();
+
+		/*Get corners fast*/
+		cvCornerFast(src, threshold_fast, 9, false, &numCorners, &corners, &scores);
+
+		/*Check unique corners*/
+		for(int i=0;i<numCorners;i++) {
+			/*Save unique corners*/
+			if(is_unique_corner(corners[i].x, corners[i].y, scores[i])) {
+				new_corner.x = (float) corners[i].x;
+				new_corner.y = (float) corners[i].y;
+				new_corner.h = (float) scores[i];				
+				image::unique_corners->push_back(new_corner);
+			}
+		}
+
+		/*Free memory*/
+		if(corners != NULL)	free(corners);
+		if(scores != NULL) free(scores);
+
+		/*Select lines*/
+		for(std::vector<HPoint2D>::iterator p1=image::unique_corners->begin(); p1 != image::unique_corners->end(); p1++)
+			for(std::vector<HPoint2D>::iterator p2=p1+1; p2 != image::unique_corners->end(); p2++) {
+				/*Check distance between corners*/
+				if(!(geometry::distanceBetweenPoints2D((*p1).x, (*p1).y, (*p2).x, (*p2).y) > MIN_DISTANCE_CORNERS))
+					continue;
+			
+				/*Check line (fast way)*/
+				if(!isLineFast((*p1).x, (*p1).y, (*p2).x, (*p2).y))
+					continue;
+
+				/*Check line (slow way)*/
+				if(!isLineSlow((*p1).x, (*p1).y, (*p2).x, (*p2).y))
+					continue;
+
+				/*Save line*/
+				segment.start.x = (float) (*p1).x;
+				segment.start.y = (float) (*p1).y;
+				segment.end.x = (float) (*p2).x;
+				segment.end.y = (float) (*p2).y;
+				segment.isValid = true;
+				segments->push_back(segment);
+			}
+
+		return image::unique_corners;
+	}
+
+/*	int image::multiplyFFT (const CvArr* srcAarr, const CvArr* srcBarr, CvArr* dstarr) {
+		CvMat *srcA = (CvMat*)srcAarr;
+		CvMat *srcB = (CvMat*)srcBarr;
+		CvMat *dst = (CvMat*)dstarr;
+
+		int i,j, rows, cols;
+		rows = srcA->rows;
+		cols = srcA->cols;
+		double c_re,c_im;
+
+		for( i=0; i<rows; i++ )	{
+			for( j = 0; j < cols; j ++ ) {
+				c_re = ((double*)(srcA->data.ptr + srcA->step*i))[j*2]*((double*)(srcB->data.ptr + srcB->step*i))[j*2] -
+				((double*)(srcA->data.ptr + srcA->step*i))[j*2+1]*((double*)(srcB->data.ptr + srcB->step*i))[j*2+1];
+				c_im = ((double*)(srcA->data.ptr + srcA->step*i))[j*2]*((double*)(srcB->data.ptr + srcB->step*i))[j*2+1] +
+				((double*)(srcA->data.ptr + srcA->step*i))[j*2+1]*((double*)(srcB->data.ptr + srcB->step*i))[j*2];
+				((double*)(dst->data.ptr + dst->step*i))[j*2]	= c_re;
+				((double*)(dst->data.ptr + dst->step*i))[j*2+1]	= c_im;
+			}
+		}
+
+		return 1;
+	}*/
+
+	bool image::isLineFast(int x1, int y1, int x2, int y2) {
+		HPoint2D v;
+		int cx, cy;
+
+		/*Get vector*/
+		v.x = x2-x1;
+		v.y = y2-y1;
+			
+		/*Center*/
+		cx = x1 + 0.5*v.x;
+		cy = y1 + 0.5*v.y;
+
+		if(!isEdge(cx, cy))
+			return false;
+
+		/*1st cuarter*/
+		cx = x1 + 0.25*v.x;
+		cy = y1 + 0.25*v.y;
+
+		if(!isEdge(cx, cy))
+			return false;
+
+		/*3rd cuarter*/
+		cx = x1 + 0.75*v.x;
+		cy = y1 + 0.75*v.y;
+
+		if(!isEdge(cx, cy))
+			return false;
+
+		return true;
+	}
+
+	bool image::isLineSlow(int x1, int y1, int x2, int y2) {
+		HPoint2D v;
+		int cx, cy;
+		int dist, num_steps, max_nvalid, step = 2;
+		double frac, frac_step;
+		int n_nvalid = 0;
+
+		/*Get vector*/
+		v.x = x2-x1;
+		v.y = y2-y1;
+
+		/*Distance between points*/
+		dist = geometry::distanceBetweenPoints2D(x1, y1, x2, y2);
+		frac_step = (double)step/(double)dist;
+		num_steps = dist/step;
+
+		/*Calculate max non valid*/
+		max_nvalid = (int) ((double)num_steps*(1.0-MIN_PERCENTAGE_VALID) + 1.0);
+
+		/*Cover line*/
+		frac = frac_step;
+		while(frac <= 1.0) {
+			cx = x1 + frac*v.x;
+			cy = y1 + frac*v.y;
+
+			if(!isEdge(cx, cy))
+				n_nvalid++;
+
+			/*Max non valid reached, it's not a valid line*/
+			if(n_nvalid >= max_nvalid)
+				return false;
+
+			frac += frac_step;
+		}
+	
+		return true;
+	}
+
+	bool image::isEdge(int x, int y) {
+		int pos;
+
+		pos = y*IMAGE_WIDTH + x;	
+
+		/*Check if its already calculated*/
+		if(image::calThreshold[pos])
+			return image::thresholds[pos];
+
+		/*Calculate new point*/
+		if(image::getEdgeThresholed(x, y))
+			image::thresholds[pos] = true;
+		else
+			image::thresholds[pos] = false;
+
+		image::calThreshold[pos] = true;
+		return image::thresholds[pos];
+	}
+
+	bool image::getEdgeThresholed(int x, int y) {
+		int threshold = 2;
+		int ti, tj;
+
+		/*Check basic point*/
+		if(getEdge(x, y))
+			return true;
+
+		/*Check neighbors*/
+		for(int i=2;i<=threshold;i++) {
+			/*Top*/
+			ti = x;
+			tj = y-i;
+			if(tj>=0) {
+				if(getEdge(ti, tj))
+					return true;
+			}
+
+			/*Bottom*/
+			ti = x;
+			tj = y+i;
+			if(tj<IMAGE_HEIGHT) {
+				if(getEdge(ti, tj))
+					return true;
+			}
+
+			/*Left*/
+			ti = x-i;
+			tj = y;
+			if(ti>=0) {
+				if(getEdge(ti, tj))
+					return true;
+			}
+
+			/*Right*/
+			ti = x+i;
+			tj = y;
+			if(ti<IMAGE_WIDTH) {
+				if(getEdge(ti, tj))
+					return true;
+			}
+		}
+
+		return false;
+	}
+
+	bool image::getEdge(int x, int y) {
+		int pos;
+		int gx, gy, sum;
+		int posc1, posc2, posc3;
+
+		pos = y*IMAGE_WIDTH + x;
+
+		/*Check if its already calculated*/
+		if(image::calPixel[pos])
+			return image::pixels[pos];
+
+		/*Check borders*/
+		if(x==0 || y==0 || x==IMAGE_WIDTH-1 || y==IMAGE_WIDTH-1) {
+			image::pixels[pos] = false;
+			image::calPixel[pos] = true;
+			return false;
+		}
+
+		posc1 = (y-1)*IMAGE_WIDTH + x;
+		posc2 = pos;
+		posc3 = (y+1)*IMAGE_WIDTH + x;
+
+		/*Sobel filter: Sum = abs(Gx) + abs(Gy):
+
+					-1	0	+1					+1	+2	+1	
+		Gx = 	-2	0	+2		Gy = 	0		0		0
+					-1	0	+1					-1	-2	-1*/
+
+		gx = 	-(unsigned int)image::current_src->data[posc1-1] + (unsigned int)image::current_src->data[posc1+1] +
+					-2*(unsigned int)image::current_src->data[posc2-1] + 2*(unsigned int)image::current_src->data[posc2+1] +
+					-(unsigned int)image::current_src->data[posc3-1] + (int)image::current_src->data[posc3+1];
+
+		gy = 	1*(unsigned int)image::current_src->data[posc1-1] + 2*(unsigned int)image::current_src->data[posc1] + 1*(unsigned int)image::current_src->data[posc1+1] +
+					-1*(unsigned int)image::current_src->data[posc3-1] + -2*(unsigned int)image::current_src->data[posc3] + -1*(unsigned int)image::current_src->data[posc3+1];
+
+		sum = abs(gx) + abs(gy);
+		
+		/*Calculate new point*/
+		if(sum > image::sobel_threshold)
+			image::pixels[pos] = true;
+		else
+			image::pixels[pos] = false;
+
+		image::calPixel[pos] = true;
+		return image::pixels[pos];
+			
+	}
+
+	void image::getSegmentsDebug(cv::Mat &src) {
+
+		for(int ti=0;ti<IMAGE_WIDTH;ti++)
+			for(int tj=0;tj<IMAGE_HEIGHT;tj++)
+				isEdge(ti, tj);
+
+		for(int ti=0;ti<IMAGE_WIDTH;ti++)
+			for(int tj=0;tj<IMAGE_HEIGHT;tj++) {
+				int pos = tj*IMAGE_WIDTH + ti;
+				if(image::thresholds[pos])
+					src.data[pos] = 255;
+				else
+					src.data[pos] = 0;
+			}
+	}
+
+	bool image::is_unique_corner(int x, int y, int score) {
+		double dist;
+
+		for(std::vector<HPoint2D>::iterator p1=image::unique_corners->begin(); p1 != image::unique_corners->end(); p1++) {
+			dist = geometry::distanceBetweenPoints2D((double)(*p1).x, (double)(*p1).y, (double)x, (double)y);
+
+			/*Check distance in pixels*/
+			if(dist <= MIN_DISTANCE_UNIQUE_CORNERS) {
+				/*Check score*/
+				if((float) score > (*p1).h) {
+					(*p1).x = (float) x;
+					(*p1).y = (float) y;
+					(*p1).h = (float) score;
+				}
+				return false;
+			}
+		}
+
+		return true;
+	}
+}
+

Copied: trunk/src/stable/libs/visionlib/imgAnalyze/image.h (from rev 1026, trunk/src/stable/libs/visionlib/image.h)
===================================================================
--- trunk/src/stable/libs/visionlib/imgAnalyze/image.h	                        (rev 0)
+++ trunk/src/stable/libs/visionlib/imgAnalyze/image.h	2013-10-09 15:11:57 UTC (rev 1027)
@@ -0,0 +1,86 @@
+/*
+ *  Copyright (C) 2010 Julio Vega Pérez
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU Library General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * 	Author : Julio Vega Pérez (julio [dot] vega [at] urjc [dot] es)
+ *           Eduardo Perdices (eperdices [at] gsyc [dot] es)
+ *
+ *  This library was programed for RobotVision Project http://jderobot.org/index.php/robotvision
+ *
+ */
+
+#ifndef VISIONLIBRARY_IMAGE_H
+#define VISIONLIBRARY_IMAGE_H
+
+#include <iostream>
+#include <opencv/cv.h>
+#include <opencv/highgui.h>
+#include "structs.h"
+#include <visionlib/cvFast/cvfast.h>
+#include "geometry.h"
+
+#ifndef I_SQUARE
+#define I_SQUARE(a) ( (a) * (a) )
+#endif
+
+namespace visionLibrary {
+  class image {
+
+		public:
+			image ();
+		  virtual ~image ();
+
+			/*Get segments from the image src. Return corners*/
+			static std::vector<HPoint2D> * getSegments(cv::Mat &src, std::vector<Segment2D> * segments, double threshold_fast = 50.0, double threshold_sobel = 100.0);
+
+			/*Multiply fast fourier transform*/
+			//static int multiplyFFT (const CvArr* srcAarr, const CvArr* srcBarr, CvArr* dstarr);
+
+			/*Debug function*/
+			static void getSegmentsDebug(cv::Mat &src);
+		
+		private:
+
+			static const int IMAGE_WIDTH;
+			static const int IMAGE_HEIGHT;
+			static const double MIN_DISTANCE_CORNERS;
+			static const double MIN_PERCENTAGE_VALID;
+			static const double MIN_DISTANCE_UNIQUE_CORNERS;
+
+			/*Check line fast*/
+			static bool isLineFast(int x1, int y1, int x2, int y2);
+			/*Check line slow*/
+			static bool isLineSlow(int x1, int y1, int x2, int y2);
+			/*Check edge filter*/
+			static bool isEdge(int x, int y);
+			/*Calculate edge in a concrete pixel*/
+			static bool getEdge(int x, int y);
+			/*Calculate edge in a concrete pixel with a threshold*/
+			static bool getEdgeThresholed(int x, int y);
+			/*Check if a corner is unique*/
+			static bool is_unique_corner(int x, int y, int score);
+
+			static cv::Mat *current_src;
+			static double sobel_threshold;
+			static bool * calThreshold;
+			static bool * thresholds;
+			static bool * calPixel;
+			static bool * pixels;
+			static std::vector<HPoint2D> * unique_corners;
+	};
+}
+
+#endif

Copied: trunk/src/stable/libs/visionlib/imgAnalyze/linesDetection.cpp (from rev 1023, trunk/src/stable/libs/visionlib/linesDetection.cpp)
===================================================================
--- trunk/src/stable/libs/visionlib/imgAnalyze/linesDetection.cpp	                        (rev 0)
+++ trunk/src/stable/libs/visionlib/imgAnalyze/linesDetection.cpp	2013-10-09 15:11:57 UTC (rev 1027)
@@ -0,0 +1,230 @@
+/*
+ *  Copyright (C) 2010 Julio Vega Pérez
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU Library General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * 	Author : Julio Vega Pérez (julio [dot] vega [at] urjc [dot] es)
+ *
+ *  This library was programed for RobotVision Project http://jde.gsyc.es/index.php/robotvision
+ *
+ */
+
+#include "linesDetection.h"
+
+namespace visionLibrary {
+
+	const int linesDetection::CASES_OFFSET = 5;
+	const int linesDetection::solis_cases[][11] = {
+		{6,6,6,7,7,7,7,7,8,8,8},
+		{6,6,6,7,7,7,7,7,8,8,8},
+		{6,6,6,6,7,7,7,8,8,8,8},
+		{5,5,6,6,7,7,7,8,8,1,1},
+		{5,5,5,5,0,0,0,1,1,1,1},
+		{5,5,5,5,0,0,0,1,1,1,1},
+		{5,5,5,5,0,0,0,1,1,1,1},
+		{5,5,4,4,3,3,3,2,2,1,1},
+		{4,4,4,4,3,3,3,2,2,2,2},
+		{4,4,4,3,3,3,3,3,2,2,2},
+		{4,4,4,3,3,3,3,3,2,2,2}
+	};
+
+	void linesDetection::solisAlgorithm (cv::Mat &image, std::vector<Segment2D> *segments) {
+		cv::Mat imgTmp1,imgTmp2,imgBlack,imgLaplace;
+		CvPoint pstart, pend;
+		int i, i_jump = 6;
+		int ThressValue = 30;
+		int diff_x, diff_y;
+		const int min_size_contour = 30;
+		CvScalar color;
+		Segment2D mySegment;
+		int type, current_type;
+		int num_frag = 0, min_frags = 3, counter = 0;
+		double max_distance;
+		bool first, debug = false;
+
+		imgTmp1 = cv::Mat(image.size(), CV_8UC1);
+		imgTmp2 = cv::Mat(image.size(), CV_8UC1);
+		imgLaplace = cv::Mat(image.size(), CV_16SC1);
+
+		if(debug) {
+			imgBlack = cv::Mat(image.size(), CV_8UC3);
+			imgBlack = (const cv::Scalar&) 0;
+		}
+
+		/*Convert to Gray Image*/
+		cv::cvtColor(image, imgTmp1, CV_RGB2GRAY);
+
+		/*Normalize image*/
+		cv::normalize(imgTmp1, imgTmp1, 0, 255, CV_MINMAX);
+
+		// Make a average filtering
+		cv::blur(imgTmp1,imgTmp2,cv::Size(3,3));
+
+		//Laplace
+		cv::Laplacian(imgTmp2, imgLaplace, CV_16S, 3);
+		cv::convertScaleAbs(imgLaplace,imgTmp1);
+
+		/*Perform a binary threshold*/
+		cv::threshold(imgTmp1,imgTmp2,ThressValue,255,CV_THRESH_BINARY);
+
+		/*Find contours*/
+		std::vector< std::vector<cv::Point> > vecContours;
+		cv::findContours(imgTmp2, vecContours, CV_RETR_LIST, CV_CHAIN_APPROX_NONE);
+
+		/*Run through found coutours*/
+		for(int contour=0; contour<vecContours.size(); contour++) {
+
+			/*Check size*/
+			if(vecContours[contour].size() < min_size_contour)
+				continue;
+
+			i = 0;
+			first = true;
+
+			while ((i < (vecContours[contour].size() - (i_jump-1)))) {
+
+				counter++;
+
+				pstart.x = vecContours[contour][(int)i].x;
+				pstart.y = vecContours[contour][(int)i].y;
+				pend.x = vecContours[contour][(int)(i+i_jump-1)].x;
+				pend.y = vecContours[contour][(int)(i+i_jump-1)].y;
+
+				/*Calculate type*/
+				diff_x = pstart.x - pend.x;
+				diff_y = pstart.y - pend.y;
+				type = linesDetection::solis_cases[diff_x+linesDetection::CASES_OFFSET][diff_y+linesDetection::CASES_OFFSET];
+
+				if (debug) {
+					/*Visual portions*/
+					if (type==0)
+						color = CV_RGB(255,255,255);
+					else if (type==1)
+						color = CV_RGB(255,255,0);
+					else if (type==2)
+						color = CV_RGB(0,255,255);
+					else if (type==3)
+						color = CV_RGB(255,0,0);
+					else if (type==4)
+						color = CV_RGB(0,255,0);
+					else if (type==5)
+						color = CV_RGB(0,0,255);
+					else if (type==6)
+						color = CV_RGB(255,0,255);
+					else if (type==7)
+						color = CV_RGB(0,128,128);
+					else if (type==8)
+						color = CV_RGB(128,128,0);
+
+					/*Draw line with orientation*/
+					cv::line(imgBlack, pstart, pend, color, 2, CV_AA, 0);
+				} else {
+					if (first) {
+						if(type != 0) {
+							mySegment.start.x = pstart.x;
+							mySegment.start.y = pstart.y;
+							mySegment.start.h = (float) counter;
+							mySegment.end.x = pend.x;
+							mySegment.end.y = pend.y;
+							mySegment.end.h = (float) counter;
+							mySegment.type = type;
+							first = false;
+							current_type = type;
+							num_frag = 1;
+						}
+					} else {
+						/*Check type threshold*/
+						if (current_type == type) { //current_type == type || type == 0
+							/*Save current end*/
+							mySegment.end.x = pend.x;
+							mySegment.end.y = pend.y;
+							mySegment.end.h = (float) counter;
+							num_frag++;
+						} else {
+							/*Save current segment if length is enough*/
+							if(num_frag >= min_frags)
+								segments->push_back(mySegment);
+							first = true;
+						}
+					}
+				}
+
+				i += i_jump;
+			}
+
+			/*Save the last one*/
+			if(!first && num_frag >= min_frags)
+				segments->push_back(mySegment);
+		}
+
+		if (debug) {
+			//cv::cvtColor(imgTmp1, imgBlack, CV_GRAY2RGB);
+			imgBlack.copyTo(image);
+		} else {
+
+			/*CvPoint p1, p2;*/
+
+			/*Draw lines*/
+			/*for(std::vector<Segment2D>::iterator it1 = segments->begin(); it1 != segments->end(); it1++) {
+				p1.x = (*it1).start.x;
+				p1.y = (*it1).start.y;
+				p2.x = (*it1).end.x;
+				p2.y = (*it1).end.y;
+				cv::line (&image, p1, p2, CV_RGB(0,0,255), 2, 8);	
+			}*/
+		}
+
+		max_distance = (double) (i_jump*min_frags);
+
+		/*Merge consecutive fragments*/
+		std::vector<Segment2D>::iterator it1 = segments->begin();
+		while(it1 != segments->end()) {
+				/*Compare with next one*/
+				std::vector<Segment2D>::iterator it2 = it1;
+				it2++;
+				if(it2 != segments->end()) {	
+					if((*it1).type == (*it2).type && (*it2).start.h - (*it1).end.h <= min_frags) {
+						if(geometry::distanceBetweenPoints2D((*it2).start.x, (*it2).start.y, (*it1).end.x, (*it1).end.y) <= max_distance) { 
+							(*it1).end.x = (*it2).end.x;
+							(*it1).end.y = (*it2).end.y;
+							(*it1).end.h = (*it2).end.h;
+							segments->erase(it2);
+							continue;
+						}
+					}
+				}
+
+				it1++;
+		}
+
+		/*Reset .h values*/
+		for(std::vector<Segment2D>::iterator it_s = segments->begin(); it_s != segments->end(); it_s++) {
+			(*it_s).start.h = 1.0;
+			(*it_s).end.h = 1.0;
+		}
+
+		/*Clean up*/
+		imgTmp1.release();
+		imgTmp2.release();
+		imgLaplace.release();
+		if(debug)
+			imgBlack.release();
+
+		for(int t1 = 0; t1<vecContours.size(); t1++)
+			vecContours[t1].clear();
+		vecContours.clear();
+	}
+}
+

Copied: trunk/src/stable/libs/visionlib/imgAnalyze/linesDetection.h (from rev 1026, trunk/src/stable/libs/visionlib/linesDetection.h)
===================================================================
--- trunk/src/stable/libs/visionlib/imgAnalyze/linesDetection.h	                        (rev 0)
+++ trunk/src/stable/libs/visionlib/imgAnalyze/linesDetection.h	2013-10-09 15:11:57 UTC (rev 1027)
@@ -0,0 +1,48 @@
+/*
+ *  Copyright (C) 2010 Julio Vega Pérez
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU Library General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * 	Author : Julio Vega Pérez (julio [dot] vega [at] urjc [dot] es)
+ *
+ *  This library was programed for RobotVision Project http://jde.gsyc.es/index.php/robotvision
+ *
+ */
+
+#ifndef VISUALMEMORY_LINESDETECTION_H
+#define VISUALMEMORY_LINESDETECTION_H
+
+#include <opencv/cv.h>
+#include <opencv/highgui.h>
+#include <stdio.h>
+#include <visionlib/colorspaces/colorspacesmm.h>
+#include <sys/time.h>
+#include "image.h"
+
+using namespace visionLibrary;
+using namespace std;
+
+namespace visionLibrary {
+  class linesDetection {
+		public:
+			static void solisAlgorithm (cv::Mat &image, std::vector<Segment2D> *segments);
+		
+		private:
+			static const int solis_cases[][11];
+			static const int CASES_OFFSET;
+	};
+}
+
+#endif

Copied: trunk/src/stable/libs/visionlib/imgAnalyze/structs.h (from rev 1023, trunk/src/stable/libs/visionlib/structs.h)
===================================================================
--- trunk/src/stable/libs/visionlib/imgAnalyze/structs.h	                        (rev 0)
+++ trunk/src/stable/libs/visionlib/imgAnalyze/structs.h	2013-10-09 15:11:57 UTC (rev 1027)
@@ -0,0 +1,108 @@
+#include <progeo/progeo.h>
+
+#ifndef VISUALMEMORY_STRUCTS_H
+#define VISUALMEMORY_STRUCTS_H
+
+typedef struct SoRtype{
+  struct SoRtype *father;
+  float posx;
+  float posy;
+  float posz;
+  float foax;
+  float foay;
+  float foaz;
+  float roll;
+} SofReference;
+
+struct image_struct {
+	int width;
+	int height;
+	int bpp;	// bytes per pixel
+	char *image;
+};
+
+typedef struct {
+	float R;
+	float G;
+	float B;
+} colorRGB;
+
+typedef struct {
+	HPoint3D start;
+	HPoint3D end;
+	int isValid;
+} Segment3D;
+
+typedef struct {
+	HPoint2D start;
+	HPoint2D end;
+	int type;
+	int isValid;
+} Segment2D;
+
+typedef struct {
+	HPoint3D p1;
+	HPoint3D p2;
+	HPoint3D p3;
+	HPoint3D p4;
+	HPoint3D centroid;
+	bool isValid;
+} Parallelogram3D;
+
+typedef struct {
+	HPoint3D center;
+	int isValid;
+} Face3D;
+
+typedef struct {
+	HPoint3D start; // base de la flecha
+	HPoint3D end; // extremo de la flecha (hacia donde apunta)
+	colorRGB color;
+	int isAttainable; // es atendible? (si está dentro de un cierto radio le prestamos atención de rumbo)
+} Arrow3D;
+
+typedef struct {
+	int isValid;
+	Segment3D base; // base (segmento más largo) de la flecha
+	Segment3D cross; // uno de las aspas de la flecha
+	colorRGB color;
+} SemiArrow3D;
+
+enum movement_pantilt {up,down,left,right};
+
+// Parámetros relacionados con la atención visual
+enum state {think, search, analizeSearch};
+
+typedef struct {
+	float pan;
+	float tilt;
+} scenePoint;
+
+typedef struct {
+	int x;
+	int y;
+} imagePoint;
+
+typedef struct {
+  int x;
+  int y;
+} t_vector;
+
+struct elementStruct {
+	double lastInstant; // último instante de tiempo en su detección
+	double firstInstant; // primer instante de tiempo en su detección
+	float latitude; // posición absoluta del pantilt, en eje tilt
+	float longitude; // posición absoluta del pantilt, en eje pan
+	int scenePos; // it can be left, center or right, depends on pantilt pos where face was detected
+	float saliency;
+	float liveliness;
+	int type; // 0 = elemento virtual; 1 = rectángulo; 2 = face; 3 = arrow
+	int isVisited;
+	Parallelogram3D parallelogram;
+	Face3D face;
+	Arrow3D arrow;
+	struct elementStruct* next;
+};
+
+#endif
+

Deleted: trunk/src/stable/libs/visionlib/linesDetection.cpp
===================================================================
--- trunk/src/stable/libs/visionlib/linesDetection.cpp	2013-10-09 14:41:27 UTC (rev 1026)
+++ trunk/src/stable/libs/visionlib/linesDetection.cpp	2013-10-09 15:11:57 UTC (rev 1027)
@@ -1,230 +0,0 @@
-/*
- *  Copyright (C) 2010 Julio Vega Pérez
- *
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2 of the License, or
- *  (at your option) any later version.
- *
- *  This program is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU Library General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *
- * 	Author : Julio Vega Pérez (julio [dot] vega [at] urjc [dot] es)
- *
- *  This library was programed for RobotVision Project http://jde.gsyc.es/index.php/robotvision
- *
- */
-
-#include "linesDetection.h"
-
-namespace visionLibrary {
-
-	const int linesDetection::CASES_OFFSET = 5;
-	const int linesDetection::solis_cases[][11] = {
-		{6,6,6,7,7,7,7,7,8,8,8},
-		{6,6,6,7,7,7,7,7,8,8,8},
-		{6,6,6,6,7,7,7,8,8,8,8},
-		{5,5,6,6,7,7,7,8,8,1,1},
-		{5,5,5,5,0,0,0,1,1,1,1},
-		{5,5,5,5,0,0,0,1,1,1,1},
-		{5,5,5,5,0,0,0,1,1,1,1},
-		{5,5,4,4,3,3,3,2,2,1,1},
-		{4,4,4,4,3,3,3,2,2,2,2},
-		{4,4,4,3,3,3,3,3,2,2,2},
-		{4,4,4,3,3,3,3,3,2,2,2}
-	};
-
-	void linesDetection::solisAlgorithm (cv::Mat &image, std::vector<Segment2D> *segments) {
-		cv::Mat imgTmp1,imgTmp2,imgBlack,imgLaplace;
-		CvPoint pstart, pend;
-		int i, i_jump = 6;
-		int ThressValue = 30;
-		int diff_x, diff_y;
-		const int min_size_contour = 30;
-		CvScalar color;
-		Segment2D mySegment;
-		int type, current_type;
-		int num_frag = 0, min_frags = 3, counter = 0;
-		double max_distance;
-		bool first, debug = false;
-
-		imgTmp1 = cv::Mat(image.size(), CV_8UC1);
-		imgTmp2 = cv::Mat(image.size(), CV_8UC1);
-		imgLaplace = cv::Mat(image.size(), CV_16SC1);
-
-		if(debug) {
-			imgBlack = cv::Mat(image.size(), CV_8UC3);
-			imgBlack = (const cv::Scalar&) 0;
-		}
-
-		/*Convert to Gray Image*/
-		cv::cvtColor(image, imgTmp1, CV_RGB2GRAY);
-
-		/*Normalize image*/
-		cv::normalize(imgTmp1, imgTmp1, 0, 255, CV_MINMAX);
-
-		// Make a average filtering
-		cv::blur(imgTmp1,imgTmp2,cv::Size(3,3));
-
-		//Laplace
-		cv::Laplacian(imgTmp2, imgLaplace, CV_16S, 3);
-		cv::convertScaleAbs(imgLaplace,imgTmp1);
-
-		/*Perform a binary threshold*/
-		cv::threshold(imgTmp1,imgTmp2,ThressValue,255,CV_THRESH_BINARY);
-
-		/*Find contours*/
-		std::vector< std::vector<cv::Point> > vecContours;
-		cv::findContours(imgTmp2, vecContours, CV_RETR_LIST, CV_CHAIN_APPROX_NONE);
-
-		/*Run through found coutours*/
-		for(int contour=0; contour<vecContours.size(); contour++) {
-
-			/*Check size*/
-			if(vecContours[contour].size() < min_size_contour)
-				continue;
-
-			i = 0;
-			first = true;
-
-			while ((i < (vecContours[contour].size() - (i_jump-1)))) {
-
-				counter++;
-
-				pstart.x = vecContours[contour][(int)i].x;
-				pstart.y = vecContours[contour][(int)i].y;
-				pend.x = vecContours[contour][(int)(i+i_jump-1)].x;
-				pend.y = vecContours[contour][(int)(i+i_jump-1)].y;
-
-				/*Calculate type*/
-				diff_x = pstart.x - pend.x;
-				diff_y = pstart.y - pend.y;
-				type = linesDetection::solis_cases[diff_x+linesDetection::CASES_OFFSET][diff_y+linesDetection::CASES_OFFSET];
-
-				if (debug) {
-					/*Visual portions*/
-					if (type==0)
-						color = CV_RGB(255,255,255);
-					else if (type==1)
-						color = CV_RGB(255,255,0);
-					else if (type==2)
-						color = CV_RGB(0,255,255);
-					else if (type==3)
-						color = CV_RGB(255,0,0);
-					else if (type==4)
-						color = CV_RGB(0,255,0);
-					else if (type==5)
-						color = CV_RGB(0,0,255);
-					else if (type==6)
-						color = CV_RGB(255,0,255);
-					else if (type==7)
-						color = CV_RGB(0,128,128);
-					else if (type==8)
-						color = CV_RGB(128,128,0);
-
-					/*Draw line with orientation*/
-					cv::line(imgBlack, pstart, pend, color, 2, CV_AA, 0);
-				} else {
-					if (first) {
-						if(type != 0) {
-							mySegment.start.x = pstart.x;
-							mySegment.start.y = pstart.y;
-							mySegment.start.h = (float) counter;
-							mySegment.end.x = pend.x;
-							mySegment.end.y = pend.y;
-							mySegment.end.h = (float) counter;
-							mySegment.type = type;
-							first = false;
-							current_type = type;
-							num_frag = 1;
-						}
-					} else {
-						/*Check type threshold*/
-						if (current_type == type) { //current_type == type || type == 0
-							/*Save current end*/
-							mySegment.end.x = pend.x;
-							mySegment.end.y = pend.y;
-							mySegment.end.h = (float) counter;
-							num_frag++;
-						} else {
-							/*Save current segment if length is enough*/
-							if(num_frag >= min_frags)
-								segments->push_back(mySegment);
-							first = true;
-						}
-					}
-				}
-
-				i += i_jump;
-			}
-
-			/*Save the last one*/
-			if(!first && num_frag >= min_frags)
-				segments->push_back(mySegment);
-		}
-
-		if (debug) {
-			//cv::cvtColor(imgTmp1, imgBlack, CV_GRAY2RGB);
-			imgBlack.copyTo(image);
-		} else {
-
-			/*CvPoint p1, p2;*/
-
-			/*Draw lines*/
-			/*for(std::vector<Segment2D>::iterator it1 = segments->begin(); it1 != segments->end(); it1++) {
-				p1.x = (*it1).start.x;
-				p1.y = (*it1).start.y;
-				p2.x = (*it1).end.x;
-				p2.y = (*it1).end.y;
-				cv::line (&image, p1, p2, CV_RGB(0,0,255), 2, 8);	
-			}*/
-		}
-
-		max_distance = (double) (i_jump*min_frags);
-
-		/*Merge consecutive fragments*/
-		std::vector<Segment2D>::iterator it1 = segments->begin();
-		while(it1 != segments->end()) {
-				/*Compare with next one*/
-				std::vector<Segment2D>::iterator it2 = it1;
-				it2++;
-				if(it2 != segments->end()) {	
-					if((*it1).type == (*it2).type && (*it2).start.h - (*it1).end.h <= min_frags) {
-						if(geometry::distanceBetweenPoints2D((*it2).start.x, (*it2).start.y, (*it1).end.x, (*it1).end.y) <= max_distance) { 
-							(*it1).end.x = (*it2).end.x;
-							(*it1).end.y = (*it2).end.y;
-							(*it1).end.h = (*it2).end.h;
-							segments->erase(it2);
-							continue;
-						}
-					}
-				}
-
-				it1++;
-		}
-
-		/*Reset .h values*/
-		for(std::vector<Segment2D>::iterator it_s = segments->begin(); it_s != segments->end(); it_s++) {
-			(*it_s).start.h = 1.0;
-			(*it_s).end.h = 1.0;
-		}
-
-		/*Clean up*/
-		imgTmp1.release();
-		imgTmp2.release();
-		imgLaplace.release();
-		if(debug)
-			imgBlack.release();
-
-		for(int t1 = 0; t1<vecContours.size(); t1++)
-			vecContours[t1].clear();
-		vecContours.clear();
-	}
-}
-

Deleted: trunk/src/stable/libs/visionlib/linesDetection.h
===================================================================
--- trunk/src/stable/libs/visionlib/linesDetection.h	2013-10-09 14:41:27 UTC (rev 1026)
+++ trunk/src/stable/libs/visionlib/linesDetection.h	2013-10-09 15:11:57 UTC (rev 1027)
@@ -1,48 +0,0 @@
-/*
- *  Copyright (C) 2010 Julio Vega Pérez
- *
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2 of the License, or
- *  (at your option) any later version.
- *
- *  This program is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU Library General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *
- * 	Author : Julio Vega Pérez (julio [dot] vega [at] urjc [dot] es)
- *
- *  This library was programed for RobotVision Project http://jde.gsyc.es/index.php/robotvision
- *
- */
-
-#ifndef VISUALMEMORY_LINESDETECTION_H
-#define VISUALMEMORY_LINESDETECTION_H
-
-#include <opencv/cv.h>
-#include <opencv/highgui.h>
-#include <stdio.h>
-#include <visionlib/colorspaces/colorspacesmm.h>
-#include <sys/time.h>
-#include "image.h"
-
-using namespace visionLibrary;
-using namespace std;
-
-namespace visionLibrary {
-  class linesDetection {
-		public:
-			static void solisAlgorithm (cv::Mat &image, std::vector<Segment2D> *segments);
-		
-		private:
-			static const int solis_cases[][11];
-			static const int CASES_OFFSET;
-	};
-}
-
-#endif

Deleted: trunk/src/stable/libs/visionlib/structs.h
===================================================================
--- trunk/src/stable/libs/visionlib/structs.h	2013-10-09 14:41:27 UTC (rev 1026)
+++ trunk/src/stable/libs/visionlib/structs.h	2013-10-09 15:11:57 UTC (rev 1027)
@@ -1,108 +0,0 @@
-#include <progeo/progeo.h>
-
-#ifndef VISUALMEMORY_STRUCTS_H
-#define VISUALMEMORY_STRUCTS_H
-
-typedef struct SoRtype{
-  struct SoRtype *father;
-  float posx;
-  float posy;
-  float posz;
-  float foax;
-  float foay;
-  float foaz;
-  float roll;
-} SofReference;
-
-struct image_struct {
-	int width;
-	int height;
-	int bpp;	// bytes per pixel
-	char *image;
-};
-
-typedef struct {
-	float R;
-	float G;
-	float B;
-} colorRGB;
-
-typedef struct {
-	HPoint3D start;
-	HPoint3D end;
-	int isValid;
-} Segment3D;
-
-typedef struct {
-	HPoint2D start;
-	HPoint2D end;
-	int type;
-	int isValid;
-} Segment2D;
-
-typedef struct {
-	HPoint3D p1;
-	HPoint3D p2;
-	HPoint3D p3;
-	HPoint3D p4;
-	HPoint3D centroid;
-	bool isValid;
-} Parallelogram3D;
-
-typedef struct {
-	HPoint3D center;
-	int isValid;
-} Face3D;
-
-typedef struct {
-	HPoint3D start; // base de la flecha
-	HPoint3D end; // extremo de la flecha (hacia donde apunta)
-	colorRGB color;
-	int isAttainable; // es atendible? (si está dentro de un cierto radio le prestamos atención de rumbo)
-} Arrow3D;
-
-typedef struct {
-	int isValid;
-	Segment3D base; // base (segmento más largo) de la flecha
-	Segment3D cross; // uno de las aspas de la flecha
-	colorRGB color;
-} SemiArrow3D;
-
-enum movement_pantilt {up,down,left,right};
-
-// Parámetros relacionados con la atención visual
-enum state {think, search, analizeSearch};
-
-typedef struct {
-	float pan;
-	float tilt;
-} scenePoint;
-
-typedef struct {
-	int x;
-	int y;
-} imagePoint;
-
-typedef struct {
-  int x;
-  int y;
-} t_vector;
-
-struct elementStruct {
-	double lastInstant; // último instante de tiempo en su detección
-	double firstInstant; // primer instante de tiempo en su detección
-	float latitude; // posición absoluta del pantilt, en eje tilt
-	float longitude; // posición absoluta del pantilt, en eje pan
-	int scenePos; // it can be left, center or right, depends on pantilt pos where face was detected
-	float saliency;
-	float liveliness;
-	int type; // 0 = elemento virtual; 1 = rectángulo; 2 = face; 3 = arrow
-	int isVisited;
-	Parallelogram3D parallelogram;
-	Face3D face;
-	Arrow3D arrow;
-	struct elementStruct* next;
-};
-
-#endif
-

Modified: trunk/src/stable/libs/visionlib/visionlib.h
===================================================================
--- trunk/src/stable/libs/visionlib/visionlib.h	2013-10-09 14:41:27 UTC (rev 1026)
+++ trunk/src/stable/libs/visionlib/visionlib.h	2013-10-09 15:11:57 UTC (rev 1027)
@@ -1,11 +1,10 @@
 #ifndef VISIONLIB_H
 #define VISIONLIB_H
 
-#include <geometry.h>
-#include <cvfast.h>
-#include <image.h>
-#include <structs.h>
-#include <progeo/progeo.h>
+#include <visionlib/imgAnalyze/geometry.h>
+#include <visionlib/imgAnalyze/image.h>
+#include <visionlib/imgAnalyze/structs.h>
 #include <visionlib/cvFast/cvfast.h>
+#include <progeo/progeo.h>
 
 #endif



More information about the Jderobot-admin mailing list