Ask Your Question
0

selectROI does not close the window after 'enter' pressed?

asked 2019-07-16 16:57:17 -0600

ev gravatar image

updated 2019-07-17 07:11:40 -0600

supra56 gravatar image

I am using cv.selectROI twice (it was a conscious choice not to use selectROIs) and when I go to press 'enter', the second selectROI pops up but the first one does not go away. Why? selectROI should go away on its own after pressing 'space' or 'enter,' correct?

my code is like this:

img = cv.imread('image.jpg')
retval1 = cv.selectROI('select', img)
retval2 = cv.selectROI('select2', img)

I solved the problem by just using cv.destroyWindow('select') after the retval1 line. However, I shouldn't have to do that, right? Why didn't selectROI delete the window?

edit retag flag offensive close merge delete

Comments

and which language / os / opencv version are you talking about ?

berak gravatar imageberak ( 2019-07-16 23:31:35 -0600 )edit

python3-5 on ubuntu/linux with OpenCV 4

ev gravatar imageev ( 2019-07-24 12:46:19 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
0

answered 2019-07-17 10:55:44 -0600

kbarni gravatar image

Because it's not supposed to. According to the documentation:

SelectROI()

Selects ROI on the given image. Function creates a window and allows user to select a ROI using mouse. Controls: use space or enter to finish selection, use key c to cancel selection

So pressing space simply finishes the selection, it doesn't close the window. The solution is to manually delete the window, just as you did.

edit flag offensive delete link more

Comments

Hm, usually if I use cv.selectROI() once, it automatically closes the window when I press enter or space.

ev gravatar imageev ( 2019-07-24 12:45:55 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2019-07-16 16:57:17 -0600

Seen: 5,634 times

Last updated: Jul 17 '19