ソースを参照

Fixed crash when intersection == null in removeConvexityDefectsCausedByFingers().

Daniel Kauth 11 年 前
コミット
450ca1ce67
1 ファイル変更4 行追加3 行削除
  1. 4 3
      bbiwarg/Detectors/PalmDetection/PalmDetector.cs

+ 4 - 3
bbiwarg/Detectors/PalmDetection/PalmDetector.cs

@@ -223,7 +223,8 @@ namespace bbiwarg.Detectors.PalmDetection
                 {
                     Utility.LineSegment2D defectLine = new Utility.LineSegment2D(new Vector2D(d.StartPoint), new Vector2D(d.EndPoint));
                     Vector2D intersection = defectLine.Line.getIntersection(f.LineSegment.Line);
-                    if (intersection.isInBox(defectLine.P1, defectLine.P2) && intersection.isInBox(f.LineSegment.P1, f.LineSegment.P2))
+                    if (intersection != null &&
+                        intersection.isInBox(defectLine.P1, defectLine.P2) && intersection.isInBox(f.LineSegment.P1, f.LineSegment.P2))
                     {
                         fingerIntersectsStartEnd = true;
                         break;
@@ -264,7 +265,7 @@ namespace bbiwarg.Detectors.PalmDetection
             }
 
 
-            /*Console.WriteLine("no palm defect found (" + i + ")");
+            Console.WriteLine("no palm defect found (" + i + ")");
             foreach (MCvConvexityDefect d in convexityDefects)
             {
                 Vector2D depth = new Vector2D(d.DepthPoint);
@@ -278,7 +279,7 @@ namespace bbiwarg.Detectors.PalmDetection
                 float angle = (float)((depth - start).getAngleBetween(depth - end) * 180 / Math.PI);
 
                 Console.WriteLine("angle: " + angle + " quotient: " + lengthQuotient);
-            }*/
+            }
 
             ++i;
             return null;