Python MPA image example
-
Hi, I am working on the integration of a camera on the VOXL2. The camera acts as a USB CDC device and outputs an 8-bit greyscale image on ttyACM0. The manufacturer provides a python example to talk to the camera. I was able to deploy it on the voxl2 and read the images. Now I would like to push those to a pipeline for consumption by voxl-streamer and other processes. Do you have any sample code or guidance on how to do this on python? I would like to have a functional prototype of the whole thing before porting it to C++.
Thanks!
-
@david-moro , here is a complete example that receives rtsp stream and publishes images via MPA:
You need to build
voxl-mpa-tools
package from this branch and install it on VOXL2. The python scripts will get installed to/usr/share/modalai/voxl-mpa-tools/
, you will need at leastpympa.py
which provides wrappers for python bindings for the mpa functions.libpympa.so
will be installed to/usr/lib
which contains the C side of the bindings.Since you don't need opencv, you can just extract the mpa publishing part from the example and add it to your python camera code.
Alex
-
Awesome! Will give it a try. Thanks @Alex-Kushleyev !
-
@Alex-Kushleyev , it worked. Thanks!
-
@david-moro , awesome! thanks for confirming.
Alex
-
@Alex-Kushleyev Hi!
My team and I are working with both voxl1 and voxl2 based platforms. We used your example and changed it to publish a ros topic (Image) to pipe on voxl2. It works great. Now we try to do the same on voxl1 (compiling the same code to ipk) and encounter the problem:
Traceback (most recent call last): File "ros_img_mpa_pub.py", line 19, in <module> from pympa import * File "/usr/share/modalai/voxl-mpa-tools/pympa.py", line 23, in <module> pympa = ct.CDLL("libpympa.so") File "/usr/lib/python3.6/ctypes/__init__.py", line 348, in __init__ self._handle = _dlopen(self._name, mode) OSError: libpympa.so: wrong ELF class: ELFCLASS64
Is there any other branch that may be suitable for voxl1 to our purpose?
Thank you, Meytal
-
Hi @Meytal-Lempel ,
There was an issue causing a 64 bit library to be installed into
/usr/lib
on VOXL1. 32 bit library was never built. I fixed the issue on the pympa branch : https://gitlab.com/voxl-public/voxl-sdk/utilities/voxl-mpa-tools/-/commit/4e9f35ee26217e490c28cf559f4c4b33e0bacd59Native python3 on VOXL1 is 32 bit.
After building and installing the ipk on voxl1, you can check the library for 32 bit:
readelf -a /usr/lib/libpympa.so | more ELF Header: Magic: 7f 45 4c 46 01 01 01 00 00 00 00 00 00 00 00 00 Class: ELF32 Data: 2's complement, little endian
The 64-bit
libpympa.so
library will now go to/usr/lib64
, as it should on VOXL1I hope this helps!
Alex
-
@Alex-Kushleyev Thank you, it works!