0

I am trying to create a Mat object as follows:

// ROI by creating mask for the trapezoid
Mat mask = Mat(frame.rows(), frame.cols(), CvType.CV_8UC1, new Scalar(0));

However I get the following compile-time error:

The method Mat(int, int, int, Scalar) is undefined for the type 

Whereas in Mat.class file I can surely see the following function signature:

//
// C++: Mat::Mat(int rows, int cols, int type, Scalar s)
//

// javadoc: Mat::Mat(rows, cols, type, s)
public Mat(int rows, int cols, int type, Scalar s)
{

    nativeObj = n_Mat(rows, cols, type, s.val[0], s.val[1], s.val[2], s.val[3]);

    return;
}

Is this a bug, or?

2
  • 1
    shouldn't it be Mat mask = new Mat(...) in the first place? Commented Nov 14, 2016 at 11:45
  • You are right, stupid of me, I am converting the code from C++ to Java, hence the mistake. I'll accept it as answer if you write it. Thanks. Commented Nov 14, 2016 at 11:59

1 Answer 1

1

The signature is correct. In Java you need to use the new keyword to create new objects:

Mat mask = new Mat(frame.rows(), frame.cols(), CvType.CV_8UC1, new Scalar(0));
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.