On Wed, Jul 11, 2012 at 8:35 AM, Wolfgang Draxinger <firstname.lastname@example.org>
I have a plot of an image of which I'd like to interactively select a
quadrilateral. This is for a homography operation (perspective
correction). It suffices if the quadrilateral can be dragged by only
its vertices (display the vertices as rects or circled to click within).
In principle I want to implement a tool similar to the
"Perspective" tool of The GIMP in corrective mode. The whole image
processing and geometric transformation is already implemented, but now
I need a user interface. Since I'm already making heavy use of
Matplotlib I'd like to stay within this.
After the user applied the homography the next step is placing the
calibration markers, which would be basically one axvline and two
axhlines to be dragged to reference points on the previously
perspective corrected image.
How do I implement such interaction elements?
You can find a decent start to this in the event handling examples. The poly editor demo is particularly useful:
Awhile back, I wrote a tool for my own work. It probably needs a little cleanup, but it works. I've posted it as a gist if you want to try it out:
At some point, I had problems with it on certain backends, so you may need to uncomment the 'tkagg' line. In any case, it seems to work fine with my current backend (qt4agg).