Android OpenCV getPerspectiveTransform and warpPerspective

后端 未结 1 1539
轻奢々
轻奢々 2020-12-15 01:36

I am a bit confused with the parameters of getPerspectiveTransform as I cannot see a proper image. Here is my code. The original_image variable is the image that contains a

相关标签:
1条回答
  • 2020-12-15 02:13

    This worked for me. in the src_mat.put you should have 0,0 at first and then the float values for the coordinates.

        Mat mat=Highgui.imread("inputImage.jpg");
        Mat src_mat=new Mat(4,1,CvType.CV_32FC2);
        Mat dst_mat=new Mat(4,1,CvType.CV_32FC2);
    
    
        src_mat.put(0,0,407.0,74.0,1606.0,74.0,420.0,2589.0,1698.0,2589.0);
        dst_mat.put(0,0,0.0,0.0,1600.0,0.0, 0.0,2500.0,1600.0,2500.0);
        Mat perspectiveTransform=Imgproc.getPerspectiveTransform(src_mat, dst_mat);
    
        Mat dst=mat.clone();
    
        Imgproc.warpPerspective(mat, dst, perspectiveTransform, new Size(1600,2500));
        Highgui.imwrite("resultImage.jpg", dst);
    
    0 讨论(0)
提交回复
热议问题