denismakogon/gocv-alpine

gocv.io/x/gocv.NewWindow() exception

radekwlsk opened this issue · 5 comments

I am not surprised that trying to open a GUI in docker using this image and Dockerfile based in the example is not working. But as I am completely green in OpenCV and quite new to Docker:

Is it possible to run window app using this image? I am trying to run the example from gocv attempts at which can be found in my repo gocv-tests.

Any advice?

@AfroMetal Hi, thank for stopping by. The purpose of this docker images I've been working on is for image/video processing only, you can't do a lot of things like creating displaying an image.

Seems like this should be possible using x11 sockets. Any thoughts, @denismakogon on adding to this repo?

I started playing around with setting up a Dockerfile that could build the GUI. I added the Alpine packages for gtk+3.0 and gtk+3.0-dev, then tried to build and got the following error.

[ 63%] Building CXX object modules/highgui/CMakeFiles/opencv_highgui.dir/src/window_gtk.cpp.o
In file included from /usr/include/fortify/stdlib.h:28:0,
                 from /usr/include/c++/6.4.0/cstdlib:75,
                 from /usr/include/c++/6.4.0/stdlib.h:36,
                 from /usr/lib/gcc/x86_64-alpine-linux-musl/6.4.0/include/mm_malloc.h:27,
                 from /usr/lib/gcc/x86_64-alpine-linux-musl/6.4.0/include/xmmintrin.h:34,
                 from /usr/lib/gcc/x86_64-alpine-linux-musl/6.4.0/include/emmintrin.h:31,
                 from /tmp/opencv/opencv-3.4.1/modules/core/include/opencv2/core/cv_cpu_dispatch.h:32,
                 from /tmp/opencv/opencv-3.4.1/modules/core/include/opencv2/core/cvdef.h:202,
                 from /tmp/opencv/opencv-3.4.1/modules/core/include/opencv2/core.hpp:52,
                 from /tmp/opencv/opencv-3.4.1/modules/highgui/include/opencv2/highgui.hpp:46,
                 from /tmp/opencv/opencv-3.4.1/build/modules/highgui/precomp.hpp:45:
/usr/include/fortify/unistd.h:108:1: error: type of 'cv::read' is unknown
 _FORTIFY_FN(read) ssize_t read(int __f, void *__s, size_t __n)
 ^
In file included from /usr/include/glib-2.0/gio/gcredentials.h:32:0,
                 from /usr/include/glib-2.0/gio/gio.h:46,
                 from /usr/include/gtk-3.0/gdk/gdkapplaunchcontext.h:28,
                 from /usr/include/gtk-3.0/gdk/gdk.h:32,
                 from /usr/include/gtk-3.0/gtk/gtk.h:30,
                 from /tmp/opencv/opencv-3.4.1/modules/highgui/src/window_gtk.cpp:51:
/usr/include/fortify/unistd.h: In function 'ssize_t read(int, void*, size_t)':
/usr/include/fortify/unistd.h:114:34: error: '__orig_read' cannot be used as a function
  return __orig_read(__f, __s, __n);
                                  ^
In file included from /usr/include/fortify/stdlib.h:28:0,
                 from /usr/include/c++/6.4.0/cstdlib:75,
                 from /usr/include/c++/6.4.0/stdlib.h:36,
                 from /usr/lib/gcc/x86_64-alpine-linux-musl/6.4.0/include/mm_malloc.h:27,
                 from /usr/lib/gcc/x86_64-alpine-linux-musl/6.4.0/include/xmmintrin.h:34,
                 from /usr/lib/gcc/x86_64-alpine-linux-musl/6.4.0/include/emmintrin.h:31,
                 from /tmp/opencv/opencv-3.4.1/modules/core/include/opencv2/core/cv_cpu_dispatch.h:32,
                 from /tmp/opencv/opencv-3.4.1/modules/core/include/opencv2/core/cvdef.h:202,
                 from /tmp/opencv/opencv-3.4.1/modules/core/include/opencv2/core.hpp:52,
                 from /tmp/opencv/opencv-3.4.1/modules/highgui/include/opencv2/highgui.hpp:46,
                 from /tmp/opencv/opencv-3.4.1/build/modules/highgui/precomp.hpp:45:
/usr/include/fortify/unistd.h: At global scope:
/usr/include/fortify/unistd.h:144:1: error: type of 'cv::write' is unknown
 _FORTIFY_FN(write) ssize_t write(int __f, const void *__s, size_t __n)
 ^
In file included from /usr/include/glib-2.0/gio/gcredentials.h:32:0,
                 from /usr/include/glib-2.0/gio/gio.h:46,
                 from /usr/include/gtk-3.0/gdk/gdkapplaunchcontext.h:28,
                 from /usr/include/gtk-3.0/gdk/gdk.h:32,
                 from /usr/include/gtk-3.0/gtk/gtk.h:30,
                 from /tmp/opencv/opencv-3.4.1/modules/highgui/src/window_gtk.cpp:51:
/usr/include/fortify/unistd.h: In function 'ssize_t write(int, const void*, size_t)':
/usr/include/fortify/unistd.h:150:35: error: '__orig_write' cannot be used as a function
  return __orig_write(__f, __s, __n);

Any ideas on making this work in Alpine?

OK, I have now gotten my containers to build, but when I execute my new test container, it exits immediately without any errors being displayed.

My code can be found here:
https://github.com/hybridgroup/gocv-alpine/blob/feature/gui/gui/Dockerfile

Hi, personally I haven't tried to make GUI work, the purpose of this repo and containers to make backend applications that don't really care about UI/GUI.