Exemplo n.º 1
0
        private void ExtractCalibLinesFromRaw(XmlNode extractorNode)
        {
            // TODO: Move Extractor initialization to other method
            // <PointsExtractor type="CalibShape">
            //   <Parameters>....

            CalibrationModule.CalibrationPointsFinder pointsExtractor;
            CalibrationModule.ICalibrationLinesExtractor linesExtractor;
            if(extractorNode == null)
            {
                pointsExtractor = new CalibrationModule.ShapesGridCPFinder();
                linesExtractor = pointsExtractor.LinesExtractor;
                pointsExtractor.InitParameters();
                pointsExtractor.UpdateParameters();
                pointsExtractor.PrimaryShapeChecker = new CalibrationModule.RedNeighbourhoodChecker();
            }
            else
            {
                // Get type of extractor
                string extractorType = extractorNode.Attributes["type"].Value;
                if(extractorType == "CalibShape") { }
                pointsExtractor = new CalibrationModule.ShapesGridCPFinder();
                linesExtractor = pointsExtractor.LinesExtractor;
                pointsExtractor.InitParameters();

                XmlNode paramsNode = extractorNode.FirstChildWithName("Parameters");
                if(paramsNode != null)
                {
                    AlgorithmParameter.ReadParametersFromXml(pointsExtractor.Parameters, paramsNode);
                }

                pointsExtractor.UpdateParameters();
            }

            for(int i = 0; i < _calibImagesIndices.Count; ++i)
            {
                ImageIndex idx = _calibImagesIndices[i];
                ColorImage image = _rawCalibImages[idx.ListIndex];
                pointsExtractor.Image = image;
                pointsExtractor.FindCalibrationPoints();
                linesExtractor.ExtractLines();
            }
        }
Exemplo n.º 2
0
        public static DisparityMap CreateFromNode(XmlNode mapNode)
        {
            int rows = int.Parse(mapNode.Attributes["rows"].Value);
            int cols = int.Parse(mapNode.Attributes["cols"].Value);

            DisparityMap map = new DisparityMap(rows, cols);
            XmlNode rowNode = mapNode.FirstChildWithName("Row");
            for(int r = 0; r < rows; ++r)
            {
                XmlNode dispNode = rowNode.FirstChildWithName("Disparity");
                for(int c = 0; c < cols; ++c)
                {
                    Disparity disp = Disparity.CreateFromNode(dispNode);
                    map.Disparities[r, c] = disp;
                    dispNode = dispNode.NextSibling;
                }
                rowNode = rowNode.NextSibling;
            }

            return map;
        }