Ask Your Question
0

Closing an image on left mouse click(OpenCV2 / Python 3.4)

asked 2017-04-10 03:20:51 -0500

Xazec gravatar image

updated 2017-04-10 06:50:32 -0500

Hey all,

The relevant part of my current code looks like this:

#a whole bunch of stuff that generates the image file
cv2.imshow(<image file>, img)
cv2.waitKey(0)
cv2.destroyAllWindows
#more stuff

Currently it closes, as expected, the image on a keypress.

What I'd like to do is, using a RPI + RPI touch screen, to close the image on a left mouse button press (any touch command to the screen in this case). Searching through the documentation I've been unable to find a way to do this, any pointers would be grealty appreciated.

edit: I know this is possible by just pressing the "x" in the top right, in real world use case this might prove to be difficult at times, hence I'd like to avoid it.

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
0

answered 2017-04-10 06:55:45 -0500

You will need to

  1. Simulate a key being pressed, which is C/C++, not OpenCV: http://stackoverflow.com/questions/56...
  2. And do this inside a loop that is monitoring your mouse events, have a look at the opencv_annotationcode for example: https://github.com/opencv/opencv/blob...
edit flag offensive delete link more
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2017-04-10 03:20:51 -0500

Seen: 145 times

Last updated: Apr 10 '17