android - 当我在打开的简历中传递newSize参数时,resize()失败

标签 android opencv

在android中,我正在尝试使用以下代码缩放我的垫子。

Mat destMat = new Mat(); 
Size newSize=new Size(output.width()/6.0f, output.height()/6.0f); 
Imgproc.resize(output, destMat, newSize, 0, 0, Imgproc.INTER_CUBIC);

当它尝试执行调整大小方法时,出现以下异常。我的代码在onCameraFrame()中。

MatToBitmap catched cv::Exception: /home/reports/ci/slave_desktop/50-SDK/opencv/modules/java/generator/src/cpp/utils.cpp:97: error: (-215) src.dims == 2 && info.height == (uint32_t)src.rows && info.width == (uint32_t)src.cols in function void Java_org_opencv_android_Utils_nMatToBitmap2(JNIEnv*, jclass, jlong, jobject, jboolean)

最佳答案

在变量“newSize”所在的位置,您实际上需要的是destMat的原始大小。您可以使用fx和fy参数将其缩小。从javadocs:

The function resize resizes the image src down to or up to the specified size.Note that the initial dst type or size are not taken into account. Instead, the size and type are derived from the src,dsize,fx, and fy.



稍后的:

// explicitly specify dsize=dst.size(); fx and fy will be computed from that.

关于android - 当我在打开的简历中传递newSize参数时,resize()失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19839584/

相关文章:

android - 无法在 Kivy 中为动画选择 id

Android - 视频重新启动或恢复

android opencv RGB转HSV

Android:将多条记录插入/更新到 SQL 数据库

java - 使用 OutputStreamWriter 写入 : line by line vs all at once

android - 什么是蓝牙?

python - cv2编辑的图像以错误的颜色保存

Python - 播放带音频的视频(使用 OpenCV?)

c++ - Opencv 3.0加载人脸级联时出错

python - 在 Python 中将 OpenCV 3 (iplImage) 转换为 PyQt5 QImage/QPixmap