Пример #1
0
        private IEnumerable <ClusterObjects> ConverterDados()
        {
            var dados = new List <ClusterObjects>();

            foreach (var usuario in _usuariosPesquisa)
            {
                var cluster = new ClusterObjects()
                {
                    Id                                 = usuario.Id,
                    Genero                             = usuario.Genero,
                    DataNascimento                     = usuario.DataNascimento,
                    IdIdiomaOrigem                     = usuario.IdiomaOrigem.Id,
                    IdIdiomaParaAprender               = usuario.IdiomaParaAprender.Id,
                    IdIdiomaFluenteSecundario          = usuario.IdiomaFluenteSecundario.Id,
                    IdAreaEstudoDominioGeral           = usuario.AreaEstudoDominioGeral.Id,
                    IdAreaEstudoDominioEspecifica      = usuario.AreaEstudoDominioEspecifica.Id,
                    IdAreaEstudoParaAprenderGeral      = usuario.AreaEstudoParaAprenderGeral.Id,
                    IdAreaEstudoParaAprenderEspecifico = usuario.AreaEstudoParaAprenderEspecifico.Id,
                    TipoIteracao                       = usuario.TipoIteracao
                };
            }

            dados.Add(InverterPreferenciasParaPesquisa());
            return(dados);
        }
        public static List <ClusterObjects> ExtractClusterFromIEPF(List <PolarPointRssiExtended> ptList, List <PolarPointRssiExtended> ptIEPF)
        {
            List <ClusterObjects> list_of_clusters = new List <ClusterObjects>();


            /// Maybe sort
            for (int i = 0; i < ptIEPF.Count - 2; i += 2)
            {
                ClusterObjects cluster = new ClusterObjects(ptList.GetRange(ptList.IndexOf(ptIEPF[i]), ptList.IndexOf(ptIEPF[i + 1]) - ptList.IndexOf(ptIEPF[i])));
                list_of_clusters.Add(cluster);
            }
            return(list_of_clusters);
        }
        /// <summary>
        /// Detect and return a list of Clusters point in pointList
        /// </summary>
        /// <param name="pointsList"></param>
        /// <param name="thresold"></param>
        /// <param name="mininum_amount_of_points"></param>
        /// <returns></returns>
        public static List <ClusterObjects> DetectClusterOfPoint(List <PolarPointRssiExtended> pointsList, double thresold, int mininum_amount_of_points = 5)
        {
            /// ABD Stand for Adaptative breakpoint Detection
            List <ClusterObjects> listOfClusters = new List <ClusterObjects>();
            ClusterObjects        cluster        = new ClusterObjects();
            int i;

            for (i = 1; i < pointsList.Count - 1; i++)
            {
                PolarPointRssiExtended point_n_minus_1 = pointsList[i - 1];
                PolarPointRssiExtended point_n_plus_1  = pointsList[i + 1];
                PolarPointRssiExtended point_n         = pointsList[i];



                //double dist_n_minus_1 = point_n_minus_1.Distance;
                //double delta_theta = Math.Abs(point_n_minus_1.Angle - point_n.Angle);
                //double lambda = point_n_plus_1.Angle - point_n_minus_1.Angle;

                double ABD_Thresold           = thresold; // dist_n_minus_1 * (Math.Sin(delta_theta) / Math.Sin(lambda - delta_theta));
                double distance_between_point = Toolbox.Distance(point_n, point_n_minus_1);
                if (distance_between_point < ABD_Thresold)
                {
                    cluster.points.Add(point_n);
                }
                else
                {
                    if (Toolbox.Distance(point_n_plus_1, point_n_minus_1) <= 2 * thresold)
                    {
                        //cluster.points.Add(point_n);
                    }
                    else
                    {
                        if (cluster.points.Count() > mininum_amount_of_points)
                        {
                            listOfClusters.Add(cluster);
                        }
                        cluster = new ClusterObjects();
                    }
                }
            }

            if (cluster.points.Count() > mininum_amount_of_points)
            {
                listOfClusters.Add(cluster);
            }

            return(listOfClusters);
        }
        public Segment DetectLine(ClusterObjects blob, double thresold, double alignNbr, int moy = 5)
        {
            List <PolarPointRssi> pointList = blob.points.Select(x => x.Pt).ToList();

            List <double> derivate1 = new List <double>();
            List <double> derivate2 = new List <double>();
            Segment       line      = new Segment();

            int i;

            for (i = 0; i < pointList.Count - 1; i++)
            {
                derivate1.Add(Math.Abs(pointList[i].Distance - pointList[i + 1].Distance));
            }
            for (i = 0; i < derivate1.Count - 1; i++)
            {
                derivate2.Add(Math.Abs(derivate1[i] - derivate1[i + 1]));
            }

            uint nbrOfCurrentAlign = 0;

            for (i = 0; i < derivate2.Count - 1; i++)
            {
                if (derivate2[i] >= 0 && derivate2[i] <= thresold)
                {
                    nbrOfCurrentAlign++;
                }
                else if (nbrOfCurrentAlign > 0)
                {
                    if (nbrOfCurrentAlign >= alignNbr)
                    {
                        return(CreateLineSegment(pointList, moy));
                    }
                    nbrOfCurrentAlign = 0;
                }
            }

            if (nbrOfCurrentAlign >= alignNbr)
            {
                return(CreateLineSegment(pointList, moy));
            }

            return(line);
        }
        public Cup DetectCup(ClusterObjects cluster)
        {
            /// TEMPORARY NEED TO EDIT: ONLY FOR DEBUG PURPOSE

            PolarPointRssi begin_point = cluster.points[0].Pt;
            PolarPointRssi end_point   = cluster.points[cluster.points.Count - 1].Pt;

            double lenght_of_cluster = Toolbox.Distance(begin_point, end_point);

            if (lenght_of_cluster >= 0.040 && lenght_of_cluster <= 0.08)
            {
                List <PointD> pointDs = cluster.points.Select(x => Toolbox.ConvertPolarToPointD(x.Pt)).ToList();

                double median = 0.80;

                double b = cluster.points[(int)(cluster.points.Count() * median)].Pt.Rssi;
                double e = cluster.points[(int)(cluster.points.Count() * (1 - median))].Pt.Rssi;

                double moyenne = (b + e) / 2;
                Color  color   = Color.White;
                if (moyenne >= 9000 && moyenne <= 12000)
                {
                    color = Color.Green;
                }
                else if (moyenne >= 12000 && moyenne <= 14000)
                {
                    color = Color.Red;
                }
                else
                {
                    return(new Cup());
                }
                //Console.WriteLine(moyenne);
                PointD center_point = GetMediumPoint(pointDs);
                return(new Cup(center_point, 0.065, color));
            }
            else
            {
                return(null);
            }
        }