Blurring a Rect within a screenshot

The C++ code to achieve this task is shared below with comments and sample images:

// load an input image
Mat img = imread("C:\\elon_tusk.png");

img:

enter image description here

// extract subimage
Rect roi(113, 87, 100, 50);
Mat subimg = img(roi);

subimg:

enter image description here

// blur the subimage
Mat blurred_subimage;
GaussianBlur(subimg, blurred_subimage, Size(0, 0), 5, 5);

blurred_subimage:

enter image description here

// copy the blurred subimage back to the original image
blurred_subimage.copyTo(img(roi));

img:

enter image description here

Android equivalent:

Mat img = Imgcodecs.imread("elon_tusk.png");
Rect roi = new Rect(113, 87, 100, 50);
Mat subimage = img.submat(roi).clone();
Imgproc.GaussianBlur(subimg, subimg, new Size(0,0), 5, 5);
subimg.copyTo(img.submat(roi));

You could just implement your own helper function, let's call it roi (region of interest). Since images in opencv are numpy ndarrays, you can do something like this:

def roi(image: np.ndarray, region: QRect) -> np.ndarray:
    a1 = region.upperLeft().x()
    b1 = region.bottomRight().y()
    a2 = region.upperLeft().x()
    b2 = region.bottomRight().y()
    return image[a1:a2, b1:b2]

And just use this helper function to extract the subregions of the image that you are interested, blur them and put the result back on the original picture.