如何加载图像到Android和调整 [英] How to load image to android and resize
本文介绍了如何加载图像到Android和调整的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我试图加载图像的垫子,并与下面code调整其大小
I am trying to load an image in a mat and resize it with the below code
Mat temp1= new Mat();
int[] train_responses = null;
Mat temp2 = new Mat();
Mat temp3 = new Mat();
Mat train_samples = new Mat();
for (int ii = 0; ii < 10; ii++){
temp1 = Highgui.imread("/mnt/sdcard/images/train/" + ii + ".png");
Imgproc.resize(temp1, temp2, new Size(30,20));
}
但具有下列日志code崩溃
but the code crashes with the following log
opencv error assertion failed (ssize.area() > 0) in void cv::resize....
我在哪里错了?
Where am I wrong?
推荐答案
请检查你所有的PNG图像0.png,1.png,... 9.png都存在,是在正确的位置,并具有非零当您通过imread加载它们的尺寸。这没有什么错,否则用code - 它为我使用code,当我打开我自己的PNG图像
Check that all your png images 0.png, 1.png, ... 9.png all exist, are in the correct location and have non-zero dimensions when you load them via imread. There's nothing otherwise wrong with the code - it works for me when I load my own png image using your code.
这篇关于如何加载图像到Android和调整的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文