本文整理汇总了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);
}
示例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);
}
示例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));
}
}
}
示例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;
}