Exemple #1
0
        public void merge_detecions(Detection new_det)
        {
            color[0] += new_det.color[0];
            color[1] += new_det.color[1];
            color[2] += new_det.color[2];
            update_color_id();
            seen_times++;
            area_m = (area_m * (seen_times - 1) + new_det.area_m) / seen_times;

            double latitude  = (gps_location.Latitude * (seen_times - 1) + new_det.gps_location.Latitude) / seen_times;
            double longitude = (gps_location.Longitude * (seen_times - 1) + new_det.gps_location.Longitude) / seen_times;

            gps_location = new GeodesicLocation(latitude, longitude);
        }
        public List <Detection> detect(Image <Bgr, byte> frame)
        {
            VectorOfVectorOfPoint[] contours = extract_contours(frame);

            List <Detection> detections = new List <Detection>();

            for (int c = 0; c < 3; c++)
            {
                for (int i = 0; i < contours[c].Size; i++)
                {
                    double area = CvInvoke.ContourArea(contours[c][i]);

                    if (area > GlobalValues.MIN_AREA)
                    {
                        Rectangle bb = CvInvoke.BoundingRectangle(contours[c][i]);

                        int           shape;
                        VectorOfPoint points;

                        get_contour_shape(contours[c][i], frame, bb, out shape, out points);

                        if (shape != -1)
                        {
                            Point mid;
                            if (shape != GlobalValues.TRIANGLE)
                            {
                                mid = new Point((int)(bb.X + bb.Width / 2), (int)(bb.Y + bb.Height / 2));
                            }
                            else
                            {
                                mid = new Point((int)((points[0].X + points[1].X + points[2].X) / 3), (int)((points[0].Y + points[1].Y + points[2].Y) / 3));
                            }
                            int[] detection_color = { 0, 0, 0 };
                            detection_color[c] += 1;

                            Detection detection = new Detection(shape, bb, area, detection_color, points, mid);
                            detections.Add(detection);
                        }
                    }
                }
            }
            return(detections);
        }
Exemple #3
0
 public bool check_detection(Detection new_det)
 {
     return((shape == new_det.shape) && (Math.Abs(gps_location.Latitude - new_det.gps_location.Latitude) < GlobalValues.MAX_LONG_LAT_DIFF) &&
            (Math.Abs(gps_location.Longitude - new_det.gps_location.Longitude) < GlobalValues.MAX_LONG_LAT_DIFF) &&
            Math.Abs(area_m - new_det.area_m) < GlobalValues.MAX_AREA_DIFF);
 }