'Regarding Multiple ROIs in an image using python/opencv

When you select multiple ROIs in an image, how to display them all simultaneously in that image white selecting one by one? How to deselect some selected ROIs in that image at the same instance of selecting ROIs? some of the code I have written below. Please modify and add the requirements.

If possible, please also help in changing the width and height of the selected ROI in the images itself.

path=r'D:\abc.jpg'
img_raw = cv2.imread(path)
ROIs = cv2.selectROIs("Select Rois",img_raw,0,0)
print(ROIs)
for roi in ROIs:
    x1=roi[0]
    y1=roi[1]
    x2=roi[2]
    y2=roi[3]
    img_crop=img_raw[y1:y1+y2,x1:x1+x2]
    cv2.imshow(img_crop)
cv2.waitKey(0)
cv2.destroyAllWindows()


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source