Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

linux support - any specific reason or just "no linux"? #6

Open
yarikoptic opened this issue Jan 26, 2023 · 1 comment
Open

linux support - any specific reason or just "no linux"? #6

yarikoptic opened this issue Jan 26, 2023 · 1 comment

Comments

@yarikoptic
Copy link

magewell SDK provides dynamic library also for Linux, so I would assume it would have similar to .dll API?

I've not done of "loading dynamic libraries from Python" recently so not sure what to do about following but I would expect it to be possible to load the .so as well:

In [1]: from ctypes import cdll

In [2]: l = cdll.LoadLibrary('./Capture/Lib/x64/libMWCapture.so')
---------------------------------------------------------------------------
OSError                                   Traceback (most recent call last)
Input In [2], in <cell line: 1>()
----> 1 l = cdll.LoadLibrary('./Capture/Lib/x64/libMWCapture.so')

File /usr/lib/python3.10/ctypes/__init__.py:452, in LibraryLoader.LoadLibrary(self, name)
    451 def LoadLibrary(self, name):
--> 452     return self._dlltype(name)

File /usr/lib/python3.10/ctypes/__init__.py:374, in CDLL.__init__(self, name, mode, handle, use_errno, use_last_error, winmode)
    371 self._FuncPtr = _FuncPtr
    373 if handle is None:
--> 374     self._handle = _dlopen(self._name, mode)
    375 else:
    376     self._handle = handle

OSError: ./Capture/Lib/x64/libMWCapture.so: undefined symbol: snd_mixer_first_elem

where that symbol is provided by /usr/lib/x86_64-linux-gnu/libasound.so, but libMWCapture.so didn't link against it... googled myself into a solution

In [3]: from ctypes import CDLL, RTLD_GLOBAL

In [4]: CDLL('libasound.so', mode = RTLD_GLOBAL)
Out[4]: <CDLL 'libasound.so', handle 5618b3565990 at 0x7f86b8247eb0>

In [5]: CDLL('libudev.so', mode = RTLD_GLOBAL)
Out[5]: <CDLL 'libudev.so', handle 5618b3568d20 at 0x7f86b3548190>

In [6]: CDLL('libv4l2.so', mode = RTLD_GLOBAL)
Out[6]: <CDLL 'libv4l2.so', handle 5618b3552d70 at 0x7f86b8158d60>

In [7]: l = CDLL('./Capture/Lib/x64/libMWCapture.so', mode = RTLD_GLOBAL)

In [11]: l
Out[11]: <CDLL './Capture/Lib/x64/libMWCapture.so', handle 5618b32912c0 at 0x7f86b83a4490>

so I guess could be loaded fine under Linux ;-)

@crnbaker
Copy link
Collaborator

Hey, sorry for the extremely slow reply. pymagewell is based on and includes a python file called libmwcapture.py which is provided by Magewell with their SDK. This file only supports Windows. It looks like it might be trivial to modify the file to load .so libraries on linux but I do not have a linux system with a frame grabber to try this out on. It would be great it you could have a go at getting it to work on your system! It might simply be a case of modifying line 715 of libmwcapture.py to load the .so file as you have done above.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants