|
@@ -19,12 +19,14 @@ namespace bbiwarg.Detectors.Finger
|
|
|
private PointF pointOnLine;
|
|
|
private PointF start;
|
|
|
private PointF end;
|
|
|
+ private bool startEndUpToDate;
|
|
|
|
|
|
public Finger(FingerPoint fingerPoint)
|
|
|
{
|
|
|
fingerPoints = new List<FingerPoint>();
|
|
|
nearest = fingerPoint;
|
|
|
farthest = fingerPoint;
|
|
|
+ startEndUpToDate = false;
|
|
|
addFingerPoint(fingerPoint);
|
|
|
}
|
|
|
|
|
@@ -38,11 +40,15 @@ namespace bbiwarg.Detectors.Finger
|
|
|
return farthest;
|
|
|
}
|
|
|
|
|
|
- public PointF getStart() {
|
|
|
+ public PointF getStart()
|
|
|
+ {
|
|
|
+ if (!startEndUpToDate) updateStartEnd();
|
|
|
return start;
|
|
|
}
|
|
|
|
|
|
- public PointF getEnd() {
|
|
|
+ public PointF getEnd()
|
|
|
+ {
|
|
|
+ if (!startEndUpToDate) updateStartEnd();
|
|
|
return end;
|
|
|
}
|
|
|
|
|
@@ -56,19 +62,7 @@ namespace bbiwarg.Detectors.Finger
|
|
|
//update farthest
|
|
|
if (fingerPoint.getDepth() > farthest.getDepth()) farthest = fingerPoint;
|
|
|
|
|
|
- //update direction+pointonline
|
|
|
- PointF[] pointArray = new PointF[fingerPoints.Count];
|
|
|
- int i = 0;
|
|
|
- foreach (FingerPoint fp in fingerPoints)
|
|
|
- {
|
|
|
- pointArray[i] = new PointF(fp.getX(), fp.getY());
|
|
|
- ++i;
|
|
|
- }
|
|
|
- PointCollection.Line2DFitting(pointArray, Emgu.CV.CvEnum.DIST_TYPE.CV_DIST_L2, out direction, out pointOnLine);
|
|
|
-
|
|
|
- //update start+end
|
|
|
- start = projectToLine(new PointF(farthest.getX(), farthest.getY()));
|
|
|
- end = projectToLine(new PointF(nearest.getX(), nearest.getY()));
|
|
|
+ startEndUpToDate = false;
|
|
|
}
|
|
|
|
|
|
public float getMinDistance(FingerPoint fingerPoint)
|
|
@@ -106,5 +100,23 @@ namespace bbiwarg.Detectors.Finger
|
|
|
|
|
|
return new PointF(ox + q * dx, oy + q * dy);
|
|
|
}
|
|
|
+
|
|
|
+ private void updateStartEnd() {
|
|
|
+ //update direction+pointonline
|
|
|
+ PointF[] pointArray = new PointF[fingerPoints.Count];
|
|
|
+ int i = 0;
|
|
|
+ foreach (FingerPoint fp in fingerPoints)
|
|
|
+ {
|
|
|
+ pointArray[i] = new PointF(fp.getX(), fp.getY());
|
|
|
+ ++i;
|
|
|
+ }
|
|
|
+ PointCollection.Line2DFitting(pointArray, Emgu.CV.CvEnum.DIST_TYPE.CV_DIST_L2, out direction, out pointOnLine);
|
|
|
+
|
|
|
+ //update start+end
|
|
|
+ start = projectToLine(new PointF(farthest.getX(), farthest.getY()));
|
|
|
+ end = projectToLine(new PointF(nearest.getX(), nearest.getY()));
|
|
|
+
|
|
|
+ startEndUpToDate = true;
|
|
|
+ }
|
|
|
}
|
|
|
}
|