예제 #1
0
 /// <summary>
 /// Create a Ridge detection filter.
 /// </summary>
 /// <param name="dDepthType">Specifies output image depth.</param>
 /// <param name="dChannels">Specifies output image channel.</param>
 /// <param name="dx">Order of derivative x</param>
 /// <param name="dy">Order of derivative y</param>
 /// <param name="ksize">Sobel kernel size</param>
 /// <param name="outDepthType">Converted format for output</param>
 /// <param name="outChannels">Converted format for output</param>
 /// <param name="scale">Optional scale value for derivative values</param>
 /// <param name="delta">Optional bias added to output</param>
 /// <param name="borderType">Pixel extrapolation method</param>
 public RidgeDetectionFilter(
     CvEnum.DepthType dDepthType = CvEnum.DepthType.Cv32F,
     int dChannels = 1,
     int dx        = 1,
     int dy        = 1,
     int ksize     = 3,
     CvEnum.DepthType outDepthType = CvEnum.DepthType.Cv8U,
     int outChannels = 1,
     double scale    = 1,
     double delta    = 0,
     Emgu.CV.CvEnum.BorderType borderType = Emgu.CV.CvEnum.BorderType.Default)
 {
     _ptr = XImgprocInvoke.cveRidgeDetectionFilterCreate(
         CvInvoke.MakeType(dDepthType, dChannels),
         dx,
         dy,
         ksize,
         CvInvoke.MakeType(outDepthType, outChannels),
         scale,
         delta,
         borderType,
         ref _algorithm,
         ref _sharedPtr);
 }
예제 #2
0
 /// <summary>
 /// Create a umat of the specific type.
 /// </summary>
 /// <param name="rows">Number of rows in a 2D array.</param>
 /// <param name="cols">Number of columns in a 2D array.</param>
 /// <param name="type">Mat element type</param>
 /// <param name="channels">Number of channels</param>
 /// <param name="usage">Allocation Usage</param>
 public UMat(int rows, int cols, CvEnum.DepthType type, int channels, Usage usage = Usage.Default)
     : this()
 {
     Create(rows, cols, type, channels, usage);
 }
예제 #3
0
파일: GpuMat.cs 프로젝트: virzak/emgucv
 internal static extern void gpuMatConvertTo(IntPtr src, IntPtr dst, CvEnum.DepthType rtype, double scale, double shift, IntPtr stream);
예제 #4
0
파일: GpuMat.cs 프로젝트: virzak/emgucv
 /// <summary>
 /// This function has several different purposes and thus has several synonyms. It copies one GpuMat to another with optional scaling, which is performed first, and/or optional type conversion, performed after:
 /// dst(I)=src(I)*scale + (shift,shift,...)
 /// All the channels of multi-channel GpuMats are processed independently.
 /// The type conversion is done with rounding and saturation, that is if a result of scaling + conversion can not be represented exactly by a value of destination GpuMat element type, it is set to the nearest representable value on the real axis.
 /// In case of scale=1, shift=0 no prescaling is done. This is a specially optimized case and it has the appropriate convertTo synonym.
 /// </summary>
 /// <param name="dst">Destination GpuMat</param>
 /// <param name="rtype">Result type</param>
 /// <param name="scale">Scale factor</param>
 /// <param name="shift">Value added to the scaled source GpuMat elements</param>
 /// <param name="stream">Use a Stream to call the function asynchronously (non-blocking) or IntPtr.Zero to call the function synchronously (blocking).</param>
 public void ConvertTo(IOutputArray dst, CvEnum.DepthType rtype, double scale = 1.0, double shift = 0, Stream stream = null)
 {
     using (OutputArray oaDst = dst.GetOutputArray())
         CudaInvoke.gpuMatConvertTo(Ptr, oaDst, rtype, scale, shift, stream);
 }
예제 #5
0
 /// <summary>
 /// Create a multiBandBlender
 /// </summary>
 /// <param name="tryGpu">If true, will try to use GPU</param>
 /// <param name="numBands">Number of bands</param>
 /// <param name="weightType">The weight type</param>
 public MultiBandBlender(bool tryGpu = true, int numBands = 5, CvEnum.DepthType weightType = CvEnum.DepthType.Cv32F)
 {
     _ptr = StitchingInvoke.cveMultiBandBlenderCreate(tryGpu ? 1 : 0, numBands, weightType, ref _blenderPtr);
 }
예제 #6
0
파일: UMat.cs 프로젝트: gxliu/emgucv-code
        /// <summary>
        /// Convert this Mat to Image
        /// </summary>
        /// <typeparam name="TColor">The type of Color</typeparam>
        /// <typeparam name="TDepth">The type of Depth</typeparam>
        /// <returns>The image</returns>
        public Image <TColor, TDepth> ToImage <TColor, TDepth>()
            where TColor : struct, IColor
            where TDepth : new()
        {
            TColor c = new TColor();

            int numberOfChannels = NumberOfChannels;

            if (typeof(TDepth) == CvInvoke.GetDepthType(this.Depth) && c.Dimension == numberOfChannels)
            {
                //same color, same depth
                Image <TColor, TDepth> img = new Image <TColor, TDepth>(Size);
                CopyTo(img);
                return(img);
            }
            else if (typeof(TDepth) != CvInvoke.GetDepthType(this.Depth) && c.Dimension == numberOfChannels)
            {
                //different depth, same color
                Image <TColor, TDepth> result = new Image <TColor, TDepth>(Size);
                if (numberOfChannels == 1)
                {
                    using (Image <Gray, TDepth> tmp = this.ToImage <Gray, TDepth>())
                        result.ConvertFrom(tmp);
                }
                else if (numberOfChannels == 3)
                {
                    using (Image <Bgr, TDepth> tmp = this.ToImage <Bgr, TDepth>())
                        result.ConvertFrom(tmp);
                }
                else if (numberOfChannels == 4)
                {
                    using (Image <Bgra, TDepth> tmp = this.ToImage <Bgra, TDepth>())
                        result.ConvertFrom(tmp);
                }
                else
                {
                    throw new Exception("Unsupported conversion");
                }
                return(result);
            }
            else if (typeof(TDepth) == CvInvoke.GetDepthType(this.Depth) && c.Dimension != numberOfChannels)
            {
                //same depth, different color
                Image <TColor, TDepth> result = new Image <TColor, TDepth>(Size);

                CvEnum.DepthType depth = Depth;
                if (depth == CvEnum.DepthType.Cv8U)
                {
                    using (Image <TColor, Byte> tmp = this.ToImage <TColor, Byte>())
                        result.ConvertFrom(tmp);
                }
                else if (depth == CvEnum.DepthType.Cv8S)
                {
                    using (Image <TColor, SByte> tmp = this.ToImage <TColor, SByte>())
                        result.ConvertFrom(tmp);
                }
                else if (depth == CvEnum.DepthType.Cv16U)
                {
                    using (Image <TColor, UInt16> tmp = this.ToImage <TColor, UInt16>())
                        result.ConvertFrom(tmp);
                }
                else if (depth == CvEnum.DepthType.Cv16S)
                {
                    using (Image <TColor, Int16> tmp = this.ToImage <TColor, Int16>())
                        result.ConvertFrom(tmp);
                }
                else if (depth == CvEnum.DepthType.Cv32S)
                {
                    using (Image <TColor, Int32> tmp = this.ToImage <TColor, Int32>())
                        result.ConvertFrom(tmp);
                }
                else if (depth == CvEnum.DepthType.Cv32F)
                {
                    using (Image <TColor, float> tmp = this.ToImage <TColor, float>())
                        result.ConvertFrom(tmp);
                }
                else if (depth == CvEnum.DepthType.Cv64F)
                {
                    using (Image <TColor, double> tmp = this.ToImage <TColor, double>())
                        result.ConvertFrom(tmp);
                }
                else
                {
                    throw new Exception("Unsupported conversion");
                }
                return(result);
            }
            else
            {
                //different color, different depth
                using (UMat tmp = new UMat())
                {
                    ConvertTo(tmp, CvInvoke.GetDepthType(typeof(TDepth)));
                    return(tmp.ToImage <TColor, TDepth>());
                }
            }
        }
예제 #7
0
 internal extern static void cveUMatConvertTo(IntPtr umat, IntPtr outArray, CvEnum.DepthType rtype, double alpha, double beta);
예제 #8
0
        /// <summary>
        /// Convert this Mat to Image
        /// </summary>
        /// <typeparam name="TColor">The type of Color</typeparam>
        /// <typeparam name="TDepth">The type of Depth</typeparam>
        /// <returns>The image</returns>
        public Image <TColor, TDepth> ToImage <TColor, TDepth>()
            where TColor : struct, IColor
            where TDepth : new()
        {
            TColor c = new TColor();

            int numberOfChannels = NumberOfChannels;

            if (typeof(TDepth) == CvInvoke.GetDepthType(this.Depth) && c.Dimension == numberOfChannels)
            {
                //same color, same depth
                Image <TColor, TDepth> img = new Image <TColor, TDepth>(Size);
                CopyTo(img);
                return(img);
            }
            else if (typeof(TDepth) != CvInvoke.GetDepthType(this.Depth) && c.Dimension == numberOfChannels)
            {
                //different depth, same color
                Image <TColor, TDepth> result = new Image <TColor, TDepth>(Size);
                CvEnum.DepthType       depth  = Depth;
                Mat resultMat = result.Mat;
                this.ConvertTo(resultMat, resultMat.Depth);

                /*
                 * if (depth == CvEnum.DepthType.Cv8U)
                 * {
                 * using (Image<TColor, Byte> tmp = this.ToImage<TColor, Byte>())
                 *    result.ConvertFrom(tmp);
                 * }
                 * else if (depth == CvEnum.DepthType.Cv8S)
                 * {
                 * using (Image<TColor, SByte> tmp = this.ToImage<TColor, SByte>())
                 *    result.ConvertFrom(tmp);
                 * }
                 * else if (depth == CvEnum.DepthType.Cv16U)
                 * {
                 * using (Image<TColor, UInt16> tmp = this.ToImage<TColor, UInt16>())
                 *    result.ConvertFrom(tmp);
                 * }
                 * else if (depth == CvEnum.DepthType.Cv16S)
                 * {
                 * using (Image<TColor, Int16> tmp = this.ToImage<TColor, Int16>())
                 *    result.ConvertFrom(tmp);
                 * }
                 * else if (depth == CvEnum.DepthType.Cv32S)
                 * {
                 * using (Image<TColor, Int32> tmp = this.ToImage<TColor, Int32>())
                 *    result.ConvertFrom(tmp);
                 * }
                 * else if (depth == CvEnum.DepthType.Cv32F)
                 * {
                 * using (Image<TColor, float> tmp = this.ToImage<TColor, float>())
                 *    result.ConvertFrom(tmp);
                 * }
                 * else if (depth == CvEnum.DepthType.Cv64F)
                 * {
                 * using (Image<TColor, double> tmp = this.ToImage<TColor, double>())
                 *    result.ConvertFrom(tmp);
                 * }
                 * else
                 * {
                 * throw new Exception("Unsupported conversion");
                 * }*/
                return(result);
            }
            else if (typeof(TDepth) == CvInvoke.GetDepthType(this.Depth) && c.Dimension != numberOfChannels)
            {
                //same depth, different color
                Image <TColor, TDepth> result = new Image <TColor, TDepth>(Size);
                Type t = numberOfChannels == 1
                   ? typeof(Gray)
                   : numberOfChannels == 3
                      ? typeof(Bgr)
                      : numberOfChannels == 4
                         ? typeof(Bgra)
                         : null;
                if (t == null)
                {
                    throw new Exception("Unsupported conversion");
                }
                CvInvoke.CvtColor(this, result, t, typeof(TColor));

                /*
                 * if (numberOfChannels == 1)
                 * {
                 * using (Image<Gray, TDepth> tmp = this.ToImage<Gray, TDepth>())
                 *    result.ConvertFrom(tmp);
                 * }
                 * else if (numberOfChannels == 3)
                 * {
                 * using (Image<Bgr, TDepth> tmp = this.ToImage<Bgr, TDepth>())
                 *    result.ConvertFrom(tmp);
                 * }
                 * else if (numberOfChannels == 4)
                 * {
                 * using (Image<Bgra, TDepth> tmp = this.ToImage<Bgra, TDepth>())
                 *    result.ConvertFrom(tmp);
                 * }
                 * else
                 * {
                 * throw new Exception("Unsupported conversion");
                 * }*/
                return(result);
            }
            else
            {
                //different color, different depth
                using (UMat tmp = new UMat())
                {
                    ConvertTo(tmp, CvInvoke.GetDepthType(typeof(TDepth)));
                    return(tmp.ToImage <TColor, TDepth>());
                }
            }
        }
예제 #9
0
파일: Mat.cs 프로젝트: aykanat/emgucv-code
 /// <summary>
 /// Allocates new array data if needed.
 /// </summary>
 /// <param name="rows">New number of rows.</param>
 /// <param name="cols">New number of columns.</param>
 /// <param name="type">New matrix element depth type.</param>
 /// <param name="channels">New matrix number of channels</param>
 public void Create(int rows, int cols, CvEnum.DepthType type, int channels)
 {
     MatInvoke.cvMatCreateData(_ptr, rows, cols, CvInvoke.MakeType(type, channels));
 }
예제 #10
0
        /// <summary>
        /// This function performs the same as MakeType macro
        /// </summary>
        /// <param name="depth">The type of depth</param>
        /// <param name="channels">The number of channels</param>
        /// <returns>An interger tha represent a mat type</returns>
        public static int MakeType(CvEnum.DepthType depth, int channels)
        {
            const int shift = 3;

            return((((int)depth) & ((1 << shift) - 1)) + (((channels) - 1) << shift));
        }
예제 #11
0
파일: Mat.cs 프로젝트: formylover/emgucv-1
 /// <summary>
 /// Create a Mat header from existing data
 /// </summary>
 /// <param name="size">Size of the Mat</param>
 /// <param name="type">Mat element type</param>
 /// <param name="channels">Number of channels</param>
 /// <param name="data">Pointer to the user data. Matrix constructors that take data and step parameters do not allocate matrix data. Instead, they just initialize the matrix header that points to the specified data, which means that no data is copied. This operation is very efficient and can be used to process external data using OpenCV functions. The external data is not automatically deallocated, so you should take care of it.</param>
 /// <param name="step">Number of bytes each matrix row occupies. The value should include the padding bytes at the end of each row, if any.</param>
 public Mat(Size size, CvEnum.DepthType type, int channels, IntPtr data, int step)
     : this(size.Height, size.Width, type, channels, data, step)
 {
 }
예제 #12
0
파일: Mat.cs 프로젝트: formylover/emgucv-1
 /// <summary>
 /// Create multi-dimension mat using existing data.
 /// </summary>
 /// <param name="sizes">The sizes of each dimension</param>
 /// <param name="type">The type of data</param>
 /// <param name="data">The pointer to the unmanaged data</param>
 /// <param name="steps">The steps</param>
 public Mat(int[] sizes, CvEnum.DepthType type, IntPtr data, IntPtr[] steps = null)
     : this(MatInvoke.cveMatCreateMultiDimWithData(sizes, type, data, steps), true, true)
 {
 }
예제 #13
0
파일: Mat.cs 프로젝트: formylover/emgucv-1
 /// <summary>
 /// Create a mat of the specific type.
 /// </summary>
 /// <param name="size">Size of the Mat</param>
 /// <param name="type">Mat element type</param>
 /// <param name="channels">Number of channels</param>
 public Mat(Size size, CvEnum.DepthType type, int channels)
     : this(size.Height, size.Width, type, channels)
 {
 }
예제 #14
0
파일: Mat.cs 프로젝트: formylover/emgucv-1
 private static extern IntPtr cveMatCreateMultiDimWithData(int ndims, IntPtr sizes, CvEnum.DepthType type, IntPtr data,
                                                           IntPtr steps);
예제 #15
0
 /// <summary>
 /// Create a umat of the specific type.
 /// </summary>
 /// <param name="size">Size of the UMat</param>
 /// <param name="type">Mat element type</param>
 /// <param name="channels">Number of channels</param>
 /// <param name="usage">Allocation Usage</param>
 public UMat(Size size, CvEnum.DepthType type, int channels, Usage usage = Usage.Default)
     : this(size.Height, size.Width, type, channels, usage)
 {
 }
예제 #16
0
 /// <summary>
 /// Allocates new array data if needed.
 /// </summary>
 /// <param name="rows">New number of rows.</param>
 /// <param name="cols">New number of columns.</param>
 /// <param name="type">New matrix element depth type.</param>
 /// <param name="channels">New matrix number of channels</param>
 /// <param name="usage">Allocation Usage</param>
 public void Create(int rows, int cols, CvEnum.DepthType type, int channels, Usage usage = Usage.Default)
 {
     UMatInvoke.cveUMatCreateData(_ptr, rows, cols, CvInvoke.MakeType(type, channels), usage);
 }
예제 #17
0
파일: Mat.cs 프로젝트: aykanat/emgucv-code
 /// <summary>
 /// Create a mat of the specific type.
 /// </summary>
 /// <param name="rows">Number of rows in a 2D array.</param>
 /// <param name="cols">Number of columns in a 2D array.</param>
 /// <param name="type">Mat element type</param>
 /// <param name="channels">Number of channels</param>
 public Mat(int rows, int cols, CvEnum.DepthType type, int channels)
     : this()
 {
     Create(rows, cols, type, channels);
 }
예제 #18
0
 /// <summary>
 /// Converts an array to another data type with optional scaling.
 /// </summary>
 /// <param name="m">Output matrix; if it does not have a proper size or type before the operation, it is reallocated.</param>
 /// <param name="rtype">Desired output matrix type or, rather, the depth since the number of channels are the same as the input has; if rtype is negative, the output matrix will have the same type as the input.</param>
 /// <param name="alpha">Optional scale factor.</param>
 /// <param name="beta">Optional delta added to the scaled values.</param>
 public void ConvertTo(IOutputArray m, CvEnum.DepthType rtype, double alpha = 1.0, double beta = 0.0)
 {
     using (OutputArray oaM = m.GetOutputArray())
         UMatInvoke.cveUMatConvertTo(Ptr, oaM, rtype, alpha, beta);
 }
예제 #19
0
파일: Mat.cs 프로젝트: aykanat/emgucv-code
 /// <summary>
 /// Create a Mat header from existing data
 /// </summary>
 /// <param name="rows">Number of rows in a 2D array.</param>
 /// <param name="cols">Number of columns in a 2D array.</param>
 /// <param name="type">Mat element type</param>
 /// <param name="channels">Number of channels</param>
 /// <param name="data">Pointer to the user data. Matrix constructors that take data and step parameters do not allocate matrix data. Instead, they just initialize the matrix header that points to the specified data, which means that no data is copied. This operation is very efficient and can be used to process external data using OpenCV functions. The external data is not automatically deallocated, so you should take care of it.</param>
 /// <param name="step">Number of bytes each matrix row occupies. The value should include the padding bytes at the end of each row, if any.</param>
 public Mat(int rows, int cols, CvEnum.DepthType type, int channels, IntPtr data, int step)
     : this(MatInvoke.cvMatCreateWithData(rows, cols, CvInvoke.MakeType(type, channels), data, new IntPtr(step)), true, true)
 {
 }
예제 #20
0
 private static extern void cveSepFilter2D(IntPtr src, IntPtr dst, CvEnum.DepthType ddepth, IntPtr kernelX, IntPtr kernelY, ref Point anchor, double delta, CvEnum.BorderType borderType);
예제 #21
0
 internal static extern IntPtr cveMultiBandBlenderCreate(int tryGpu, int numBands, CvEnum.DepthType weightType, ref IntPtr blender);