Return rate of investment in OpenCV from Android… here is a solution to the problem.
Return rate of investment in OpenCV from Android
I want to use ROI in OpenCV for Android.
Is this the correct code?
Mat image = new Mat();
Mat imageRIO = new Mat();
Rect roi = new Rect(300, 50, 50, 10);
public Mat onCameraFrame(CvCameraViewFrame inputFrame) {
image = inputFrame.gray();
image.submat(roi); set roi
image.copyTo(imageRIO);
return imageRIO;
}
Solution
I’m not sure exactly what you’re trying to do, but submat()
returns a Mat you need and you didn’t assign it to anything. image.copyTo()
copies image
instead of the subpad you extracted in the previous line.
You can simply do this:
Rect roi = new Rect(300, 50, 50, 10);
public Mat onCameraFrame(CvCameraViewFrame inputFrame) {
return new Mat(inputFrame.gray(), roi);
}