Browse Source

Add another Canny overload (issue #142)

pull/143/head
Linquize 7 years ago
parent
commit
dde3980d05
  1. 5
      Emgu.CV.Extern/imgproc/imgproc_c.cpp
  2. 1
      Emgu.CV.Extern/imgproc/imgproc_c.h
  3. 27
      Emgu.CV/PInvoke/CvInvokeImgproc.cs

5
Emgu.CV.Extern/imgproc/imgproc_c.cpp

@ -111,6 +111,11 @@ void cveCanny(cv::_InputArray* image, cv::_OutputArray* edges, double threshold1
cv::Canny(*image, *edges, threshold1, threshold2, apertureSize, L2gradient);
}
void cveCanny2(cv::_InputArray* dx, cv::_InputArray* dy, cv::_OutputArray* edges, double threshold1, double threshold2, bool L2gradient)
{
cv::Canny(*dx, *dy, *edges, threshold1, threshold2, L2gradient);
}
void cveCornerHarris(cv::_InputArray* src, cv::_OutputArray* dst, int blockSize, int ksize, double k, int borderType)
{
cv::cornerHarris(*src, *dst, blockSize, ksize, k, borderType);

1
Emgu.CV.Extern/imgproc/imgproc_c.h

@ -44,6 +44,7 @@ CVAPI(void) cvePyrDown(cv::_InputArray* src, cv::_OutputArray* dst, CvSize* size
CVAPI(void) cveBuildPyramid(cv::_InputArray* src, cv::_OutputArray* dst, int maxlevel, int borderType);
CVAPI(void) cveCanny(cv::_InputArray* image, cv::_OutputArray* edges, double threshold1, double threshold2, int apertureSize, bool L2gradient);
CVAPI(void) cveCanny2(cv::_InputArray* dx, cv::_InputArray* dy, cv::_OutputArray* edges, double threshold1, double threshold2, bool L2gradient);
CVAPI(void) cveCornerHarris(cv::_InputArray* src, cv::_OutputArray* dst, int blockSize, int ksize, double k, int borderType);
CVAPI(double) cveThreshold(cv::_InputArray* src, cv::_OutputArray* dst, double thresh, double maxval, int type);
CVAPI(void) cveWatershed(cv::_InputArray* image, cv::_InputOutputArray* markers);

27
Emgu.CV/PInvoke/CvInvokeImgproc.cs

@ -1021,6 +1021,33 @@ namespace Emgu.CV
[MarshalAs(CvInvoke.BoolMarshalType)]
bool l2Gradient);
/// <summary>
/// Finds the edges on the input <paramref name="dx"/>, <paramref name="dy"/> and marks them in the output image edges using the Canny algorithm. The smallest of threshold1 and threshold2 is used for edge linking, the largest - to find initial segments of strong edges.
/// </summary>
/// <param name="dx">16-bit x derivative of input image</param>
/// <param name="dy">16-bit y derivative of input image</param>
/// <param name="edges">Image to store the edges found by the function</param>
/// <param name="threshold1">The first threshold</param>
/// <param name="threshold2">The second threshold.</param>
///<param name="l2Gradient">a flag, indicating whether a more accurate norm should be used to calculate the image gradient magnitude ( L2gradient=true ), or whether the default norm is enough ( L2gradient=false ).</param>
public static void Canny(
IInputArray dx,
IInputArray dy,
IOutputArray edges,
double threshold1,
double threshold2,
bool l2Gradient = false)
{
using (InputArray iax = dx.GetInputArray())
using (InputArray iay = dy.GetInputArray())
using (OutputArray oaEdges = edges.GetOutputArray())
cveCanny2(iax, iay, oaEdges, threshold1, threshold2, l2Gradient);
}
[DllImport(ExternLibrary, CallingConvention = CvInvoke.CvCallingConvention)]
private static extern void cveCanny2(IntPtr dx, IntPtr dy, IntPtr edges, double threshold1, double threshold2,
[MarshalAs(CvInvoke.BoolMarshalType)]
bool l2Gradient);
/// <summary>
/// The function tests whether the input contour is convex or not. The contour must be simple, that is, without self-intersections. Otherwise, the function output is undefined.
/// </summary>

Loading…
Cancel
Save