Closed neilyoung closed 6 years ago
Situation has changed a bit. Following some advices in the web I decorated all "CFLAGS" found in CMakeList.txt with -fPIC
That at least let me compile and linke and even a deb could be produced.
However, now the server spits into the soup and refuses to load because of a missing external:
2018-07-17 00:36:01,048486 8772 [0x00007f4fd50d3880] warning KurentoModuleManager ModuleManager.cpp:63 loadModule() Module /home/decades/Documents/MyFilter/my-filter/build/src/server/libkmsmyfilterimpl.so cannot be loaded: /home/decades/Documents/MyFilter/my-filter/build/src/server/libkmsmyfilterimpl.so: undefined symbol: _ZN2cv6String10deallocateEv
Whatsoever...Wondering how other's made it...
I think this is an opencv version mismatch, so I downloaded KMS server sources following http://doc-kurento.readthedocs.io/en/stable/dev/dev_guide.html#developing-kms
While running CMake I got an interesting error message:
-- Checking for module 'opencv'
-- Found opencv, version 3.4.1
-- Resolving opencv version ^2.0.0 with 3.4.1
CMake Error at kms-cmake-utils/CMake/VersionHelpers.cmake:301 (message):
Version does not match <3.0.0 with 3.4.1
Yep: Seems so https://stackoverflow.com/questions/43688544/how-can-kurento-use-opencv-3-0
Interesting plot twist: I was able to compile the KMS server code by changing the opencv requirement in
./kms-filters/CMakeLists.txt
to
set(OPENCV_REQUIRED >= 2.0.0)
Because none of the inbuilt filters did compile now I excluded them from build by commenting the appropriate entries in
./kms-filters/src/gst-plugins/CMakeList.txt
At least the server starts and reacts to external requests. Let's see, if it launches my module now.
Oh that sucks... No it didn't work. Since the "opencvfilter" module was the only one, which compiled with this setup, I did compile it, but on load here the good old known issue:
(gst-plugin-scanner:20338): GStreamer-WARNING **: Failed to load plugin './kms-filters/src/gst-plugins/opencvfilter/libopencvfilter.so': ./kms-filters/src/gst-plugins/opencvfilter/libopencvfilter.so: undefined symbol: _ZN2cv6String10deallocateEv
I suppose, KMS and opencv > 2 = nogo
OK, to end this self-talk: I have stopped messing with OpenCV 3 and installed KMS from source as described in the docs on a brand new Ubuntu 16.04 VM. Works like a charm.
We know that can be a bit frustrating to ask for help and receive nothing from our side. But KMS is huge for our small team and we have to focus on core features.
We really appreciate contributions and Pull Requests.
When se have resources, we will take a look to this issue.
El mar., 17 jul. 2018 18:51, neilyoung notifications@github.com escribió:
OK, to end this self-talk: I have stopped messing with OpenCV 3 and installed KMS from source as described in the docs on a brand new Ubuntu 16.04 VM. Works like a charm.
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/Kurento/bugtracker/issues/280#issuecomment-405651401, or mute the thread https://github.com/notifications/unsubscribe-auth/ABBdKDs6l_VjUQU5cgP6t9cNa0tVE9jnks5uHhYogaJpZM4VQwnh .
@micaelgallego No issue, I know that. In the end there is an answer :) Supporting OpenCV 3 would be a burner.
Just do a quick Google search for cv::string::deallocate. This is not a problem with Kurento, is a problem with system configuration.
There is nothing intrinsic in Kurento that makes it depend on any specific version of OpenCV; of course, the demonstration filters may use some functions that were present on v2 but changed in v3, so those will stop building. But, a filter is kind of a self-contained "application", Kurento just loads it dynamically and passes video frames to it. If your code compiles with the v3 headers, it should work just fine.
The problem you're facing here is that your plugin wants to dynamically resolve some symbols belonging to OpenCV, but the system's dynamic linker is looking for them in the wrong places. This is done by Kurento / GStreamer's plugin registry, i.e. a dlopen()
operation. The system's dynamic linker looks for the required symbols in all of the system's search paths, in their preference order. If you happen to have installed the OpenCV libraries from Ubuntu 16.04 (v2.4.9), then those are probably being the ones found.
To check what OpenCV packages you have installed:
dpkg -l *opencv* | grep ii
To check what actual OpenCV library files you have in your system:
sudo updatedb
locate *libopencv*.so
To inspect what exact files are being loaded by KMS while it runs (it might need some tweaking):
strace -e trace=open kurento-media-server
Source.
C++ uses mangled symbol names, but they are kinda easy to read: _ZN2cv6String10deallocateEv
translates into cv::String::deallocate
. So, the system is looking for the implementation of this function which I assume exists only in OpenCV v3, but it looks into the v2 libraries (.so
files) and those don't contain that symbol.
So what can you do?
I guess building from source code in a clean environment worked because there was no mixing of library versions. I can think of 3 options you have to use a non-standard OpenCV version in Ubuntu:
Compile OpenCV v3 as a static library against your plugin. This way, the resulting .so will be bigger in size, but it will be self-contained and won't need to dynamically load any additional library.
Use LD_LIBRARYPATH
to tell the dynamic linker where your custom OpenCV library is built.
Only needed if you don't have it already in a system directory such as /lib or /usr/lib. For example, if it is in /opt/opencv3, you would do:
export LD_LIBRARY_PATH=/opt/opencv3/lib:$LD_LIBRARY_PATH
kurento-media-server ...
Use rpath
or runpath
. Source.
@j1elo Thanks for the detailed answer. I was already answering (a very long thread, a lot of quotes), but after "Reopen and comment" it disappeared.
Trying to provide some info here again.
I'm too tired today, will check tomorrow. Thanks for your answer again.
It's getting weird a bit. I found my OpenCV3 libs in /usr/local/lib and provided this as load path.
All compiled modules and plugins refuse to load like so:
open("./kms-filters/tests/CMakeFiles", O_RDONLY|O_NONBLOCK|O_DIRECTORY|O_CLOEXEC
(gst-plugin-scanner:22292): GStreamer-WARNING **: Failed to load plugin './kms-filters/src/gst-plugins/opencvfilter/libopencvfilter.so': ./kms-filters/src/gst-plugins/opencvfilter/libopencvfilter.so: undefined symbol: _ZN2cv6String10deallocateEv
) = 7
There is no clue, what libopencv is taken to resolve that from the strace, since there is no such a trace
I cannot make this run. No way. Can anybody of you try to explain, what is required to do in order to combine KMS with an OpenCV 3 installation?
I'm afraid you'll depend on being lucky and finding someone in the community forum who has had the same problem and has been able to solve it... try and post a message there. Kurento officially supports the OpenCV version that ships with Ubuntu 14.04 and 16.04 Long Term Support editions, which means 2.x until we upgrade the whole project to work with the latest Ubuntu LTS (18.04); that one seems to ship OpenCV 3.20, but I'm afraid I don't see the upgrade happening until late this year, at best
OK, thanks.
ok, maybe one easy question then: I managed to scaffold my own opencv plugin following http://doc-kurento.readthedocs.io/en/stable/user/writing_modules.html#opencv-module. I'm now on that VM, which let me compile and run KMS perfectly. I also managed to make my module known to KSM, it appears as myFilter.MyFilter.
Since there is a "process" entry in MyFilterOpenCVImpl.cpp my simple epxectation was, that I will be able to see this exception somehow, once I'm able to connect to that module. But even this seems to not work for me
My module appears as "myFilter.MyFilter" and this is what I tried to connect from client JS:
pipeline.create('myFilter.MyFilter', function(error, filter)
to no avail, of course. Other variations did also not work.. The scaffoled JS code seems to be too ugly for me and overkill, but maybe you know more?
Please, what is wrong with this approach? I made another attempt with your kms-opencv-plugin-sample. The sample is loaded, it is visible with --list under factories as OpencvPluginsample and opencvpluginsample.OpencvPluginsampel and with option -v as opencvpluginsampe.
I'm using the same JS code as for the FaceOverlay (which works), just altering the name of the plugin to be piped. But that does not work... The remote video window just shows the spinner.
Oh man, why the heck does it have to be that complicated???
OK, guys. After all those years I thought I would be tough enough to make it, after having seen the Super Mario hat on my head. I admit, I was wrong: Even though I made it to roll my own OpenCV module and put it under your server, so that the server is claiming to have it, there is no visible way on earth for me to make use of it from a simple browser app (it does not have to be Node or Java, just plain JS).
THANKS A LOT for this great experience 👎
Hi, we are an extremely small team and at this point we cannot halt other tasks to check on this issue and how to solve it.
If you think that Kurento Media Server does provide some added value for you and your project, consider a support contract by which we will dedicate exclusive focus to the problem at hand. And it's also a way of making the whole project sustainable for the future.
The (free) alternative is accomodating to the free-software project priorities and scheduling. I know there are problems with creation of custom plugins, I took notes and will check on those whenever I get some free time. But currently our priority is developing means for full automatic performance and integration tests, which allow to do some critical upgrades to libnice and gstreamer libraries.
Sent: Friday, July 20, 2018 at 12:12 AM From: neilyoung notifications@github.com To: Kurento/bugtracker bugtracker@noreply.github.com Cc: "Juan Navarro" juan.navarro@gmx.es, Mention mention@noreply.github.com Subject: Re: [Kurento/bugtracker] Cannot build opencv module (#280)
OK, guys. After all those years I thought I would be tough enough to make it, after having seen the Super Mario hat on my head. I admit, I was wrong: Even though I made it to roll my own OpenCV module and put it under your server, so that the server is claiming to have it, there is no visible way on earth for me to make use of it from a simple browser app (it does not have to be Node or Java, just plain JS).
THANKS A LOT for this great experience 👎
-- You are receiving this because you were mentioned. Reply to this email directly or view it on GitHub: https://github.com/Kurento/bugtracker/issues/280#issuecomment-406430379
I'm trying to create my first KMS plugin (at least I'm hoping to do so). Following http://doc-kurento.readthedocs.io/en/stable/user/writing_modules.html#opencv-module IMHO there is a missing step in doc between
kurento-module-scaffold.sh <module_name> <output_directory> opencv_filter
and
cd build
cmake ..
since the build directory is not existent after scaffolding.
However, I can scaffold and compile, but I can't link. Here is the final linker error, which I can't get over currently:
OS is Ubuntu 16.04, 64 bit. Any pointer welcome.