Browse Source

Added Weighted Hough Transform

pull/768/merge
Canming Huang 5 months ago
parent
commit
d3cc5260b9
  1. 17
      Emgu.CV.Extern/imgproc/imgproc_c.cpp
  2. 13
      Emgu.CV.Extern/imgproc/imgproc_c.h
  3. 9
      Emgu.CV/Core/Image.cs
  4. 47
      Emgu.CV/PInvoke/CvInvokeImgproc.cs

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

@ -261,9 +261,20 @@ void cveHoughCircles(cv::_InputArray* image, cv::_OutputArray* circles, int meth
{
cv::HoughCircles(*image, *circles, method, dp, minDist, param1, param2, minRadius, maxRadius);
}
void cveHoughLines(cv::_InputArray* image, cv::_OutputArray* lines, double rho, double theta, int threshold, double srn, double stn)
{
cv::HoughLines(*image, *lines, rho, theta, threshold, srn, stn);
void cveHoughLines(
cv::_InputArray* image,
cv::_OutputArray* lines,
double rho,
double theta,
int threshold,
double srn,
double stn,
double minTheta,
double maxTheta,
bool useEdgeVal
)
{
cv::HoughLines(*image, *lines, rho, theta, threshold, srn, stn, minTheta, maxTheta, useEdgeVal);
}
void cveHoughLinesP(cv::_InputArray* image, cv::_OutputArray* lines, double rho, double theta, int threshold, double minLineLength, double maxGap)
{

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

@ -81,7 +81,18 @@ CVAPI(void) cveLinearPolar(cv::_InputArray* src, cv::_OutputArray* dst, CvPoint2
CVAPI(void) cveRemap(cv::_InputArray* src, cv::_OutputArray* dst, cv::_InputArray* map1, cv::_InputArray* map2, int interpolation, int borderMode, CvScalar* borderValue);
CVAPI(void) cveRepeat(cv::_InputArray* src, int ny, int nx, cv::_OutputArray* dst);
CVAPI(void) cveHoughCircles(cv::_InputArray* image, cv::_OutputArray* circles, int method, double dp, double minDist, double param1, double param2, int minRadius, int maxRadius);
CVAPI(void) cveHoughLines(cv::_InputArray* image, cv::_OutputArray* lines, double rho, double theta, int threshold, double srn, double stn);
CVAPI(void) cveHoughLines(
cv::_InputArray* image,
cv::_OutputArray* lines,
double rho,
double theta,
int threshold,
double srn,
double stn,
double minTheta,
double maxTheta,
bool useEdgeVal
);
CVAPI(void) cveHoughLinesP(cv::_InputArray* image, cv::_OutputArray* lines, double rho, double theta, int threshold, double minLineLength, double maxGap);
CVAPI(void) cveMatchTemplate(cv::_InputArray* image, cv::_InputArray* templ, cv::_OutputArray* result, int method, cv::_InputArray* mask);

9
Emgu.CV/Core/Image.cs

@ -856,7 +856,14 @@ namespace Emgu.CV
/// <param name="minLineWidth">Minimum width of a line</param>
/// <param name="gapBetweenLines">Minimum gap between lines</param>
/// <returns>The line segments detected for each of the channels</returns>
public LineSegment2D[][] HoughLines(double cannyThreshold, double cannyThresholdLinking, double rhoResolution, double thetaResolution, int threshold, double minLineWidth, double gapBetweenLines)
public LineSegment2D[][] HoughLines(
double cannyThreshold,
double cannyThresholdLinking,
double rhoResolution,
double thetaResolution,
int threshold,
double minLineWidth,
double gapBetweenLines)
{
using (Image<Gray, Byte> canny = Canny(cannyThreshold, cannyThresholdLinking))
{

47
Emgu.CV/PInvoke/CvInvokeImgproc.cs

@ -1752,15 +1752,50 @@ namespace Emgu.CV
/// <param name="theta">Angle resolution of the accumulator in radians.</param>
/// <param name="threshold">Accumulator threshold parameter. Only those lines are returned that get enough votes (&gt; threshold)</param>
/// <param name="srn">For the multi-scale Hough transform, it is a divisor for the distance resolution rho . The coarse accumulator distance resolution is rho and the accurate accumulator resolution is rho/srn . If both srn=0 and stn=0 , the classical Hough transform is used. Otherwise, both these parameters should be positive.</param>
/// <param name="stn"> For the multi-scale Hough transform, it is a divisor for the distance resolution theta</param>
public static void HoughLines(IInputArray image, IOutputArray lines, double rho, double theta, int threshold, double srn = 0, double stn = 0)
/// <param name="stn">For the multi-scale Hough transform, it is a divisor for the distance resolution theta</param>
/// <param name="minTheta">For standard and multi-scale Hough transform, minimum angle to check for lines. Must fall between 0 and max_theta.</param>
/// <param name="maxTheta">For standard and multi-scale Hough transform, an upper bound for the angle. Must fall between min_theta and CV_PI. The actual maximum angle in the accumulator may be slightly less than max_theta, depending on the parameters min_theta and theta.</param>
/// <param name="useEdgeVal">True if you want to use weighted Hough transform.</param>
public static void HoughLines(
IInputArray image,
IOutputArray lines,
double rho,
double theta,
int threshold,
double srn = 0,
double stn = 0,
double minTheta = 0,
double maxTheta = Math.PI,
bool useEdgeVal = false
)
{
using (InputArray iaImage = image.GetInputArray())
using (OutputArray oaLines = lines.GetOutputArray())
cveHoughLines(iaImage, oaLines, rho, theta, threshold, srn, stn);
}
[DllImport(ExternLibrary, CallingConvention = CvInvoke.CvCallingConvention)]
private static extern void cveHoughLines(IntPtr image, IntPtr lines, double rho, double theta, int threshold, double srn, double stn);
cveHoughLines(
iaImage,
oaLines,
rho,
theta,
threshold,
srn,
stn,
minTheta,
maxTheta,
useEdgeVal);
}
[DllImport(ExternLibrary, CallingConvention = CvInvoke.CvCallingConvention)]
private static extern void cveHoughLines(
IntPtr image,
IntPtr lines,
double rho,
double theta,
int threshold,
double srn,
double stn,
double minTheta,
double maxTheta,
[MarshalAs(CvInvoke.BoolMarshalType)]
bool useEdgeVal);
/// <summary>
/// Finds line segments in a binary image using the probabilistic Hough transform.

Loading…
Cancel
Save