plugin/element
  • 30 May 2022
  • 2 Minutes to read
  • Contributors
  • Dark
    Light

plugin/element

  • Dark
    Light

Article Summary

Essential tools

How to run a basic image display?

you can run the following test command for:
Linux

$ gst-launch-1.0 videotestsrc ! ximagesink

Windows

> gst-launch-1.0 videotestsrc ! d3dvideosink

Why my custom python plugin can not get correct return value from my import C/C++ library or pass correct arguments to my import C/C++ library?

Do not forget to bind correct return and signatures in Python(More Python calling functions in DLLs or shared libraries could be found in Python document). While importing the external library into python, do not remember to bind the correct ctype for return and signatures. For example, While calling three functions in ADLINK AVS_SDK(or other C/C++ API library you are going to import):

  • AVS_GetProductHandle
  • AVS_GetProductType
  • AVS_DIOSetDOState
    Remember to bind each return and signatures as below:
C_POINTER = ctypes.POINTER(ctypes.c_int)
avs_lib = ctypes.CDLL("/usr/local/lib/libAVS_SDK.so")
avs_lib.AVS_GetProductHandle.restype = C_POINTER
avs_lib.AVS_GetProductHandle.argtypes = [ctypes.c_int]
avs_lib.AVS_GetProductType.restype = C_POINTER
avs_lib.AVS_GetProductType.argtypes = [ctypes.c_int]
avs_lib.AVS_DIOSetDOState.restype = ctypes.c_int
avs_lib.AVS_DIOSetDOState.argtypes = [C_POINTER, ctypes.c_int, ctypes.c_int]

You can refer to the writing method of ADLINK AVS_SDK python plugin here: GPIOAlert.py.

How to config the meson build system when 3rd party libraries used in element/plugin?

If there are 3rd party library used in the element(like opencv, DLib, GPIO, etc.), meson build configuration(meson.build) required to edit. For example, if user is going to use "libNeon.so" in element source code, the user is required to add the library path and include path in the meson.build. Then add them to the element library dependencies array. For example, when utilizing the 3rd party library: libNeon.so, add the below lines in the meson.build first:

avs_root_dir = get_option('avs_dir')
libs_avs = []
libs_avs += cc.find_library('Neon',
                required : true,
                dirs : [join_paths(avs_root_dir)])

the above lines find the required library "libNeon.so" from assigned "dirs" path in variable libs_avs in ubuntu. get_option('avs_dir') is the function to get the meson option variable defined in meson_option.txt. Second, add the include path below:

inc_avs = include_directories('/usr/include/Neon')

the above line set the include path in variable inc_avs. When the both library and include path are set ready, declare the dependency below:

avs_dep = declare_dependency(
  dependencies : libs_avs,
  include_directories: inc_avs,
)

After the dependency variable is set, add this dependency variable to the element library finally:

library('weardetection',
    'gstweardetection.cpp',
    dependencies : [gst, gst_base, gst_video, cv_dep, gstmeta_dep, avs_dep],
  )

Here, we assume the user is going to add the 3rd party library in custom element modified from the Showcases, weardetection plugin. After the meson.build is modified, user can keep following the compilation process like sample source codes, Showcases, useful AI Applications which you can find in this portal. Here are the example used in this question you can download for reference.

add_3rd_party_in_meson_syntax.zip


Was this article helpful?

What's Next