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


Java Imgproc.getPerspectiveTransform方法代碼示例

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


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

示例1: adaptativeProcess

import org.opencv.imgproc.Imgproc; //導入方法依賴的package包/類
public static Mat adaptativeProcess(Mat img){
	Mat im = new Mat();
	Imgproc.threshold(img,im,120,255,Imgproc.THRESH_TRUNC);
	im = Thresholding.adaptativeThresholding(im);
	Imgproc.medianBlur(im,im,7);
	Mat threshImg = Thresholding.InvertImageColor(im);
	Thresholding.gridDetection(threshImg);
	
		Mat mat = Mat.zeros(4,2,CvType.CV_32F);
	mat.put(0,0,0); mat.put(0,1,512);
	mat.put(1,0,0); mat.put(1,1,0);
	mat.put(2,0,512); mat.put(2,1,0);
	mat.put(3,0,512); mat.put(3,1,512);
	
	mat = Imgproc.getPerspectiveTransform(Thresholding.grid,mat);
	
	Mat M = new Mat();
	
	Imgproc.warpPerspective(threshImg,M,mat, new Size(512,512));
	
	Imgproc.medianBlur(M,M,3);
	Imgproc.threshold(M,M,254,255,Imgproc.THRESH_BINARY);
	
	return Thresholding.InvertImageColor(M);
}
 
開發者ID:Sanahm,項目名稱:SudoCAM-Ku,代碼行數:26,代碼來源:Thresholding.java

示例2: normalProcess

import org.opencv.imgproc.Imgproc; //導入方法依賴的package包/類
public static Mat normalProcess(Mat img){
	Mat threshImg = Thresholding.InvertImageColor(img);
	Thresholding.gridDetection(threshImg);
	Mat mat = Mat.zeros(4,2,CvType.CV_32F);
	mat.put(0,0,0); mat.put(0,1,512);
	mat.put(1,0,0); mat.put(1,1,0);
	mat.put(2,0,512); mat.put(2,1,0);
	mat.put(3,0,512); mat.put(3,1,512);
	
	mat = Imgproc.getPerspectiveTransform(Thresholding.grid,mat);
	
	Mat M = new Mat();
	
	Imgproc.warpPerspective(threshImg,M,mat, new Size(512,512));
	return Thresholding.InvertImageColor(M);
}
 
開發者ID:Sanahm,項目名稱:SudoCAM-Ku,代碼行數:17,代碼來源:Thresholding.java

示例3: doProjection

import org.opencv.imgproc.Imgproc; //導入方法依賴的package包/類
private static void doProjection(ImgWindow projWnd) {
    if (corners.size() == 4) {
        Mat cornersMat = Converters.vector_Point2f_to_Mat(corners);
        Mat targetMat = Converters.vector_Point2f_to_Mat(target);
        trans = Imgproc.getPerspectiveTransform(cornersMat, targetMat);
        invTrans = Imgproc.getPerspectiveTransform(targetMat, cornersMat);
        proj = new Mat();
        Imgproc.warpPerspective(img, proj, trans, new Size(img.cols(), img.rows()));
        if (projWnd.isClicked()) {
            perspPoints.add(new Point(projWnd.mouseX, projWnd.mouseY));
        }
    }
}
 
開發者ID:nbfontana,項目名稱:pdi,代碼行數:14,代碼來源:TransformacaoPerspectiva.java

示例4: transform

import org.opencv.imgproc.Imgproc; //導入方法依賴的package包/類
public static TransformResult transform(CalibrationResult calibrationResult) {
    MatOfPoint2f src = new MatOfPoint2f(
            new org.opencv.core.Point(calibrationResult.getLeftLowX(), calibrationResult.getLeftLowY()), // tl
            new org.opencv.core.Point(calibrationResult.getLeftUpX(), calibrationResult.getLeftUpY()), // tr
            new org.opencv.core.Point(calibrationResult.getRightLowX(), calibrationResult.getRightLowY()), // br
            new org.opencv.core.Point(calibrationResult.getRightUpX(), calibrationResult.getRightUpY()) // bl
    );
    MatOfPoint2f dst = new MatOfPoint2f(
            new org.opencv.core.Point(0, 0), // tl
            new org.opencv.core.Point(0, 100), // tr
            new org.opencv.core.Point(500, 0), // br
            new org.opencv.core.Point(500, 100) // bl
    );


    TransformResult transformResult = new TransformResult();
    MatOfPoint2f Src = new MatOfPoint2f(
            new org.opencv.core.Point(calibrationResult.getLeftLowX(), calibrationResult.getLeftLowY()), // tl
            new org.opencv.core.Point(calibrationResult.getLeftUpRightX(), calibrationResult.getLeftUpRightY()), // tr
            new org.opencv.core.Point(calibrationResult.getRightLowX(), calibrationResult.getRightLowY()), // br
            new org.opencv.core.Point(calibrationResult.getRightUpLeftX(), calibrationResult.getRightUpLeftY()) // bl
    );
    MatOfPoint2f Dst = new MatOfPoint2f(
            new org.opencv.core.Point(calibrationResult.getLeftLowX(), calibrationResult.getLeftLowY()), // tl
            new org.opencv.core.Point(calibrationResult.getLeftUpRightX(), calibrationResult.getLeftUpRightY()), // tr
            new org.opencv.core.Point(calibrationResult.getRightLowX(), calibrationResult.getRightLowY()), // br
            new org.opencv.core.Point(calibrationResult.getRightUpLeftX(), calibrationResult.getRightUpLeftY()) // bl
    );


    transformResult.m = Imgproc.getPerspectiveTransform(src, dst);
    Core.perspectiveTransform(Src, Dst, transformResult.m);
    org.opencv.core.Point[] points = Dst.toArray();
    double widthleft = Math.abs(points[0].x - points[1].x);
    double widthright = Math.abs(points[2].x - points[3].x);
    transformResult.blackWidth = (widthleft + widthright) / 2;


    return transformResult;

}
 
開發者ID:hgs1217,項目名稱:Paper-Melody,代碼行數:42,代碼來源:Calibration.java


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