Example #1
0
        private static dynamic CreateElement(DepthType depthType, dynamic value)
        {
            var element = CreateElement(depthType);
            element = value;

            return element;
        }
Example #2
0
 public static bool IsCompatible <T>(this DepthType depthType, T val)
 {
     if (depthType == DepthType.Cv8S)
     {
         return(val is sbyte);
     }
     if (depthType == DepthType.Cv8U)
     {
         return(val is byte);
     }
     if (depthType == DepthType.Cv16S)
     {
         return(val is short);
     }
     if (depthType == DepthType.Cv16U)
     {
         return(val is ushort);
     }
     if (depthType == DepthType.Cv32S)
     {
         return(val is int);
     }
     if (depthType == DepthType.Cv32F)
     {
         return(val is float);
     }
     if (depthType == DepthType.Cv64F)
     {
         return(val is double);
     }
     return(val is float);
 }
Example #3
0
        /// <summary>
        /// Copies the values of the <paramref name="data"/> to Mat.
        /// </summary>
        /// <param name="data">The data storage, must match the size of the Mat</param>
        public void SetTo(Array data)
        {
            if (IsEmpty)
            {
                int dimension = data.Rank;

                DepthType dt = Mat.GetDepthTypeFromArray(data);
                if (dt == DepthType.Default)
                {
                    throw new Exception("The specific data type is not supported.");
                }

                if (dimension == 1)
                {
                    this.Create(data.GetLength(0), 1, dt, 1);
                }
                else if (dimension == 2)
                {
                    this.Create(data.GetLength(0), data.GetLength(1), dt, 1);
                }
                else if (dimension == 3)
                {
                    this.Create(data.GetLength(0), data.GetLength(1), dt, 1);
                }
                else
                {
                    throw new Exception("The Mat has to be pre-allocated");
                }
            }

            using (Mat.MatWithHandle m = Mat.PrepareArrayForCopy(Depth, Size, NumberOfChannels, data))
                m.CopyTo(this);
        }
Example #4
0
 public DepthBuffer(FrameBuffer buffer, DepthType type, int samples)
     : base(buffer)
 {
     MakeCurrent();
     OpenGL.glRenderbufferStorageMultisample(OpenGL.Const.GL_RENDERBUFFER, samples, (uint)type, buffer.Width, buffer.Height);
     OpenGL.glFramebufferRenderbuffer(OpenGL.Const.GL_FRAMEBUFFER, OpenGL.Const.GL_DEPTH_ATTACHMENT, OpenGL.Const.GL_RENDERBUFFER, handle);
 }
Example #5
0
        private static dynamic CreateElement(DepthType depthType, dynamic value)
        {
            var element = CreateElement(depthType);

            element[0] = value;
            return(element);
        }
Example #6
0
 /// <summary>
 /// Create and allocate storage for two dimensional single or multi channel dataset.
 /// </summary>
 /// <param name="rows">Declare amount of rows</param>
 /// <param name="cols">Declare amount of columns</param>
 /// <param name="depthType">The pixel depth type</param>
 /// <param name="channels">The number of channels</param>
 /// <param name="dsLabel">Specify the hdf5 dataset label. Existing dataset label will cause an error.</param>
 /// <param name="compressLevel">Specify the compression level 0-9 to be used, -1 is the default value and means no compression. The value 0 also means no compression. A value 9 indicating the best compression ration. Note that a higher compression level indicates a higher computational cost. It relies on GNU gzip for compression.</param>
 /// <param name="dimsChunks">Each array member specifies the chunking size to be used for block I/O, by default null means none at all.</param>
 public void DsCreate(int rows, int cols, DepthType depthType, int channels, String dsLabel, int compressLevel = -1, VectorOfInt dimsChunks = null)
 {
     using (CvString csDsLabel = new CvString(dsLabel))
     {
         HdfInvoke.cveHDF5DsCreate(_ptr, rows, cols, CvInvoke.MakeType(depthType, channels), csDsLabel, compressLevel, dimsChunks);
     }
 }
Example #7
0
 public DepthBuffer(FrameBuffer buffer, DepthType type, int samples)
     : base(buffer)
 {
     MakeCurrent();
     OpenGL.glRenderbufferStorageMultisample(OpenGL.Const.GL_RENDERBUFFER, samples, (uint)type, buffer.Width, buffer.Height);
     OpenGL.glFramebufferRenderbuffer(OpenGL.Const.GL_FRAMEBUFFER, OpenGL.Const.GL_DEPTH_ATTACHMENT, OpenGL.Const.GL_RENDERBUFFER, handle);
 }
Example #8
0
 private static dynamic CreateElement(DepthType depthType)
 {
     if (depthType == DepthType.Cv8S)
     {
         return(new sbyte[1]);
     }
     if (depthType == DepthType.Cv8U)
     {
         return(new byte[1]);
     }
     if (depthType == DepthType.Cv16S)
     {
         return(new short[1]);
     }
     if (depthType == DepthType.Cv16U)
     {
         return(new ushort[1]);
     }
     if (depthType == DepthType.Cv32S)
     {
         return(new int[1]);
     }
     if (depthType == DepthType.Cv32F)
     {
         return(new float[1]);
     }
     if (depthType == DepthType.Cv64F)
     {
         return(new double[1]);
     }
     return(new float[1]);
 }
Example #9
0
        /// <summary>
        /// 创建大小为1的基本类型数组
        /// </summary>
        /// <param name="depthType">Mat的深度类型</param>
        /// <returns>数组结果</returns>
        private dynamic CreateElement()
        {
            DepthType depthType = this.Depth;

            if (depthType == DepthType.Cv8S)
            {
                return(new sbyte[1]);
            }
            else if (depthType == DepthType.Cv8U)
            {
                return(new byte[1]);
            }
            else if (depthType == DepthType.Cv16S)
            {
                return(new short[1]);
            }
            else if (depthType == DepthType.Cv16U)
            {
                return(new ushort[1]);
            }
            else if (depthType == DepthType.Cv32S)
            {
                return(new int[1]);
            }
            else if (depthType == DepthType.Cv64F)
            {
                return(new double[1]);
            }
            else
            {
                return(new float[1]);
            }
        }
Example #10
0
 private static dynamic CreateElement(DepthType depthType)
 {
     if (depthType == DepthType.Cv8S)
     {
         return new sbyte[1];
     }
     if (depthType == DepthType.Cv8U)
     {
         return new byte[1];
     }
     if (depthType == DepthType.Cv16S)
     {
         return new short[1];
     }
     if (depthType == DepthType.Cv16U)
     {
         return new ushort[1];
     }
     if (depthType == DepthType.Cv32S)
     {
         return new int[1];
     }
     if (depthType == DepthType.Cv32F)
     {
         return new float[1];
     }
     if (depthType == DepthType.Cv64F)
     {
         return new double[1];
     }
     return new float[1];
 }
Example #11
0
 public ColumnSumFilter(
     DepthType srcDepth, int srcChannels,
     DepthType dstDepth, int dstChannels,
     int ksize, int anchor,
     CvEnum.BorderType borderType = BorderType.Default, MCvScalar borderValue = new MCvScalar())
 {
     _ptr = CudaInvoke.cudaCreateColumnSumFilter(CvInvoke.MakeType(srcDepth, srcChannels), CvInvoke.MakeType(dstDepth, dstChannels), ksize, anchor, borderType, ref borderValue);
 }
Example #12
0
        /// <summary>
        /// Reverts a working copy specified by <paramref name="path"/> to its original state.
        /// </summary>
        /// <param name="path">Working copy path.</param>
        /// <param name="depth">Affective depth of the command.</param>
        public void Revert(string path, DepthType depth)
        {
            SvnCommandOptions options = _defaultOptions.Clone();

            options.Depth = depth;
            options.Paths.Add(SvnPath.CreateWCPath(path));
            _command.Run("revert", options);
        }
Example #13
0
 /// <summary>
 /// Convert the DepthType to a string that represent the OpenCL value type.
 /// </summary>
 /// <param name="depthType">The depth type</param>
 /// <param name="channels">The number of channels</param>
 /// <returns>A string the repsent the OpenCL value type</returns>
 public static String TypeToString(DepthType depthType, int channels = 1)
 {
     using (CvString str = new CvString())
     {
         oclTypeToString(CvInvoke.MakeType(depthType, channels), str);
         return(str.ToString());
     }
 }
Example #14
0
 /// <summary>
 /// Extracts pixels from src:
 /// dst(x, y) = src(x + center.x - (width(dst)-1)*0.5, y + center.y - (height(dst)-1)*0.5)
 /// where the values of pixels at non-integer coordinates are retrieved using bilinear interpolation. Every channel of multiple-channel images is processed independently. Whereas the rectangle center must be inside the image, the whole rectangle may be partially occluded. In this case, the replication border mode is used to get pixel values beyond the image boundaries.
 /// </summary>
 /// <param name="image">Source image</param>
 /// <param name="patchSize">Size of the extracted patch.</param>
 /// <param name="patch">Extracted rectangle</param>
 /// <param name="patchType">Depth of the extracted pixels. By default, they have the same depth as <paramref name="image"/>.</param>
 /// <param name="center">Floating point coordinates of the extracted rectangle center within the source image. The center must be inside the image.</param>
 public static void GetRectSubPix(IInputArray image, Size patchSize, PointF center, IOutputArray patch, DepthType patchType = DepthType.Default)
 {
    using (InputArray iaSrc = image.GetInputArray())
    using (OutputArray oaPatch = patch.GetOutputArray())
    {
       cveGetRectSubPix(iaSrc, ref patchSize, ref center, oaPatch, patchType);
    }
 }
Example #15
0
 /// <summary>
 /// Produce domain transform filtering operation on source image.
 /// </summary>
 /// <param name="src">Filtering image with unsigned 8-bit or floating-point 32-bit depth and up to 4 channels.</param>
 /// <param name="dst">Destination image.</param>
 /// <param name="dDepth">Optional depth of the output image. dDepth can be set to Default, which will be equivalent to src.depth().</param>
 public void Filter(IInputArray src, IOutputArray dst, DepthType dDepth = DepthType.Default)
 {
     using (InputArray iaSrc = src.GetInputArray())
         using (OutputArray oaDst = dst.GetOutputArray())
         {
             XImgprocInvoke.cveDTFilterFilter(_ptr, iaSrc, oaDst, dDepth);
         }
 }
Example #16
0
 /// <summary>
 /// Produce domain transform filtering operation on source image.
 /// </summary>
 /// <param name="src">Filtering image with unsigned 8-bit or floating-point 32-bit depth and up to 4 channels.</param>
 /// <param name="dst">Destination image.</param>
 /// <param name="dDepth">Optional depth of the output image. dDepth can be set to Default, which will be equivalent to src.depth().</param>
 public void Filter(IInputArray src, IOutputArray dst, DepthType dDepth = DepthType.Default)
 {
    using (InputArray iaSrc = src.GetInputArray())
       using (OutputArray oaDst = dst.GetOutputArray())
       {
          XimgprocInvoke.cveDTFilterFilter(_ptr, iaSrc, oaDst, dDepth);
       }
    
 }
Example #17
0
 /// <summary>
 /// Create a Sobel filter.
 /// </summary>
 /// <param name="srcDepth">The depth of the source image</param>
 /// <param name="srcChannels">The number of channels of the source image</param>
 /// <param name="dstDepth">The depth of the destination image</param>
 /// <param name="dstChannels">The number of channels of the the destination image</param>
 /// <param name="dx">Order of the derivative x</param>
 /// <param name="dy">Order of the derivative y</param>
 /// <param name="ksize">Size of the extended Sobel kernel</param>
 /// <param name="scale">Optional scale, use 1 for default.</param>
 /// <param name="rowBorderType">The row border type.</param>
 /// <param name="columnBorderType">The column border type.</param>
 public CudaSobelFilter(
     DepthType srcDepth, int srcChannels,
     DepthType dstDepth, int dstChannels,
     int dx, int dy, int ksize       = 3, double scale = 1.0,
     CvEnum.BorderType rowBorderType = BorderType.Default, CvEnum.BorderType columnBorderType = BorderType.NegativeOne)
 {
     _ptr = CudaInvoke.cudaCreateSobelFilter(CvInvoke.MakeType(srcDepth, srcChannels), CvInvoke.MakeType(dstDepth, dstChannels),
                                             dx, dy, ksize, scale, rowBorderType, columnBorderType, ref _sharedPtr);
 }
Example #18
0
 public CudaDerivFilter(
     DepthType srcDepth, int srcChannels, DepthType dstDepth, int dstChannels,
     int dx, int dy,
     int ksize, bool normalize, double scale,
     CvEnum.BorderType rowBorderType    = BorderType.Default,
     CvEnum.BorderType columnBorderType = BorderType.Default)
 {
     _ptr = CudaInvoke.cudaCreateDerivFilter(CvInvoke.MakeType(srcDepth, srcChannels), CvInvoke.MakeType(dstDepth, dstChannels), dx, dy, ksize, normalize, scale, rowBorderType, columnBorderType);
 }
Example #19
0
 /// <summary>
 /// Create a Sobel filter.
 /// </summary>
 /// <param name="dx">Order of the derivative x</param>
 /// <param name="dy">Order of the derivative y</param>
 /// <param name="ksize">Size of the extended Sobel kernel</param>
 /// <param name="scale">Optional scale, use 1 for default.</param>
 /// <param name="rowBorderType">The row border type.</param>
 /// <param name="columnBorderType">The column border type.</param>
 public CudaSobelFilter(
    DepthType srcDepth, int srcChannels, 
    DepthType dstDepth, int dstChannels,
    int dx, int dy, int ksize = 3, double scale = 1.0, 
    CvEnum.BorderType rowBorderType = BorderType.Default, CvEnum.BorderType columnBorderType = BorderType.NegativeOne)
 {
    _ptr = CudaInvoke.cudaCreateSobelFilter(CvInvoke.MakeType(srcDepth, srcChannels), CvInvoke.MakeType(dstDepth, dstChannels), 
       dx, dy, ksize, scale, rowBorderType, columnBorderType);
 }
Example #20
0
        /// <summary>
        /// Updates the working copy specified in <paramref name="path"/> to the specified numeric <paramref name="revision"/>.
        /// </summary>
        /// <param name="path">Working copy path to update.</param>
        /// <param name="revision">Numeric revision to which the working path will be updated.</param>
        /// <param name="depth">The depth to which the operation will apply.</param>
        public void Update(string path, Revision revision, DepthType depth)
        {
            SvnCommandOptions options = _defaultOptions.Clone();

            options.Revision = revision;
            options.Depth    = depth;
            options.Paths.Add(SvnPath.CreateWCPath(path));
            _command.Run("update", options);
        }
Example #21
0
 /// <summary>
 /// Create a Laplacian filter.
 /// </summary>
 /// <param name="ksize">Either 1 or 3</param>
 /// <param name="scale">Optional scale. Use 1.0 for default</param>
 /// <param name="borderType">The border type.</param>
 /// <param name="borderValue">The border value.</param>
 /// <param name="srcDepth">The depth type of the source image</param>
 /// <param name="srcChannels">The number of channels in the source image</param>
 /// <param name="dstDepth">The depth type of the destination image</param>
 /// <param name="dstChannels">The number of channels in the destination image</param>
 public CudaLaplacianFilter(
     DepthType srcDepth, int srcChannels,
     DepthType dstDepth, int dstChannels,
     int ksize = 1, double scale = 1.0,
     CvEnum.BorderType borderType = BorderType.Default, MCvScalar borderValue = new MCvScalar())
 {
     _ptr = CudaInvoke.cudaCreateLaplacianFilter(
         CvInvoke.MakeType(srcDepth, srcChannels), CvInvoke.MakeType(dstDepth, dstChannels),
         ksize, scale, borderType, ref borderValue, ref _sharedPtr);
 }
Example #22
0
 internal static extern IntPtr cveRgbdNormalsCreate(
     int rows,
     int cols,
     DepthType depth,
     IntPtr K,
     int windowSize,
     RgbdNormals.Method method,
     ref IntPtr algorithm,
     ref IntPtr sharedPtr
     );
Example #23
0
 /// <summary>
 /// Create a Cuda Harris Corner detector
 /// </summary>
 /// <param name="srcDepth">The depth of the source image</param>
 /// <param name="srcChannels">The number of channels in the source image</param>
 /// <param name="blockSize">Neighborhood size.</param>
 /// <param name="kSize">Kernel size</param>
 /// <param name="k">Harris detector free parameter.</param>
 /// <param name="borderType">Border type.</param>
 public CudaHarrisCorner(
     DepthType srcDepth,
     int srcChannels,
     int blockSize,
     int kSize,
     double k,
     CvEnum.BorderType borderType = BorderType.Default)
 {
     _ptr = CudaInvoke.cudaCreateHarrisCorner(CvInvoke.MakeType(srcDepth, srcChannels), blockSize, kSize, k, borderType, ref _sharedPtr);
 }
Example #24
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="idx"></param>
        /// <returns></returns>
        public DepthType GetDepth(int idx = -1)
        {
            DepthType result = DepthType.Default;

            if (InnerPointer != IntPtr.Zero)
            {
                result = CvInvoke.cveInputArrayGetDepth(InnerPointer, idx);
            }
            return(result);
        }
 /// <summary>
 /// Create a Laplacian filter.
 /// </summary>
 /// <param name="ksize">Either 1 or 3</param>
 /// <param name="scale">Optional scale. Use 1.0 for default</param>
 /// <param name="borderType">The border type.</param>
 /// <param name="borderValue">The border value.</param>
 public CudaLaplacianFilter(
    DepthType srcDepth, int srcChannels,
    DepthType dstDepth, int dstChannels,
    int ksize = 1, double scale = 1.0, 
    CvEnum.BorderType borderType = BorderType.Default, MCvScalar borderValue = new MCvScalar())
 {
    _ptr = CudaInvoke.cudaCreateLaplacianFilter(
       CvInvoke.MakeType(srcDepth, srcChannels), CvInvoke.MakeType(dstDepth, dstChannels), 
       ksize, scale, borderType, ref borderValue);
 }
Example #26
0
        /// <summary>
        /// Exports the <paramref name="depth"/> of the <paramref name="revision" /> of the <paramref name="uri"/> to the <paramref name="localPath"/>.
        /// </summary>
        /// <param name="uri">URI to export.</param>
        /// <param name="revision">Repository revision to export.</param>
        /// <param name="depth">Depth of the export.</param>
        /// <param name="localPath">Local path to which the files will be exported.</param>
        /// <param name="force">Whether or not to force overwrite existing files. Required if target directory exists, even if empty.</param>
        public void Export(string uri, Revision revision, DepthType depth, string localPath, bool force)
        {
            SvnCommandOptions options = _defaultOptions.Clone();

            options.Revision = revision;
            options.Depth    = depth;
            options.MiscArgs.Add(force ? "--force" : null);
            options.Paths.Add(SvnPath.CreateSvnPath(uri));
            options.Paths.Add(SvnPath.CreateWCPath(localPath));
            _command.Run("export", options);
        }
        public Mat CreateMask(Size size, DepthType depth, int val = 1)
        {
            Mat cont_mask = new Mat(size, depth, 1);

            using (VectorOfPoint vp = new VectorOfPoint(m_points))
                using (VectorOfVectorOfPoint vvp = new VectorOfVectorOfPoint(vp))
                {
                    CvInvoke.FillPoly(cont_mask, vvp, new MCvScalar(val));
                }
            return(cont_mask);
        }
Example #28
0
 /// <summary>
 /// Create a Gaussian filter.
 /// </summary>
 /// <param name="ksize">The size of the kernel</param>
 /// <param name="sigma1">This parameter may specify Gaussian sigma (standard deviation). If it is zero, it is calculated from the kernel size.</param>
 /// <param name="sigma2">In case of non-square Gaussian kernel the parameter may be used to specify a different (from param3) sigma in the vertical direction. Use 0 for default</param>
 /// <param name="rowBorderType">The row border type.</param>
 /// <param name="columnBorderType">The column border type.</param>
 /// <param name="srcDepth">The depth type of the source image</param>
 /// <param name="srcChannels">The number of channels in the source image</param>
 /// <param name="dstDepth">The depth type of the destination image</param>
 /// <param name="dstChannels">The number of channels in the destination image</param>
 public CudaGaussianFilter(
    DepthType srcDepth, int srcChannels,
    DepthType dstDepth, int dstChannels,
    Size ksize, 
    double sigma1, double sigma2 = 0, 
    CvEnum.BorderType rowBorderType = BorderType.Default, CvEnum.BorderType columnBorderType = BorderType.NegativeOne)
 {
    _ptr = CudaInvoke.cudaCreateGaussianFilter(
       CvInvoke.MakeType(srcDepth, srcChannels), CvInvoke.MakeType(dstDepth, dstChannels), 
       ref ksize, sigma1, sigma2, (int)rowBorderType, (int)columnBorderType);
 }
 /// <summary>
 /// Create a Gaussian filter.
 /// </summary>
 /// <param name="ksize">The size of the kernel</param>
 /// <param name="sigma1">This parameter may specify Gaussian sigma (standard deviation). If it is zero, it is calculated from the kernel size.</param>
 /// <param name="sigma2">In case of non-square Gaussian kernel the parameter may be used to specify a different (from param3) sigma in the vertical direction. Use 0 for default</param>
 /// <param name="rowBorderType">The row border type.</param>
 /// <param name="columnBorderType">The column border type.</param>
 public CudaGaussianFilter(
     DepthType srcDepth, int srcChannels,
     DepthType dstDepth, int dstChannels,
     Size ksize,
     double sigma1, double sigma2    = 0,
     CvEnum.BorderType rowBorderType = BorderType.Default, CvEnum.BorderType columnBorderType = BorderType.NegativeOne)
 {
     _ptr = CudaInvoke.cudaCreateGaussianFilter(
         CvInvoke.MakeType(srcDepth, srcChannels), CvInvoke.MakeType(dstDepth, dstChannels),
         ref ksize, sigma1, sigma2, (int)rowBorderType, (int)columnBorderType);
 }
Example #30
0
 /// <summary>
 /// Creates a vertical or horizontal Scharr operator.
 /// </summary>
 /// <param name="srcDepth">Source image depth.</param>
 /// <param name="srcChannels">Source image channels.</param>
 /// <param name="dstDepth">Destination array depth.</param>
 /// <param name="dstChannels">Destination array channels.</param>
 /// <param name="dx">Order of the derivative x.</param>
 /// <param name="dy">Order of the derivative y.</param>
 /// <param name="scale">Optional scale factor for the computed derivative values. By default, no scaling is applied. </param>
 /// <param name="rowBorderMode">Pixel extrapolation method in the vertical direction. For details, see borderInterpolate.</param>
 /// <param name="columnBorderMode">Pixel extrapolation method in the horizontal direction.</param>
 public ScharrFilter(
     DepthType srcDepth, int srcChannels,
     DepthType dstDepth, int dstChannels,
     int dx, int dy,
     double scale = 1.0,
     CvEnum.BorderType rowBorderMode    = BorderType.Default,
     CvEnum.BorderType columnBorderMode = BorderType.NegativeOne)
 {
     _ptr = CudaInvoke.cudaCreateScharrFilter(
         CvInvoke.MakeType(srcDepth, srcChannels), CvInvoke.MakeType(dstDepth, dstChannels),
         dx, dy, scale, rowBorderMode, columnBorderMode);
 }
Example #31
0
 /// <summary>
 /// Create a Gpu LinearFilter
 /// </summary>
 /// <param name="kernel">Convolution kernel, single-channel floating point matrix (e.g. Emgu.CV.Matrix). If you want to apply different kernels to different channels, split the gpu image into separate color planes and process them individually</param>
 /// <param name="anchor">The anchor of the kernel that indicates the relative position of a filtered point within the kernel. The anchor shoud lie within the kernel. The special default value (-1,-1) means that it is at the kernel center</param>
 /// <param name="borderType">Border type. Use REFLECT101 as default.</param>
 /// <param name="borderValue">The border value</param>
 /// <param name="srcDepth">The depth type of the source image</param>
 /// <param name="srcChannels">The number of channels in the source image</param>
 /// <param name="dstDepth">The depth type of the dest image</param>
 /// <param name="dstChannels">The number of channels in the dest image</param>
 public CudaLinearFilter(
     DepthType srcDepth, int srcChannels,
     DepthType dstDepth, int dstChannels,
     IInputArray kernel,
     System.Drawing.Point anchor,
     CvEnum.BorderType borderType = BorderType.Default, MCvScalar borderValue = new MCvScalar())
 {
     using (InputArray iaKernel = kernel.GetInputArray())
         _ptr = CudaInvoke.cudaCreateLinearFilter(
             CvInvoke.MakeType(srcDepth, srcChannels), CvInvoke.MakeType(dstDepth, dstChannels),
             iaKernel, ref anchor, borderType, ref borderValue, ref _sharedPtr);
 }
Example #32
0
 /// <summary>
 /// Create a Gpu LinearFilter
 /// </summary>
 /// <param name="kernel">Convolution kernel, single-channel floating point matrix (e.g. Emgu.CV.Matrix). If you want to apply different kernels to different channels, split the gpu image into separate color planes and process them individually</param>
 /// <param name="anchor">The anchor of the kernel that indicates the relative position of a filtered point within the kernel. The anchor shoud lie within the kernel. The special default value (-1,-1) means that it is at the kernel center</param>
 /// <param name="borderType">Border type. Use REFLECT101 as default.</param>
 /// <param name="borderValue">The border value</param>
 public CudaLinearFilter(
    DepthType srcDepth, int srcChannels,
    DepthType dstDepth, int dstChannels,
    IInputArray kernel,
    System.Drawing.Point anchor,
    CvEnum.BorderType borderType = BorderType.Default, MCvScalar borderValue = new MCvScalar())
 {
    using (InputArray iaKernel = kernel.GetInputArray())
       _ptr = CudaInvoke.cudaCreateLinearFilter(
          CvInvoke.MakeType(srcDepth, srcChannels), CvInvoke.MakeType(dstDepth, dstChannels),
          iaKernel, ref anchor, borderType, ref borderValue);
 }
Example #33
0
 /// <summary>
 /// Create a GpuMat of the specified size
 /// </summary>
 /// <param name="rows">The number of rows (height)</param>
 /// <param name="cols">The number of columns (width)</param>
 /// <param name="channels">The number of channels</param>
 /// <param name="depthType">The type of depth</param>
 /// <param name="continuous">Indicates if the data should be continuous</param>
 public GpuMat(int rows, int cols, DepthType depthType, int channels, bool continuous = false)
     : this(
         continuous ?
         CudaInvoke.gpuMatCreateContinuous(rows, cols, CvInvoke.MakeType(depthType, channels))
       : CudaInvoke.gpuMatCreateDefault(),
         true)
 {
     if (!continuous)
     {
         Create(rows, cols, depthType, channels);
     }
 }
 /// <summary>
 /// Create the Cuda implementation of GoodFeaturesToTrackDetector
 /// </summary>
 /// <param name="srcDepth">The depth of the src image</param>
 /// <param name="srcChannels">The number of channels in the src image</param>
 /// <param name="maxCorners">The maximum number of channels</param>
 /// <param name="qualityLevel">The quality level</param>
 /// <param name="minDistance">The minimum distance</param>
 /// <param name="blockSize">The block size</param>
 /// <param name="useHarrisDetector">If true, use Harris detector</param>
 /// <param name="harrisK">Harris K</param>
 public CudaGoodFeaturesToTrackDetector(
     DepthType srcDepth,
     int srcChannels,
     int maxCorners         = 1000,
     double qualityLevel    = 0.01,
     double minDistance     = 0,
     int blockSize          = 3,
     bool useHarrisDetector = false,
     double harrisK         = 0.04)
 {
     _ptr = CudaInvoke.cudaGoodFeaturesToTrackDetectorCreate(CvInvoke.MakeType(srcDepth, srcChannels), maxCorners, qualityLevel, minDistance, blockSize, useHarrisDetector, harrisK, ref _sharedPtr);
 }
 /// <summary>
 /// Create a SeparableLinearFilter
 /// </summary>
 /// <param name="srcDepth">Source array depth</param>
 /// <param name="srcChannels">Source array channels</param>
 /// <param name="dstDepth">Destination array depth</param>
 /// <param name="dstChannels">Destination array channels</param>
 /// <param name="rowKernel">Horizontal filter coefficients. Support kernels with size &lt;= 32 .</param>
 /// <param name="columnKernel">Vertical filter coefficients. Support kernels with size &lt;= 32 .</param>
 /// <param name="anchor">Anchor position within the kernel. Negative values mean that anchor is positioned at the aperture center.</param>
 /// <param name="rowBorderType">Pixel extrapolation method in the vertical direction</param>
 /// <param name="columnBorderType">Pixel extrapolation method in the horizontal direction</param>
 public SeparableLinearFilter(
     DepthType srcDepth, int srcChannels,
     DepthType dstDepth, int dstChannels,
     IInputArray rowKernel,
     IInputArray columnKernel,
     Point anchor,
     CvEnum.BorderType rowBorderType    = BorderType.Default,
     CvEnum.BorderType columnBorderType = BorderType.Default)
 {
     using (InputArray iaRowKernel = rowKernel.GetInputArray())
         using (InputArray iaColumnKernel = columnKernel.GetInputArray())
             _ptr = CudaInvoke.cudaCreateSeparableLinearFilter(CvInvoke.MakeType(srcDepth, srcChannels), CvInvoke.MakeType(dstDepth, dstChannels), iaRowKernel, iaColumnKernel, ref anchor, rowBorderType, columnBorderType, ref _sharedPtr);
 }
Example #36
0
        /// <summary>
        /// Gets a list of items in the specified <paramref name="path"/>.
        /// </summary>
        /// <param name="path">Path of which the contents will be listed.</param>
        /// <param name="revision">Revision to list.</param>
        /// <param name="depth">Desired depth of the listings.</param>
        /// <returns></returns>
        public List <SvnItem> List(SvnPath path, Revision revision, DepthType depth)
        {
            List <SvnItem>    result  = new List <SvnItem>();
            SvnItem           item    = null;
            SvnCommandOptions options = _defaultOptions.Clone();

            options.Depth    = depth;
            options.Revision = revision;
            options.Paths.Add(path);

            XmlReader xReader = _command.GetXmlReader("list", options);

            while (xReader.Read())
            {
                if (xReader.NodeType == XmlNodeType.EndElement)
                {
                    continue;
                }
                switch (xReader.Name.ToLower())
                {
                case "entry":
                    item = new SvnItem();
                    result.Add(item);
                    item.Type   = GetItemType(xReader.GetAttribute("kind"));
                    item.Commit = new SvnCommit();
                    break;

                case "name":
                    item.Name = xReader.ReadString();
                    break;

                case "size":
                    item.Size = xReader.ReadElementContentAsInt();
                    break;

                case "commit":
                    item.Commit.Revision = int.Parse(xReader.GetAttribute("revision"));
                    break;

                case "author":
                    item.Commit.Author = xReader.ReadString();
                    break;

                case "date":
                    item.Commit.Date = xReader.ReadElementContentAsDateTime();
                    break;
                }
            }

            return(result);
        }
Example #37
0
        /*
         * /// <summary>
         * /// Convert this Mat to UMat
         * /// </summary>
         * /// <param name="access">Access type</param>
         * /// <returns>The UMat</returns>
         * public Mat ToMat(CvEnum.AccessType access)
         * {
         * return new Mat(UMatInvoke.cvUMatGetMat(Ptr, access), true);
         * }*/

        ///<summary>
        ///Split current Image into an array of gray scale images where each element
        ///in the array represent a single color channel of the original image
        ///</summary>
        ///<returns>
        ///An array of gray scale images where each element
        ///in the array represent a single color channel of the original image
        ///</returns>
        public UMat[] Split()
        {
            UMat[]    mats = new UMat[NumberOfChannels];
            Size      s    = this.Size;
            DepthType d    = this.Depth;

            for (int i = 0; i < mats.Length; i++)
            {
                mats[i] = new UMat(s, d, 1);
            }
            using (VectorOfUMat vm = new VectorOfUMat(mats))
            {
                CvInvoke.Split(this, vm);
            }
            return(mats);
        }
Example #38
0
        static byte[] ConvertTo <T>(this Mat mat, T value)
        {
            byte[]    buffer;
            DepthType depth = mat.Depth;

            if (depth == DepthType.Cv8S)
            {
                buffer    = new byte[mat.ElementSize];
                buffer[0] = (byte)Convert.ChangeType(value, typeof(sbyte));
            }
            else if (depth == DepthType.Cv8U)
            {
                buffer    = new byte[mat.ElementSize];
                buffer[0] = (byte)Convert.ChangeType(value, typeof(byte));
            }
            else if (depth == DepthType.Cv16S)
            {
                short tmp = (short)Convert.ChangeType(value, typeof(short));
                buffer = BitConverter.GetBytes(tmp);
            }
            else if (depth == DepthType.Cv16U)
            {
                ushort tmp = (ushort)Convert.ChangeType(value, typeof(ushort));
                buffer = BitConverter.GetBytes(tmp);
            }
            else if (depth == DepthType.Cv32S)
            {
                int tmp = (int)Convert.ChangeType(value, typeof(int));
                buffer = BitConverter.GetBytes(tmp);
            }
            else if (depth == DepthType.Cv64F)
            {
                double tmp = (double)Convert.ChangeType(value, typeof(double));
                buffer = BitConverter.GetBytes(tmp);
            }
            else
            {
                //if (depthType == DepthType.Cv32F) {
                float tmp = (float)Convert.ChangeType(value, typeof(float));
                buffer = BitConverter.GetBytes(tmp);
            }
            return(buffer);
        }
Example #39
0
        /// <summary>
        /// 将矩阵转化为相应类型的数组
        /// </summary>
        /// <returns>数组结果</returns>
        public dynamic ToArray()
        {
            DepthType depthType = this.Depth;
            int       length    = this.Rows * this.Cols;
            dynamic   arr;

            if (depthType == DepthType.Cv8S)
            {
                arr = new sbyte[length];
                this.CopyTo <sbyte>(arr);
            }
            else if (depthType == DepthType.Cv8U)
            {
                arr = new byte[length];
                this.CopyTo <byte>(arr);
            }
            else if (depthType == DepthType.Cv16S)
            {
                arr = new short[length];
                this.CopyTo <short>(arr);
            }
            else if (depthType == DepthType.Cv16U)
            {
                arr = new ushort[length];
                this.CopyTo <ushort>(arr);
            }
            else if (depthType == DepthType.Cv32S)
            {
                arr = new int[length];
                this.CopyTo <int>(arr);
            }
            else if (depthType == DepthType.Cv64F)
            {
                arr = new double[length];
                this.CopyTo <double>(arr);
            }
            else
            {
                arr = new float[length];
                this.CopyTo <float>(arr);
            }
            return(arr);
        }
Example #40
0
 public Mat(int rows, int cols, DepthType type, int channels, IntPtr data, int step)
     : this(CvInvoke.cveMatCreateWithData(rows, cols, CvInvoke.MakeType(type, channels), data, new IntPtr(step)), true)
 {
 }
Example #41
0
 private static extern void cveBoxFilter(
    IntPtr src, IntPtr dst, DepthType ddepth, ref Size ksize, ref Point anchor,
    [MarshalAs(CvInvoke.BoolMarshalType)]
    bool normailize, CvEnum.BorderType borderType);
Example #42
0
 /// <summary>
 /// Blurs an image using the box filter.
 /// </summary>
 /// <param name="src">Input image.</param>
 /// <param name="dst">Output image of the same size and type as src.</param>
 /// <param name="ddepth">The output image depth (-1 to use src.depth()).</param>
 /// <param name="ksize">Blurring kernel size.</param>
 /// <param name="anchor">Anchor point; default value Point(-1,-1) means that the anchor is at the kernel center.</param>
 /// <param name="normalize">Specifying whether the kernel is normalized by its area or not.</param>
 /// <param name="borderType">Border mode used to extrapolate pixels outside of the image.</param>
 public static void BoxFilter(IInputArray src, IOutputArray dst, DepthType ddepth, Size ksize, Point anchor,
    bool normalize = true, CvEnum.BorderType borderType = BorderType.Default)
 {
    using (InputArray iaSrc = src.GetInputArray())
    using (OutputArray oaDst = dst.GetOutputArray())
       cveBoxFilter(iaSrc, oaDst, ddepth, ref ksize, ref anchor, normalize, borderType);
 }
Example #43
0
 private static extern void cveGetRectSubPix(IntPtr image, ref Size patchSize, ref PointF center, IntPtr patch, DepthType patchType);
Example #44
0
 private static extern void cudaDivide(IntPtr a, IntPtr b, IntPtr c, double scale, DepthType depthType, IntPtr stream);
Example #45
0
 private static extern int cveConnectedComponents(IntPtr image, IntPtr labels, CvEnum.LineType connectivity, DepthType labelType);
Example #46
0
 /// <summary>
 /// Create a BoxMin filter.
 /// </summary>
 /// <param name="ksize">Size of the kernel</param>
 /// <param name="anchor">The center of the kernel. User (-1, -1) for the default kernel center.</param>
 /// <param name="borderType">The border type.</param>
 /// <param name="borderValue">The border value.</param>
 /// <param name="srcDepth">The depth of the source image</param>
 /// <param name="srcChannels">The number of channels in the source image</param>
 public CudaBoxMinFilter(DepthType srcDepth, int srcChannels, Size ksize, Point anchor, CvEnum.BorderType borderType = BorderType.Default, MCvScalar borderValue = new MCvScalar())
 {
    _ptr = CudaInvoke.cudaCreateBoxMinFilter(CvInvoke.MakeType(srcDepth, srcChannels), ref ksize, ref anchor, borderType, ref borderValue);
 }
Example #47
0
 internal static extern void cveDTFilterFilter(IntPtr filter, IntPtr src, IntPtr dst, DepthType dDepth);
Example #48
0
 /// <summary>
 /// Subtracts one matrix from another (c = a - b).
 /// </summary>
 /// <param name="a">The matrix where subtraction take place</param>
 /// <param name="b">The matrix to be substracted</param>
 /// <param name="c">The result of a - b</param>
 /// <param name="mask">The optional mask that is used to select a subarray. Use null if not needed</param>
 /// <param name="stream">Use a Stream to call the function asynchronously (non-blocking) or null to call the function synchronously (blocking).</param>
 public static void Subtract(IInputArray a, IInputArray b, IOutputArray c, IInputArray mask = null, DepthType depthType = DepthType.Default, Stream stream = null)
 {
    using (InputArray iaA = a.GetInputArray())
    using (InputArray iaB = b.GetInputArray())
    using (OutputArray oaC = c.GetOutputArray())
    using (InputArray iaMask = mask == null ? InputArray.GetEmpty() : mask.GetInputArray())
       cudaSubtract(iaA, iaB, oaC, iaMask, depthType, stream);
 }
Example #49
0
 private static extern void cudaSubtract(IntPtr a, IntPtr b, IntPtr c, IntPtr mask, DepthType depthType, IntPtr stream);
Example #50
0
 private static extern void cudaReduce(IntPtr mtx, IntPtr vec, CvEnum.ReduceDimension dim, CvEnum.ReduceType reduceOp, DepthType dType, IntPtr stream);
Example #51
0
 /// <summary>
 /// Reduces GpuMat to a vector by treating the GpuMat rows/columns as a set of 1D vectors and performing the specified operation on the vectors until a single row/column is obtained. 
 /// </summary>
 /// <param name="mtx">The input GpuMat</param>
 /// <param name="vec">The destination GpuMat. Must be preallocated 1 x n matrix and have the same number of channels as the input GpuMat</param>
 /// <param name="dim">The dimension index along which the matrix is reduce.</param>
 /// <param name="reduceOp">The reduction operation type</param>
 /// <param name="stream">Use a Stream to call the function asynchronously (non-blocking) or null to call the function synchronously (blocking).</param>      
 public static void Reduce(IInputArray mtx, IOutputArray vec, CvEnum.ReduceDimension dim, CvEnum.ReduceType reduceOp, DepthType dType = DepthType.Default, Stream stream = null)
 {
    using (InputArray iaMtx = mtx.GetInputArray())
    using (OutputArray oaVec = vec.GetOutputArray())
       cudaReduce(iaMtx, oaVec, dim, reduceOp, dType, stream);
 }
Example #52
0
 private static extern void cudaAddWeighted(IntPtr src1, double alpha, IntPtr src2, double beta, double gamma, IntPtr dst, DepthType depthType, IntPtr stream);
Example #53
0
 /// <summary>
 /// Computes the weighted sum of two arrays (dst = alpha*src1 + beta*src2 + gamma)
 /// </summary>
 /// <param name="src1">The first source GpuMat</param>
 /// <param name="alpha">The weight for <paramref name="src1"/></param>
 /// <param name="src2">The second source GpuMat</param>
 /// <param name="beta">The weight for <paramref name="src2"/></param>
 /// <param name="gamma">The constant to be added</param>
 /// <param name="dst">The result</param>
 /// <param name="stream">Use a Stream to call the function asynchronously (non-blocking) or null to call the function synchronously (blocking).</param>
 public static void AddWeighted(IInputArray src1, double alpha, IInputArray src2, double beta, double gamma, IOutputArray dst, DepthType depthType = DepthType.Default, Stream stream = null)
 {
    using (InputArray iaSrc1 = src1.GetInputArray())
    using (InputArray iaSrc2 = src2.GetInputArray())
    using (OutputArray oaDst = dst.GetOutputArray())
       cudaAddWeighted(iaSrc1, alpha, iaSrc2, beta, gamma, oaDst, depthType, stream);
 }
Example #54
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="rows"></param>
 /// <param name="cols"></param>
 /// <param name="depthType"></param>
 /// <param name="channels"></param>
 public Mat(int rows, int cols, DepthType depthType, int channels)
     : this()
 {
     Create(rows, cols, depthType, channels);
 }
Example #55
0
 private static extern int cveConnectedComponentsWithStats(IntPtr image, IntPtr labels, IntPtr stats, IntPtr centroids, CvEnum.LineType connectivity, DepthType type);
Example #56
0
 /// <summary>
 /// Convert the DepthType to a string that represent the OpenCL value type.
 /// </summary>
 /// <param name="depthType">The depth type</param>
 /// <param name="channels">The number of channels</param>
 /// <returns>A string the repsent the OpenCL value type</returns>
 public static String TypeToString(DepthType depthType, int channels = 1)
 {
    using (CvString str = new CvString())
    {
       oclTypeToString(CvInvoke.MakeType(depthType, channels), str);
       return str.ToString();
    }
 }
Example #57
0
 /// <summary>
 /// Computes the connected components labeled image of boolean image
 /// </summary>
 /// <param name="image">The boolean image</param>
 /// <param name="labels">The connected components labeled image of boolean image</param>
 /// <param name="stats">Statistics output for each label, including the background label, see below for available statistics. Statistics are accessed via stats(label, COLUMN) where COLUMN is one of cv::ConnectedComponentsTypes. The data type is CV_32S</param>
 /// <param name="centroids">Centroid output for each label, including the background label. Centroids are accessed via centroids(label, 0) for x and centroids(label, 1) for y. The data type CV_64F.</param>
 /// <param name="connectivity">4 or 8 way connectivity</param>
 /// <param name="labelType">Specifies the output label image type, an important consideration based on the total number of labels or alternatively the total number of pixels in the source image</param>
 /// <returns>N, the total number of labels [0, N-1] where 0 represents the background label.</returns>
 public static int ConnectedComponentsWithStats(IInputArray image, IOutputArray labels, IOutputArray stats,
    IOutputArray centroids, CvEnum.LineType connectivity = LineType.EightConnected, DepthType labelType = DepthType.Cv32S)
 {
    using (InputArray iaImage = image.GetInputArray())
    using (OutputArray oaLabels = labels.GetOutputArray())
    using (OutputArray oaStats = stats.GetOutputArray())
    using (OutputArray oaCentroids = centroids.GetOutputArray())
    {
       return cveConnectedComponentsWithStats(iaImage, oaLabels, oaStats, oaCentroids, connectivity, labelType);
    }
 }
Example #58
0
 private static extern void cveGuidedFilter(IntPtr guide, IntPtr src, IntPtr dst, int radius, double eps, DepthType dDepth);
Example #59
0
 public void Create(int rows, int cols, DepthType depthType, int channels)
 {
     int matType = CvInvoke.MakeType(depthType, channels);
     CvInvoke.cveMatCreateData(InnerPointer, rows, cols, matType);
 }
Example #60
0
 /// <summary>
 /// Computes element-wise quotient of the two GpuMat (c = scale *  a / b).
 /// </summary>
 /// <param name="a">The first GpuMat</param>
 /// <param name="b">The second GpuMat</param>
 /// <param name="c">The element-wise quotient of the two GpuMat</param>
 /// <param name="scale">The scale</param>
 /// <param name="stream">Use a Stream to call the function asynchronously (non-blocking) or null to call the function synchronously (blocking).</param>
 public static void Divide(IInputArray a, IInputArray b, IOutputArray c, double scale = 1.0, DepthType depthType = DepthType.Default, Stream stream = null)
 {
    using (InputArray iaA = a.GetInputArray())
    using (InputArray iaB = b.GetInputArray())
    using (OutputArray oaC = c.GetOutputArray())
       cudaDivide(iaA, iaB, oaC, scale, depthType, stream);
 }