Ejemplo n.º 1
0
        internal IplImage(IImage image, Func <Type, IplChannelDepth> translationFunc)
        {
            /************************ default values initialization *********************************/
            this.StructureSize   = sizeof(IplImage);
            this.ID              = 0;
            this.Align           = 4;
            this.AlphaChannel    = 0;
            this.DataOrder       = ChannelDataOrder.INTERLEAVED;
            this.Origin          = DataOrigin.TopLeft;
            this.ROI             = IntPtr.Zero;
            this.MaskROI         = IntPtr.Zero;
            this.ImageId         = IntPtr.Zero;
            this.TileInfo        = IntPtr.Zero;
            this.ImageDataOrigin = IntPtr.Zero; //set to zero to avoid deallocation (should be equal to ImageData)
            /************************ default values initialization *********************************/

            var colorInfo = image.ColorInfo;

            this.Align = (image.Stride % 8 == 0) ? 8 :
                         (image.Stride % 4 == 0) ? 4 : 0; //TODO: check does OpenCV supports non-aligned images

            this.ChannelDepth     = translationFunc(colorInfo.ColorType);
            this.NumberOfChannels = colorInfo.ChannelCount;

            this.Width     = image.Width;
            this.Height    = image.Height;
            this.WidthStep = image.Stride;
            this.ImageSize = image.Stride * image.Height;

            this.ImageData = image.ImageData;
        }
        internal IplImage(IImage image, Func<Type, IplChannelDepth> translationFunc)
        {
            /************************ default values initialization *********************************/
            this.StructureSize = sizeof(IplImage);
            this.ID = 0;
            this.Align = 4;
            this.AlphaChannel = 0;
            this.DataOrder = ChannelDataOrder.INTERLEAVED;
            this.Origin = DataOrigin.TopLeft;
            this.ROI = IntPtr.Zero;
            this.MaskROI = IntPtr.Zero;
            this.ImageId = IntPtr.Zero;
            this.TileInfo = IntPtr.Zero;
            this.ImageDataOrigin = IntPtr.Zero;
            /************************ default values initialization *********************************/

            var colorInfo = image.ColorInfo;

            this.Align = (image.Stride % 8 == 0) ? 8 :
                         (image.Stride % 4 == 0) ? 4 : 0; //TODO: check does OpenCV supports non-aligned images

            this.ChannelDepth = translationFunc(colorInfo.ChannelType);
            this.NumberOfChannels = colorInfo.NumberOfChannels;

            this.Width = image.Width;
            this.Height = image.Height;
            this.WidthStep = image.Stride;
            this.ImageSize = colorInfo.Size * image.Stride * image.Height;

            this.ImageData = image.ImageData;
        }