Custom OpenCV module

145 views
Skip to first unread message

fazi r

unread,
Sep 16, 2021, 10:33:21 AM9/16/21
to kurento
Hi,
I'm trying to install a custom OpenCV module compiled by myself.

In attachments you can find the source of the plugin.
After I've compiled the src with "docker run --rm --mount type=bind,src="$PWD",dst=/hostdir kurento/kurento-buildpackage:bionic --install-kurento 6.16.0 --apt-add-repo --release", I found three .deb files inside working directory.

I've created a Dockerfile with this lines of code (I need to install opencv 3.2 because is not present inside kurento default image):
---
FROM kurento/kurento-media-server:latest 

ADD opencv_install /opencv_install
WORKDIR /opencv_install
RUN dpkg -i *.deb

WORKDIR /
COPY plugin.deb /
RUN dpkg -i plugin.deb
---
After that I will restart openvidu kms deployment with new image builded and log in into kms shell.
I will launch "kurento-media-server --version and kurento-media-server --list" but module is not listed.

Any help?
plugin.zip

Neil Young

unread,
Sep 16, 2021, 10:46:13 AM9/16/21
to kurento
You should check the kms logs if possible in order to find out if your module got loaded. This is traced. Not sure how to do that in a container, but if you can gain console access you could launch the server manually and see what happens

Neil Young

unread,
Sep 16, 2021, 10:48:56 AM9/16/21
to kurento
And maybe you check the code. I might have overseen this, but I only see one "break" from an inner while loop, while the outer while is not left. The `process` callback is called for every single frame.

Ruben Fazi

unread,
Sep 16, 2021, 11:19:27 AM9/16/21
to kur...@googlegroups.com
I've found in the logs this warning: 2021-09-16T14:16:44,994396 1 0x00007f461cc1c280 warning KurentoModuleManager      ModuleManager.cpp:65 loadModule()  Module /usr/lib/x86_64-linux-gnu/kurento/modules/libkmsmycvmodulemodule.so cannot be loaded: /usr/lib/x86_64-linux-gnu/libkmsmycvmoduleimpl.so.0: undefined symbol: _ZTv0_n64_NK7kurento12OpenCVFilter7getTypeB5cxx11Ev

How can I solve this?

--
You received this message because you are subscribed to a topic in the Google Groups "kurento" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/kurento/6-9nvIPmh98/unsubscribe.
To unsubscribe from this group and all its topics, send an email to kurento+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/kurento/d4ec7f5b-7659-45b6-ab64-3ed99f29bfa5n%40googlegroups.com.

Neil Young

unread,
Sep 16, 2021, 11:23:25 AM9/16/21
to kurento
What OpenCV version is installed?

Ruben Fazi

unread,
Sep 16, 2021, 11:25:33 AM9/16/21
to kur...@googlegroups.com
3.2 but is installed on kurento image meanwhile the deb package was compiled with kurento-module-compiler with it's own opencv packages

Neil Young

unread,
Sep 16, 2021, 11:39:04 AM9/16/21
to kurento
I had issues like this with OpenCV exports in 2019. That time KMS was supporting OpenCV 2 only and I had a hard time to convince it to use OpenCV 3. Meanwhile 3 is there, but you must have a hidden imported symbol (kurentoOpenCVFIlter?) which is not resolvable from the installed OpenCV version in the container...Did you scaffold the plugin on the target machine? I always scaffolded and compiled my plugin on the target... And OpenCV is dynamically linked, as far as I remember.

Ruben Fazi

unread,
Sep 17, 2021, 4:25:09 AM9/17/21
to kur...@googlegroups.com
The problem is that I don't have a target machine because I'm using docker to use OpenVidu. I've create the scaffold with a container with Ubuntu 18.04:
----
FROM ubuntu:18.04

RUN apt-get update && apt-get install --no-install-recommends --yes gnupg

RUN apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 5AFA7A83
RUN echo "deb [arch=amd64] http://ubuntu.openvidu.io/6.16.0 bionic kms6" | tee /etc/apt/sources.list.d/kurento.list

RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install --no-install-recommends --yes kurento-media-server-dev

RUN mkdir /module

RUN apt install -y git
RUN git config --global user.email "y...@example.com"
RUN git config --global user.name "Your Name"

RUN kurento-module-scaffold KurentoModule /module true
----
And then I copied the module folder:
----
docker build -t scaff .
docker run --rm --mount type=bind,src="$PWD",dst=/hostdir scaff cp -r /module /hostdir
-----


Neil Young

unread,
Sep 17, 2021, 4:40:03 AM9/17/21
to kurento
Can you access a shell in the container and look from there?

docker exec -it <container name> /bin/bash

Ruben Fazi

unread,
Sep 17, 2021, 4:44:07 AM9/17/21
to kur...@googlegroups.com
Yes I can but I cannot install  kurento-media-server-dev to create scaffold because there is a package conflict.

Neil Young

unread,
Sep 17, 2021, 4:46:38 AM9/17/21
to kurento
Not sure (not tested), but I would expect to find kurento-module-creator already in the container as part of the installation.

Ruben Fazi

unread,
Sep 17, 2021, 4:50:10 AM9/17/21
to kur...@googlegroups.com
In the official Kurento docker image there is only the kurento-media-server command. Probably you are talking about the dev image?

Neil Young

unread,
Sep 17, 2021, 4:54:56 AM9/17/21
to kur...@googlegroups.com
I always build from source.

Sorry, no idea.

You received this message because you are subscribed to the Google Groups "kurento" group.
To unsubscribe from this group and stop receiving emails from it, send an email to kurento+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/kurento/CAL8r_wCmBZ2kEO44ZL3zyj72wCyXTVACFKBx3NZwZLuRQcM5ig%40mail.gmail.com.

Juan Navarro

unread,
Oct 5, 2021, 6:53:02 AM10/5/21
to kur...@googlegroups.com
Hi,

I think that your problem might be happening because you build a binary object (your OpenCV plugin) in one version of Ubuntu, and then try to make it run in a different one. This is the cause Nº1 for linkage errors and things like "libkmsmycvmoduleimpl.so.0: undefined symbol: _ZTv0_n64_NK7kurento12OpenCVFilter7getTypeB5cxx11Ev"

When building binaries in linux, the safest bet is to do it in the same machine type and version than the destination. Because the Kurento Docker images are based on "ubuntu:16.04", that's where you should be building your plugin.

You can install "kurento-module-creator" without issues in a Kurento container:

# On the host:
docker run -ti --rm --entrypoint /bin/bash kurento/kurento-media-server:latest

# On the container:
apt-get update && apt-get install kurento-module-creator


There is an added problem: Ubuntu 16.04 (Xenial) came with OpenCV 2.x:

apt-cache policy libopencv-dev | grep Candidate
  Candidate: 2.4.9.1+dfsg-1.5ubuntu1.1


While Ubuntu 18.04 (Bionic) came with OpenCV 3.x:

apt-cache policy libopencv-dev | grep Candidate
  Candidate: 3.2.0+dfsg-4ubuntu0.1



So if you build your plugin against OpenCV 3, then it will surely fail if you copy it and try to run with OpenCV 2.

Ideally, if your plugin is compatible with OpenCV 2, you would build it inside a 16.04 container, and it will have a compatible binary API for usage in Kurento Docker containers.

So I find two possibilities:

  • If your plugin can be built with the OpenCV 2.x that comes with Ubuntu 16.04, nice! all is done, and it's a good step towards making it work.
  • Otherwise, you'd need to check if it's too much effort to add conditionals (#if and such) so that it compiles, or otherwise maybe trying to install OpenCV 3.x on Ubuntu 16.04 (but that will be tricky and much more complicated to get right)

We are well aware that Ubuntu 16.04 is an ancient version, that now is even End Of Life, so we're planning on finally pulling the plug and upgrading to Ubuntu 18.04 and Kurento 7.0 towards the end of this year.


Regards,
Juan
You received this message because you are subscribed to the Google Groups "kurento" group.
To unsubscribe from this group and stop receiving emails from it, send an email to kurento+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/kurento/CAL8r_wAFeSwsp7%2BDw1AL80kn5Ycy6GrrLLzjTdt6FSrYyFsmyw%40mail.gmail.com.

Neil Young

unread,
Oct 5, 2021, 8:23:37 AM10/5/21
to kurento
This is most likely the reason, as already suspected earlier. 

Vitalii Napastiuk

unread,
Feb 14, 2022, 3:24:52 AM2/14/22
to kurento
Hi, we have resolved our previous issues by installing the plugin on an ubuntu 16.04 container. Now we have new problems, there is some features of opencv3  that we need to use for our purposes that aren't available in opencv2. You've mentioned in your answer that you're planning to upgrade kurento to Ubuntu 18.04 soon. Can you tell us when the upgrade will be made? 

Neil Young

unread,
Feb 14, 2022, 5:23:13 AM2/14/22
to kur...@googlegroups.com
Kurento is right now available as apt installation for 18.04. And by that it supports OpenCV 3 natively. You can even compile KMS from source in order to use it on 20.04. Also OpenCV 4 works with KMS

Sent from my iPhone


Am 14.02.2022 um 09:24 schrieb Vitalii Napastiuk <napv...@gmail.com>:

Hi, we have resolved our previous issues by installing the plugin on an ubuntu 16.04 container. Now we have new problems, there is some features of opencv3  that we need to use for our purposes that aren't available in opencv2. You've mentioned in your answer that you're planning to upgrade kurento to Ubuntu 18.04 soon. Can you tell us when the upgrade will be made? 
Message has been deleted

Neil Young

unread,
Feb 15, 2022, 9:50:18 AM2/15/22
to kur...@googlegroups.com
Getting this mail not the third time. Do you know, why?

Regards

Am 14.02.2022 um 17:11 schrieb Vitalii Napastiuk <napv...@gmail.com>:


Thank you for your answer. I have another question, as far as you know if we install opencv contrib module will it work with kms? 
Reply all
Reply to author
Forward
0 new messages