Bossgaming099 / ctypes-opencv

Automatically exported from code.google.com/p/ctypes-opencv
0 stars 0 forks source link

mouse callback and parameter support #21

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
While seeing about packaging up a background image thread I've been using
on Windows (which OpenCV doesn't support natively) I realized I had
implemented some of the same support the highgui module already does for
trackbars, but for mouse callbacks.  So it seemed like the highgui module
should probably take care of similar stuff for mouse callbacks.

Namely, the parameter might not be a c_void_p but some other ctypes type,
and that a reference to the parameter should be kept for safety.  So the
attached patch adds that for mouse callbacks, as well as permits a None
callback (to remove it) similar to the recent patch for None trackbar
callbacks.

There's probably an enhancement that would permit passing in arbitrary
Python objects (e.g., an internal highgui ctypes type that also kept a
reference to the Python object), but I left that for later, as you can't do
that right now anyway.

Original issue reported on code.google.com by db3l.em...@gmail.com on 14 Jan 2009 at 1:54

Attachments:

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
Grumble - ok, third time's the charm.  To be completely safe, the cache needs 
to hold
not only the actual parameter used for the callback, but if that was a local 
c_void_p
wrapping of the caller's parameter it needs to hold both that wrapping as well 
as the
original parameter.  I've got some debug windows that throw away their images 
after
using them for a callback that tickled this.  Attached patch is complete, so 
ignore
the first (I'll delete my second comment to minimize confusion).

Original comment by db3l.em...@gmail.com on 14 Jan 2009 at 3:06

Attachments:

GoogleCodeExporter commented 8 years ago
I haven't got a chance to read your second comment. I've patched using the last
patch. Thanks.

Original comment by pmtri80@gmail.com on 14 Jan 2009 at 3:26