user1874406
user1874406

Reputation: 71

resize() fail when i pass newSize parameter in open cv

In android i am trying to scale my mat using following code.

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);

When it try to execute the resize method i get following exception. My code is in 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)

Upvotes: 1

Views: 359

Answers (1)

Dylan Katz
Dylan Katz

Reputation: 194

Where the variable 'newSize' is, you actually want the original size of destMat. You can scale it down by using the fx and fy parameters. From the 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.

Later on:

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

Upvotes: 0

Related Questions