Page 1 of 1

What is the simplest way to create my own python function ?

Posted: Tue Jul 16, 2019 11:44 am
by chrisPyres66
Dear all,

I have some problem of memory size with F7 cam if my python code is too big, not yet with H7, lol

To improve this, and my knowledge, i would like to do and integrate my own python function with openmv github source.

I have so two questions :

- What is the simplest way to create my own python function ?

- How get the latest github openmv update all along keeping my own function ?

Thanks for help,

Re: What is the simplest way to create my own python function ?

Posted: Tue Jul 16, 2019 4:17 pm
by iabdalkader
There's no documentation for this you have to read the code. To keep your changes, you have to know your way around github. If your function is general and useful enough, send a pull request and we'll merge it in the upstream firmware.

Re: What is the simplest way to create my own python function ?

Posted: Wed Jul 17, 2019 5:06 am
by chrisPyres66
Well thanks, but i dont know if i am sure to do a good and generic code well integrated enough to github it...
I tried to do a manual exposition and gain control (MEC and MGC) in function of a ROI luminance in a gray image.

Re: What is the simplest way to create my own python function ?

Posted: Wed Jul 17, 2019 1:52 pm
by kwagyeman
Um, so there are a lot of Pull Requests that you can look at done by me that show how to add methods. It's not really hard. See the closed Pull Requests in the OpenMV GitHub. You can see exactly what changes are needed there.

Re: What is the simplest way to create my own python function ?

Posted: Thu Jul 25, 2019 2:43 am
by chrisPyres66
Is it possible to have a template lib for newbie like there are in imlib_config.h ?

Re: What is the simplest way to create my own python function ?

Posted: Thu Jul 25, 2019 10:37 am
by kwagyeman
What do you mean?

Re: What is the simplest way to create my own python function ?

Posted: Thu Aug 01, 2019 5:46 am
by chrisPyres66
Sorry i was not very explicit, because i proposed a solution and dit not with the idea.
The idea is to have a template python function included in the github for newbie to understand how it works and test it.

I think to do it by myseld, i should
- create and add in py directory the files : py_file.c and py_file.h
- create function in py_file like py_file_functioname()
- modifiy MakeFile of OMV directory by adding py_file.o in FIRM_OBJ and py_file.c in SRCS
- adding import file in the python code, and use the function by calling with functioname()

It is something close ?
Thanks for help,

Re: What is the simplest way to create my own python function ?

Posted: Thu Aug 01, 2019 1:54 pm
by kwagyeman
Yes, that's about right. You know, folks keep failing to find the wiki and asking this. I think I'll move the wiki to the readme file along with adding a note about how to do this.