3

Is it possible to have enaml as target for OpenCV?

I'm thinking how to setup GUI and what to use. Nothing too complicated, I need to be able to set some bitmap background, draw rectangles and circles over it, but also have the possibility to select/move these graphics objects.

Also, I would like that I do not have to take care of all these elements when I stretch the window, etc. they should do this automatically since they would be defined in some "absolute" space. I think I could easily make it work for the bitmaps (even from memory), by overriding request_image in ImageProvider object (even though I see some strange cache happening in provider/enaml view).

Problem that I'm having now with OpenCV (OSX 64) is that even when I get resize to work with qt backend and CV_WINDOW_NORMAL, the content does not stretch. I like OpenCV, because easily I get basic UI functions.

On the other hand I started to like enaml so I'm thinking did anyone manage to get these to to work together. I'm thinking if link with MPL works, it's possible that coupling with OpenCV should be possible :)

Thanks!

4

2 回答 2

2

如果您可以将图像转换为 argb32 或 png 格式,则可以使用 Enaml ImageView 来显示它。

看一下 ImageView 示例: https ://github.com/nucleic/enaml/blob/master/examples/widgets/image_view.enaml

于 2013-11-26T01:28:19.203 回答
2

这应该这样做:

from enaml.image import Image
from cv2 import imread, imencode

open_cv_image = imread('./cat.png')
png_image = imencode('.png', open_cv_image)[1].tostring()
enaml_image = Image(data=png_image)
于 2017-07-17T00:57:38.637 回答