Skip to content

Commit

Permalink
In progress: new algorithm for finger segmentation
Browse files Browse the repository at this point in the history
  • Loading branch information
sheley1998 committed Nov 1, 2015
1 parent 6013e96 commit 266d5e6
Show file tree
Hide file tree
Showing 6 changed files with 131 additions and 67 deletions.
22 changes: 21 additions & 1 deletion track_plus_core/track_plus/math_plus.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,32 @@ float map_val(float value, float left_min, float left_max, float right_min, floa
return right_min + (value_scaled * right_span);
}

float get_angle(Point p1, Point p2, bool horizontal)
{
Point p3;
if (horizontal)
p3 = Point(0, p1.y);
else
p3 = Point(p1.x, 0);

float p12 = get_distance(p1, p2, true);
float p13 = get_distance(p1, p3, true);
float p23 = get_distance(p2, p3, true);
float angle = acos((pow(p12, 2) + pow(p13, 2) - pow(p23, 2)) / (2 * p12 * p13)) * 180 / CV_PI;

if ((horizontal && p2.y < p1.y) || (!horizontal && p2.x > p1.x))
angle = 360 - angle;

return angle;
}

float get_angle(Point p1, Point p2, Point p3)
{
float p12 = get_distance(p1, p2, true);
float p13 = get_distance(p1, p3, true);
float p23 = get_distance(p2, p3, true);
return acos((pow(p12, 2) + pow(p13, 2) - pow(p23, 2)) / (2 * p12 * p13)) * 180 / CV_PI;
float angle = acos((pow(p12, 2) + pow(p13, 2) - pow(p23, 2)) / (2 * p12 * p13)) * 180 / CV_PI;
return angle;
}

float get_angle(float x0, float y0, float x1, float y1)
Expand Down
1 change: 1 addition & 0 deletions track_plus_core/track_plus/math_plus.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ float get_distance(Point pt0, Point pt1, bool accurate);
float get_distance(Point2f pt0, Point2f pt1, bool accurate);
float get_distance(Point3f pt0, Point3f pt1, bool accurate);
float map_val(float value, float left_min, float left_max, float right_min, float right_max);
float get_angle(Point pt0, Point pt1, bool horizontal);
float get_angle(Point pt0, Point pt1, Point pt2);
float get_angle(float x0, float y0, float x1, float y1);
float get_slope(Point pt0, Point pt1);
Expand Down
Loading

0 comments on commit 266d5e6

Please sign in to comment.