Life2Coding
How to Crop OpenCV Image using Mouse Click and Movement in Python

Click and Crop Image

You can easily crop an image using mouse clicks on OpenCV. For this you need call the OpenCV cv2.setMouseCallback(“window”, image). You then need to detect the left mouse button down using the cv2.EVENT_LBUTTONDOWN event, then continuously locate the position of the mouse using the cv2.EVENT_MOUSEMOVE event and at last you need to detect the left mouse button released or cv2.EVENT_LBUTTONUP event.

By doing this it will create an rectangle to the image and also give the output ROI of the cropped image

Code:

Output:

 

crop How to Crop OpenCV Image using Mouse Click and Movement in Python

life2coding_icon [] How to Crop OpenCV Image using Mouse Click and Movement in Python

Life2Coding

Technology Related Blog at Life2Coding
Feel free to contact us for your any kind of technical problems. We are here to help you.
life2coding_icon [] How to Crop OpenCV Image using Mouse Click and Movement in Python

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.