[英]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.