示例#1
0
        public virtual void InitParameters()
        {
            // Add all available cost computers
            ParametrizedObjectParameter costParam =
                new ParametrizedObjectParameter("Matching Cost Computer", "COST");

            costParam.Parameterizables = new List<IParameterizable>();
            var cens = new CensusCostComputer();
            cens.InitParameters();
            costParam.Parameterizables.Add(cens);
            var rank = new RankCostComputer();
            rank.InitParameters();
            costParam.Parameterizables.Add(rank);

            _params.Add(costParam);
        }
示例#2
0
        public void Test_EpiScan_Ideal()
        {
            EpilineScanAggregator agg = new EpilineScanAggregator();
            RankCostComputer cost = new RankCostComputer();
            MatchConfidenceComputer conf = new MatchConfidenceComputer();

            cost.ImageBase = new GrayScaleImage() { ImageMatrix = _imageLeft };
            cost.ImageMatched = new GrayScaleImage() { ImageMatrix = _imageRight };
            cost.RankMaskHeight = 3;
            cost.RankMaskWidth = 3;
            cost.CorrMaskWidth = 3;
            cost.CorrMaskHeight = 3;
            //cost.MaskHeight = 3;
            //cost.MaskWidth = 3;
            agg.CostComp = cost;

            conf.CostComp = cost;
            conf.UsedConfidenceMethod = ConfidenceMethod.TwoAgainstTwo;

            DisparityMap disp = new DisparityMap(_imageLeft.RowCount, _imageLeft.ColumnCount);
            agg.DisparityMap = disp;

            agg.ImageBase = cost.ImageBase;
            agg.ImageMatched = cost.ImageMatched;
            agg.IsLeftImageBase = true;
            agg.Fundamental = _F;

            cost.Init();
            agg.ComputeMatchingCosts();
        }
示例#3
0
        public void Test_Rank()
        {
            RankCostComputer costCpu = new RankCostComputer();
            costCpu.RankMaskHeight = 1;
            costCpu.RankMaskWidth = 1;
            costCpu.CorrMaskHeight = 1;
            costCpu.CorrMaskWidth = 1;
            costCpu.ImageBase = new GrayScaleImage() { ImageMatrix = _imageLeft };
            costCpu.ImageMatched = new GrayScaleImage() { ImageMatrix = _imageRight };

            costCpu.Init();

            // Expected rank in points (base):
            // [0,0] : 0, [0,1] : 3, [1,1] : 6, [2,2] : 3
            Assert.IsTrue(costCpu.RankBase[0, 0] == 0, "Wrong rank transform in point [0,0]. Expected: 0; Actual: " + costCpu.RankBase[0, 0]);
            Assert.IsTrue(costCpu.RankBase[1, 0] == 3, "Wrong rank transform in point [0,1]. Expected: 3; Actual: " + costCpu.RankBase[0, 1]);
            Assert.IsTrue(costCpu.RankBase[1, 1] == 6, "Wrong rank transform in point [1,1]. Expected: 6; Actual: " + costCpu.RankBase[1, 1]);
            Assert.IsTrue(costCpu.RankBase[2, 2] == 3, "Wrong rank transform in point [2,2]. Expected: 3; Actual: " + costCpu.RankBase[2, 2]);

            // Expected matching cost in points (base, matched):
            // ([2,2], [2,3]) : 36/9
            // ([2,2], [2,4]) : 0
            // ([2,2], [2,2]) : 36/9
            double cost = costCpu.GetCost(new IntVector2(2, 2), new IntVector2(3, 2));
            Assert.IsTrue(Math.Abs(cost - 36.0 / 9.0) < 1e-6, "Wrong rank cost in points ([2,2],[2,3]). Expected: 4; Actual: " + cost);
            cost = costCpu.GetCost(new IntVector2(2, 2), new IntVector2(4, 2));
            Assert.IsTrue(Math.Abs(cost - 0.0) < 1e-6, "Wrong rank cost in points ([2,2],[2,4]). Expected: 0; Actual: " + cost);
            cost = costCpu.GetCost(new IntVector2(2, 2), new IntVector2(2, 2));
            Assert.IsTrue(Math.Abs(cost - 36.0 / 9.0) < 1e-6, "Wrong rank cost in points ([2,2],[2,2]). Expected: 4; Actual: " + cost);
        }