OPENCV在Imgproc Java上使用重音和特殊字符调整大小

时间:2014-06-18 14:59:35

标签: java opencv resize

我正在处理包含重音和特殊字母(如“º”)的文件,因此当您尝试旋转图像或使用Imgproc调整大小时,会发出以下错误:

String originalFileName = "D:\\ºteste\\teste4.jpg"
Mat image =  Highgui.imread(originalFileName);

int width = image.cols();
int height = image.rows();

double resizeRate = 0;

if (resizeToHeight <= 0) {
    resizeRate = ((resizeToWidth * 100.0) / width) / 100.0;
}

if (resizeToWidth <= 0) {
    resizeRate = ((resizeToHeight * 100.0) / height) / 100.0;
}

Mat resizeImage = new Mat();

if (resizeRate > 0) {
    Size sz = new Size(resizeRate * width, resizeRate * height);
    Imgproc.resize(image, resizeImage, sz);
} else {
    Size sz = new Size(resizeToWidth, resizeToHeight);
    Imgproc.resize(image, resizeImage, sz);
}

旋转消息

“OpenCV错误:断言失败(src.cols&gt; 0&amp; src.rows&gt; 0)在cv :: warpAffine中,文件........ \ opencv \ modules \ imgproc \ src \ imgwarp.cpp,第3455行线程“main”中的异常CvException [org.opencv.core.CvException:cv :: Exception:........ \ opencv \ modules \ imgproc \ src \ imgwarp.cpp:3455 :错误:(-215)src.cols&gt; 0&amp;&amp; src.rows&gt; 0 in function cv :: warpAffine] org.opencv.imgproc.Imgproc.warpAffine_2(Native Method)at org.opencv.imgproc .Imgproc.warpAffine(Imgproc.java:9559)位于juca.bastiao.Processor.doResize(Processor.java:91)的juca.bastiao.Processor.autoRotate(Processor.java:258)juca.bastiao.Processor.resizeToFile( Processor.java:52)at juca.bastiao.Testes.main(Testes.java:30)“

调整大小的消息

OpenCV错误:断言失败(ssize.area()&gt; 0)在cv :: resize,file ........ \ opencv \ modules \ imgproc \ src \ imgwarp.cpp,第1834行异常thread“main”CvException [org.opencv.core.CvException:cv :: Exception:........ \ opencv \ modules \ imgproc \ src \ imgwarp.cpp:1834:error:( - 1515)ssize。 area()&gt;函数cv :: resize中的0,位于org.opencv.imgproc.Imgproc.resize_1(本机方法)atg.opencv.imgproc.Imgproc.resize(Imgproc.java:8959)at juca.bastiao.Processor.doResize(Processor。 java:111)juca.bastiao.Processor.resizeToFile(Processor.java:52)at juca.bastiao.Testes.main(Testes.java:30)

0 个答案:

没有答案