[英]JavaCV Perspective Transform Gives Error
我正在使用Java纠正透视图的应用程序(也称为梯形失真)。 为此,我使用Bytedeco的JavaCV 。 通过在线参考文档以及其他一些网站和手册,我尝试使用两个OpenCV方法warpPerspective
和cvGetPerspectiveTransform
来实现此cvGetPerspectiveTransform
。 更具体地说,这是我的代码:
public static void main(String[] args) {
IplImage img = new IplImage(imread("src/res/mona-lisa.jpg"));
IplImage img2 = new IplImage(3);
CvMat mmat = cvCreateMat(3, 3, CV_32FC1);
CvPoint2D32f c1 = new CvPoint2D32f(4);
CvPoint2D32f c2 = new CvPoint2D32f(4);
c1.position(0).put(0, 0);
c1.position(1).put(400, 0);
c1.position(2).put(0, 300);
c1.position(3).put(400, 300);
c2.position(0).put(0, 0);
c2.position(1).put(img.width(), 0);
c2.position(2).put(0, img.height());
c2.position(3).put(img.width(), img.height());
mmat = cvGetPerspectiveTransform(c1, c2, mmat);
cvWarpPerspective(img, img2, mmat);
cvNamedWindow("Image", 1);
cvShowImage("Image", img);
cvWaitKey();
}
如果执行该代码,则控制台会给我一个“ OpenCV错误:cv :: cvarrToMat中的错误参数(未知数组类型),文件src \\ matrix.cpp,第880行”,以及以下其中一项:
#
# A fatal error has been detected by the Java Runtime Environment:
#
# EXCEPTION_UNCAUGHT_CXX_EXCEPTION (0xe06d7363) at pc=0x00007ffb1e24a1c8, pid=2020, tid=12660
#
# JRE version: Java(TM) SE Runtime Environment (8.0_66-b18) (build 1.8.0_66-b18)
# Java VM: Java HotSpot(TM) 64-Bit Server VM (25.66-b18 mixed mode windows-amd64 compressed oops)
# Problematic frame:
# C [KERNELBASE.dll+0x2a1c8]
#
# Failed to write core dump. Minidumps are not enabled by default on client versions of Windows
#
# An error report file with more information is saved as:
# ...
#
# If you would like to submit a bug report, please visit:
# http://bugreport.java.com/bugreport/crash.jsp
# The crash happened outside the Java Virtual Machine in native code.
# See problematic frame for where to report the bug.
#
但是,我知道mona-lisa.jpg
可以正确读取,因为如果我跳过所有mmat
程序,那么它将正确呈现原始图像。
我正在努力达到类似的目的 。
有什么想法吗?
这不是应该将结果存储在其他图像(img2)中吗?
cvWarpPerspective(img,img,mmat);
还有关于崩溃的问题-有人建议这与确定变量范围有关,这是一个长期的问题。 也许您可以查看最新的创新
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.