OpenCV 3 Computer Vision with Python Cookbook
上QQ阅读APP看书,第一时间看更新

How it works...

In cv2.setMouseCallback , we assigned our mouse events handler, mouse_callback , to the window named image.

After launching, we will be able to select a region by pushing the left mouse button somewhere in the image, dragging the mouse to the end point, and releasing the mouse button to confirm that our selection is finished. We can repeat the process by clicking in a new place—the previous selection disappears:

By hitting the C button on the keyboard, we can cut an area inside the selected region, as follows: