Schütze
Schütze

Reputation: 1084

Java Opencv Mat constructor mismatch

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?

Upvotes: 0

Views: 111

Answers (1)

Miki
Miki

Reputation: 41776

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

Upvotes: 1

Related Questions