/// <summary> /// Computes a proximity map for a raster template and an image where the template is searched for. /// </summary> /// <param name="image">Source image. CV_32F and CV_8U depth images (1..4 channels) are supported for now.</param> /// <param name="templ">Template image with the size and type the same as image.</param> /// <param name="result">Map containing comparison results (CV_32FC1). If image is W x H and templ is w x h, then result must be W-w+1 x H-h+1.</param> /// <param name="method">Specifies the way to compare the template with the image.</param> /// <param name="stream">Stream for the asynchronous version.</param> public static void MatchTemplate( GpuMat image, GpuMat templ, GpuMat result, MatchTemplateMethod method, Stream stream = null) { ThrowIfGpuNotAvailable(); if (image == null) { throw new ArgumentNullException(nameof(image)); } if (templ == null) { throw new ArgumentNullException(nameof(templ)); } if (result == null) { throw new ArgumentNullException(nameof(result)); } image.ThrowIfDisposed(); templ.ThrowIfDisposed(); result.ThrowIfDisposed(); NativeMethods.gpu_matchTemplate1( image.CvPtr, templ.CvPtr, result.CvPtr, (int)method, Cv2.ToPtr(stream)); }
/// <summary> /// Computes the proximity map for the raster template and the image where the template is searched for /// The input is Image where the search is running; should be 8-bit or 32-bit floating-point. /// </summary> /// <param name="templ">Searched template; must be not greater than the source image and have the same data type</param> /// <param name="method">Specifies the comparison method</param> /// <returns>A map of comparison results; will be single-channel 32-bit floating-point. /// If image is WxH and templ is wxh then result will be (W-w+1) x (H-h+1).</returns> public Mat MatchTemplate(InputArray templ, MatchTemplateMethod method) { var dst = new Mat(); Cv2.MatchTemplate(this, templ, dst, method); return dst; }
/// <summary> /// Computes the proximity map for the raster template and the image where the template is searched for /// </summary> /// <param name="image">Image where the search is running; should be 8-bit or 32-bit floating-point</param> /// <param name="templ">Searched template; must be not greater than the source image and have the same data type</param> /// <param name="result">A map of comparison results; will be single-channel 32-bit floating-point. /// If image is WxH and templ is wxh then result will be (W-w+1) x (H-h+1).</param> /// <param name="method">Specifies the comparison method</param> public static void MatchTemplate(InputArray image, InputArray templ, OutputArray result, MatchTemplateMethod method) { if (image == null) throw new ArgumentNullException("image"); if (templ == null) throw new ArgumentNullException("templ"); if (result == null) throw new ArgumentNullException("result"); image.ThrowIfDisposed(); templ.ThrowIfDisposed(); result.ThrowIfNotReady(); NativeMethods.imgproc_matchTemplate(image.CvPtr, templ.CvPtr, result.CvPtr, (int)method); result.Fix(); }
/// <summary> /// Computes a proximity map for a raster template and an image where the template is searched for. /// </summary> /// <param name="image">Source image. CV_32F and CV_8U depth images (1..4 channels) are supported for now.</param> /// <param name="templ">Template image with the size and type the same as image.</param> /// <param name="result">Map containing comparison results (CV_32FC1). If image is W x H and templ is w x h, then result must be W-w+1 x H-h+1.</param> /// <param name="method">Specifies the way to compare the template with the image.</param> /// <param name="stream">Stream for the asynchronous version.</param> public static void MatchTemplate( GpuMat image, GpuMat templ, GpuMat result, MatchTemplateMethod method, Stream stream = null) { ThrowIfGpuNotAvailable(); if (image == null) throw new ArgumentNullException("image"); if (templ == null) throw new ArgumentNullException("templ"); if (result == null) throw new ArgumentNullException("result"); image.ThrowIfDisposed(); templ.ThrowIfDisposed(); result.ThrowIfDisposed(); NativeMethods.gpu_matchTemplate1( image.CvPtr, templ.CvPtr, result.CvPtr, (int)method, Cv2.ToPtr(stream)); }