Esempio n. 1
0
        public void SetImage(IImage image)
        {
            #region display the size of the image
            Size size = image.Size;
            widthTextbox.Text  = size.Width.ToString();
            heightTextBox.Text = size.Height.ToString();
            #endregion

            #region display the color type of the image
            Type     colorType       = Reflection.ReflectIImage.GetTypeOfColor(image);
            Object[] colorAttributes = colorType.GetCustomAttributes(typeof(ColorInfoAttribute), true);
            if (colorAttributes.Length > 0)
            {
                ColorInfoAttribute info = (ColorInfoAttribute)colorAttributes[0];
                typeOfColorTexbox.Text = info.ConversionCodename;
            }
            else
            {
                typeOfColorTexbox.Text = Properties.StringTable.Unknown;
            }

            Type colorDepth = Reflection.ReflectIImage.GetTypeOfDepth(image);
            typeOfDepthTextBox.Text = colorDepth.Name;
            #endregion

            UpdateHistogram();
            UpdateZoomScale();
        }
Esempio n. 2
0
        private static CvEnum.COLOR_CONVERSION GetCode(Type srcType, Type destType)
        {
            ColorInfoAttribute srcInfo  = (ColorInfoAttribute)srcType.GetCustomAttributes(typeof(ColorInfoAttribute), true)[0];
            ColorInfoAttribute destInfo = (ColorInfoAttribute)destType.GetCustomAttributes(typeof(ColorInfoAttribute), true)[0];

            String key = String.Format("CV_{0}2{1}", srcInfo.ConversionCodename, destInfo.ConversionCodename);

            return((CvEnum.COLOR_CONVERSION)Enum.Parse(typeof(CvEnum.COLOR_CONVERSION), key, true));
        }
Esempio n. 3
0
        private static String GetConversionCodenameFromType(Type colorType)
        {
#if NETFX_CORE || NETSTANDARD1_4
            if (colorType == typeof(Bgr))
            {
                return("BGR");
            }
            else if (colorType == typeof(Bgra))
            {
                return("BGRA");
            }
            else if (colorType == typeof(Gray))
            {
                return("GRAY");
            }
            else if (colorType == typeof(Hls))
            {
                return("HLS");
            }
            else if (colorType == typeof(Hsv))
            {
                return("HSV");
            }
            else if (colorType == typeof(Lab))
            {
                return("Lab");
            }
            else if (colorType == typeof(Luv))
            {
                return("Luv");
            }
            else if (colorType == typeof(Rgb))
            {
                return("RGB");
            }
            else if (colorType == typeof(Rgba))
            {
                return("RGBA");
            }
            else if (colorType == typeof(Xyz))
            {
                return("XYZ");
            }
            else if (colorType == typeof(Ycc))
            {
                return("YCrCb");
            }
            else
            {
                throw new Exception(String.Format("Unable to get Color Conversion Codename for type {0}", colorType.ToString()));
            }
#else
            ColorInfoAttribute info = (ColorInfoAttribute)colorType.GetCustomAttributes(typeof(ColorInfoAttribute), true)[0];
            return(info.ConversionCodename);
#endif
        }
Esempio n. 4
0
        public void SetImage(IImage image)
        {
            #region display the size of the image
            Size size = image.Size;
            widthTextbox.Text  = size.Width.ToString();
            heightTextBox.Text = size.Height.ToString();
            #endregion

            #region display the color type of the image
            Type     colorType       = Reflection.ReflectIImage.GetTypeOfColor(image);
            Object[] colorAttributes = colorType.GetCustomAttributes(typeof(ColorInfoAttribute), true);
            if (colorAttributes.Length > 0)
            {
                ColorInfoAttribute info = (ColorInfoAttribute)colorAttributes[0];
                typeOfColorTexbox.Text = info.ConversionCodename;
            }
            else
            {
                typeOfColorTexbox.Text = Properties.StringTable.Unknown;
            }

            Type colorDepth = Reflection.ReflectIImage.GetTypeOfDepth(image);
            typeOfDepthTextBox.Text = colorDepth.Name;
            #endregion

            #region check if image is a subclass of CvArr type
            Type imageType = image.GetType();
            isCvArray = true;
            Type cvArrayType = typeof(CvArray <>);
            while (cvArrayType != imageType)
            {
                if (imageType.IsGenericType && imageType.GetGenericTypeDefinition() == cvArrayType)
                {
                    break;
                }
                imageType = imageType.BaseType;
                if (imageType == null)
                {
                    isCvArray = false;
                    break;
                }
            }
            #endregion

            UpdateHistogram();
            UpdateZoomScale();
        }
Esempio n. 5
0
        public void SetImage(IInputArray image)
        {
            #region display the size of the image
            if (image != null)
            {
                using (InputArray iaImage = image.GetInputArray())
                {
                    Size size = iaImage.GetSize();
                    widthTextbox.Text  = size.Width.ToString();
                    heightTextBox.Text = size.Height.ToString();
                }
            }
            else
            {
                widthTextbox.Text  = String.Empty;
                heightTextBox.Text = string.Empty;
            }
            #endregion

            #region display the color type of the image
            if (image != null)
            {
                Type     colorType       = Reflection.ReflectIImage.GetTypeOfColor(image);
                Object[] colorAttributes = colorType.GetCustomAttributes(typeof(ColorInfoAttribute), true);
                if (colorAttributes.Length > 0)
                {
                    ColorInfoAttribute info = (ColorInfoAttribute)colorAttributes[0];
                    typeOfColorTexbox.Text = info.ConversionCodename;
                }
                else
                {
                    typeOfColorTexbox.Text = Properties.StringTable.Unknown;
                }

                Type colorDepth = Reflection.ReflectIImage.GetTypeOfDepth(image);
                typeOfDepthTextBox.Text = colorDepth.Name;
            }
            else
            {
                typeOfColorTexbox.Text  = string.Empty;
                typeOfDepthTextBox.Text = string.Empty;
            }
            #endregion

            #region check if image is a subclass of CvArr type
            if (image != null)
            {
                Type imgType = image.GetType();
                if (IsSubTypeOf(imgType, typeof(CvArray <>)))
                {
                    _imageType = typeof(CvArray <>);
                }
                else if (IsSubTypeOf(imgType, typeof(Mat)))
                {
                    _imageType = typeof(Mat);
                }
                else if (IsSubTypeOf(imgType, typeof(UMat)))
                {
                    _imageType = typeof(UMat);
                }
                else
                {
                    _imageType = null;
                }
            }
            else
            {
                _imageType = null;
            }
            #endregion

            UpdateHistogram();
            UpdateZoomScale();
        }
Esempio n. 6
0
        private static String GetConversionCodenameFromType(Type colorType)
        {
            ColorInfoAttribute info = (ColorInfoAttribute)colorType.GetCustomAttributes(typeof(ColorInfoAttribute), true)[0];

            return(info.ConversionCodename);
        }