This code allows you to crop images dynamically and save them. Mouse Events in OpenCV will be used to achieve this.
- Run the .py file by running the command
python3 crop.py
in the terminal or cmd. - Use the Left mouse button to drag out a rectangular region of the image you want to crop. Release the button, once you are done.
- The selected rectangular is shown on the image. You can press r to reset your selection.
- Press c to crop the image. A new window opens up.
a) Press s to save the cropped image.
b) Press r to reset and return to the original image. - Repeat from step 2 to crop more images.