Using the plugin to get data¶
API provides a EnablePlugin()
function to enable plugins under a path.
Official provided plugins for calculating binocular parallax are now available in the MYNTEYE_BOX located in the Plugins
directory.
Plugins/
├─linux-x86_64/
│ ├─libplugin_b_ocl1.2_opencv3.4.0.so
│ ├─libplugin_g_cuda9.1_opencv2.4.13.5.so
│ ├─libplugin_g_cuda9.1_opencv3.3.1.so
│ └─libplugin_g_cuda9.1_opencv3.4.0.so
├─tegra-armv8/
└─win-x86_64/
- The
linux-x86_64
directory shows the system and architecture.- You can find your CPU architecture from system information or
uname -a
.
- You can find your CPU architecture from system information or
- The library name
libplugin_*
shows the plugin identity and the third party dependency.b
g
is a plugin identifier, indicating that different algorithms are used.ocl1.2
shows it dependence onOpenCL 1.2
, if it exists.cuda9.1
shows it dependence onCUDA 9.1
, if it exists.opencv3.4.0
shows it dependence onOpenCV 3.4.0
, if it exists.mynteye2.0.0
shows it dependency onMYNT EYE SDK 2.0.0
, if it exists.
First, select the plugins that you are going to use depending on your situation. If you relying on third parties, please install a corresponding version.
Then, enable the plugin with the following code:
auto &&api = API::Create(argc, argv);
api->EnablePlugin("plugins/linux-x86_64/libplugin_g_cuda9.1_opencv3.4.0.so");
The path can be an absolute path or a relative path (relative to the current working directory).
Finally, just call the API to get the data as before.
Tip
If the plugin is not enabled, api->Start(Source::VIDEO_STREAMING);
will automatically find the appropriate plug-in in the <sdk>/plugins/<platform>
directory to load.
In other words, you can move the plug-in directory of the current platform into the < SDK > / plugins
directory. To automatically load the official plugin, install the corresponding CUDA
OpenCV
plugin dependency, recompiling and then run API
layer interface program.
Before running, please execute the following commands to ensure that the plugin’s dependency library can be searched:
# Linux
export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH
# /usr/local/lib 指依赖库所在路径
# macOS
export DYLD_LIBRARY_PATH=/usr/local/lib:$DYLD_LIBRARY_PATH
# /usr/local/lib 指依赖库所在路径
# Windows
set PATH=C:\opencv\x64\vc14\bin;%PATH%
# 或者,添加进系统环境变量 Path 里。
In addition, the following command can be executed to check whether the dependency Library of the plug-in can be searched:
# Linux
ldd *.so
# *.so 指具体插件路径
# macOS
otool -L *.dylib
# *.dylib 指具体插件路径
# Windows
# 请下载如 Dependency Walker ,打开 DLL 。
If the plugin’s dependent library is not found, it will report an error “Open plugin failed” when loading.
Complete code sample, see get_with_plugin.cc .
Tip
Linux can also add a dependency library path to the system environment, so that the compiled program can run directly. (does not require export LD_LIBRARY_PATH
in the terminal then run again).
- Create a
/etc/ld.so.conf.d/libmynteye.conf
file and write the dependent library path. - Execute the
sudo /sbin/ldconfig
command in the terminal and refresh the cache.
# libmynteye configuration
#
# 1) Copy this file to: /etc/ld.so.conf.d/libmynteye.conf
# 2) Run this cmd in Terminal: sudo /sbin/ldconfig
/usr/local/cuda/lib64
$HOME/opencv-3.4.1/lib