Exemple #1
0
        public static List <Vector3> GetVertices(AugmentableObjectSample curr)
        {
            // compute the current candidate's bounding points
            List <Vector3> BoundingBoxPoints = new List <Vector3>();
            int            x = 1, y = 1, z = 1;

            for (int c = 0; c < 2; c++)
            {
                x = -x;
                for (int j = 0; j < 2; j++)
                {
                    y = -y;
                    for (int k = 0; k < 2; k++)
                    {
                        z = -z;

                        BoundingBoxPoints.Add(new Vector3(curr.location.X + x * curr.sizeMeters.X / 2,
                                                          curr.location.Y + y * curr.sizeMeters.Y / 2,
                                                          curr.location.Z + z * curr.sizeMeters.Z / 2));
                    }
                }
            }

            return(BoundingBoxPoints);
        }
        // only returns the aug_object_samples and not the rbnn min vals!
        public static List<AugmentableObjectSample> AugmentableSampleResultFormat(string augmentable_format_content)
        {
            // id   position scale  shape airplane_position distance_from_transitive_floor
            // int  x,y,z    x,y,z  BIRD  x,y,z             double
            // space separated
            List<AugmentableObjectSample> samples = new List<AugmentableObjectSample>();
            string[] lines = augmentable_format_content.Split("\n");
            foreach (var line in lines)
            {
                if (line.Length < 5)
                    continue;

                string[] parts = line.Split(" ");

                int id = int.Parse(parts[0]);
                string[] pos_string = parts[1].Split(",");
                Vector3 pos = new Vector3(float.Parse(pos_string[0]), float.Parse(pos_string[1]), float.Parse(pos_string[2]));

                string[] scale_string = parts[2].Split(",");
                Vector3 scale = new Vector3(float.Parse(scale_string[0]), float.Parse(scale_string[1]), float.Parse(scale_string[2]));

                string name = parts[3];



                AugmentableObjectSample samp = new AugmentableObjectSample(name, scale, pos, Numpy.MaxDimension(scale));
                samples.Add(samp);
            }
            return samples;
        }
Exemple #3
0
        public void UnfilteredSampleObjects(int ObjectsToAdd, Vector3 minWorldBound, Vector3 maxWorldBound)
        {
            this.minWorldBound = minWorldBound;
            this.maxWorldBound = maxWorldBound;

            for (int i = 0; i < 20 * ObjectsToAdd; i++)
            {
                AugmentableObjectSample curr = SampleObject();
                samples.Add(curr);
            }
        }
        public void ExecuteTest(string[] args)
        {
            string dmr = String.Join("\n", GenerateDmrGrid());

            // write dmr
            File.WriteAllText(Path.Combine(workdir, dmrfilename), dmr);
            new CoreProcedure(Path.Combine(workdir, dmrfilename)).Dmr2Pcd();

            for (int i = 0; i < 5000; i++)
            {
                Vector3 tmp = Vector3.Multiply((float)dimension, common.Numpy.RandomVector());
                tmp = Vector3.Subtract(tmp,
                                       new Vector3(0, 0, (float)dimension / 2.0f));
                AugmentableObjectSample samp = new AugmentableObjectSample("BIRD", new Vector3(0.1f, 0.1f, 0.1f),
                                                                           tmp,
                                                                           5);
                samples.Add(samp);
                if (samp.location.Z > 0.0f)
                {
                    solutions.Add(1);
                }
                else
                {
                    solutions.Add(0);
                }
            }

            // write augs
            string serialized_augs = external_tools.common.PointCloudiaFormatSerializer.PointBoundingBoxAndMaxDimFormat(samples);

            File.WriteAllText(Path.Combine(workdir, augsfilename), serialized_augs);

            // write sols
            File.WriteAllText(Path.Combine(workdir, "sols"), String.Join("\n", solutions));

            List <int> predictions = UndergroundFilter.Execute(samples, Path.Combine(workdir, dmrfilename));

            int[] preds = new int[samples.Count];
            foreach (int p in predictions)
            {
                preds[p] = 1;
            }

            for (int i = 0; i < predictions.Count; i++)
            {
                if (preds[i] != solutions[i])
                {
                    Console.WriteLine(preds[i] + " " + solutions[i]);
                }
            }
            Console.ReadLine();
        }
        private int CreateNewPointsAndIndexThemBackIntoOriginalSamples(int nextIndex, List <Vector3> ToAdd, Dictionary <int, int> LidarPointIndexToSampleIndex)
        {
            for (int i = 0; i < samples.Count; i++)
            {
                AugmentableObjectSample curr     = samples[i];
                Vector3        location          = samples[i].location;
                List <Vector3> BoundingBoxPoints = BoundingBox.GetVertices(curr);

                // add the bounding points both to be added and to keep track of what their object is, which indices belong to which object
                for (int j = 0; j < BoundingBoxPoints.Count; j++)
                {
                    ToAdd.Add(BoundingBoxPoints[j]);
                    LidarPointIndexToSampleIndex.Add(nextIndex++, i);
                }
            }

            return(nextIndex);
        }