コード例 #1
0
ファイル: HpolarTests.cs プロジェクト: williammc/sentience
        public void GroundPlaneUpdate()
        {
            int    image_width  = 320;
            int    image_height = 240;
            Hpolar map          = new Hpolar();

            map.footline         = new ushort[image_width / map.SVS_HORIZONTAL_SAMPLING];
            map.footline_dist_mm = new ushort[image_width / map.SVS_HORIZONTAL_SAMPLING];

            // create a footline
            for (int x = image_width * 20 / 100; x < image_width * 40 / 100; x++)
            {
                map.footline[x / map.SVS_HORIZONTAL_SAMPLING] = (ushort)(image_height / 2);
            }
            for (int x = image_width * 60 / 100; x < image_width * 80 / 100; x++)
            {
                map.footline[x / map.SVS_HORIZONTAL_SAMPLING] = (ushort)(image_height / 2);
            }

            map.GroundPlaneUpdate();

            Assert.AreEqual(image_height / 2, map.footline[(image_width / 2) / map.SVS_HORIZONTAL_SAMPLING]);
            Assert.AreEqual(image_height / 2, map.footline[(image_width - 1) / map.SVS_HORIZONTAL_SAMPLING]);
            Assert.AreEqual(image_height / 2, map.footline[0]);
        }
コード例 #2
0
ファイル: HpolarTests.cs プロジェクト: williammc/sentience
        public void FootlineUpdate()
        {
            Hpolar map = new Hpolar();

            map.imgWidth             = 320;
            map.imgHeight            = 240;
            map.footline             = new ushort[map.imgWidth / map.SVS_HORIZONTAL_SAMPLING];
            map.footline_dist_mm     = new ushort[map.imgWidth / map.SVS_HORIZONTAL_SAMPLING];
            map.svs_ground_y_percent = 50;

            // create a footline
            for (int x = 0; x < (int)map.imgWidth / 2; x++)
            {
                map.footline[x / map.SVS_HORIZONTAL_SAMPLING] = (ushort)(map.imgHeight * 70 / 100);
            }
            for (int x = (int)map.imgWidth / 2; x < (int)map.imgWidth; x++)
            {
                map.footline[x / map.SVS_HORIZONTAL_SAMPLING] = (ushort)(map.imgHeight * 60 / 100);
            }

            map.FootlineUpdate(40);

            Console.WriteLine("dist0: " + map.footline_dist_mm[0].ToString());
            Console.WriteLine("dist1: " + map.footline_dist_mm[(map.imgWidth - 1) / map.SVS_HORIZONTAL_SAMPLING].ToString());

            Assert.IsTrue(map.footline_dist_mm[0] > 0);
            Assert.IsTrue(map.footline_dist_mm[(map.imgWidth - 1) / map.SVS_HORIZONTAL_SAMPLING] > 0);
            Assert.IsTrue(map.footline_dist_mm[(map.imgWidth - 1) / map.SVS_HORIZONTAL_SAMPLING] > map.footline_dist_mm[0]);
        }
コード例 #3
0
    private void SaveHpolarLookup()
    {
        int   cartesian_dimension_cells_width = 40;
        int   cartesian_dimension_cells_range = 40;
        float cartesian_cell_size_mm          = 100;

        int[] HpolarLookup      = null;
        float scale_down_factor = 10;

        Hpolar.CreateHpolarLookupSRV(
            cartesian_dimension_cells_width,
            cartesian_dimension_cells_range,
            cartesian_cell_size_mm,
            scale_down_factor,
            ref HpolarLookup);
        Hpolar.ShowHpolar(
            cartesian_dimension_cells_width,
            cartesian_dimension_cells_range,
            cartesian_cell_size_mm,
            HpolarLookup,
            1000,
            scale_down_factor,
            "Hpolar.jpg");
        Hpolar.SaveHpolar(HpolarLookup, "HpolarLookup.txt");
        Hpolar.SaveTrigLookup("TrigLookup.txt");
    }
コード例 #4
0
ファイル: HpolarTests.cs プロジェクト: williammc/sentience
        public void MapUpdate()
        {
            int max_disparity_percent = 40;
            int map_x = 60;
            int map_y = 60;

            byte[] cartesian_map  = new byte[map_x * map_y * 3];
            int    stereo_matches = 0;

            Hpolar map = new Hpolar();

            map.imgWidth         = 320;
            map.imgHeight        = 240;
            map.footline         = new ushort[(int)map.imgWidth / map.SVS_HORIZONTAL_SAMPLING];
            map.footline_dist_mm = new ushort[(int)map.imgWidth / map.SVS_HORIZONTAL_SAMPLING];

            // create a footline
            for (int x = 0; x < (int)map.imgWidth / map.SVS_HORIZONTAL_SAMPLING; x++)
            {
                map.footline[x] = (ushort)(map.imgHeight / 2);
            }

            map.FootlineUpdate(max_disparity_percent);

            /* create a map */
            drawing.drawLine(cartesian_map, map_x, map_y, (map_x / 2) - 2, (map_y / 2) - 6, (map_x / 2) - 2, (map_y / 2) - 29, 255, 0, 0, 0, false);
            drawing.drawLine(cartesian_map, map_x, map_y, (map_x / 2) + 2, (map_y / 2) - 6, (map_x / 2) + 2, (map_y / 2) - 29, 255, 0, 0, 0, false);

            drawing.drawLine(cartesian_map, map_x, map_y, (map_x / 2) - 2, (map_y / 2) - 6, (map_x / 2) - 10, (map_y / 2) - 6, 255, 0, 0, 0, false);
            drawing.drawLine(cartesian_map, map_x, map_y, (map_x / 2) + 2, (map_y / 2) - 6, (map_x / 2) + 10, (map_y / 2) - 6, 255, 0, 0, 0, false);

            Bitmap bmp = new Bitmap(map_x, map_y, System.Drawing.Imaging.PixelFormat.Format24bppRgb);

            BitmapArrayConversions.updatebitmap_unsafe(cartesian_map, bmp);
            bmp.Save("HpolarTests_MapUpdate0.bmp", System.Drawing.Imaging.ImageFormat.Bmp);

            /* convert map to stereo view */
            map.SimulateStereoView(
                max_disparity_percent,
                map_x, map_y,
                cartesian_map,
                ref stereo_matches);

            map.SaveDisparities(
                "HpolarTests_MapUpdate1.bmp",
                stereo_matches);

            map.MapUpdate(stereo_matches, 40);
            map.Show("HpolarTests_MapUpdate2.bmp");

            Assert.IsTrue(stereo_matches > 0);
        }
コード例 #5
0
ファイル: HpolarTests.cs プロジェクト: kasertim/sentience
        public void FootlineUpdate()
        {
            Hpolar map = new Hpolar();
            map.imgWidth = 320;
            map.imgHeight = 240;
            map.footline = new ushort[map.imgWidth / map.SVS_HORIZONTAL_SAMPLING];
            map.footline_dist_mm = new ushort[map.imgWidth / map.SVS_HORIZONTAL_SAMPLING];
            map.svs_ground_y_percent = 50;

            // create a footline
            for (int x = 0; x < (int)map.imgWidth/2; x++)
                map.footline[x / map.SVS_HORIZONTAL_SAMPLING] = (ushort)(map.imgHeight*70/100);
            for (int x = (int)map.imgWidth/2; x < (int)map.imgWidth; x++)
                map.footline[x / map.SVS_HORIZONTAL_SAMPLING] = (ushort)(map.imgHeight*60/100);

            map.FootlineUpdate(40);

            Console.WriteLine("dist0: " + map.footline_dist_mm[0].ToString());
            Console.WriteLine("dist1: " + map.footline_dist_mm[(map.imgWidth-1) / map.SVS_HORIZONTAL_SAMPLING].ToString());

            Assert.IsTrue(map.footline_dist_mm[0] > 0);
            Assert.IsTrue(map.footline_dist_mm[(map.imgWidth-1) / map.SVS_HORIZONTAL_SAMPLING] > 0);
            Assert.IsTrue(map.footline_dist_mm[(map.imgWidth-1) / map.SVS_HORIZONTAL_SAMPLING] > map.footline_dist_mm[0]);
        }
コード例 #6
0
ファイル: HpolarTests.cs プロジェクト: kasertim/sentience
        public void Recenter()
        {
            int max_disparity_percent = 40;
            int map_x = 60;
            int map_y = 60;
            byte[] cartesian_map = new byte[map_x * map_y * 3];
            int stereo_matches = 0;
            
            Hpolar map = new Hpolar();
            map.imgWidth = 320;
            map.imgHeight = 240;
            map.footline = new ushort[(int)map.imgWidth / map.SVS_HORIZONTAL_SAMPLING];
            map.footline_dist_mm = new ushort[(int)map.imgWidth / map.SVS_HORIZONTAL_SAMPLING];

            // create a footline
            for (int x = 0; x < (int)map.imgWidth / map.SVS_HORIZONTAL_SAMPLING; x++)
                map.footline[x] = (ushort)(map.imgHeight/2);

            map.FootlineUpdate(max_disparity_percent);
            
            /* create a map */
            drawing.drawLine(cartesian_map, map_x, map_y, (map_x/2) - 2, (map_y/2)-6, (map_x/2) - 2, (map_y/2)-29, 255,0,0,0,false);
            drawing.drawLine(cartesian_map, map_x, map_y, (map_x/2) + 2, (map_y/2)-6, (map_x/2) + 2, (map_y/2)-29, 255,0,0,0,false);

            drawing.drawLine(cartesian_map, map_x, map_y, (map_x/2) - 2, (map_y/2)-6, (map_x/2) - 10, (map_y/2)-6, 255,0,0,0,false);
            drawing.drawLine(cartesian_map, map_x, map_y, (map_x/2) + 2, (map_y/2)-6, (map_x/2) + 10, (map_y/2)-6, 255,0,0,0,false);
            
            Bitmap bmp = new Bitmap(map_x,map_y,System.Drawing.Imaging.PixelFormat.Format24bppRgb);
            BitmapArrayConversions.updatebitmap_unsafe(cartesian_map, bmp);
            bmp.Save("HpolarTests_Recenter0.bmp", System.Drawing.Imaging.ImageFormat.Bmp);

            /* convert map to stereo view */            
            map.SimulateStereoView(
                max_disparity_percent,
                map_x, map_y,
                cartesian_map,
                ref stereo_matches);

            map.SaveDisparities(
                "HpolarTests_Recenter1.bmp",
                stereo_matches);

            map.MapUpdate(stereo_matches, 40);
            map.Show("HpolarTests_Recenter2.bmp");

            Assert.IsTrue(stereo_matches > 0);            
        
            map.robot_y_mm -= 200;
            map.Recenter();
            map.Show("HpolarTests_Recenter3.bmp");

            map.robot_y_mm -= 200;
            map.Recenter();
            map.Show("HpolarTests_Recenter4.bmp");

            map.robot_y_mm += 200;
            map.Recenter();
            map.Show("HpolarTests_Recenter5.bmp");

            map.robot_y_mm += 200;
            map.Recenter();
            map.Show("HpolarTests_Recenter6.bmp");
        }
コード例 #7
0
ファイル: HpolarTests.cs プロジェクト: kasertim/sentience
        public void GroundPlaneUpdate()
        {
            int image_width = 320;
            int image_height = 240;
            Hpolar map = new Hpolar();
            map.footline = new ushort[image_width / map.SVS_HORIZONTAL_SAMPLING];
            map.footline_dist_mm = new ushort[image_width / map.SVS_HORIZONTAL_SAMPLING];

            // create a footline
            for (int x = image_width*20/100; x < image_width*40/100; x++)
                map.footline[x / map.SVS_HORIZONTAL_SAMPLING] = (ushort)(image_height/2);
            for (int x = image_width*60/100; x < image_width*80/100; x++)
                map.footline[x / map.SVS_HORIZONTAL_SAMPLING] = (ushort)(image_height/2);
            
            map.GroundPlaneUpdate();

            Assert.AreEqual(image_height/2, map.footline[(image_width/2) / map.SVS_HORIZONTAL_SAMPLING]);
            Assert.AreEqual(image_height/2, map.footline[(image_width-1) / map.SVS_HORIZONTAL_SAMPLING]);
            Assert.AreEqual(image_height/2, map.footline[0]);
        }