|
@@ -30,7 +30,7 @@ namespace bbiwarg.Detectors.Touch
|
|
foreach (Finger finger in fingers) {
|
|
foreach (Finger finger in fingers) {
|
|
Vector2D tipPoint = finger.Tip;
|
|
Vector2D tipPoint = finger.Tip;
|
|
|
|
|
|
- float floodValue = getFloodValue((int)tipPoint.X, (int)tipPoint.Y);
|
|
|
|
|
|
+ float floodValue = getFloodValue(tipPoint);
|
|
if (floodValue > floodValueThreshold)
|
|
if (floodValue > floodValueThreshold)
|
|
{
|
|
{
|
|
//correct touchEvent position
|
|
//correct touchEvent position
|
|
@@ -40,7 +40,7 @@ namespace bbiwarg.Detectors.Touch
|
|
float y = HelperFunctions.thresholdRange<float>(0, depthImage.getHeight() - 1, tipPoint.Y + directionFactor * direction.Y);
|
|
float y = HelperFunctions.thresholdRange<float>(0, depthImage.getHeight() - 1, tipPoint.Y + directionFactor * direction.Y);
|
|
Vector2D tep = new Vector2D(x,y);
|
|
Vector2D tep = new Vector2D(x,y);
|
|
|
|
|
|
- touchImage.setTouchAt(tep.IntX, tep.IntY, TouchImageState.touchDetected);
|
|
|
|
|
|
+ touchImage.setStateAt(tep, TouchImageState.touchDetected);
|
|
TouchEvent touchEvent = new TouchEvent(tep, floodValue, finger);
|
|
TouchEvent touchEvent = new TouchEvent(tep, floodValue, finger);
|
|
touchEvents.Add(touchEvent);
|
|
touchEvents.Add(touchEvent);
|
|
}
|
|
}
|
|
@@ -51,26 +51,26 @@ namespace bbiwarg.Detectors.Touch
|
|
return touchEvents;
|
|
return touchEvents;
|
|
}
|
|
}
|
|
|
|
|
|
- private float getFloodValue(int touchX, int touchY) {
|
|
|
|
|
|
+ private float getFloodValue(Point touchPoint) {
|
|
int searchSize = 15;
|
|
int searchSize = 15;
|
|
int maxDepthDifference = 20;
|
|
int maxDepthDifference = 20;
|
|
Int16 fingerDiameter = 5;
|
|
Int16 fingerDiameter = 5;
|
|
- Int16 depthAtTouch = (Int16) (depthImage.getDepthAt(touchX, touchY) + fingerDiameter);
|
|
|
|
|
|
+ Int16 depthAtTouch = (Int16) (depthImage.getDepthAt(touchPoint) + fingerDiameter);
|
|
|
|
|
|
- int minX = Math.Max(touchX - searchSize, 0);
|
|
|
|
- int maxX = Math.Min(touchX + searchSize, depthImage.getWidth());
|
|
|
|
- int minY = Math.Max(touchY - searchSize, 0);
|
|
|
|
- int maxY = Math.Min(touchY + searchSize, depthImage.getHeight());
|
|
|
|
|
|
+ int minX = Math.Max(touchPoint.X - searchSize, 0);
|
|
|
|
+ int maxX = Math.Min(touchPoint.X + searchSize, depthImage.getWidth());
|
|
|
|
+ int minY = Math.Max(touchPoint.Y - searchSize, 0);
|
|
|
|
+ int maxY = Math.Min(touchPoint.Y + searchSize, depthImage.getHeight());
|
|
|
|
|
|
int matchedPixels = 0;
|
|
int matchedPixels = 0;
|
|
int countedPixels = 0;
|
|
int countedPixels = 0;
|
|
for (int x = minX; x < maxX; x++) {
|
|
for (int x = minX; x < maxX; x++) {
|
|
for (int y = minY; y < maxY; y++) {
|
|
for (int y = minY; y < maxY; y++) {
|
|
Int16 depth = depthImage.getDepthAt(x,y);
|
|
Int16 depth = depthImage.getDepthAt(x,y);
|
|
- touchImage.setTouchAt(x, y, TouchImageState.touchArea);
|
|
|
|
|
|
+ touchImage.setStateAt(x, y, TouchImageState.touchArea);
|
|
if (Math.Abs(depthAtTouch - depth) < maxDepthDifference) {
|
|
if (Math.Abs(depthAtTouch - depth) < maxDepthDifference) {
|
|
matchedPixels++;
|
|
matchedPixels++;
|
|
- touchImage.setTouchAt(x, y, TouchImageState.touchAreaMatched);
|
|
|
|
|
|
+ touchImage.setStateAt(x, y, TouchImageState.touchAreaMatched);
|
|
}
|
|
}
|
|
countedPixels++;
|
|
countedPixels++;
|
|
}
|
|
}
|
|
@@ -80,7 +80,7 @@ namespace bbiwarg.Detectors.Touch
|
|
|
|
|
|
//status bar (% of matched pixels) -> green
|
|
//status bar (% of matched pixels) -> green
|
|
for (int x = minX; x < minX + (maxX-minX)*rel; x++) {
|
|
for (int x = minX; x < minX + (maxX-minX)*rel; x++) {
|
|
- touchImage.setTouchAt(x, maxY - 1, TouchImageState.touchAreaStatusBar);
|
|
|
|
|
|
+ touchImage.setStateAt(x, maxY - 1, TouchImageState.touchAreaStatusBar);
|
|
}
|
|
}
|
|
|
|
|
|
return rel;
|
|
return rel;
|