This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

AM5728: create an application to run a python code

Part Number: AM5728

Hi 

Now i'm working with 'matrix app launcher' and created an example icon but that runs a shell script only .i already  create python code in terminal and run it successfully there.Now i need to open that code with an application icon that is i need to create an app working with a python code.How can i do this ? (i create the application based on this link below)

processors.wiki.ti.com/.../Matrix_Users_Guide

  • Hello Aju s,

    Just to confirm, you have your own application and you are executing this demo in the console and it works fine.
    Now, you want to add this demo to matrix launcher and execute it from there right?

    BR
    Margarita
  • Hello,

    If the above understanding is right then I will give you an example which already exists.
    Under multimedia folder there is an h265dec example.
    If you cd usr/share/matrix-gui-2.0/apps/arm_multimedia_h265dec/ you will see two files.
    The HTML file contains the application description. You could cat the arm_multimedia_h265dec.desktop and check it.
    This line :
    Exec=runH265Dec.sh
    executes a shell script called runH265Dec.sh in this case.
    This shell script runH265Dec.sh could be found here:
    /usr/bin

    If you are searching how to run your program(binary) via shell script I would recommend you to google it.


    Hope this helps.

    BR
    Margarita
  • Hi thanks for your reply.
    Now i create a sample python code to print hello world and include it in shell script ,which works fine .
    here is the shell script:-
    #!/bin/bash
    /usr/bin/python /usr/share/matrix-gui-2.0/apps/ex_application/tst.py

    but now occurs the real problem,I wrote a python code with importing 'open cv' then the terminal shows some error and code doesn't work in the application icon.
    this is my code:-
    import numpy as np
    import cv2

    img = cv2.imread('rgb.jpg')
    np_image = np.array(img)

    num_list = np_image.tolist()
    str1 =str(num_list)
    print( len(num_list))

    Error in terminal:-
    [ 6860.067644] omap_hwmod: mmu0_dsp2: _wait_target_disable failed
    [ 6860.073549] omap-iommu 41501000.mmu: 41501000.mmu: version 3.0
    [ 6860.079683] omap-iommu 41502000.mmu: 41502000.mmu: version 3.0
    [ 6860.093489] omap_hwmod: mmu0_dsp1: _wait_target_disable failed
    [ 6860.099385] omap-iommu 40d01000.mmu: 40d01000.mmu: version 3.0
    [ 6860.105342] omap-iommu 40d02000.mmu: 40d02000.mmu: version 3.0
    [ 6870.136544] omap_hwmod: mmu1_dsp1: _wait_target_disable failed
    [ 6870.149842] omap_hwmod: mmu0_dsp1: _wait_target_disable failed
    [ 6870.163511] omap_hwmod: mmu1_dsp2: _wait_target_disable failed
    [ 6870.176696] omap_hwmod: mmu0_dsp2: _wait_target_disable failed

    (i can run the code directly in terminal and got output but the above error message is same)
    i don't know why the code doesn't have an output in shell script ?why that error message shown ?
    How to run the code in shell script ?

    i hope if you gave me a valid answer it may help others also, that who were facing the same problem.

    Aju S

  • Hello,

    What is the software that you are using here?

    Aju s said:
    but now occurs the real problem,I wrote a python code with importing 'open cv' then the terminal shows some error and code doesn't work in the application icon.

    Is this working when is executed in the console? If yes, are you executing something else in the console before to run it?

    BR
    Margarita

  • Thanks for your support Margarita
    I found the solution .The problem is related with openCV.
    Solution:
    "Even if the image path is wrong, it won’t throw any error, but 'print img' will give you 'None' ".Which is mentioned in the openCV documentation . So i changed the line

    img = cv2.imread('rgb.jpg')

    to

    img = cv2.imread('/usr/share/matrix-gui-2.0/apps/ex_application/rgb.jpg')


    Aju S
  • Hello Aju S,

    I am glad that this issue is solved.
    Thank you for sharing the solution.

    BR
    Margarita