user3104589
user3104589

Reputation: 137

ROI in OpenCV from Android

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

Answers (1)

Bull
Bull

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

Related Questions