4

cv2.selectROI display my image but it's too big for the screen and i can't navigate on the image because it's automatically starting the crop procedure.

can anyone tell me how to adjust the function? cv2.namedWindow('image', cv2.WINDOW_NORMAL) before cv2.selectROI does not help.

Thank you

alon
  • 41
  • 3
  • ciao! have you tried to add also `cv2.resize(im, (960, 540))` after the other line as reported [here](https://stackoverflow.com/a/35183247/4092588)? also, better if you post your attempts to let people check what you already did and avoid downvotes – Antonino Dec 24 '18 at 11:01
  • 1
    Hi, thank you for your comment. i've trouble with using resize function because i don't want to lose any information in the image. if i'm using the Pillow (plt) the image is presented, just like matlab imshow, without resample it. my problem is that i don't have the knowledge to edit the cv2.selectROI function display. – alon Dec 25 '18 at 08:33

1 Answers1

1

I was wondering the same.

If your IDE allows you to check the definitions of the selectROI function you should see something like this :

CV_EXPORTS_W Rect selectROI(const String& windowName, InputArray img, bool showCrosshair = true, bool fromCenter = false);

A function which is overloaded with this definition that we use the most often :

CV_EXPORTS_W Rect selectROI(InputArray img, bool showCrosshair = true, bool fromCenter = false);

This means you can use both functions depending on which arguments you put.

Concretely you can do something like this :

cv::namedWindow("Resized window", cv::WINDOW_NORMAL);
cv::resizeWindow("Resized window", 1280 , 720);
cv::Rect rect = cv::selectROI("Resized window",img);

If you don't want to mess the ratio of your image, you will probably have to adjust the parameters 1280 and 720 according to your picture.

Dakom
  • 11
  • 5