當前位置: 首頁>>代碼示例>>Java>>正文


Java Imgproc.HoughLinesP方法代碼示例

本文整理匯總了Java中org.opencv.imgproc.Imgproc.HoughLinesP方法的典型用法代碼示例。如果您正苦於以下問題:Java Imgproc.HoughLinesP方法的具體用法?Java Imgproc.HoughLinesP怎麽用?Java Imgproc.HoughLinesP使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.opencv.imgproc.Imgproc的用法示例。


在下文中一共展示了Imgproc.HoughLinesP方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: HoughLines

import org.opencv.imgproc.Imgproc; //導入方法依賴的package包/類
void HoughLines() {

        Mat grayMat = new Mat();
        Mat cannyEdges = new Mat();
        Mat lines = new Mat();

        //Converting the image to grayscale
        Imgproc.cvtColor(originalMat, grayMat, Imgproc.COLOR_BGR2GRAY);

        Imgproc.Canny(grayMat, cannyEdges, 10, 100);

        Imgproc.HoughLinesP(cannyEdges, lines, 1, Math.PI / 180, 50, 20, 20);

        Mat houghLines = new Mat();
        houghLines.create(cannyEdges.rows(), cannyEdges.cols(), CvType.CV_8UC1);

        //Drawing lines on the image
        for (int i = 0; i < lines.cols(); i++) {
            double[] points = lines.get(0, i);
            double x1, y1, x2, y2;

            x1 = points[0];
            y1 = points[1];
            x2 = points[2];
            y2 = points[3];

            Point pt1 = new Point(x1, y1);
            Point pt2 = new Point(x2, y2);

            //Drawing lines on an image
            Imgproc.line(houghLines, pt1, pt2, new Scalar(255, 0, 0), 1);
        }

        //Converting Mat back to Bitmap
        Utils.matToBitmap(houghLines, currentBitmap);
        imageView.setImageBitmap(currentBitmap);

    }
 
開發者ID:johnhany,項目名稱:MOAAP,代碼行數:39,代碼來源:MainActivity.java

示例2: HoughLines

import org.opencv.imgproc.Imgproc; //導入方法依賴的package包/類
public Mat HoughLines(Mat image) {
    Mat grayMat = new Mat();
    Mat cannyEdges = new Mat();
    Mat lines = new Mat();

    Imgproc.cvtColor(image, grayMat, Imgproc.COLOR_RGB2GRAY);

    Imgproc.Canny(grayMat, cannyEdges, 10, 100);

    Imgproc.HoughLinesP(cannyEdges, lines, 1, Math.PI/180, 50,20,20);

    return lines;

}
 
開發者ID:jocstech,項目名稱:AndroidCameraSudokuSolver,代碼行數:15,代碼來源:GridRecognizer.java


注:本文中的org.opencv.imgproc.Imgproc.HoughLinesP方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。