ModalAI Forum
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Register
    • Login

    Python MPA image example

    Modal Pipe Architecture (MPA)
    3
    8
    364
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • D
      david.moro
      last edited by

      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!

      Alex KushleyevA 1 Reply Last reply Reply Quote 0
      • Alex KushleyevA
        Alex Kushleyev ModalAI Team @david.moro
        last edited by Alex Kushleyev

        @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

        1 Reply Last reply Reply Quote 0
        • D
          david.moro
          last edited by

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

          D 1 Reply Last reply Reply Quote 0
          • D
            david.moro @david.moro
            last edited by

            @Alex-Kushleyev , it worked. Thanks!

            Alex KushleyevA 1 Reply Last reply Reply Quote 0
            • Alex KushleyevA
              Alex Kushleyev ModalAI Team @david.moro
              last edited by

              @david-moro , awesome! thanks for confirming.

              Alex

              Meytal LempelM 1 Reply Last reply Reply Quote 0
              • Meytal LempelM
                Meytal Lempel @Alex Kushleyev
                last edited by

                @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

                Alex KushleyevA 1 Reply Last reply Reply Quote 0
                • Alex KushleyevA
                  Alex Kushleyev ModalAI Team @Meytal Lempel
                  last edited by Alex Kushleyev

                  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

                  Meytal LempelM 1 Reply Last reply Reply Quote 0
                  • Meytal LempelM
                    Meytal Lempel @Alex Kushleyev
                    last edited by

                    @Alex-Kushleyev Thank you, it works!

                    1 Reply Last reply Reply Quote 0
                    • First post
                      Last post
                    Powered by NodeBB | Contributors