Example #1
0
        private MatrixMode getMatrixMode(MatrixType matrix)
        {
            switch (matrix)
            {
            case MatrixType.Color: return(OpenTK.Graphics.OpenGL.MatrixMode.Color);

            case MatrixType.ModelView: return(OpenTK.Graphics.OpenGL.MatrixMode.Modelview);

            case MatrixType.ModelView0Ext: return(OpenTK.Graphics.OpenGL.MatrixMode.Modelview0Ext);

            case MatrixType.Projection: return(OpenTK.Graphics.OpenGL.MatrixMode.Projection);

            case MatrixType.Texture: return(OpenTK.Graphics.OpenGL.MatrixMode.Texture);

            default: throw new NotSupportedException(matrix.ToString());
            }
        }
        public static void Read(out CvMat matrix, XmlElement element)
        {
            int           cols    = int.Parse(element.GetAttribute("cols"));
            int           rows    = int.Parse(element.GetAttribute("rows"));
            MatrixType    matType = (MatrixType)Enum.Parse(typeof(MatrixType), element.GetAttribute("type"));
            string        terms   = element.GetAttribute("values");
            List <double> values  = new List <double>();

            string[] words = terms.Split(',');
            foreach (string w in words)
            {
                values.Add(double.Parse(w.Trim()));
            }

            switch (matType)
            {
            case MatrixType.F32C1:
                break;

            case MatrixType.F64C1:
                break;

            default:
                throw new Exception("Read unsupported MatrixType " + matType.ToString());
            }
            matrix = new CvMat(rows, cols, matType);

            // Fill the matrix popping values off
            for (int x = 0; x < cols; ++x)
            {
                for (int y = 0; y < rows; ++y)
                {
                    matrix.Set2D(x, y, new CvScalar(values[0]));
                    values.RemoveAt(0);
                }
            }
        }