I have been trying to apply an Ellipse mask on top of a cvMat. In C++ the code would look like this :
Mat mask = Mat(warped.size(), CV_8UC1, Scalar(255));
double dw = DESIRED_FACE_WIDTH;
double dh = DESIRED_FACE_HEIGHT;
Point faceCenter = Point( cvRound(dw * 0.5),
cvRound(dh * 0.4) );
Size size = Size( cvRound(dw * 0.5), cvRound(dh * 0.8) );
ellipse(mask, faceCenter, size, 0, 0, 360, Scalar(0),CV_FILLED);
filtered.setTo(Scalar(128), mask);
Im unable to find any method in javaCV that is equivalent to setTo. Can anyone help with a work-around for this.
You need to create a 1x1 Matrix from your scalar and use that instead something like:
filtered.setTo(Mat(1,1,CV_16S1C1, 128), mask);
the method is defined as:
@ByRef
public native opencv_core.Mat setTo(@ByVal opencv_core.Mat var1, @ByVal(
nullValue = "cv::noArray()"
) opencv_core.Mat var2);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With