# Python MPA image example

Source: https://forum.modalai.com/topic/3631/python-mpa-image-example
Category: VOXL SDK and Software (https://forum.modalai.com/category/47/voxl-sdk-and-software)
Tags: mpa
Posted: 2024-07-11 13:43:00 UTC by david.moro
Replies: 7 · Views: 5051

## david.moro · 2024-07-11 13:43:00 UTC

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!

## Reply by Alex Kushleyev (ModalAI staff) · 2024-07-11 15:06:14 UTC

@david-moro , here is a complete example that receives rtsp stream and publishes images via MPA:

https://gitlab.com/voxl-public/voxl-sdk/utilities/voxl-mpa-tools/-/blob/pympa-experimental/tools/python/rtsp_rx_mpa_pub.py

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 least `pympa.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

## Reply by david.moro · 2024-07-11 18:47:44 UTC

Awesome! Will give it a try. Thanks @Alex-Kushleyev !

## Reply by david.moro · 2024-07-12 13:03:52 UTC (in reply to david.moro)

@Alex-Kushleyev , it worked. Thanks!

## Reply by Alex Kushleyev (ModalAI staff) · 2024-07-12 19:18:45 UTC (in reply to david.moro)

@david-moro , awesome! thanks for confirming.

Alex

## Reply by Meytal Lempel · 2025-03-11 07:22:29 UTC (in reply to Alex Kushleyev)

@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

## Reply by Alex Kushleyev (ModalAI staff) · 2025-03-11 13:25:48 UTC (in reply to Meytal Lempel)

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/4e9f35ee26217e490c28cf559f4c4b33e0bacd59

Native 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 VOXL1

I hope this helps! 

Alex

## Reply by Meytal Lempel · 2025-03-13 16:38:51 UTC (in reply to Alex Kushleyev)

@Alex-Kushleyev Thank you, it works!
