org.opencv.imgproc.Imgproc.Canny()方法的使用及代码示例

x33g5p2x  于2022-01-21 转载在 其他  
字(3.9k)|赞(0)|评价(0)|浏览(327)

本文整理了Java中org.opencv.imgproc.Imgproc.Canny()方法的一些代码示例,展示了Imgproc.Canny()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Imgproc.Canny()方法的具体详情如下:
包路径:org.opencv.imgproc.Imgproc
类名称:Imgproc
方法名:Canny

Imgproc.Canny介绍

[英]Finds edges in an image using the [Canny86] algorithm.

The function finds edges in the input image image and marks them in the output map edges using the Canny algorithm. The smallest value between threshold1 and threshold2 is used for edge linking. The largest value is used to find initial segments of strong edges. See http://en.wikipedia.org/wiki/Canny_edge_detector

Note:

  • An example on using the canny edge detector can be found at opencv_source_code/samples/cpp/edge.cpp
  • (Python) An example on using the canny edge detector can be found at opencv_source_code/samples/python/edge.py
    [中]使用[Canny 86]算法查找图像中的边缘。
    函数在输入图像image中查找边,并使用Canny算法在输出贴图edges中标记它们。threshold1threshold2之间的最小值用于边缘链接。最大值用于查找强边的初始分段。看见http://en.wikipedia.org/wiki/Canny_edge_detector
    注:
    *使用canny边缘检测器的示例可以在opencv_源代码/samples/cpp/edge中找到。cpp
    *(Python)可以在opencv_source_code/samples/Python/edge上找到使用canny边缘检测器的示例。派克

代码示例

代码示例来源:origin: RaiMan/SikuliX2

public static Mat detectEdges(Mat mSource) {
 Mat mSourceGray = Element.getNewMat();
 Mat mDetectedEdges = Element.getNewMat();
 int edgeThresh = 1;
 int lowThreshold = 100;
 int ratio = 3;
 int kernelSize = 5;
 int blurFilterSize = 3;
 if (mSource.channels() == 1) {
  mSourceGray = mSource;
 } else {
  Imgproc.cvtColor(mSource, mSourceGray, toGray);
 }
 Imgproc.blur(mSourceGray, mDetectedEdges, new Size(blurFilterSize, blurFilterSize));
 Imgproc.Canny(mDetectedEdges, mDetectedEdges,
     lowThreshold, lowThreshold * ratio, kernelSize, false);
 return mDetectedEdges;
}
//</editor-fold>

代码示例来源:origin: openpnp/openpnp

@Override
  public Result process(CvPipeline pipeline) throws Exception {
    Mat mat = pipeline.getWorkingImage();
    Imgproc.Canny(mat, mat, threshold1, threshold2);
    return null;
  }
}

代码示例来源:origin: openpnp/openpnp

public FluentCv findEdgesCanny(double threshold1, double threshold2, String... tag) {
  Imgproc.Canny(mat, mat, threshold1, threshold2);
  return store(mat, tag);
}

代码示例来源:origin: SOFTPOWER1991/OpenCVCheck

@Override
public Mat onCameraFrame(CameraBridgeViewBase.CvCameraViewFrame inputFrame) {
  mRgba = inputFrame.rgba();
  Imgproc.cvtColor(mRgba, imgGray, Imgproc.COLOR_RGB2GRAY);
  Imgproc.Canny(imgGray, imgCanny, 50, 150);
  return imgCanny;
}

代码示例来源:origin: SOFTPOWER1991/OpenCVCheck

@Override
public Mat onCameraFrame(CameraBridgeViewBase.CvCameraViewFrame inputFrame) {
  mRgba = inputFrame.rgba();
  Imgproc.cvtColor(mRgba, imgGray, Imgproc.COLOR_RGB2GRAY);
  Imgproc.Canny(imgGray, imgCanny, 50, 150);
  return imgCanny;
}

代码示例来源:origin: JavaOpenCVBook/code

protected void processOperation() {

    if(sobelString.equals(operation)){
      Imgproc.Sobel(originalImage, image, -1, xOrder,yOrder,aperture,1.0, 0.0);
//            Core.convertScaleAbs(image, image);
    }
    else if(laplaceString.equals(operation)){
      Imgproc.Laplacian(originalImage, image, -1, aperture, 1.0, 0.0);
//            Core.convertScaleAbs(image, image);
//            Imgproc.threshold(image, image, 1, 255, Imgproc.THRESH_BINARY_INV);
      
    }
    else if(cannyString.equals(operation)){
      Imgproc.Canny(originalImage, image, lowThreshold, highThreshold, aperture, false);
    }
    else if(noneString.equals(operation)){
      image = originalImage.clone();
    }

    updateView(image);
  }

代码示例来源:origin: hschott/Camdroid

protected void execute() {
  out = gray();
  Imgproc.blur(out, out, new Size(3, 3));
  Imgproc.Canny(out, out, min, max);
}

代码示例来源:origin: ytai/IOIOPlotter

Imgproc.Canny(edgesImage_, edgesImage_, high, low);
Imgproc.threshold(edgesImage_, edgesImage_, 0, 1, Imgproc.THRESH_BINARY);
Log.v(TAG, "Canny took: " + (System.currentTimeMillis() - start));

代码示例来源:origin: JavaOpenCVBook/code

protected void processOperation() {
  Imgproc.Canny(originalImage, image, 220, 255, 3, false);
  Imgproc.threshold(image, image, 100, 255, Imgproc.THRESH_BINARY_INV);
  Imgproc.distanceTransform(image, image, Imgproc.CV_DIST_L2, 3);
  image.convertTo(image, CvType.CV_8UC1);
  Core.multiply(image, new Scalar(20), image);
  
  updateView();
}

代码示例来源:origin: JavaOpenCVBook/code

Imgproc.Canny(originalImage, canny,10 , 50, aperture, false);
image = originalImage.clone();
Mat lines = new Mat();
Imgproc.Canny(originalImage, canny,10 , 50, aperture, false);

相关文章

微信公众号

最新文章

更多

Imgproc类方法