Reputation: 137
I want to use ROI in OpenCV for Android.
This is code true?
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;
}
Upvotes: 3
Views: 8759
Reputation: 11941
I am not sure exactly what you are trying to do, but submat()
returns a Mat that you need and you are not assigning it to anything. image.copyTo()
copies image
not the submat you extracted in the previous line.
You could simply do this:
Rect roi = new Rect(300, 50, 50, 10);
public Mat onCameraFrame(CvCameraViewFrame inputFrame) {
return new Mat(inputFrame.gray(), roi);
}
Upvotes: 5