maix.example

example module, this will be maix.example module in MaixPy, maix::example namespace in MaixCDK

You can use maix.example to access this module with MaixPy
This module is generated from MaixCDK

Module

No module

Enum

Kind

item doc
brief Example enum
values KIND_NONE: Kind none, value always 0, other enum value will auto increase
KIND_DOG: Kind dog
KIND_CAT: Kind cat, value is auto generated according to KING_DOG
KIND_BIRD:
KIND_MAX: Max Kind quantity
You can get max Kind value by KIND_MAX - 1

C++ defination code:

enum Kind
        {
            KIND_NONE = 0, /** Kind none, value always 0, other enum value will auto increase */
            KIND_DOG,      /** Kind dog*/
            KIND_CAT,      // Kind cat, value is auto generated according to KING_DOG
            KIND_BIRD,
            KIND_MAX /* Max Kind quantity,
                        You can get max Kind value by KIND_MAX - 1
                     */
        }

Variable

var1

item doc
brief Example module variable
attention It's a copy of this variable in MaixPy,
so change it in C++ (e.g. update var in hello function) will not take effect the var inMaixPy.
So we add const for this var to avoid this mistake.
value "Sipeed"
readonly True

C++ defination code:

const std::string var1 = "Sipeed"

list_var

item doc
brief Tensor data type size in bytes
attention 1. DO NOT use C/C++ array directly for python API, the python wrapper not support it.
Use std::vector instead.
2. It's a copy of this variable in MaixPy,
so change it in C++ (e.g. update var in hello function) will not take effect the var inMaixPy.
So we add const for this var to avoid this mistake.
value {
0, 1, 2, 3, 4, 5, 6, 7, 8, 9}
readonly True

C++ defination code:

const std::vector<int> list_var = {
            0, 1, 2, 3, 4, 5, 6, 7, 8, 9}

test_var

item doc
brief Example module variable test_var
attention It's a copy of this variable in MaixPy, so if you change it in C++, it will not take effect in MaixPy.
And change it in MaixPy will not take effect in C++ as well !!!
If you want to use vars shared between C++ and MaixPy, you can create a class and use its member.
value 100
readonly False

C++ defination code:

int test_var = 100

Function

hello

def hello(name: str) -> str
item doc
brief say hello to someone
param name: direction [in], name of someone, string type
return string type, content is hello + name

C++ defination code:

std::string hello(std::string name)

change_arg_name

item doc
brief Change arg name example
param e: Example object
return same as arg

C++ defination code:

example::Example *change_arg_name(example::Example *e)

change_arg_name2

def change_arg_name2(e: Example) -> None
item doc
brief Change arg name example
param e: Example object

C++ defination code:

void change_arg_name2(example::Example &e)

Class

Test

item doc
brief Test class

C++ defination code:

class Test

__init__

def __init__(self) -> None
item doc
type func
brief Test constructor
static False

C++ defination code:

Test()

Example

item doc
brief Example class\nthis class will be export to MaixPy as maix.example.Example

C++ defination code:

class Example

__init__

def __init__(self, name: str, age: int = 18, pet: Kind = ...) -> None
item doc
type func
brief Example constructor\nthis constructor will be export to MaixPy as maix.example.Example.init
param name: direction [in], name of Example, string type
age: direction [in], age of Example, int type, default is 18, value range is [0, 100]
attention to make auto generate code work, param Kind should with full namespace name example::Kind instead of Kind,
namespace maix can be ignored.
static False

C++ defination code:

Example(std::string &name, int age = 18, example::Kind pet = example::KIND_NONE)

get_name

def get_name(self) -> str
item doc
type func
brief get name of Example\nyou can also get name by property name.
return name of Example, string type
static False

C++ defination code:

std::string get_name()

get_age

def get_age(self) -> int
item doc
type func
brief get age of Example
return age of Example, int type, value range is [0, 100]
static False

C++ defination code:

int get_age()

set_name

def set_name(self, name: str) -> None
item doc
type func
brief set name of Example
param name: name of Example, string type
static False

C++ defination code:

void set_name(std::string name)

set_age

def set_age(self, age: int) -> None
item doc
type func
brief set age of Example
param age: age of Example, int type, value range is [0, 100]
static False

C++ defination code:

void set_age(int age)

set_pet

def set_pet(self, pet: Kind) -> None
item doc
type func
brief Example enum member
attention
static False

C++ defination code:

void set_pet(example::Kind pet)

get_pet

def get_pet(self) -> Kind
item doc
type func
brief Example enum member
static False

C++ defination code:

example::Kind get_pet()

get_list

def get_list(self, in: list[int]) -> list[int]
item doc
type func
brief get list example
param in: direction [in], input list, items are int type.
In MaixPy, you can pass list or tuple to this API
return list, items are int type, content is [1, 2, 3] + in. Alloc item, del in MaixPy will auto free memory.
static False

C++ defination code:

std::vector<int> *get_list(std::vector<int> in)

get_dict

def get_dict(self, in: dict[str, int]) -> dict[str, int]
item doc
type func
brief Example dict API
param in: direction [in], input dict, key is string type, value is int type.
In MaixPy, you can pass dict to this API
return dict, key is string type, value is int type, content is {"a": 1} + in
In MaixPy, return type is dict object
static False

C++ defination code:

std::map<std::string, int> get_dict(std::map<std::string, int> &in)

hello

def hello(name: str) -> str
item doc
type func
brief say hello to someone
param name: name of someone, string type
return string type, content is Example::hello_str + name
static True

C++ defination code:

static std::string hello(std::string name)

hello_bytes

def hello_bytes(*args, **kwargs)
item doc
type func
brief param is bytes example
param bytes: bytes type param
return bytes type, return value is bytes changed value
static True

C++ defination code:

static Bytes *hello_bytes(Bytes &bytes)

callback

def callback(cb: typing.Callable[[int, int], int]) -> int
item doc
type func
brief Callback example
param cb: callback function, param is two int type, return is int type
return int type, return value is cb(1, 2)
static True

C++ defination code:

static int callback(std::function<int(int, int)> cb)

hello_dict

def hello_dict(dict: dict[str, int]) -> dict[str, int]
item doc
type func
brief Dict param example
param dict: dict type param, key is string type, value is int type
static True

C++ defination code:

static std::map<std::string, int> *hello_dict(std::map<std::string, int> *dict)

name

item doc
type var
brief name member of Example
static False
readonly False

C++ defination code:

std::string name

age

item doc
type var
brief age member of Example, value range should be [0, 100]
static False
readonly False

C++ defination code:

int age

hello_str

item doc
type var
brief hello_str member of Example, default value is "hello "
static True
readonly False

C++ defination code:

static std::string hello_str

var1

item doc
type var
brief Example module readonly variable
static False
readonly True

C++ defination code:

const std::string var1 = "Example.var1"

var2

item doc
type var
brief Example module readonly variable
static False
readonly True

C++ defination code:

std::string var2 = "Example.var2"

dict_test

def dict_test() -> dict[str, Test]
item doc
type func
brief dict_test, return dict type, and element is pointer type(alloc in C++).\nHere when the returned Tensor object will auto delete by Python GC.
static True

C++ defination code:

static std::map<std::string, example::Test *> *dict_test()