How to convert ROI in gray (monochrome) on android?
Hello. How to convert ROI in gray (monochrome) on android?
I try that, but it does not work:
public Mat onCameraFrame(CvCameraViewFrame inputFrame) {
Mat image = inputFrame.rgba();
Rect roi = new Rect(300, 50, 50, 10);
Imgproc.cvtColor(image.submat(roi), image.submat(roi), Imgproc.COLOR_RGBA2GRAY);
return image;
}
and
public Mat onCameraFrame(CvCameraViewFrame inputFrame) {
Mat image = inputFrame.rgba();
Rect roi = new Rect(300, 50, 50, 10);
Mat sub =image.submat(roi);
Imgproc.cvtColor(sub, sub, Imgproc.COLOR_RGBA2GRAY);
sub.copyTo(image.submat(roi));
return image;
}
See the answer here
Actually this link might disappear in the future. To help future searches for this problem, I copied the solution here!
sidenote, you can query a grayscale image from CvCameraViewFrame already: