protected void Clustering(List <Line> lines, Image <Bgr, byte> frame) { List <Point> intersections = new List <Point>(); foreach (Line inLine in lines) { foreach (Line cmpLine in lines) { if (inLine == cmpLine) { continue; } Point intersection = inLine.Intersect(cmpLine); if (intersection != null && !intersections.Contains(intersection)) { intersections.Add(intersection); } } } if (intersections.Count > 0) { ClusterSet clusters = DBSCAN.DBSCAN.CalculateClusters( intersections.Select(p => new PointContainer(p)).ToList(), 20, (int)Math.Round(0.1 * intersections.Count, 0) ); if (clusters.IsValid()) { if (Filtering.Add(clusters.GetBestCluster().GetMean())) { if (Confidence < 100) { Confidence = Confidence >= 100 ? 100 : Confidence + 5f; } } else { Confidence = 10; } } Vector vector = BoxContainer.Hit(Filtering.GetMean()); try { ((RenderPoint)Filtering.GetMean()).Render(frame); } catch (Exception e) { } LatestResponse = !vector.IsNull() ? new Response(true, BoxContainer.Hit(Filtering.GetMean()), Confidence) : new Response(false, null); CvInvoke.Imshow("frame", frame); CvInvoke.WaitKey(1); } }