https://funvision.blogspot.com
Code here
https://funvision.blogspot.com/2020/0...
Example and explanation of how to use the mouse in opencv to select Roi image in your window. The basic explanation of setMouseCallback and how to remember the initial state of the mouse and actual mouse coordinates by using a global structure. The global structure is updated by standard mouse actions like move, left and right button down and up.