Beispiel #1
0
        public Mat Convert(
            [InputPin(PropertyMode = PropertyMode.Never)] Mat image,
            [InputPin(PropertyMode = PropertyMode.Default)] MatDepth depth,
            [InputPin(PropertyMode = PropertyMode.Default)] int channels)
        {
            MatType type   = MatType.MakeType((int)depth, channels);
            var     result = new Mat(image.Size(), type);

            image.ConvertTo(result, type);
            return(result);
        }
Beispiel #2
0
        public Mat Convert(
            [InputPin(PropertyMode = PropertyMode.Allow)] Array array,
            [InputPin(PropertyMode = PropertyMode.Default)] MatDepth depth
            )
        {
            var arrayType = array.GetType();

            var dimensions = arrayType.GetArrayRank();

            if (dimensions == 1)
            {
                var type = MatType.MakeType((int)depth, 1);
                var m    = new Mat(1, array.Length, type, array.Cast <float>().ToArray());
                return(m);
            }

            throw new NotImplementedException(string.Format("Cannot convert '{0}' to 'Mat'", arrayType));
        }
Beispiel #3
0
 public static int makeType(int channels, MatDepth depth) => (((channels - 1) & CV_CN_MASK) << CV_CN_SHIFT) | (int)depth;