diff --git a/maixpy/en/index.html b/maixpy/en/index.html index b722746..ef02aa3 100644 --- a/maixpy/en/index.html +++ b/maixpy/en/index.html @@ -183,14 +183,14 @@

MaixPy

MaixPy (v4)

Easily create AI projects with Python on edge device

-
- Quick Start 🚀📖 - API Reference 📚 - Hardware:MaixCAM 📷 - Source Code ⭐️ +
+ Quick Start 🚀📖 + API Reference 📚 + Hardware:MaixCAM 📷 + Source Code ⭐️
-

GitHub Repo starsApache 2.0PyPIPyPI - DownloadsGitHub repo size Build MaixCAMTrigger wiki

+

GitHub Repo starsApache 2.0PyPIPyPI - DownloadsGitHub repo size Build MaixCAMTrigger wiki

English | 中文

@@ -202,7 +202,7 @@

Easily create AI projects with Python on edge device

-
+

Easy-to-use API, AI vision classify in 10 lines

from maix import camera, display, image, nn
@@ -225,9 +225,10 @@ 

Easy-to-use API, AI vision classify in 10 lines

+

Hardware peripheral control:

-
+

Serial send and receive:

from maix import uart
@@ -239,7 +240,7 @@ 

Hardware peripheral control:

print("received:", serial.read(timeout = 2000))
-
+

I2C send and receive:

from maix import i2c
@@ -252,6 +253,7 @@ 

Hardware peripheral control:

+

MaixVision Workstation

diff --git a/maixpy/index.html b/maixpy/index.html index 923f76f..a7a7460 100644 --- a/maixpy/index.html +++ b/maixpy/index.html @@ -183,14 +183,14 @@

MaixPy

MaixPy (v4)

快速落地 AI 视觉、听觉应用

-
- 快速开始 🚀📖 - API 参考 📚 - 硬件平台:MaixCAM 📷 - 开源仓库 ⭐️ +
-

GitHub Repo starsApache 2.0PyPIPyPI - DownloadsGitHub repo size Build MaixCAMTrigger wiki

+

GitHub Repo starsApache 2.0PyPIPyPI - DownloadsGitHub repo size Build MaixCAMTrigger wiki

English | 中文

@@ -202,7 +202,7 @@

快速落地 AI 视觉、听觉应用

-
+

简易的 API 设计, 10 行代码进行 AI 图像识别:

from maix import camera, display, image, nn
@@ -225,9 +225,10 @@ 

简易的 API 设计, 10 行代码进行 AI 图像识别:

+

硬件外设控制,不在话下:

-
-
+
+

串口收发:

from maix import uart
@@ -239,7 +240,7 @@ 

硬件外设控制,不在话下:

print("received:", serial.read(timeout = 2000))
-
+

I2C 收发:

from maix import i2c
@@ -252,6 +253,7 @@ 

硬件外设控制,不在话下:

+

便捷的 MaixVision 工作站

diff --git a/maixpy/sitemap.xml b/maixpy/sitemap.xml index 9a1f1e4..9c790de 100644 --- a/maixpy/sitemap.xml +++ b/maixpy/sitemap.xml @@ -1,97 +1,97 @@ - https://wiki.sipeed.com/maixpy/api/maix/touchscreen.html + https://wiki.sipeed.com/maixpy/api/index.html 2024-03-28 weekly 1.0 - https://wiki.sipeed.com/maixpy/api/maix/peripheral/wdt.html + https://wiki.sipeed.com/maixpy/api/maix/touchscreen.html 2024-03-28 weekly 1.0 - https://wiki.sipeed.com/maixpy/api/maix/peripheral/spi.html + https://wiki.sipeed.com/maixpy/api/maix/peripheral/wdt.html 2024-03-28 weekly 1.0 - https://wiki.sipeed.com/maixpy/api/index.html + https://wiki.sipeed.com/maixpy/api/maix/peripheral/spi.html 2024-03-28 weekly 1.0 - https://wiki.sipeed.com/maixpy/api/maix/peripheral/uart.html + https://wiki.sipeed.com/maixpy/api/maix/peripheral.html 2024-03-28 weekly 1.0 - https://wiki.sipeed.com/maixpy/api/maix/peripheral/key.html + https://wiki.sipeed.com/maixpy/api/maix/app.html 2024-03-28 weekly 1.0 - https://wiki.sipeed.com/maixpy/api/maix/peripheral/adc.html + https://wiki.sipeed.com/maixpy/api/maix/i18n.html 2024-03-28 weekly 1.0 - https://wiki.sipeed.com/maixpy/api/maix/peripheral.html + https://wiki.sipeed.com/maixpy/api/maix/peripheral/timer.html 2024-03-28 weekly 1.0 - https://wiki.sipeed.com/maixpy/api/maix/app.html + https://wiki.sipeed.com/maixpy/api/maix/peripheral/i2c.html 2024-03-28 weekly 1.0 - https://wiki.sipeed.com/maixpy/api/maix/i18n.html + https://wiki.sipeed.com/maixpy/api/maix/peripheral/gpio.html 2024-03-28 weekly 1.0 - https://wiki.sipeed.com/maixpy/api/maix/peripheral/timer.html + https://wiki.sipeed.com/maixpy/api/maix/peripheral/pwm.html 2024-03-28 weekly 1.0 - https://wiki.sipeed.com/maixpy/api/maix/peripheral/i2c.html + https://wiki.sipeed.com/maixpy/api/maix/time.html 2024-03-28 weekly 1.0 - https://wiki.sipeed.com/maixpy/api/maix/peripheral/gpio.html + https://wiki.sipeed.com/maixpy/api/maix/fs.html 2024-03-28 weekly 1.0 - https://wiki.sipeed.com/maixpy/api/maix/example.html + https://wiki.sipeed.com/maixpy/api/maix/comm.html 2024-03-28 weekly 1.0 - https://wiki.sipeed.com/maixpy/api/maix/thread.html + https://wiki.sipeed.com/maixpy/api/maix/sys.html 2024-03-28 weekly 1.0 - https://wiki.sipeed.com/maixpy/api/maix/err.html + https://wiki.sipeed.com/maixpy/api/maix/display.html 2024-03-28 weekly 1.0 @@ -115,37 +115,37 @@ 1.0 - https://wiki.sipeed.com/maixpy/api/maix/comm.html + https://wiki.sipeed.com/maixpy/api/maix/example.html 2024-03-28 weekly 1.0 - https://wiki.sipeed.com/maixpy/api/maix/sys.html + https://wiki.sipeed.com/maixpy/api/maix/thread.html 2024-03-28 weekly 1.0 - https://wiki.sipeed.com/maixpy/api/maix/display.html + https://wiki.sipeed.com/maixpy/api/maix/err.html 2024-03-28 weekly 1.0 - https://wiki.sipeed.com/maixpy/api/maix/peripheral/pwm.html + https://wiki.sipeed.com/maixpy/api/maix/peripheral/uart.html 2024-03-28 weekly 1.0 - https://wiki.sipeed.com/maixpy/api/maix/time.html + https://wiki.sipeed.com/maixpy/api/maix/peripheral/key.html 2024-03-28 weekly 1.0 - https://wiki.sipeed.com/maixpy/api/maix/fs.html + https://wiki.sipeed.com/maixpy/api/maix/peripheral/adc.html 2024-03-28 weekly 1.0 @@ -193,25 +193,25 @@ 1.0 - https://wiki.sipeed.com/maixpy/doc/zh/basic/maixpy_upgrade.html - 2024-03-31 + https://wiki.sipeed.com/maixpy/doc/zh/vision/yolov5.html + 2024-03-07 weekly 1.0 - https://wiki.sipeed.com/maixpy/doc/zh/pro/compile_os.html + https://wiki.sipeed.com/maixpy/doc/zh/vision/face_recognize.html 2024-03-07 weekly 1.0 - https://wiki.sipeed.com/maixpy/doc/zh/modules/thermal_cam.html + https://wiki.sipeed.com/maixpy/doc/zh/vision/camera.html 2024-03-07 weekly 1.0 - https://wiki.sipeed.com/maixpy/doc/zh/modules/tof.html + https://wiki.sipeed.com/maixpy/doc/zh/vision/find_blobs.html 2024-03-07 weekly 1.0 @@ -241,175 +241,175 @@ 1.0 - https://wiki.sipeed.com/maixpy/doc/zh/source_code/faq.html + https://wiki.sipeed.com/maixpy/doc/zh/modules/acc.html 2024-03-07 weekly 1.0 - https://wiki.sipeed.com/maixpy/doc/zh/source_code/build.html - 2024-04-01 + https://wiki.sipeed.com/maixpy/doc/zh/audio/recognize.html + 2024-03-07 weekly 1.0 - https://wiki.sipeed.com/maixpy/doc/zh/source_code/maixcdk.html - 2024-03-07 + https://wiki.sipeed.com/maixpy/doc/zh/index.html + 2024-04-01 weekly 1.0 - https://wiki.sipeed.com/maixpy/doc/zh/source_code/add_c_module.html + https://wiki.sipeed.com/maixpy/doc/zh/source_code/contribute.html 2024-03-07 weekly 1.0 - https://wiki.sipeed.com/maixpy/doc/zh/peripheral/gpio.html + https://wiki.sipeed.com/maixpy/doc/zh/peripheral/wdt.html 2024-03-07 weekly 1.0 - https://wiki.sipeed.com/maixpy/doc/zh/peripheral/uart.html + https://wiki.sipeed.com/maixpy/doc/zh/peripheral/spi.html 2024-03-07 weekly 1.0 - https://wiki.sipeed.com/maixpy/doc/zh/peripheral/pwm.html - 2024-03-07 + https://wiki.sipeed.com/maixpy/doc/zh/peripheral/i2c.html + 2024-03-30 weekly 1.0 - https://wiki.sipeed.com/maixpy/doc/zh/modules/acc.html + https://wiki.sipeed.com/maixpy/doc/zh/peripheral/gpio.html 2024-03-07 weekly 1.0 - https://wiki.sipeed.com/maixpy/doc/zh/audio/recognize.html + https://wiki.sipeed.com/maixpy/doc/zh/peripheral/uart.html 2024-03-07 weekly 1.0 - https://wiki.sipeed.com/maixpy/doc/zh/index.html - 2024-04-01 + https://wiki.sipeed.com/maixpy/doc/zh/peripheral/pwm.html + 2024-03-07 weekly 1.0 - https://wiki.sipeed.com/maixpy/doc/zh/vision/self_learn_detector.html - 2024-03-30 + https://wiki.sipeed.com/maixpy/doc/zh/basic/maixpy_upgrade.html + 2024-03-31 weekly 1.0 - https://wiki.sipeed.com/maixpy/doc/zh/vision/apriltag.html + https://wiki.sipeed.com/maixpy/doc/zh/pro/compile_os.html 2024-03-07 weekly 1.0 - https://wiki.sipeed.com/maixpy/doc/zh/vision/self_learn_classifier.html + https://wiki.sipeed.com/maixpy/doc/zh/modules/thermal_cam.html 2024-03-07 weekly 1.0 - https://wiki.sipeed.com/maixpy/doc/zh/vision/object_track.html + https://wiki.sipeed.com/maixpy/doc/zh/modules/tof.html 2024-03-07 weekly 1.0 - https://wiki.sipeed.com/maixpy/doc/zh/source_code/contribute.html + https://wiki.sipeed.com/maixpy/doc/zh/source_code/faq.html 2024-03-07 weekly 1.0 - https://wiki.sipeed.com/maixpy/doc/zh/peripheral/wdt.html - 2024-03-07 + https://wiki.sipeed.com/maixpy/doc/zh/source_code/build.html + 2024-04-01 weekly 1.0 - https://wiki.sipeed.com/maixpy/doc/zh/peripheral/spi.html + https://wiki.sipeed.com/maixpy/doc/zh/source_code/maixcdk.html 2024-03-07 weekly 1.0 - https://wiki.sipeed.com/maixpy/doc/zh/peripheral/i2c.html - 2024-03-30 + https://wiki.sipeed.com/maixpy/doc/zh/source_code/add_c_module.html + 2024-03-07 weekly 1.0 - https://wiki.sipeed.com/maixpy/doc/zh/vision/display.html - 2024-03-31 + https://wiki.sipeed.com/maixpy/doc/zh/vision/self_learn_detector.html + 2024-03-30 weekly 1.0 - https://wiki.sipeed.com/maixpy/doc/zh/vision/body_key_points.html + https://wiki.sipeed.com/maixpy/doc/zh/vision/apriltag.html 2024-03-07 weekly 1.0 - https://wiki.sipeed.com/maixpy/doc/zh/vision/qrcode.html + https://wiki.sipeed.com/maixpy/doc/zh/vision/self_learn_classifier.html 2024-03-07 weekly 1.0 - https://wiki.sipeed.com/maixpy/doc/zh/vision/classify.html + https://wiki.sipeed.com/maixpy/doc/zh/vision/object_track.html 2024-03-07 weekly 1.0 - https://wiki.sipeed.com/maixpy/doc/zh/vision/image_ops.html - 2024-03-07 + https://wiki.sipeed.com/maixpy/doc/zh/vision/display.html + 2024-03-31 weekly 1.0 - https://wiki.sipeed.com/maixpy/doc/zh/vision/maixhub_train.html + https://wiki.sipeed.com/maixpy/doc/zh/vision/body_key_points.html 2024-03-07 weekly 1.0 - https://wiki.sipeed.com/maixpy/doc/zh/vision/ai.html + https://wiki.sipeed.com/maixpy/doc/zh/vision/qrcode.html 2024-03-07 weekly 1.0 - https://wiki.sipeed.com/maixpy/doc/zh/vision/yolov5.html + https://wiki.sipeed.com/maixpy/doc/zh/vision/classify.html 2024-03-07 weekly 1.0 - https://wiki.sipeed.com/maixpy/doc/zh/vision/face_recognize.html + https://wiki.sipeed.com/maixpy/doc/zh/vision/image_ops.html 2024-03-07 weekly 1.0 - https://wiki.sipeed.com/maixpy/doc/zh/vision/camera.html + https://wiki.sipeed.com/maixpy/doc/zh/vision/maixhub_train.html 2024-03-07 weekly 1.0 - https://wiki.sipeed.com/maixpy/doc/zh/vision/find_blobs.html + https://wiki.sipeed.com/maixpy/doc/zh/vision/ai.html 2024-03-07 weekly 1.0 @@ -422,7 +422,7 @@ https://wiki.sipeed.com/maixpy/doc/en/no_translate.html - 2024-04-02 + 2024-04-03 weekly 1.0 diff --git a/maixpy/static/search_index/index_0.json b/maixpy/static/search_index/index_0.json index 4e98a3a..e4d7ee9 100644 --- a/maixpy/static/search_index/index_0.json +++ b/maixpy/static/search_index/index_0.json @@ -1 +1 @@ -{"/maixpy/api/maix/touchscreen.html":{"title":"maix.touchscreen","content":" title: maix.touchscreen maix.touchscreen module > This module is generated from [MaixCDK](https://github.com/sipeed/MaixCDK) > You can use `maix.touchscreen` to access this module. ## Module No module ## Enum ## Variable ## Function ## Class ### TouchScreen item doc **brief** TouchScreen class **C++ defination code**: ```cpp class TouchScreen ``` #### \\_\\_init\\_\\_ item doc **type** func **brief** Construct a new TouchScreen object **param** **device**: touchscreen device path, you can get devices by list_devices method, by default(value is NULL(None in MaixPy)) means the first device
**open**: If true, touchscreen will automatically call open() after creation. default is true.
**static** False **C++ defination code**: ```cpp TouchScreen(const std::string &device \"\", bool open true) ``` #### open item doc **type** func **brief** open touchscreen device **return** error code, err::ERR_NONE means success, others means failed **static** False **C++ defination code**: ```cpp err::Err open() ``` #### close item doc **type** func **brief** close touchscreen device **return** error code, err::ERR_NONE means success, others means failed **static** False **C++ defination code**: ```cpp err::Err close() ``` #### read item doc **type** func **brief** read touchscreen device **attention** This method will discard same event in buffer, that is:
if too many move event in buffer when call this method, it will only return the last one,
and if read pressed or released event, it will return immediately. **return** Returns a list include x, y, pressed state **static** False **C++ defination code**: ```cpp std::vector read() ``` #### read (overload 1) item doc **type** func **brief** read touchscreen device **attention** This method will return immediately if have event, so it's better to use available() to check if have more event in buffer,
or too much event in buffer when your program call this read() interval is too long will make your program slow. **return** Returns a list include x, y, pressed state **static** False **C++ defination code**: ```cpp std::vector read0() ``` #### available item doc **type** func **brief** If we need to read from touchscreen, for event driven touchscreen means have event or not **param** **timeout**: 1 means block, 0 means no block, >0 means timeout, default is 0, unit is ms.
**return** true if need to read(have event), false if not **static** False **C++ defination code**: ```cpp bool available(int timeout 0) ``` #### is\\_opened item doc **type** func **brief** Check if touchscreen is opened **return** true if touchscreen is opened, false if not **static** False **C++ defination code**: ```cpp bool is_opened() ```"},"/maixpy/api/maix/peripheral/wdt.html":{"title":"maix.peripheral.wdt","content":" title: maix.peripheral.wdt maix.peripheral.wdt module > This module is generated from [MaixCDK](https://github.com/sipeed/MaixCDK) > You can use `maix.peripheral.wdt` to access this module. ## Module No module ## Enum ## Variable ## Function ## Class ### WDT item doc **brief** Peripheral wdt class **C++ defination code**: ```cpp class WDT ``` #### \\_\\_init\\_\\_ item doc **type** func **brief** WDT constructor **param** **id**: direction [in], id of wdt, int type
**feed_ms**: direction [in], feed ms of wdt, int type
**static** False **C++ defination code**: ```cpp WDT(int id, int feed_ms) ``` #### feed item doc **type** func **brief** feed wdt **return** error code, if feed success, return err::ERR_NONE **static** False **C++ defination code**: ```cpp int feed() ``` #### stop item doc **type** func **brief** stop wdt **static** False **C++ defination code**: ```cpp int stop() ``` #### restart item doc **type** func **brief** restart wdt **attention** restart WDT after stop it **static** False **C++ defination code**: ```cpp int restart() ```"},"/maixpy/api/maix/peripheral/spi.html":{"title":"maix.peripheral.spi","content":" title: maix.peripheral.spi maix.peripheral.spi module > This module is generated from [MaixCDK](https://github.com/sipeed/MaixCDK) > You can use `maix.peripheral.spi` to access this module. ## Module No module ## Enum ## Variable ### MASTER\\_MODE item doc **brief** spi master mode **value** **0x1** **readonly** True **C++ defination code**: ```cpp const int MASTER_MODE 0x1 ``` ### SLAVE\\_MODE item doc **brief** spi slave mode **value** **0x2** **readonly** True **C++ defination code**: ```cpp const int SLAVE_MODE 0x2 ``` ### CLOCK\\_MODE\\_0 item doc **brief** clock mode 0 **attention** CPOL 0, CPHA 0
means the idle level of the clock is low, data is captured on the first edge of the SPI clock cycle **value** **0x0** **readonly** True **C++ defination code**: ```cpp const int CLOCK_MODE_0 0x0 ``` ### CLOCK\\_MODE\\_1 item doc **brief** clock mode 1 **attention** CPOL 0, CPHA 1
means the idle level of the clock is low, data is captured on the second edge of the SPI clock cycle **value** **0x1** **readonly** True **C++ defination code**: ```cpp const int CLOCK_MODE_1 0x1 ``` ### CLOCK\\_MODE\\_2 item doc **brief** clock mode 2 **attention** CPOL 1, CPHA 0
means the idle level of the clock is high, data is captured on the first edge of the SPI clock cycle **value** **0x2** **readonly** True **C++ defination code**: ```cpp const int CLOCK_MODE_2 0x2 ``` ### CLOCK\\_MODE\\_3 item doc **brief** clock mode 3 **attention** CPOL 1, CPHA 1
means the idle level of the clock is high, data is captured on the second edge of the SPI clock cycle **value** **0x3** **readonly** True **C++ defination code**: ```cpp const int CLOCK_MODE_3 0x3 ``` ## Function ## Class ### SPI item doc **brief** Peripheral spi class **C++ defination code**: ```cpp class SPI ``` #### \\_\\_init\\_\\_ item doc **type** func **brief** SPI constructor **param** **id**: direction [in], id of spi, int type
**sclk**: direction [in], sclk pin of spi, int type
**mosi**: direction [in], mosi pin of spi, int type
**miso**: direction [in], miso pin of spi, int type
**cs**: direction [in], cs pin of spi, int type
**freq**: direction [in], freq of spi, int type
**use_soft_cs**: direction [in], use_soft_cs of spi, int type
this param is valid in master mode, when use_soft_cs 1, the
cs pin must be operated manually when sending data. default is 1, means use hardware cs
**mode**: direction [in], mode of spi, int type
option:
mode spi.MASTER, means use master mode
mode spi.SLAVE, means use slave mode
defualt is 1, means use spi.MASTER mode
**clock_mode**: direction [in], clock_mode of spi, int type,default is 1
option:
clock_mode spi.CLOCK_MODE_0, @see CLOCK_MODE_0
clock_mode spi.CLOCK_MODE_1, @see CLOCK_MODE_1
clock_mode spi.CLOCK_MODE_2, @see CLOCK_MODE_2
clock_mode spi.CLOCK_MODE_3, @see CLOCK_MODE_3
default is 1, means use CLOCK_MODE_0
**static** False **C++ defination code**: ```cpp SPI(int id, int sclk, int mosi, int miso, int cs, int freq, int use_soft_cs 1, int mode 1, int clock_mode 1) ``` #### cs\\_high item doc **type** func **brief** set cs pin to high level **static** False **C++ defination code**: ```cpp int cs_high() ``` #### cs\\_low item doc **type** func **brief** set cs pin to low level **static** False **C++ defination code**: ```cpp int cs_low() ``` #### read item doc **type** func **brief** read data from spi **param** **read_len**: direction [in], read length, int type
**return** read data, vector type **static** False **C++ defination code**: ```cpp std::vector read(int read_len) ``` #### write item doc **type** func **brief** write data to spi **param** **write_data**: direction [in], write data, vector type
the member range of the list is [0,255]
**return** error code, if write success, return err::ERR_NONE **static** False **C++ defination code**: ```cpp int write(std::vector write_data std::vector{}) ``` #### read\\_write item doc **type** func **brief** set spi status to high level or low level **param** **write_data**: direction [in], write data, vector type
the member range of the list is [0,255]
**read_len**: direction [in], read length, int type
default is 1, means read_len write_data.size()
**return** read data, vector type **static** False **C++ defination code**: ```cpp std::vector read_write( std::vector write_data std::vector{}, int read_len 1) ``` #### is\\_busy item doc **type** func **brief** get busy status of spi **return** busy status, bool type **static** False **C++ defination code**: ```cpp bool is_busy() ```"},"/maixpy/api/index.html":{"title":"MaixPy API -- Maix AI machine vision platform Python API","content":" title: MaixPy API Maix AI machine vision platform Python API **You can read API doc at [MaixPy API on Sipeed Wiki](https://wiki.sipeed.com/maixpy/api/index.html)** If you want to preview API doc offline, build MaixPy, and API doc will be generated in `MaixPy/docs/api/` directory. > For MaixPy developer: This API documentation is generated from the source code, DO NOT edit this file manually! MaixPy API documentation, modules: module brief [maix.err](./maix/err.html) maix.err module [maix.tensor](./maix/tensor.html) maix.tensor module [maix.image](./maix/image.html) maix.image module, image related definition and functions [maix.camera](./maix/camera.html) maix.camera module, access camera device and get image from it [maix.display](./maix/display.html) maix.display module, control display device and show image on it [maix.comm](./maix/comm.html) maix.comm module [maix.thread](./maix/thread.html) maix.thread module [maix.fs](./maix/fs.html) maix.fs module [maix.sys](./maix/sys.html) maix.sys module [maix.time](./maix/time.html) maix.time module [maix.i18n](./maix/i18n.html) maix.i18n module [maix.protocol](./maix/protocol.html) maix.protocol module [maix.example](./maix/example.html) example module, this will be maix.example module in MaixPy, maix::example namespace in MaixCDK [maix.app](./maix/app.html) maix.app module [maix.nn](./maix/nn.html) maix.nn module [maix.peripheral](./maix/peripheral.html) Chip's peripheral driver [maix.touchscreen](./maix/touchscreen.html) maix.touchscreen module "},"/maixpy/api/maix/peripheral/uart.html":{"title":"maix.peripheral.uart","content":" title: maix.peripheral.uart maix uart peripheral driver > This module is generated from [MaixCDK](https://github.com/sipeed/MaixCDK) > You can use `maix.peripheral.uart` to access this module. ## Module No module ## Enum ### PARITY item doc **brief** uart parity enum **values** **PARITY_NONE**: no parity
**PARITY_ODD**: odd parity
**PARITY_EVEN**: even parity
**PARITY_MAX**:
**C++ defination code**: ```cpp enum PARITY { PARITY_NONE 0x00, // no parity PARITY_ODD 0x01, // odd parity PARITY_EVEN 0x02, // even parity PARITY_MAX } ``` ### STOP item doc **brief** uart stop bits **values** **STOP_1**: 1 stop bit
**STOP_2**: 2 stop bits
**STOP_1_5**: 1.5 stop bits
**STOP_MAX**:
**C++ defination code**: ```cpp enum STOP { STOP_1 0x01, // 1 stop bit STOP_2 0x02, // 2 stop bits STOP_1_5 0x03, // 1.5 stop bits STOP_MAX } ``` ### BITS item doc **brief** uart stop bits **values** **BITS_5**: 5 data bits
**BITS_6**: 6 data bits
**BITS_7**: 7 data bits
**BITS_8**: 8 data bits
**BITS_MAX**:
**C++ defination code**: ```cpp enum BITS { BITS_5 5, // 5 data bits BITS_6 6, // 6 data bits BITS_7 7, // 7 data bits BITS_8 8, // 8 data bits BITS_MAX } ``` ### FLOW\\_CTRL item doc **brief** uart flow control **values** **FLOW_CTRL_NONE**: no flow control
**FLOW_CTRL_HW**: hardware flow control
**FLOW_CTRL_MAX**:
**C++ defination code**: ```cpp enum FLOW_CTRL { FLOW_CTRL_NONE 0, // no flow control FLOW_CTRL_HW 1, // hardware flow control FLOW_CTRL_MAX } ``` ## Variable ## Function ### list\\_ports item doc **brief** Get supported uart ports. **return** uart ports list, string type. **C++ defination code**: ```cpp std::vector list_ports() ``` ## Class ### UART item doc **brief** maix uart peripheral driver **C++ defination code**: ```cpp class UART : public comm::CommBase ``` #### \\_\\_init\\_\\_ item doc **type** func **brief** UART constructor. You need to call open() to open the device. **param** **port**: uart port. string type, can get it by uart.list_ports().
If empty, will not open device in constructor, default empty.
if not empty, will auto open device in constructor, open fail will throw err.Exception.
**baudrate**: baudrate of uart. int type, default 115200.
**databits**: databits, values @see uart.DATA_BITS
**parity**: parity, values @see uart.PARITY
**stopbits**: stopbits, values @see uart.STOP_BITS
**flow_control**: flow_control, values @see uart.FLOW_CTRL
**static** False **C++ defination code**: ```cpp UART(const std::string &port \"\", int baudrate 115200, uart::BITS databits uart::BITS_8, uart::PARITY parity uart::PARITY_NONE, uart::STOP stopbits uart::STOP_1, uart::FLOW_CTRL flow_ctrl uart::FLOW_CTRL_NONE) ``` #### set\\_port item doc **type** func **brief** Set port **param** **port**: uart port. string type, can get it by uart.list_ports().
**return** set port error code, err.Err type. **static** False **C++ defination code**: ```cpp err::Err set_port(const std::string &port) ``` #### get\\_port item doc **type** func **brief** Get port **return** uart port, string type. **static** False **C++ defination code**: ```cpp std::string get_port() ``` #### set\\_baudrate item doc **type** func **brief** Set baud rate **param** **baudrate**: baudrate of uart. int type, default 115200.
**return** set baud rate error code, err.Err type. **static** False **C++ defination code**: ```cpp err::Err set_baudrate(int baudrate) ``` #### get\\_baudrate item doc **type** func **brief** Get baud rate **return** baud rate, int type. **static** False **C++ defination code**: ```cpp int get_baudrate() ``` #### open item doc **type** func **brief** Open uart device, before open, port must be set in constructor or by set_port().\\nIf already opened, do nothing and return err.ERR_NONE. **return** open device error code, err.Err type. **static** False **C++ defination code**: ```cpp err::Err open() ``` #### is\\_open item doc **type** func **brief** Check if device is opened. **return** true if opened, false if not opened. **static** False **C++ defination code**: ```cpp bool is_open() ``` #### close item doc **type** func **brief** Close uart device, if already closed, do nothing and return err.ERR_NONE. **return** close device error code, err.Err type. **static** False **C++ defination code**: ```cpp err::Err close() ``` #### write\\_str item doc **type** func **brief** Send string data **param** **str**: string data
**return** sent data length, < 0 means error, value is err.Err. **static** False **C++ defination code**: ```cpp int write_str(const std::string &str) ``` #### write item doc **type** func **brief** Send data to uart **param** **data**: direction [in], data to send, bytes type. If you want to send str type, use str.encode() to convert.
**return** sent length, int type, if < 0 means error, value is err.Err. **static** False **C++ defination code**: ```cpp int write(Bytes &data) ``` #### available item doc **type** func **brief** Check if data available or wait data available. **param** **timeout**: unit ms, timeout to wait data, default 0.
0 means check data available and return immediately,
> 0 means wait until data available or timeout.
1 means wait until data available.
**return** available data number, 0 if timeout or no data, <0 if error, value is err.Err, can be err::ERR_IO, err::ERR_CANCEL, err::ERR_NOT_OPEN. **throw** err.Exception if fatal error. **static** False **C++ defination code**: ```cpp int available(int timeout 0) ``` #### read item doc **type** func **brief** Recv data from uart **param** **len**: max data length want to receive, default 1.
1 means read data in uart receive buffer.
>0 means read len data want to receive.
other values is invalid.
**timeout**: unit ms, timeout to receive data, default 0.
0 means read data in uart receive buffer and return immediately,
1 means block until read len data,
>0 means block until read len data or timeout.
**return** received data, bytes type.
Attention, you need to delete the returned object yourself in C++. **static** False **C++ defination code**: ```cpp Bytes *read(int len 1, int timeout 0) ``` #### readline item doc **type** func **brief** Read line from uart, that is read until '\\n' or '\\r\\n'. **param** **timeout**: unit ms, timeout to receive data, default 1 means block until read '\\n' or '\\r\\n'.
> 0 means block until read '\\n' or '\\r\\n' or timeout.
**return** received data, bytes type. If timeout will return the current received data despite not read '\\n' or '\\r\\n'.
e.g. If we want to read b'123\\n', but when we only read b'12', timeout, then return b'12'. **static** False **C++ defination code**: ```cpp Bytes *readline(int timeout 1) ```"},"/maixpy/api/maix/peripheral/key.html":{"title":"maix.peripheral.key","content":" title: maix.peripheral.key maix.peripheral.key module > This module is generated from [MaixCDK](https://github.com/sipeed/MaixCDK) > You can use `maix.peripheral.key` to access this module. ## Module No module ## Enum ### Keys item doc **brief** Keys enum, id the same as linux input.h(input event codes.h) **values** **KEY_NONE**:
**KEY_ESC**:
**KEY_OK**:
**KEY_OPTION**:
**KEY_NEXT**:
**KEY_PREV**:
**C++ defination code**: ```cpp enum Keys{ KEY_NONE 0x000, KEY_ESC 0x001, KEY_OK 0x160, KEY_OPTION 0x165, KEY_NEXT 0x197, KEY_PREV 0x19c } ``` ### State item doc **brief** Key state enum **values** **KEY_RELEASED**:
**KEY_PRESSED**:
**C++ defination code**: ```cpp enum State{ KEY_RELEASED 0, KEY_PRESSED 1, } ``` ## Variable ## Function ### add\\_default\\_listener item doc **brief** Add default listener, if you want to exit app when press ok button, you can just call this function.\\nThis function is auto called in MaixPy' startup code, so you don't need to call it in MaixPy.\\nCreate Key object will auto call rm_default_listener() to cancel the default ok button function.\\nWhen ok button pressed, a SIGINT signal will be raise and call app.set_exit_flag(True). **C++ defination code**: ```cpp void add_default_listener() ``` ### rm\\_default\\_listener item doc **brief** Remove default listener, if you want to cancel the default ok button function(exit app), you can just call this function. **C++ defination code**: ```cpp void rm_default_listener() ``` ## Class ### Key item doc **brief** Key input class **C++ defination code**: ```cpp class Key ``` #### \\_\\_init\\_\\_ item doc **type** func **brief** Key Device constructor **param** **callback**: When key triggered and callback is not empty(empty In MaixPy is None, in C++ is nullptr),
callback will be called with args key(key.Keys) and value(key.State).
If set to null, you can get key value by read() function.
This callback called in a standalone thread, so you can block a while in callback, and you should be carefully when operate shared data.
**open**: auto open device in constructor, if false, you need call open() to open device
**static** False **C++ defination code**: ```cpp Key(std::function callback nullptr, bool open true) ``` #### open item doc **type** func **brief** Open(Initialize) key device, if already opened, will close first and then open. **return** err::Err type, err.Err.ERR_NONE means success **static** False **C++ defination code**: ```cpp err::Err open() ``` #### close item doc **type** func **brief** Close key device **return** err::Err type, err.Err.ERR_NONE means success **static** False **C++ defination code**: ```cpp err::Err close() ``` #### is\\_opened item doc **type** func **brief** Check key device is opened **return** bool type, true means opened, false means closed **static** False **C++ defination code**: ```cpp bool is_opened() ``` #### read item doc **type** func **brief** Read key input, and return key and value, if callback is set, DO NOT call this function manually. **return** list type, first is key(maix.key.Keys), second is value(maix.key.State), if no key input, return [0, 0] **throw** If read failed, will throw maix.err.Exception. **static** False **C++ defination code**: ```cpp std::pair read() ```"},"/maixpy/api/maix/peripheral/adc.html":{"title":"maix.peripheral.adc","content":" title: maix.peripheral.adc maix.peripheral.adc module > This module is generated from [MaixCDK](https://github.com/sipeed/MaixCDK) > You can use `maix.peripheral.adc` to access this module. ## Module No module ## Enum ## Variable ### RES\\_BIT\\_8 item doc **brief** 8 bit resolution, supported by the actual hardware **value** **0x1** **readonly** True **C++ defination code**: ```cpp const int RES_BIT_8 0x1 ``` ### RES\\_BIT\\_10 item doc **brief** 10 bit resolution, supported by the actual hardware **value** **0x2** **readonly** True **C++ defination code**: ```cpp const int RES_BIT_10 0x2 ``` ### RES\\_BIT\\_12 item doc **brief** 12 bit resolution, supported by the actual hardware **value** **0x3** **readonly** True **C++ defination code**: ```cpp const int RES_BIT_12 0x3 ``` ### RES\\_BIT\\_16 item doc **brief** 16 bit resolution, supported by the actual hardware **value** **0x4** **readonly** True **C++ defination code**: ```cpp const int RES_BIT_16 0x4 ``` ## Function ## Class ### ADC item doc **brief** Peripheral adc class **C++ defination code**: ```cpp class ADC ``` #### \\_\\_init\\_\\_ item doc **type** func **brief** ADC constructor **param** **pin**: direction [in], adc pin, int type
**resolution**: direction [in], adc resolution. default is 1, means use default resolution
option:
resolution adc.RES_BIT_8, means 8 bit resolution
resolution adc.RES_BIT_10, means 10 bit resolution
resolution adc.RES_BIT_12, means 12 bit resolution
resolution adc.RES_BIT_16, means 16 bit resolution
the default resolution is determined by actual hardware.
**vref**: direction [in], adc refer voltage. default is 1, means use default refer voltage.
the default vref is determined by actual hardware. range: [0.0, 10.0]
**static** False **C++ defination code**: ```cpp ADC(int pin, int resolution 1, float vref 1) ``` #### read item doc **type** func **brief** read adc value **return** adc data, int type
if resolution is 8 bit, return value range is [0, 255]
if resolution is 10 bit, return value range is [0, 1023]
if resolution is 12 bit, return value range is [0, 4095]
if resolution is 16 bit, return value range is [0, 65535] **static** False **C++ defination code**: ```cpp int read() ``` #### read\\_vol item doc **type** func **brief** read adc voltage **return** adc voltage, float type。the range is [0.0, vref] **static** False **C++ defination code**: ```cpp float read_vol() ```"},"/maixpy/api/maix/peripheral.html":{"title":"maix.peripheral","content":" title: maix.peripheral Chip's peripheral driver > This module is generated from [MaixCDK](https://github.com/sipeed/MaixCDK) > You can use `maix.peripheral` to access this module. ## Module module brief [timer](./peripheral/timer.html) maix.peripheral.timer module [wdt](./peripheral/wdt.html) maix.peripheral.wdt module [pwm](./peripheral/pwm.html) maix.peripheral.pwm module [gpio](./peripheral/gpio.html) maix.peripheral.gpio module [spi](./peripheral/spi.html) maix.peripheral.spi module [uart](./peripheral/uart.html) maix uart peripheral driver [key](./peripheral/key.html) maix.peripheral.key module [i2c](./peripheral/i2c.html) maix.peripheral.i2c module [adc](./peripheral/adc.html) maix.peripheral.adc module ## Enum ## Variable ## Function ## Class"},"/maixpy/api/maix/app.html":{"title":"maix.app","content":" title: maix.app maix.app module > This module is generated from [MaixCDK](https://github.com/sipeed/MaixCDK) > You can use `maix.app` to access this module. ## Module No module ## Enum ## Variable ## Function ### app\\_id item doc **brief** Get current APP ID. **return** APP ID. **C++ defination code**: ```cpp string app_id() ``` ### set\\_app\\_id item doc **brief** Set current APP ID. **param** **app_id**: APP ID.
**C++ defination code**: ```cpp string set_app_id(const string &app_id) ``` ### get\\_apps\\_info\\_path item doc **brief** Get APP info file path. **C++ defination code**: ```cpp string get_apps_info_path() ``` ### get\\_apps\\_info item doc **brief** Get APP info list. **param** **ignore_launcher**: if true, ignore launcher APP. default false.
**ignore_app_store**: if true, ignore app store APP. default false.
**return** APP info list. APP_Info object list. **C++ defination code**: ```cpp vector &get_apps_info(bool ignore_launcher false, bool ignore_app_store false) ``` ### get\\_app\\_data\\_path item doc **brief** Get APP info, APP can store private data in this directory. **return** APP data path \"./data\", just return the data folder in current path because APP executed in app install path or project path.
So, you must execute your program in you project path to use the project/data folder when you debug your APP. **C++ defination code**: ```cpp string get_app_data_path() ``` ### get\\_app\\_path item doc **brief** Get APP path. **param** **app_id**: APP ID, if empty, return current APP path, else return the APP path by app_id.
**return** APP path, just return the current path because APP executed in app install path or project path.
So, you must execute your program in you project path to use the project/data folder when you debug your APP. **C++ defination code**: ```cpp string get_app_path(const string &app_id \"\") ``` ### get\\_tmp\\_path item doc **brief** Get global temporary data path, APPs can use this path as temporary data directory. **return** temporary data path. **C++ defination code**: ```cpp string get_tmp_path() ``` ### get\\_share\\_path item doc **brief** Get data path of share, shared data like picture and video will put in this directory **return** share data path. **C++ defination code**: ```cpp string get_share_path() ``` ### get\\_picture\\_path item doc **brief** Get picture path of share, shared picture will put in this directory **return** share picture path. **C++ defination code**: ```cpp string get_picture_path() ``` ### get\\_video\\_path item doc **brief** Get video path of share, shared video will put in this directory **return** share video path. **C++ defination code**: ```cpp string get_video_path() ``` ### get\\_font\\_path item doc **brief** Get font path of share, shared font will put in this directory **return** share font path. **C++ defination code**: ```cpp string get_font_path() ``` ### get\\_icon\\_path item doc **brief** Get icon path of share, shared icon will put in this directory **return** share icon path. **C++ defination code**: ```cpp string get_icon_path() ``` ### get\\_sys\\_config\\_kv item doc **brief** Get system config item value. **param** **item**: name of setting item, e.g. wifi, language. more see settings APP.
**key**: config key, e.g. for wifi, key can be ssid, for language, key can be locale.
**value**: default value, if not found, return this value.
**from_cache**: if true, read from cache, if false, read from file.
**return** config value, always string type, if not found, return empty string. **C++ defination code**: ```cpp string get_sys_config_kv(const string &item, const string &key, const string &value \"\", bool from_cache true) ``` ### get\\_app\\_config\\_kv item doc **brief** Get APP config item value. **param** **item**: name of setting item, e.g. user_info
**key**: config key, e.g. for user_info, key can be name, age etc.
**value**: default value, if not found, return this value.
**from_cache**: if true, read from cache, if false, read from file.
**return** config value, always string type, if not found, return empty string. **C++ defination code**: ```cpp string get_app_config_kv(const string &item, const string &key, const string &value \"\", bool from_cache true) ``` ### set\\_app\\_config\\_kv item doc **brief** Set APP config item value. **param** **item**: name of setting item, e.g. user_info
**key**: config key, e.g. for user_info, key can be name, age etc.
**value**: config value, always string type.
**write_file**: if true, write to file, if false, just write to cache.
**return** err::Err **C++ defination code**: ```cpp err::Err set_app_config_kv(const string &item, const string &key, const string &value, bool write_file true) ``` ### get\\_app\\_config\\_path item doc **brief** Get APP config path, ini format, so you can use your own ini parser to parse it like `configparser` in Python.\\nAll APP config info is recommended to store in this file. **return** APP config path(ini format). **C++ defination code**: ```cpp string get_app_config_path() ``` ### set\\_exit\\_msg item doc **brief** Set APP exit code and exit message.\\nIf code ! 0, the launcher will show a dialog to user, and display the msg. **param** **code**: exit code, 0 means success, other means error, if code is 0, do nothing.
**msg**: exit message, if code is 0, msg is not used.
**return** exit code, the same as arg @code. **C++ defination code**: ```cpp err::Err set_exit_msg(err::Err code, const string &msg) ``` ### get\\_exit\\_msg item doc **brief** Get APP exit code and exit message. **param** **cache**: if true, read from cache, if false, read from file. default false.
**return** exit return app_id, exit code and exit message. **C++ defination code**: ```cpp tuple get_exit_msg(bool cache false) ``` ### have\\_exit\\_msg item doc **brief** Check if have exit msg **param** **cache**: if true, just check from cache, if false, check from file. default false.
**return** true if have exit msg, false if not. **C++ defination code**: ```cpp bool have_exit_msg(bool cache false) ``` ### switch\\_app item doc **brief** Exit this APP and start another APP(by launcher).\\nCall this API will call set_exit_flag(true), you should check app::need_exit() in your code.\\nAnd exit this APP if app::need_exit() return true. **param** **app_id**: APP ID which will be started. app_id and idx must have one is valid.
**idx**: APP index. app_id and idx must have one is valid.
**C++ defination code**: ```cpp void switch_app(const string &app_id, int idx 1) ``` ### need\\_exit item doc **brief** Shoule this APP exit? **return** true if this APP should exit, false if not. **attention** This API is a function, not a variable. **C++ defination code**: ```cpp bool need_exit() ``` ### running item doc **brief** App should running? The same as !app::need_exit() (not app::need_exit() in MaixPy). **return** true if this APP should running, false if not. **attention** This API is a function, not a variable. **C++ defination code**: ```cpp bool running() ``` ### set\\_exit\\_flag item doc **brief** Set exit flag. You can get exit flag by app.need_exit(). **param** **exit**: true if this APP should exit, false if not.
**C++ defination code**: ```cpp void set_exit_flag(bool exit) ``` ## Class ### Version item doc **brief** APP version **C++ defination code**: ```cpp class Version ``` #### \\_\\_str\\_\\_ item doc **type** func **brief** Convert to string, e.g. 1.0.0 **static** False **C++ defination code**: ```cpp std::string __str__() ``` #### from\\_str item doc **type** func **brief** Convert from string, e.g. \\\"1.0.0\\\" **static** True **C++ defination code**: ```cpp static app::Version from_str(const string &version_str) ``` ### APP\\_Info item doc **brief** APP info **C++ defination code**: ```cpp class APP_Info ``` #### id item doc **type** var **brief** APP id **static** False **readonly** False **C++ defination code**: ```cpp string id ``` #### name item doc **type** var **brief** APP name **static** False **readonly** False **C++ defination code**: ```cpp string name ``` #### icon item doc **type** var **brief** APP icon **static** False **readonly** False **C++ defination code**: ```cpp string icon ``` #### version item doc **type** var **brief** APP version **static** False **readonly** False **C++ defination code**: ```cpp Version version ``` #### exec item doc **type** var **brief** APP exec **static** False **readonly** False **C++ defination code**: ```cpp string exec ``` #### author item doc **type** var **brief** APP author **static** False **readonly** False **C++ defination code**: ```cpp string author ``` #### desc item doc **type** var **brief** APP desc **static** False **readonly** False **C++ defination code**: ```cpp string desc ``` #### names item doc **type** var **brief** APP names **static** False **readonly** False **C++ defination code**: ```cpp map names ``` #### descs item doc **type** var **brief** APP descs **static** False **readonly** False **C++ defination code**: ```cpp map descs ```"},"/maixpy/api/maix/i18n.html":{"title":"maix.i18n","content":" title: maix.i18n maix.i18n module > This module is generated from [MaixCDK](https://github.com/sipeed/MaixCDK) > You can use `maix.i18n` to access this module. ## Module No module ## Enum ## Variable ### locales item doc **brief** i18n locales list **value** **{
\"en\",
\"zh\",
\"zh tw\",
\"ja\"
}** **readonly** False **C++ defination code**: ```cpp static std::vector locales { \"en\", \"zh\", \"zh tw\", \"ja\" } ``` ### names item doc **brief** i18n language names list **value** **{
\"English\",
\"简体中文\",
\"繁體中文\",
\"日本語\"
}** **readonly** True **C++ defination code**: ```cpp const static std::vector names { \"English\", \"简体中文\", \"繁體中文\", \"日本語\" } ``` ## Function ### get\\_locale item doc **brief** Get system config of locale. **return** language locale, e.g. en, zh, zh_CN, zh_TW, etc. **C++ defination code**: ```cpp string get_locale() ``` ### get\\_language\\_name item doc **brief** Get system config of language name. **return** language name, e.g. English, 简体中文, 繁體中文, etc. **C++ defination code**: ```cpp string get_language_name() ``` ## Class ### Trans item doc **brief** Translate helper class. **C++ defination code**: ```cpp class Trans ``` #### \\_\\_init\\_\\_ item doc **type** func **brief** Translate helper class constructor.\\nBy default locale is get by `i18n.get_locale()` function which set by system settings.\\nBut you can also manually set by `set_locale` function temporarily. **param** **locales_dict**: locales dict, e.g. {\"zh\": {\"Confirm\": \"确认\", \"OK\": \"好的\"}, \"en\": {\"Confirm\": \"Confirm\", \"OK\": \"OK\"}}
**static** False **C++ defination code**: ```cpp Trans(const std::map> &locales_dict) ``` #### tr item doc **type** func **brief** Translate string by key. **param** **key**: string key, e.g. \"Confirm\"
**locale**: locale name, if not assign, use default locale set by system settings or set_locale function.
**return** translated string, if find translation, return it, or return key, e.g. \"确认\", \"Confirm\", etc. **static** False **C++ defination code**: ```cpp string tr(const string &key, const string locale \"\") ``` #### set\\_locale item doc **type** func **brief** Set locale temporarily, will not affect system settings. **param** **locale**: locale name, e.g. \"zh\", \"en\", etc. @see maix.i18n.locales
**static** False **C++ defination code**: ```cpp void set_locale(const string &locale) ``` #### get\\_locale item doc **type** func **brief** Get current locale. **return** locale name, e.g. \"zh\", \"en\", etc. @see maix.i18n.locales **static** False **C++ defination code**: ```cpp string get_locale() ```"},"/maixpy/api/maix/peripheral/timer.html":{"title":"maix.peripheral.timer","content":" title: maix.peripheral.timer maix.peripheral.timer module > This module is generated from [MaixCDK](https://github.com/sipeed/MaixCDK) > You can use `maix.peripheral.timer` to access this module. ## Module No module ## Enum ## Variable ## Function ## Class ### TIMER item doc **brief** Peripheral timer class **C++ defination code**: ```cpp class TIMER ``` #### \\_\\_init\\_\\_ item doc **type** func **brief** TIMER constructor **static** False **C++ defination code**: ```cpp TIMER() ```"},"/maixpy/api/maix/peripheral/i2c.html":{"title":"maix.peripheral.i2c","content":" title: maix.peripheral.i2c maix.peripheral.i2c module > This module is generated from [MaixCDK](https://github.com/sipeed/MaixCDK) > You can use `maix.peripheral.i2c` to access this module. ## Module No module ## Enum ## Variable ### SEVEN\\_BIT item doc **brief** 7 bit address mode **value** **0x1** **readonly** True **C++ defination code**: ```cpp const int SEVEN_BIT 0x1 ``` ### TEN\\_BIT item doc **brief** 10 bit address mode **value** **0x2** **readonly** True **C++ defination code**: ```cpp const int TEN_BIT 0x2 ``` ### MASTER item doc **brief** master mode **value** **0x4** **readonly** True **C++ defination code**: ```cpp const int MASTER 0x4 ``` ### SLAVE item doc **brief** slave mode **value** **0x8** **readonly** True **C++ defination code**: ```cpp const int SLAVE 0x8 ``` ### STANDARD\\_SPEED item doc **brief** standard speed mode **value** **0x10** **readonly** True **C++ defination code**: ```cpp const int STANDARD_SPEED 0x10 ``` ### FAST\\_SPEED item doc **brief** fast speed mode **value** **0x20** **readonly** True **C++ defination code**: ```cpp const int FAST_SPEED 0x20 ``` ## Function ## Class ### I2C item doc **brief** Peripheral i2c class **C++ defination code**: ```cpp class I2C ``` #### \\_\\_init\\_\\_ item doc **type** func **brief** I2C Device constructor\\nthis constructor will be export to MaixPy as _maix.example.Example.__init__ **param** **id**: direction [in], i2c index, int type
**scl**: direction [in], sck pin of i2c, int type
**sda**: direction [in], sda pin of i2c, int type
**freq**: direction [in], i2c clock, int type
option:
in the i2c.STANDARD_SPEED mode, range is [0, 100000]
in the i2c.FAST_SPEED mode, range is [0, 400000]
default clock is 1, means use max clock
**mode**: direction [in], mode of i2c, int type.
option:
mode i2c.MASTER, means master mode
mode i2c.SLAVE, means slave mode
**bit**: direction [in], address length of i2c, int type.
option:
bit i2c.SEVEN_BIT, means 7 bit address mode
bit i2c.TEN_BIT, means 10 bit address mode
**speed_mode**: direction [in], speed mode of i2c, int type.
option:
speed_mode i2c.STANDARD_SPEED, means standard speed mode, up to 100kbit/s
speed_mode i2c.FAST_SPEED, means fast speed mode, up to 400kbit/s
**static** False **C++ defination code**: ```cpp I2C(int id, int scl, int sda, int freq 1, int mode 1, int bit 1, int speed_mode 1) ``` #### writeto item doc **type** func **brief** write data to i2c slave **param** **addr**: direction [in], i2c slave address, int type
**data**: direction [in], data to write, vector type.
Note: The member range of the list is [0,255]
**return** if success, return 0, else return 1 **static** False **C++ defination code**: ```cpp int writeto(int addr, std::vector data) ``` #### readfrom item doc **type** func **brief** read data from i2c slave **param** **addr**: direction [in], i2c slave address, int type
**len**: direction [in], data length to read, int type
**return** the list of data read from i2c slave, vector type **static** False **C++ defination code**: ```cpp std::vector readfrom(int addr, int len) ``` #### scan item doc **type** func **brief** scan all i2c address **return** the list of i2c address, vector type **static** False **C++ defination code**: ```cpp std::vector scan() ``` #### writeto\\_mem item doc **type** func **brief** write data to i2c slave **param** **addr**: direction [in], i2c slave address, int type
**start_addr**: direction [in], start address of i2c slave, int type
**data**: direction [in], data to write, vector type.
Note: The member range of the list is [0,255]
**return** if success, return 0, else return 1 **static** False **C++ defination code**: ```cpp int writeto_mem(int addr, int start_addr, std::vector data) ``` #### readfrom\\_mem item doc **type** func **brief** read data from i2c slave **param** **addr**: direction [in], i2c slave address, int type
**start_addr**: direction [in], start address of i2c slave, int type
**len**: direction [in], data length to read, int type
**return** the list of data read from i2c slave, vector type **static** False **C++ defination code**: ```cpp std::vector readfrom_mem(int addr, int start_addr, int len) ```"},"/maixpy/api/maix/peripheral/gpio.html":{"title":"maix.peripheral.gpio","content":" title: maix.peripheral.gpio maix.peripheral.gpio module > This module is generated from [MaixCDK](https://github.com/sipeed/MaixCDK) > You can use `maix.peripheral.gpio` to access this module. ## Module No module ## Enum ## Variable ### IN item doc **brief** GPIO input mode **value** **0x01** **readonly** True **C++ defination code**: ```cpp const int IN 0x01 ``` ### OUT item doc **brief** GPIO output mode **value** **0x2** **readonly** True **C++ defination code**: ```cpp const int OUT 0x2 ``` ### OUT\\_OD item doc **brief** GPIO output open drain mode **value** **0x3** **readonly** True **C++ defination code**: ```cpp const int OUT_OD 0x3 ``` ### PULL\\_NONE item doc **brief** GPIO pull none mode **value** **0x4** **readonly** True **C++ defination code**: ```cpp const int PULL_NONE 0x4 ``` ### PULL\\_UP item doc **brief** GPIO pull up mode **value** **0x5** **readonly** True **C++ defination code**: ```cpp const int PULL_UP 0x5 ``` ### PULL\\_DOWN item doc **brief** GPIO pull down mode **value** **0x6** **readonly** True **C++ defination code**: ```cpp const int PULL_DOWN 0x6 ``` ### OFF item doc **brief** GPIO off **value** **0x0** **readonly** True **C++ defination code**: ```cpp const int OFF 0x0 ``` ### ON item doc **brief** GPIO on **value** **0x1** **readonly** True **C++ defination code**: ```cpp const int ON 0x1 ``` ## Function ## Class ### GPIO item doc **brief** Peripheral gpio class **C++ defination code**: ```cpp class GPIO ``` #### \\_\\_init\\_\\_ item doc **type** func **brief** GPIO constructor **param** **pin**: direction [in], gpio pin. int type.
**mode**: direction [in], gpio mode. int type. default is 1, means gpio.IN
option:
mode gpio.IN, means input mode
mode gpio.OUT, means output mode
mode gpio.OUT_OD, means output open drain mode
**pull**: direction [in], gpio pull. int type. default is determined by actual board.
option:
pull gpio.PULL_NONE, means pull none mode
pull gpio.PULL_UP, means pull up mode
pull gpio.PULL_DOWN, means pull down mode
**static** False **C++ defination code**: ```cpp GPIO(int pin, int mode 1, int pull 1) ``` #### value item doc **type** func **brief** write/read gpio value **param** **value**: direction [in], gpio value. int type.
value 0, means write gpio to low level
value 1, means write gpio to high level
**return** int type
if success, return 0; else return 1 **static** False **C++ defination code**: ```cpp int value(int value 1) ``` #### write item doc **type** func **brief** get gpio write **param** **value**: direction [in], gpio value. int type.
value 0, means write gpio to low level
value 1, means write gpio to high level
value 1 or not set, means read gpio value
**return** int type
when read gpio value, return gpio value
when write gpio value, if success, return 0; else return 1 **static** False **C++ defination code**: ```cpp int write(int value) ``` #### read item doc **type** func **brief** get gpio read **return** int type
return 0, means gpio is low level
return 1, means gpio is high level
return other, means error **static** False **C++ defination code**: ```cpp int read() ``` #### on item doc **type** func **brief** set gpio on **static** False **C++ defination code**: ```cpp void on() ``` #### off item doc **type** func **brief** set gpio off **static** False **C++ defination code**: ```cpp void off() ``` #### high item doc **type** func **brief** set gpio high **static** False **C++ defination code**: ```cpp void high() ``` #### low item doc **type** func **brief** set gpio low **static** False **C++ defination code**: ```cpp void low() ``` #### toggle item doc **type** func **brief** gpio toggle **static** False **C++ defination code**: ```cpp void toggle() ```"},"/maixpy/api/maix/example.html":{"title":"maix.example","content":" title: maix.example example module, this will be maix.example module in MaixPy, maix::example namespace in MaixCDK > This module is generated from [MaixCDK](https://github.com/sipeed/MaixCDK) > You can use `maix.example` to access this module. ## 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**: ```cpp 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**: ```cpp 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**: ```cpp const std::vector 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**: ```cpp int test_var 100 ``` ## Function ### hello 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**: ```cpp 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**: ```cpp example::Example *change_arg_name(example::Example *e) ``` ### change\\_arg\\_name2 item doc **brief** Change arg name example **param** **e**: Example object
**C++ defination code**: ```cpp void change_arg_name2(example::Example &e) ``` ## Class ### Test item doc **brief** Test class **C++ defination code**: ```cpp class Test ``` #### \\_\\_init\\_\\_ item doc **type** func **brief** Test constructor **static** False **C++ defination code**: ```cpp Test() ``` ### Example item doc **brief** Example class\\nthis class will be export to MaixPy as maix.example.Example **C++ defination code**: ```cpp class Example ``` #### \\_\\_init\\_\\_ 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**: ```cpp Example(std::string &name, int age 18, example::Kind pet example::KIND_NONE) ``` #### get\\_name 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**: ```cpp std::string get_name() ``` #### get\\_age 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**: ```cpp int get_age() ``` #### set\\_name item doc **type** func **brief** set name of Example **param** **name**: name of Example, string type
**static** False **C++ defination code**: ```cpp void set_name(std::string name) ``` #### set\\_age 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**: ```cpp void set_age(int age) ``` #### set\\_pet item doc **type** func **brief** Example enum member **attention** **static** False **C++ defination code**: ```cpp void set_pet(example::Kind pet) ``` #### get\\_pet item doc **type** func **brief** Example enum member **static** False **C++ defination code**: ```cpp example::Kind get_pet() ``` #### get\\_list 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**: ```cpp std::vector *get_list(std::vector in) ``` #### get\\_dict 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**: ```cpp std::map get_dict(std::map &in) ``` #### hello 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**: ```cpp static std::string hello(std::string name) ``` #### hello\\_bytes 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**: ```cpp static Bytes *hello_bytes(Bytes &bytes) ``` #### callback 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**: ```cpp static int callback(std::function cb) ``` #### hello\\_dict 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**: ```cpp static std::map *hello_dict(std::map *dict) ``` #### name item doc **type** var **brief** name member of Example **static** False **readonly** False **C++ defination code**: ```cpp 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**: ```cpp 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**: ```cpp static std::string hello_str ``` #### var1 item doc **type** var **brief** Example module readonly variable **static** False **readonly** True **C++ defination code**: ```cpp const std::string var1 \"Example.var1\" ``` #### var2 item doc **type** var **brief** Example module readonly variable **static** False **readonly** True **C++ defination code**: ```cpp std::string var2 \"Example.var2\" ``` #### dict\\_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**: ```cpp static std::map *dict_test() ```"},"/maixpy/api/maix/thread.html":{"title":"maix.thread","content":" title: maix.thread maix.thread module > This module is generated from [MaixCDK](https://github.com/sipeed/MaixCDK) > You can use `maix.thread` to access this module. ## Module No module ## Enum ## Variable ## Function ## Class ### Thread item doc **brief** thread class **C++ defination code**: ```cpp class Thread ``` #### \\_\\_init\\_\\_ item doc **type** func **brief** create thread **param** **func**: direction [in], thread function, one `args` parameter, void* type, no return value
**args**: direction [in], thread function parameter
**static** False **C++ defination code**: ```cpp Thread(std::function func, void *args nullptr) ``` #### join item doc **type** func **brief** wait thread exit **static** False **C++ defination code**: ```cpp void join() ``` #### detach item doc **type** func **brief** detach thread **static** False **C++ defination code**: ```cpp void detach() ``` #### joinable item doc **type** func **brief** Check if thread is joinable **return** true if thread is joinable **static** False **C++ defination code**: ```cpp bool joinable() ```"},"/maixpy/api/maix/err.html":{"title":"maix.err","content":" title: maix.err maix.err module > This module is generated from [MaixCDK](https://github.com/sipeed/MaixCDK) > You can use `maix.err` to access this module. ## Module No module ## Enum ### Err item doc **brief** Maix Error code **values** **ERR_NONE**: No error
**ERR_ARGS**: Invalid arguments
**ERR_NO_MEM**: No memory
**ERR_NOT_IMPL**: Not implemented
**ERR_NOT_READY**: Not ready
**ERR_NOT_INIT**: Not initialized
**ERR_NOT_OPEN**: Not opened
**ERR_NOT_PERMIT**: Not permitted
**ERR_REOPEN**: Re open
**ERR_BUSY**: Busy
**ERR_READ**: Read error
**ERR_WRITE**: Write error
**ERR_TIMEOUT**: Timeout
**ERR_RUNTIME**: Runtime error
**ERR_IO**: IO error
**ERR_NOT_FOUND**: Not found
**ERR_ALREAY_EXIST**: Already exist
**ERR_BUFF_FULL**: Buffer full
**ERR_BUFF_EMPTY**: Buffer empty
**ERR_CANCEL**: Cancel
**ERR_OVERFLOW**: Overflow
**ERR_MAX**:
**C++ defination code**: ```cpp enum Err { // !!! fixed error code, DO NOT change number already defined, only append new error code ERR_NONE 0, // No error ERR_ARGS , // Invalid arguments ERR_NO_MEM , // No memory ERR_NOT_IMPL , // Not implemented ERR_NOT_READY , // Not ready ERR_NOT_INIT , // Not initialized ERR_NOT_OPEN , // Not opened ERR_NOT_PERMIT , // Not permitted ERR_REOPEN , // Re open ERR_BUSY , // Busy ERR_READ , // Read error ERR_WRITE , // Write error ERR_TIMEOUT , // Timeout ERR_RUNTIME , // Runtime error ERR_IO , // IO error ERR_NOT_FOUND , // Not found ERR_ALREAY_EXIST , // Already exist ERR_BUFF_FULL , // Buffer full ERR_BUFF_EMPTY , // Buffer empty ERR_CANCEL , // Cancel ERR_OVERFLOW , // Overflow ERR_MAX, } ``` ## Variable ## Function ### to\\_str item doc **brief** Error code to string **param** **e**: direction [in], error code, err::Err type
**return** error string **C++ defination code**: ```cpp std::string to_str(err::Err e) ``` ### get\\_error item doc **brief** get last error string **return** error string **C++ defination code**: ```cpp std::string& get_error() ``` ### set\\_error item doc **brief** set last error string **param** **str**: direction [in], error string
**C++ defination code**: ```cpp void set_error(const std::string &str) ``` ### check\\_raise item doc **brief** Check error code, if not ERR_NONE, raise err.Exception **param** **e**: direction [in], error code, err::Err type
**msg**: direction [in], error message
**C++ defination code**: ```cpp void check_raise(err::Err e, const std::string &msg \"\") ``` ### check\\_bool\\_raise item doc **brief** Check condition, if false, raise err.Exception **param** **ok**: direction [in], condition, if true, do nothing, if false, raise err.Exception
**msg**: direction [in], error message
**C++ defination code**: ```cpp void check_bool_raise(bool ok, const std::string &msg \"\") ``` ### check\\_null\\_raise item doc **brief** Check NULL pointer, if NULL, raise exception **param** **ptr**: direction [in], pointer
**msg**: direction [in], error message
**C++ defination code**: ```cpp void check_null_raise(void *ptr, const std::string &msg \"\") ``` ## Class ### Exception item doc **brief** Maix Exception **C++ defination code**: ```cpp class Exception : public std::exception ```"},"/maixpy/api/maix/protocol.html":{"title":"maix.protocol","content":" title: maix.protocol maix.protocol module > This module is generated from [MaixCDK](https://github.com/sipeed/MaixCDK) > You can use `maix.protocol` to access this module. ## Module No module ## Enum ### CMD item doc **brief** protocol cmd, more doc see MaixCDK document's convention doc **note** max app custom CMD value should < CMD_APP_MAX **values** **CMD_APP_MAX**: 200, max app custom CMD value should < CMD_APP_MAX
**CMD_SET_UPLOAD**: set auto upload data mode
**CMD_APP_LIST**:
**CMD_START_APP**:
**CMD_EXIT_APP**:
**CMD_CUR_APP_INFO**:
**CMD_APP_INFO**:
**CMD_KEY**:
**CMD_TOUCH**:
**C++ defination code**: ```cpp enum CMD { CMD_APP_MAX 0xC8, // 200, max app custom CMD value should < CMD_APP_MAX CMD_SET_UPLOAD 0xF8, // set auto upload data mode CMD_APP_LIST 0xF9, CMD_START_APP 0xFA, CMD_EXIT_APP 0xFB, CMD_CUR_APP_INFO 0xFC, CMD_APP_INFO 0xFD, CMD_KEY 0xFE, CMD_TOUCH 0xFF, } ``` ### FLAGS item doc **brief** protocol flags, more doc see MaixCDK document's convention doc **values** **FLAG_REQ**:
**FLAG_RESP**:
**FLAG_IS_RESP_MASK**:
**FLAG_RESP_OK**:
**FLAG_RESP_ERR**:
**FLAG_RESP_OK_MASK**:
**FLAG_REPORT**:
**FLAG_REPORT_MASK**:
**FLAG_VERSION_MASK**:
**C++ defination code**: ```cpp enum FLAGS { FLAG_REQ 0x00, FLAG_RESP 0x80, FLAG_IS_RESP_MASK 0x80, FLAG_RESP_OK 0x40, FLAG_RESP_ERR 0x00, FLAG_RESP_OK_MASK 0x40, FLAG_REPORT 0x20, FLAG_REPORT_MASK 0x20, FLAG_VERSION_MASK 0x03 } ``` ## Variable ### VERSION item doc **brief** protocol version **value** **1** **readonly** True **C++ defination code**: ```cpp const uint8_t VERSION 1 ``` ### HEADER item doc **brief** protocol header **value** **0xBBACCAAA** **readonly** True **C++ defination code**: ```cpp const uint32_t HEADER 0xBBACCAAA ``` ## Function ### crc16\\_IBM item doc **brief** CRC16 IBM **param** **data**: data, bytes type.
**return** CRC16 IBM value, uint16_t type. **C++ defination code**: ```cpp uint16_t crc16_IBM(const Bytes *data) ``` ## Class ### MSG item doc **brief** protocol msg **C++ defination code**: ```cpp class MSG ``` #### version item doc **type** var **brief** protocol version **static** False **readonly** False **C++ defination code**: ```cpp uint8_t version ``` #### resp\\_ok item doc **type** var **brief** Is success response or not, (only for response msg) **static** False **readonly** False **C++ defination code**: ```cpp uint8_t resp_ok ``` #### cmd item doc **type** var **brief** CMD value **static** False **readonly** False **C++ defination code**: ```cpp uint8_t cmd ``` #### is\\_resp item doc **type** var **brief** message is response or not, contrast with is_req **static** False **readonly** False **C++ defination code**: ```cpp bool is_resp ``` #### body\\_len item doc **type** var **brief** Message body length, read only, use set_body() to update **attention** DO NOT manually change this value **static** False **readonly** False **C++ defination code**: ```cpp int body_len ``` #### encode\\_resp\\_ok item doc **type** func **brief** Encode response ok(success) message **param** **body**: response body, can be null
**return** encoded data, if nullptr, means error, and the error code is err.Err **static** False **C++ defination code**: ```cpp Bytes *encode_resp_ok(Bytes *body nullptr) ``` #### encode\\_report item doc **type** func **brief** Encode proactively report message **param** **body**: report body, can be null
**return** encoded data, if nullptr, means error, and the error code is err.Err **static** False **C++ defination code**: ```cpp Bytes *encode_report(Bytes *body nullptr) ``` #### encode\\_resp\\_err item doc **type** func **brief** Encode response error message **param** **code**: error code
**msg**: error message
**return** encoded data, if nullptr, means error, and the error code is err.Err **static** False **C++ defination code**: ```cpp Bytes *encode_resp_err(err::Err code, const std::string &msg) ``` #### set\\_body item doc **type** func **brief** Update message body **param** **body_new**: new body data
**static** False **C++ defination code**: ```cpp void set_body(Bytes *body_new) ``` #### get\\_body item doc **type** func **brief** Get message body **return** message body, bytes type **static** False **C++ defination code**: ```cpp Bytes *get_body() ``` ### Protocol item doc **brief** Communicate protocol **C++ defination code**: ```cpp class Protocol ``` #### \\_\\_init\\_\\_ item doc **type** func **brief** Construct a new Protocol object **param** **buff_size**: Data queue buffer size
**static** False **C++ defination code**: ```cpp Protocol(int buff_size 1024) ``` #### buff\\_size item doc **type** func **brief** Data queue buffer size **static** False **C++ defination code**: ```cpp int buff_size() ``` #### push\\_data item doc **type** func **brief** Add data to data queue **param** **new_data**: new data
**return** error code, maybe err.Err.ERR_BUFF_FULL **static** False **C++ defination code**: ```cpp err::Err push_data(const Bytes *new_data) ``` #### decode item doc **type** func **brief** Decode data in data queue and return a message **param** **new_data**: new data add to data queue, if null, only decode.
**return** decoded message, if nullptr, means no message decoded. **static** False **C++ defination code**: ```cpp protocol::MSG *decode(const Bytes *new_data nullptr) ``` #### encode\\_resp\\_ok item doc **type** func **brief** Encode response ok(success) message to buffer **param** **cmd**: CMD value
**body**: response body, can be null
**return** encoded data, if nullptr, means error, and the error code is err.Err **static** False **C++ defination code**: ```cpp Bytes *encode_resp_ok(uint8_t cmd, Bytes *body nullptr) ``` #### encode\\_report item doc **type** func **brief** Encode proactively report message to buffer **param** **cmd**: CMD value
**body**: report body, can be null
**return** encoded data, if nullptr, means error, and the error code is err.Err **static** False **C++ defination code**: ```cpp Bytes *encode_report(uint8_t cmd, Bytes *body nullptr) ``` #### encode\\_resp\\_err item doc **type** func **brief** Encode response error message to buffer **param** **cmd**: CMD value
**code**: error code
**msg**: error message
**return** encoded data, if nullptr, means error, and the error code is err.Err **static** False **C++ defination code**: ```cpp Bytes *encode_resp_err(uint8_t cmd, err::Err code, const std::string &msg) ```"},"/maixpy/api/maix/tensor.html":{"title":"maix.tensor","content":" title: maix.tensor maix.tensor module > This module is generated from [MaixCDK](https://github.com/sipeed/MaixCDK) > You can use `maix.tensor` to access this module. ## Module No module ## Enum ### DType item doc **brief** Tensor data types **values** **UINT8**:
**INT8**:
**UINT16**:
**INT16**:
**UINT32**:
**INT32**:
**FLOAT16**:
**FLOAT32**:
**FLOAT64**:
**BOOL**:
**DTYPE_MAX**:
**C++ defination code**: ```cpp enum DType { UINT8 0, INT8, UINT16, INT16, UINT32, INT32, FLOAT16, FLOAT32, FLOAT64, BOOL, // STRING, // OBJECT, DTYPE_MAX } ``` ## Variable ### dtype\\_size item doc **brief** Tensor data type size in bytes **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** **{
1, // UINT8
1, // INT8
2, // UINT16
2, // INT16
4, // UINT32
4, // INT32
2, // FLOAT16
4, // FLOAT32
8, // FLOAT64
1, // BOOL
// 1, // STRING
// 1, // OBJECT
0
}** **readonly** True **C++ defination code**: ```cpp const std::vector dtype_size { 1, // UINT8 1, // INT8 2, // UINT16 2, // INT16 4, // UINT32 4, // INT32 2, // FLOAT16 4, // FLOAT32 8, // FLOAT64 1, // BOOL // 1, // STRING // 1, // OBJECT 0 } ``` ### dtype\\_name item doc **brief** Tensor data type name **value** **{
\"uint8\",
\"int8\",
\"uint16\",
\"int16\",
\"uint32\",
\"int32\",
\"float16\",
\"float32\",
\"float64\",
\"bool\",
// \"string\",
// \"object\",
\"invalid\"
}** **readonly** True **C++ defination code**: ```cpp const std::vector dtype_name { \"uint8\", \"int8\", \"uint16\", \"int16\", \"uint32\", \"int32\", \"float16\", \"float32\", \"float64\", \"bool\", // \"string\", // \"object\", \"invalid\" } ``` ## Function ## Class ### Tensor item doc **brief** Tensor class **C++ defination code**: ```cpp class Tensor ``` #### \\_\\_init\\_\\_ item doc **type** func **brief** Tensor constructor **param** **shape**: tensor shape, a int list
**dtype**: tensor element data type, see DType of this module
**data**: pointer to data content, can be nullptr, it will automatically alloc memory
and detroy it when this object is destroyed
**static** False **C++ defination code**: ```cpp Tensor(std::vector shape, tensor::DType dtype, void *data nullptr) ``` #### to\\_str item doc **type** func **brief** To string **static** False **C++ defination code**: ```cpp std::string to_str() ``` #### \\_\\_str\\_\\_ item doc **type** func **brief** To string **static** False **C++ defination code**: ```cpp std::string __str__() ``` #### shape item doc **type** func **brief** get tensor shape **return** tensor shape, a int list **static** False **C++ defination code**: ```cpp std::vector shape() ``` #### expand\\_dims item doc **type** func **brief** expand tensor shape **param** **axis**: axis to expand
**static** False **C++ defination code**: ```cpp void expand_dims(int axis) ``` #### reshape item doc **type** func **brief** reshape tensor shape, if size not match, it will throw an err::Exception **param** **shape**: new shape
**static** False **C++ defination code**: ```cpp void reshape(std::vector shape) ``` #### flatten item doc **type** func **brief** Flatten tensor shape to 1D **static** False **C++ defination code**: ```cpp void flatten() ``` #### dtype item doc **type** func **brief** get tensor data type **return** tensor data type, see DType of this module **static** False **C++ defination code**: ```cpp tensor::DType dtype() ``` #### argmax item doc **type** func **brief** argmax of tensor **param** **axis**: By default, the index is into the flattened array, otherwise along the specified axis., wrong axis will throw an err::Exception
**return** argmax result, you need to delete it after use in C++. **static** False **C++ defination code**: ```cpp tensor::Tensor *argmax(int axis 0xffff) ``` #### argmax1 item doc **type** func **brief** argmax1, flattened data max index **return** argmax result, int type **static** False **C++ defination code**: ```cpp int argmax1() ``` ### Tensors item doc **brief** Tensors **C++ defination code**: ```cpp class Tensors ``` #### \\_\\_init\\_\\_ item doc **type** func **brief** Constructor of Tensors **static** False **C++ defination code**: ```cpp Tensors() ``` #### add\\_tensor item doc **type** func **brief** Add tensor **static** False **C++ defination code**: ```cpp void add_tensor(const std::string &key, tensor::Tensor *tensor, bool copy, bool auto_delete) ``` #### rm\\_tensor item doc **type** func **brief** Remove tensor **static** False **C++ defination code**: ```cpp void rm_tensor(const std::string &key) ``` #### get\\_tensor item doc **type** func **brief** Get tensor by key **static** False **C++ defination code**: ```cpp tensor::Tensor *get_tensor(const std::string &key) ``` #### \\_\\_getitem\\_\\_ item doc **type** func **brief** Operator [] **static** False **C++ defination code**: ```cpp tensor::Tensor *operator[](const std::string &key) ``` #### \\_\\_len\\_\\_ item doc **type** func **brief** Size **static** False **C++ defination code**: ```cpp size_t size() ``` #### get\\_names item doc **type** func **brief** Get names **static** False **C++ defination code**: ```cpp std::vector get_names() ``` #### tensors item doc **type** var **brief** Tensors data, dict type **static** False **readonly** False **C++ defination code**: ```cpp std::map tensors ```"},"/maixpy/api/maix/nn/F.html":{"title":"maix.nn.F","content":" title: maix.nn.F maix.nn.F module > This module is generated from [MaixCDK](https://github.com/sipeed/MaixCDK) > You can use `maix.nn.F` to access this module. ## Module No module ## Enum ## Variable ## Function ### softmax item doc **brief** Softmax, only support 1D tensor, multi dimension tensor will be treated as 1D tensor **param** **tensor**: input tensor
**replace**: change input tensor data directly, if not, will create a new tensor
**throw** If arg error, will raise err.Exception error **return** output tensor, if arg replace is true, return the arg tensor's address.
If not replace, return a new object, so In C++, you should delete it manually in this case! **C++ defination code**: ```cpp tensor::Tensor *softmax(tensor::Tensor *tensor, bool replace) ``` ## Class"},"/maixpy/api/maix/comm.html":{"title":"maix.comm","content":" title: maix.comm maix.comm module > This module is generated from [MaixCDK](https://github.com/sipeed/MaixCDK) > You can use `maix.comm` to access this module. ## Module No module ## Enum ## Variable ## Function ## Class ### CommProtocol item doc **brief** Class for communication protocol **C++ defination code**: ```cpp class CommProtocol ``` #### \\_\\_init\\_\\_ item doc **type** func **brief** Construct a new CommProtocol object **param** **buff_size**: buffer size, default to 1024 bytes
**static** False **C++ defination code**: ```cpp CommProtocol(int buff_size 1024) ``` #### get\\_msg item doc **type** func **brief** Read data to buffer, and try to decode it as maix.protocol.MSG object **return** decoded data, if nullptr, means no valid frame found.
Attentioin, delete it after use in C++. **static** False **C++ defination code**: ```cpp protocol::MSG *get_msg() ``` #### resp\\_ok item doc **type** func **brief** Send response ok(success) message **param** **cmd**: CMD value
**body**: response body, can be null
**return** encoded data, if nullptr, means error, and the error code is err.Err.
Attentioin, delete it after use in C++. **static** False **C++ defination code**: ```cpp err::Err resp_ok(uint8_t cmd, Bytes *body nullptr) ``` #### report item doc **type** func **brief** Send report message **param** **cmd**: CMD value
**body**: report body, can be null
**return** encoded data, if nullptr, means error, and the error code is err.Err.
Attentioin, delete it after use in C++. **static** False **C++ defination code**: ```cpp err::Err report(uint8_t cmd, Bytes *body nullptr) ``` #### resp\\_err item doc **type** func **brief** Encode response error message to buffer **param** **cmd**: CMD value
**code**: error code
**msg**: error message
**return** encoded data, if nullptr, means error, and the error code is err.Err.
Attentioin, delete it after use in C++. **static** False **C++ defination code**: ```cpp err::Err resp_err(uint8_t cmd, err::Err code, const std::string &msg) ```"},"/maixpy/api/maix/sys.html":{"title":"maix.sys","content":" title: maix.sys maix.sys module > This module is generated from [MaixCDK](https://github.com/sipeed/MaixCDK) > You can use `maix.sys` to access this module. ## Module No module ## Enum ## Variable ## Function ### os\\_version() item doc **brief** Get system version **return** version string, e.g. \"2024.4.1 13af4b\" **C++ defination code**: ```cpp std::string os_version() ``` ### device\\_name() item doc **brief** Get device name **return** device name, e.g. \"MaixCAM\" **C++ defination code**: ```cpp std::string device_name() ``` ### host\\_name() item doc **brief** Get host name **return** host name, e.g. \"maixcam 2f9f\" **C++ defination code**: ```cpp std::string host_name() ``` ### host\\_domain() item doc **brief** Get host domain **return** host domain, e.g. \"maixcam 2f9f.local\" **C++ defination code**: ```cpp std::string host_domain() ``` ### ip\\_address() item doc **brief** Get ip address **return** ip address, dict type, e.g. {\"eth0\": \"192.168.0.195\", \"wlan0\": \"192.168.0.123\", \"usb0\": \"10.47.159.1\"} **C++ defination code**: ```cpp std::map ip_address() ``` ### mac\\_address() item doc **brief** Get mac address **return** mac address, dict type, e.g. {\"eth0\": \"00:0c:29:2f:9f:00\", \"wlan0\": \"00:0c:29:2f:9f:01\", \"usb0\": \"00:0c:29:2f:9f:02\"} **C++ defination code**: ```cpp std::map mac_address() ``` ### device\\_key() item doc **brief** Get device key, can be unique id of device **return** device key, 32 bytes hex string, e.g. \"1234567890abcdef1234567890abcdef\" **C++ defination code**: ```cpp std::string device_key() ``` ### memory\\_info() item doc **brief** Get memory info **return** memory info, dict type, e.g. {\"total\": 1024, \"used\": 512, \"hw_total\": 256*1024*1024}
total: total memory size in Byte.
used: used memory size in Byte.
hw_total: total memory size in Byte of hardware, the total < hw_total,
OS kernel may reserve some memory for some hardware like camera, npu, display etc. **C++ defination code**: ```cpp std::map memory_info() ``` ### bytes\\_to\\_human(1234) item doc **brief** Bytes to human readable string **param** **bytes:**: bytes size,e.g. 1234B 1234/1024 1.205 KB
**precision:**: decimal precision, default 2
**base:**: base number, default 1024
**unit:**: unit string, e.g. \"B\"
**sep:**: separator string, e.g. \" \"
**return** human readable string, e.g. \"1.21 KB\" **C++ defination code**: ```cpp std::string bytes_to_human(unsigned long long bytes, int precision 2, int base 1024, const std::string &unit \"B\", const std::string &sep \" \") ``` ### cpu\\_freq() item doc **brief** Get CPU frequency **return** CPU frequency, dict type, e.g. {\"cpu0\": 1000000000, \"cpu1\": 1000000000} **C++ defination code**: ```cpp std::map cpu_freq() ``` ### cpu\\_temp() item doc **brief** Get CPU temperature **return** CPU temperature, unit dgree, dict type, e.g. {\"cpu\": 50.0, \"cpu0\": 50, \"cpu1\": 50} **C++ defination code**: ```cpp std::map cpu_temp() ``` ### cpu\\_usage() item doc **brief** Get CPU usage **return** CPU usage, dict type, e.g. {\"cpu\": 50.0, \"cpu0\": 50, \"cpu1\": 50} **C++ defination code**: ```cpp std::map cpu_usage() ``` ### npu\\_freq() item doc **brief** Get NPU frequency **return** NPU frequency, dict type, e.g. {\"npu0\": 500000000} **C++ defination code**: ```cpp std::map npu_freq() ``` ### disk\\_usage() item doc **brief** Get disk usage **param** **path:**: disk path, default \"/\"
**return** disk usage, dict type, e.g. {\"total\": 1024, \"used\": 512} **C++ defination code**: ```cpp std::map disk_usage(const std::string &path \"/\") ``` ### disk\\_partitions() item doc **brief** Get disk partition and mount point info **param** **only_disk**: only return real disk, tempfs sysfs etc. not return, default true.
**return** disk partition and mount point info, list type, e.g. [{\"device\": \"/dev/mmcblk0p1\", \"mountpoint\": \"/mnt/sdcard\", \"fstype\": \"vfat\"}] **C++ defination code**: ```cpp std::vector> disk_partitions(bool only_disk true) ``` ## Class"},"/maixpy/api/maix/display.html":{"title":"maix.display","content":" title: maix.display maix.display module, control display device and show image on it > This module is generated from [MaixCDK](https://github.com/sipeed/MaixCDK) > You can use `maix.display` to access this module. ## Module No module ## Enum ## Variable ## Function ### send\\_to\\_maixvision item doc **brief** Send image to MaixVision work station if connected.\\nIf you want to debug your program an don't want to initialize display, use this method. **param** **img**: image to send, image.Image object
**C++ defination code**: ```cpp void send_to_maixvision(image::Image &img) ``` ## Class ### Display item doc **brief** Display class **C++ defination code**: ```cpp class Display ``` #### \\_\\_init\\_\\_ item doc **type** func **brief** Construct a new Display object **param** **width**: display width, by default(value is 1) means auto detect,
if width > max device supported width, will auto set to max device supported width
**height**: display height, by default(value is 1) means auto detect,
if height > max device supported height, will auto set to max device supported height
**device**: display device name, you can get devices by list_devices method, by default(value is NULL(None in MaixPy)) means the first device
**open**: If true, display will automatically call open() after creation. default is true.
**static** False **C++ defination code**: ```cpp Display(int width 1, int height 1, image::Format format image::FMT_RGB888, const char *device nullptr, bool open true) ``` #### width item doc **type** func **brief** Get display width **return** width **static** False **C++ defination code**: ```cpp int width() ``` #### height item doc **type** func **brief** Get display height **param** **ch**: channel to get, by default(value is 0) means the first channel
**return** height **static** False **C++ defination code**: ```cpp int height() ``` #### size item doc **type** func **brief** Get display size **param** **ch**: channel to get, by default(value is 0) means the first channel
**return** size A list type in MaixPy, [width, height] **static** False **C++ defination code**: ```cpp std::vector size() ``` #### format item doc **type** func **brief** Get display format **return** format **static** False **C++ defination code**: ```cpp image::Format format() ``` #### open item doc **type** func **brief** open display device, if already opened, will return err.ERR_NONE. **param** **width**: display width, default is 1, means auto, mostly means max width of display support
**height**: display height, default is 1, means auto, mostly means max height of display support
**format**: display output format, default is RGB888
**return** error code **static** False **C++ defination code**: ```cpp err::Err open(int width 1, int height 1, image::Format format image::FMT_INVALID) ``` #### close item doc **type** func **brief** close display device **return** error code **static** False **C++ defination code**: ```cpp err::Err close() ``` #### add\\_channel item doc **type** func **brief** Add a new channel and return a new Display object, you can use close() to close this channel. **param** **width**: display width, default is 1, means auto, mostly means max width of display support
**height**: display height, default is 1, means auto, mostly means max height of display support
**format**: display output format, default is RGB888
**open**: If true, display will automatically call open() after creation. default is true.
**return** new Display object **static** False **C++ defination code**: ```cpp display::Display *add_channel(int width 1, int height 1, image::Format format image::FMT_RGB888, bool open true) ``` #### is\\_opened item doc **type** func **brief** check display device is opened or not **return** opened or not, bool type **static** False **C++ defination code**: ```cpp bool is_opened() ``` #### is\\_closed item doc **type** func **brief** check display device is closed or not **return** closed or not, bool type **static** False **C++ defination code**: ```cpp bool is_closed() ``` #### show item doc **type** func **brief** show image on display device, and will also send to MaixVision work station if connected. **param** **img**: image to show, image.Image object,
if the size of image smaller than display size, will show in the center of display;
if the size of image bigger than display size, will auto resize to display size and keep ratio, fill blank with black color.
**fit**: image in screen fit mode, by default(value is image.FIT_CONTAIN), @see image.Fit for more details
e.g. image.FIT_CONTAIN means resize image to fit display size and keep ratio, fill blank with black color.
**return** error code **static** False **C++ defination code**: ```cpp err::Err show(image::Image &img, image::Fit fit image::FIT_CONTAIN) ``` #### device item doc **type** func **brief** Get display device path **return** display device path **static** False **C++ defination code**: ```cpp std::string device() ```"},"/maixpy/api/maix/peripheral/pwm.html":{"title":"maix.peripheral.pwm","content":" title: maix.peripheral.pwm maix.peripheral.pwm module > This module is generated from [MaixCDK](https://github.com/sipeed/MaixCDK) > You can use `maix.peripheral.pwm` to access this module. ## Module No module ## Enum ## Variable ## Function ## Class ### PWM item doc **brief** Peripheral pwm class **C++ defination code**: ```cpp class PWM ``` #### \\_\\_init\\_\\_ item doc **type** func **brief** PWM constructor **param** **pin**: direction [in], pwm pin. int type.
**freq**: direction [in], pwm frequency, unit: Hz. int type. default is 1000
**duty**: direction [in], pwm duty. int type. range is [0, 100], default is 1, means set duty to 50
note: you can not set duty and duty_val at the same time
**duty_val**: direction [in], pwm duty value, unit: us. int type. default is 1, means set duty_val to (1000000000 / freq) * 0.5
note: you can not set duty and duty_val at the same time
**align**: direction [in], pwm align. int type. default is 1
**sync**: direction [in], pwm sync. int type. default is false
**static** False **C++ defination code**: ```cpp PWM(int pin, int freq 1000, int duty 1, int duty_val 1, int align 1, bool sync false) ``` #### duty item doc **type** func **brief** set pwm duty **param** **duty**: direction [in], pwm duty. int type. default is 1
duty [0, 100], set duty
duty 1 or not set, return current duty
**return** int type
when get duty, return current duty
when set duty, if success, return 0; else return 1 **static** False **C++ defination code**: ```cpp int duty(int duty 1) ``` #### duty\\_val item doc **type** func **brief** set pwm duty value **param** **duty_val**: direction [in], pwm duty value. int type. default is 1
duty_val [0, 65535], set duty_val
duty_val 1 or not set, return current duty_val
**return** int type
when get duty_val, return current duty_val
when set duty_val, if success, return 0; else return 1 **static** False **C++ defination code**: ```cpp int duty_val(int duty_val 1) ``` #### freq item doc **type** func **brief** set pwm frequency **param** **freq**: direction [in], pwm frequency. int type. default is 1
freq > 0, set freq
freq 1 or not set, return current freq
**return** int type
when get freq, return current freq
when set freq, if success, return 0; else return 1 **static** False **C++ defination code**: ```cpp int freq(int freq 1) ``` #### enable item doc **type** func **brief** set pwm enable **param** **enable**: direction [in], pwm enable. int type. default is 1
enable 0, disable pwm
enable 1, enable pwm
enable 1 or not set, return current enable value
**return** int type
when get enable, return current enable value
when set enable, if success, return 0; else return 1 **static** False **C++ defination code**: ```cpp int enable(int enable 1) ```"},"/maixpy/api/maix/time.html":{"title":"maix.time","content":" title: maix.time maix.time module > This module is generated from [MaixCDK](https://github.com/sipeed/MaixCDK) > You can use `maix.time` to access this module. ## Module No module ## Enum ## Variable ## Function ### time item doc **brief** Get current time in s **return** current time in s, double type **C++ defination code**: ```cpp double time() ``` ### time\\_ms item doc **brief** Get current time in ms **return** current time in ms, uint64_t type **C++ defination code**: ```cpp uint64_t time_ms() ``` ### time\\_s item doc **brief** Get current time in s **return** current time in s, uint64_t type **C++ defination code**: ```cpp uint64_t time_s() ``` ### time\\_us item doc **brief** Get current time in us **return** current time in us, uint64_t type **C++ defination code**: ```cpp uint64_t time_us() ``` ### time\\_diff item doc **brief** Calculate time difference **param** **last**: last time
**now**: current time
**return** time difference **C++ defination code**: ```cpp double time_diff(double last, double now 1) ``` ### sleep item doc **brief** Sleep seconds **param** **s**: seconds, double type
**C++ defination code**: ```cpp void sleep(double s) ``` ### sleep\\_ms item doc **brief** Sleep milliseconds **param** **ms**: milliseconds, uint64_t type
**C++ defination code**: ```cpp void sleep_ms(uint64_t ms) ``` ### sleep\\_us item doc **brief** Sleep microseconds **param** **us**: microseconds, uint64_t type
**C++ defination code**: ```cpp void sleep_us(uint64_t us) ``` ### now item doc **brief** Get current UTC date and time **return** current date and time, DateTime type **C++ defination code**: ```cpp time::DateTime *now() ``` ### localtime item doc **brief** Get local time **return** local time, DateTime type **C++ defination code**: ```cpp time::DateTime *localtime() ``` ### strptime item doc **brief** DateTime from string **param** **str**: date time string
**format**: date time format
**return** DateTime **C++ defination code**: ```cpp time::DateTime *strptime(const std::string &str, const std::string &format) ``` ### gmtime item doc **brief** timestamp to DateTime(time zone is UTC (value 0)) **param** **timestamp**: double timestamp
**return** DateTime **C++ defination code**: ```cpp time::DateTime *gmtime(double timestamp) ``` ## Class ### DateTime item doc **brief** Date and time class **C++ defination code**: ```cpp class DateTime ``` #### year item doc **type** var **brief** Year **static** False **readonly** False **C++ defination code**: ```cpp int year ``` #### month item doc **type** var **brief** Month, 1~12 **static** False **readonly** False **C++ defination code**: ```cpp int month ``` #### day item doc **type** var **brief** Day **static** False **readonly** False **C++ defination code**: ```cpp int day ``` #### hour item doc **type** var **brief** Hour **static** False **readonly** False **C++ defination code**: ```cpp int hour ``` #### minute item doc **type** var **brief** Minute **static** False **readonly** False **C++ defination code**: ```cpp int minute ``` #### second item doc **type** var **brief** Second **static** False **readonly** False **C++ defination code**: ```cpp int second ``` #### microsecond item doc **type** var **brief** Microsecond **static** False **readonly** False **C++ defination code**: ```cpp int microsecond ``` #### yearday item doc **type** var **brief** Year day **static** False **readonly** False **C++ defination code**: ```cpp int yearday ``` #### weekday item doc **type** var **brief** Weekday, 0 is Monday, 6 is Sunday **static** False **readonly** False **C++ defination code**: ```cpp int weekday ``` #### zone item doc **type** var **brief** Time zone **static** False **readonly** False **C++ defination code**: ```cpp float zone ``` #### zone\\_name item doc **type** var **brief** Time zone name **static** False **readonly** False **C++ defination code**: ```cpp std::string zone_name ``` #### \\_\\_init\\_\\_ item doc **type** func **brief** Constructor **param** **year**: year
**month**: month
**day**: day
**hour**: hour
**minute**: minute
**second**: second
**microsecond**: microsecond
**yearday**: year day
**weekday**: weekday
**zone**: time zone
**static** False **C++ defination code**: ```cpp DateTime(int year 0, int month 0, int day 0, int hour 0, int minute 0, int second 0, int microsecond 0, int yearday 0, int weekday 0, int zone 0) ``` #### strftime item doc **type** func **brief** Convert to string **return** date time string **static** False **C++ defination code**: ```cpp std::string strftime(const std::string &format) ``` #### timestamp item doc **type** func **brief** Convert to float timestamp **return** float timestamp **static** False **C++ defination code**: ```cpp double timestamp() ```"},"/maixpy/api/maix/fs.html":{"title":"maix.fs","content":" title: maix.fs maix.fs module > This module is generated from [MaixCDK](https://github.com/sipeed/MaixCDK) > You can use `maix.fs` to access this module. ## Module No module ## Enum ### SEEK item doc **brief** SEEK enums **values** **SEEK_SET**: Seek from beginning of file.
**SEEK_CUR**: Seek from current position.
**SEEK_END**: Seek from end of file.
**C++ defination code**: ```cpp enum SEEK { SEEK_SET 0, // Seek from beginning of file. SEEK_CUR 1, // Seek from current position. SEEK_END 2, // Seek from end of file. } ``` ## Variable ## Function ### isabs item doc **brief** Check if the path is absolute path **param** **path**: path to check
**return** true if path is absolute path **C++ defination code**: ```cpp bool isabs(const std::string &path) ``` ### isdir item doc **brief** Check if the path is a directory, if not exist, throw exception **param** **path**: path to check
**return** true if path is a directory **C++ defination code**: ```cpp bool isdir(const std::string &path) ``` ### isfile item doc **brief** Check if the path is a file, if not exist, throw exception **param** **path**: path to check
**return** true if path is a file **C++ defination code**: ```cpp bool isfile(const std::string &path) ``` ### islink item doc **brief** Check if the path is a link, if not exist, throw exception **param** **path**: path to check
**return** true if path is a link **C++ defination code**: ```cpp bool islink(const std::string &path) ``` ### exists item doc **brief** Check if the path exists **param** **path**: path to check
**return** true if path exists **C++ defination code**: ```cpp bool exists(const std::string &path) ``` ### mkdir item doc **brief** Create a directory recursively **param** **path**: path to create
**exist_ok**: if true, also return true if directory already exists
**recursive**: if true, create directory recursively, otherwise, only create one directory, default is true
**return** err::ERR_NONE(err.Err.ERR_NONE in MaixPy) if success, other error code if failed **C++ defination code**: ```cpp err::Err mkdir(const std::string &path, bool exist_ok true, bool recursive true) ``` ### rmdir item doc **brief** Remove a directory **param** **path**: path to remove
**recursive**: if true, remove directory recursively, otherwise, only remove empty directory, default is false
**return** err::ERR_NONE(err.Err.ERR_NONE in MaixPy) if success, other error code if failed **C++ defination code**: ```cpp err::Err rmdir(const std::string &path, bool recursive false) ``` ### remove item doc **brief** Remove a file **param** **path**: path to remove
**return** err::ERR_NONE(err.Err.ERR_NONE in MaixPy) if success, other error code if failed **C++ defination code**: ```cpp err::Err remove(const std::string &path) ``` ### rename item doc **brief** Rename a file or directory **param** **src**: source path
**dst**: destination path, if destination dirs not exist, will auto create
**return** err::ERR_NONE(err.Err.ERR_NONE in MaixPy) if success, other error code if failed **C++ defination code**: ```cpp err::Err rename(const std::string &src, const std::string &dst) ``` ### getsize item doc **brief** Get file size **param** **path**: path to get size
**return** file size if success, err::Err code if failed **C++ defination code**: ```cpp int getsize(const std::string &path) ``` ### dirname item doc **brief** Get directory name of path **param** **path**: path to get dirname
**return** dirname if success, empty string if failed **C++ defination code**: ```cpp std::string dirname(const std::string &path) ``` ### basename item doc **brief** Get base name of path **param** **path**: path to get basename
**return** basename if success, empty string if failed **C++ defination code**: ```cpp std::string basename(const std::string &path) ``` ### abspath item doc **brief** Get absolute path **param** **path**: path to get absolute path
**return** absolute path if success, empty string if failed **C++ defination code**: ```cpp std::string abspath(const std::string &path) ``` ### getcwd item doc **brief** Get current working directory **return** current working directory absolute path **C++ defination code**: ```cpp std::string getcwd() ``` ### realpath item doc **brief** Get realpath of path **param** **path**: path to get realpath
**return** realpath if success, empty string if failed **C++ defination code**: ```cpp std::string realpath(const std::string &path) ``` ### splitext item doc **brief** Get file extension **param** **path**: path to get extension
**return** extension if success, empty string if failed **C++ defination code**: ```cpp std::string splitext(const std::string &path) ``` ### listdir item doc **brief** List files in directory **param** **path**: path to list
**recursive**: if true, list recursively, otherwise, only list current directory, default is false
**full_path**: if true, return full path, otherwise, only return basename, default is false
**return** files list if success, nullptr if failed **C++ defination code**: ```cpp std::vector *listdir(const std::string &path, bool recursive false, bool full_path false) ``` ### open item doc **brief** Open a file, and return a File object **param** **path**: path to open
**mode**: open mode, support \"r\", \"w\", \"a\", \"r+\", \"w+\", \"a+\", \"rb\", \"wb\", \"ab\", \"rb+\", \"wb+\", \"ab+\"
**return** File object if success(need to delete object manually in C/C++), nullptr if failed **C++ defination code**: ```cpp fs::File *open(const std::string &path, const std::string &mode) ``` ### tempdir item doc **brief** Get temp files directory **return** temp files directory **C++ defination code**: ```cpp std::string tempdir() ``` ## Class ### File item doc **brief** File read write ops **C++ defination code**: ```cpp class File ``` #### open item doc **type** func **brief** Open a file **param** **path**: path to open
**mode**: open mode, support \"r\", \"w\", \"a\", \"r+\", \"w+\", \"a+\", \"rb\", \"wb\", \"ab\", \"rb+\", \"wb+\", \"ab+\"
**return** err::ERR_NONE(err.Err.ERR_NONE in MaixPy) if success, other error code if failed **static** False **C++ defination code**: ```cpp err::Err open(const std::string &path, const std::string &mode) ``` #### close item doc **type** func **brief** Close a file **static** False **C++ defination code**: ```cpp void close() ``` #### read item doc **type** func **brief** Read data from file API2 **param** **size**: max read size
**return** bytes data if success(need delete manually in C/C++), nullptr if failed **static** False **C++ defination code**: ```cpp std::vector *read(int size) ``` #### readline item doc **type** func **brief** Read line from file **return** line if success, empty string if failed. You need to delete the returned object manually in C/C++. **static** False **C++ defination code**: ```cpp std::string *readline() ``` #### write item doc **type** func **brief** Write data to file API2 **param** **buf**: buffer to write
**return** write size if success, err::Err code if failed **static** False **C++ defination code**: ```cpp int write(const std::vector &buf) ``` #### seek item doc **type** func **brief** Seek file position **param** **offset**: offset to seek
**whence**: @see maix.fs.SEEK
**return** new position if success, err::Err code if failed **static** False **C++ defination code**: ```cpp int seek(int offset, int whence) ``` #### tell item doc **type** func **brief** Get file position **return** file position if success, err::Err code if failed **static** False **C++ defination code**: ```cpp int tell() ``` #### flush item doc **type** func **brief** Flush file **return** err::ERR_NONE(err.Err.ERR_NONE in MaixPy) if success, other error code if failed **static** False **C++ defination code**: ```cpp err::Err flush() ```"},"/maixpy/api/maix/camera.html":{"title":"maix.camera","content":" title: maix.camera maix.camera module, access camera device and get image from it > This module is generated from [MaixCDK](https://github.com/sipeed/MaixCDK) > You can use `maix.camera` to access this module. ## Module No module ## Enum ## Variable ## Function ### list\\_devices item doc **brief** List all supported camera devices. **return** Returns the path to the camera device. **C++ defination code**: ```cpp std::vector list_devices() ``` ### set\\_regs\\_enable item doc **brief** Enable set camera registers, default is false, if set to true, will not set camera registers, you can manually set registers by write_reg API. **param** **enable**: enable/disable set camera registers
**C++ defination code**: ```cpp void set_regs_enable(bool enable true) ``` ## Class ### Camera item doc **brief** Camera class **C++ defination code**: ```cpp class Camera ``` #### \\_\\_init\\_\\_ item doc **type** func **brief** Construct a new Camera object **param** **width**: camera width, default is 1, means auto, mostly means max width of camera support
**height**: camera height, default is 1, means auto, mostly means max height of camera support
**format**: camera output format, default is image.Format.FMT_RGB888
**device**: camera device path, you can get devices by list_devices method, by default(value is NULL(None in MaixPy)) means the first device
**fps**: camera fps, default is 1, means auto, mostly means max fps of camera support
**buff_num**: camera buffer number, default is 3, means 3 buffer, one used by user, one used for cache the next frame,
more than one buffer will accelerate image read speed, but will cost more memory.
**open**: If true, camera will automatically call open() after creation. default is true.
**static** False **C++ defination code**: ```cpp Camera(int width 1, int height 1, image::Format format image::FMT_RGB888, const char *device nullptr, int fps 1, int buff_num 3, bool open true) ``` #### get\\_ch\\_nums item doc **type** func **brief** Get the number of channels supported by the camera. **return** Returns the maximum number of channels. **static** False **C++ defination code**: ```cpp int get_ch_nums() ``` #### open item doc **type** func **brief** Open camera and run **param** **width**: camera width, default is 1, means auto, mostly means max width of camera support
**height**: camera height, default is 1, means auto, mostly means max height of camera support
**format**: camera output format, default same as the constructor's format argument
**fps**: camera fps, default is 1, means auto, mostly means max fps of camera support
**buff_num**: camera buffer number, default is 3, means 3 buffer, one used by user, one used for cache the next frame,
more than one buffer will accelerate image read speed, but will cost more memory.
**return** error code, err::ERR_NONE means success, others means failed **static** False **C++ defination code**: ```cpp err::Err open(int width 1, int height 1, image::Format format image::FMT_INVALID, int fps 1, int buff_num 1) ``` #### read item doc **type** func **brief** Get one frame image from camera buffer, must call open method before read.\\nIf open method not called, will call it automatically, if open failed, will throw exception!\\nSo call open method before read is recommended. **param** **buff**: buffer to store image data, if buff is nullptr, will alloc memory automatically.
In MaixPy, default to None, you can create a image.Image object, then pass img.data() to buff.
**block**: block read, default is true, means block util read image successfully,
if set to false, will return nullptr if no image in buffer
**return** image::Image object, if failed, return nullptr, you should delete if manually in C++ **static** False **C++ defination code**: ```cpp image::Image *read(void *buff nullptr, size_t buff_size 0, bool block true) ``` #### clear\\_buff item doc **type** func **brief** Clear buff to ensure the next read image is the latest image **static** False **C++ defination code**: ```cpp void clear_buff() ``` #### skip\\_frames item doc **type** func **brief** Read some frames and drop, this is usually used avoid read not stable image when camera just opened. **param** **num**: number of frames to read and drop
**static** False **C++ defination code**: ```cpp void skip_frames(int num) ``` #### close item doc **type** func **brief** Close camera **static** False **C++ defination code**: ```cpp void close() ``` #### add\\_channel item doc **type** func **brief** Add a new channel and return a new Camera object, you can use close() to close this channel. **param** **width**: camera width, default is 1, means auto, mostly means max width of camera support
**height**: camera height, default is 1, means auto, mostly means max height of camera support
**format**: camera output format, default is RGB888
**fps**: camera fps, default is 1, means auto, mostly means max fps of camera support
**buff_num**: camera buffer number, default is 3, means 3 buffer, one used by user, one used for cache the next frame,
more than one buffer will accelerate image read speed, but will cost more memory.
**open**: If true, camera will automatically call open() after creation. default is true.
**return** new Camera object **static** False **C++ defination code**: ```cpp camera::Camera *add_channel(int width 1, int height 1, image::Format format image::FMT_RGB888, int fps 1, int buff_num 3, bool open true) ``` #### is\\_opened item doc **type** func **brief** Check if camera is opened **return** true if camera is opened, false if not **static** False **C++ defination code**: ```cpp bool is_opened() ``` #### is\\_closed item doc **type** func **brief** check camera device is closed or not **return** closed or not, bool type **static** False **C++ defination code**: ```cpp bool is_closed() ``` #### width item doc **type** func **brief** Get camera width **return** camera width **static** False **C++ defination code**: ```cpp int width() ``` #### height item doc **type** func **brief** Get camera height **return** camera height **static** False **C++ defination code**: ```cpp int height() ``` #### fps item doc **type** func **brief** Get camera fps **return** camera fps **static** False **C++ defination code**: ```cpp int fps() ``` #### format item doc **type** func **brief** Get camera output format **return** camera output format, image::Format object **static** False **C++ defination code**: ```cpp image::Format format() ``` #### buff\\_num item doc **type** func **brief** Get camera buffer number **return** camera buffer number **static** False **C++ defination code**: ```cpp int buff_num() ``` #### hmirror item doc **type** func **brief** Get camera horizontal mirror **return** camera horizontal mirror **static** False **C++ defination code**: ```cpp int hmirror(int value 1) ``` #### vflip item doc **type** func **brief** Get camera vertical flip **return** camera vertical flip **static** False **C++ defination code**: ```cpp int vflip(int value 1) ``` #### exposure item doc **type** func **brief** Get camera exposure **return** camera exposure **static** False **C++ defination code**: ```cpp float exposure(int value 1) ``` #### gain item doc **type** func **brief** Get camera gain **return** camera gain **static** False **C++ defination code**: ```cpp float gain(int value 1) ``` #### device item doc **type** func **brief** Get camera device path **return** camera device path **static** False **C++ defination code**: ```cpp std::string device() ``` #### write\\_reg item doc **type** func **brief** Write camera register **param** **addr**: register address
**data**: register data
**bit_width**: register data bit width, default is 8
**return** error code, err::ERR_NONE means success, others means failed **static** False **C++ defination code**: ```cpp err::Err write_reg(int addr, int data, int bit_width 8) ``` #### read\\_reg item doc **type** func **brief** Read camera register **param** **addr**: register address
**bit_width**: register data bit width, default is 8
**return** register data, 1 means failed **static** False **C++ defination code**: ```cpp int read_reg(int addr, int bit_width 8) ``` #### show\\_colorbar item doc **type** func **brief** Camera output color bar image for test **param** **enable**: enable/disable color bar
**return** error code, err::ERR_NONE means success, others means failed **static** False **C++ defination code**: ```cpp err::Err show_colorbar(bool enable) ```"},"/maixpy/api/maix/nn.html":{"title":"maix.nn","content":" title: maix.nn maix.nn module > This module is generated from [MaixCDK](https://github.com/sipeed/MaixCDK) > You can use `maix.nn` to access this module. ## Module module brief [F](./nn/F.html) maix.nn.F module ## Enum ## Variable ## Function ## Class ### YOLOv5 item doc **brief** YOLOv5 class **C++ defination code**: ```cpp class YOLOv5 ``` #### \\_\\_init\\_\\_ item doc **type** func **brief** Constructor of YOLOv5 class **param** **model**: model path, default empty, you can load model later by load function.
**throw** If model arg is not empty and load failed, will throw err::Exception. **static** False **C++ defination code**: ```cpp YOLOv5(const string &model \"\") ``` #### load item doc **type** func **brief** Load model from file **param** **model**: Model path want to load
**return** err::Err **static** False **C++ defination code**: ```cpp err::Err load(const string &model) ``` #### detect item doc **type** func **brief** Detect objects from image **param** **img**: Image want to detect, if image's size not match model input's, will auto resize with fit method.
**conf_th**: Confidence threshold, default 0.5.
**iou_th**: IoU threshold, default 0.45.
**fit**: Resize method, default image.Fit.FIT_CONTAIN.
**throw** If image format not match model input format, will throw err::Exception. **return** Object list. In C++, you should delete it after use. **static** False **C++ defination code**: ```cpp std::vector *detect(image::Image &img, float conf_th 0.5, float iou_th 0.45, maix::image::Fit fit maix::image::FIT_CONTAIN) ``` #### input\\_size item doc **type** func **brief** Get model input size **return** model input size **static** False **C++ defination code**: ```cpp image::Size input_size() ``` #### input\\_width item doc **type** func **brief** Get model input width **return** model input size of width **static** False **C++ defination code**: ```cpp int input_width() ``` #### input\\_height item doc **type** func **brief** Get model input height **return** model input size of height **static** False **C++ defination code**: ```cpp int input_height() ``` #### input\\_format item doc **type** func **brief** Get input image format **return** input image format, image::Format type. **static** False **C++ defination code**: ```cpp image::Format input_format() ``` #### labels item doc **type** var **brief** Labels list **static** False **readonly** False **C++ defination code**: ```cpp std::vector labels ``` #### label\\_path item doc **type** var **brief** Label file path **static** False **readonly** False **C++ defination code**: ```cpp std::string label_path ``` #### mean item doc **type** var **brief** Get mean value, list type **static** False **readonly** False **C++ defination code**: ```cpp std::vector mean ``` #### scale item doc **type** var **brief** Get scale value, list type **static** False **readonly** False **C++ defination code**: ```cpp std::vector scale ``` #### anchors item doc **type** var **brief** Get anchors **static** False **readonly** False **C++ defination code**: ```cpp std::vector anchors ``` ### Classifier item doc **brief** Classifier **C++ defination code**: ```cpp class Classifier ``` #### \\_\\_init\\_\\_ item doc **type** func **brief** Construct a new Classifier object **param** **model**: MUD model path, if empty, will not load model, you can call load() later.
if not empty, will load model and will raise err::Exception if load failed.
**static** False **C++ defination code**: ```cpp Classifier(const string &model \"\") ``` #### load item doc **type** func **brief** Load model from file, model format is .mud,\\nMUD file should contain [extra] section, have key values:\\n model_type: classifier\\n input_type: rgb or bgr\\n mean: 123.675, 116.28, 103.53\\n scale: 0.017124753831663668, 0.01750700280112045, 0.017429193899782137\\n labels: imagenet_classes.txt **param** **model**: MUD model path
**return** error code, if load failed, return error code **static** False **C++ defination code**: ```cpp err::Err load(const string &model) ``` #### classify item doc **type** func **brief** Forward image to model, get result. Only for image input, use classify_raw for tensor input. **param** **img**: image, format should match model input_type, or will raise err.Exception
**softmax**: if true, will do softmax to result, or will return raw value
**throw** If error occurred, will raise err::Exception, you can find reason in log, mostly caused by args error or hardware error. **return** result, a list of (label, score). In C++, you need to delete it after use. **static** False **C++ defination code**: ```cpp std::vector> *classify(image::Image &img, bool softmax true) ``` #### classify\\_raw item doc **type** func **brief** Forward tensor data to model, get result **param** **data**: tensor data, format should match model input_type, or will raise err.Excetion
**softmax**: if true, will do softmax to result, or will return raw value
**throw** If error occurred, will raise err::Exception, you can find reason in log, mostly caused by args error or hardware error. **return** result, a list of (label, score). In C++, you need to delete it after use. **static** False **C++ defination code**: ```cpp std::vector> *classify_raw(tensor::Tensor &data, bool softmax true) ``` #### input\\_size item doc **type** func **brief** Get model input size, only for image input **return** model input size **static** False **C++ defination code**: ```cpp image::Size input_size() ``` #### input\\_width item doc **type** func **brief** Get model input width, only for image input **return** model input size of width **static** False **C++ defination code**: ```cpp int input_width() ``` #### input\\_height item doc **type** func **brief** Get model input height, only for image input **return** model input size of height **static** False **C++ defination code**: ```cpp int input_height() ``` #### input\\_format item doc **type** func **brief** Get input image format, only for image input **return** input image format, image::Format type. **static** False **C++ defination code**: ```cpp image::Format input_format() ``` #### input\\_shape item doc **type** func **brief** Get input shape, if have multiple input, only return first input shape **return** input shape, list type **static** False **C++ defination code**: ```cpp std::vector input_shape() ``` #### labels item doc **type** var **brief** Labels list **static** False **readonly** False **C++ defination code**: ```cpp std::vector labels ``` #### label\\_path item doc **type** var **brief** Label file path **static** False **readonly** False **C++ defination code**: ```cpp std::string label_path ``` #### mean item doc **type** var **brief** Get mean value, list type **static** False **readonly** False **C++ defination code**: ```cpp std::vector mean ``` #### scale item doc **type** var **brief** Get scale value, list type **static** False **readonly** False **C++ defination code**: ```cpp std::vector scale ``` ### MUD item doc **brief** MUD(model universal describe file) class **C++ defination code**: ```cpp class MUD ``` #### \\_\\_init\\_\\_ item doc **type** func **brief** MUD constructor **param** **model_path**: direction [in], model file path, model format can be MUD(model universal describe file) file.
If model_path set, will load model from file, load failed will raise err.Exception.
If model_path not set, you can load model later by load function.
**static** False **C++ defination code**: ```cpp MUD(const char *model_path nullptr) ``` #### load item doc **type** func **brief** Load model from file **param** **model_path**: direction [in], model file path, model format can be MUD(model universal describe file) file.
**return** error code, if load success, return err::ERR_NONE **static** False **C++ defination code**: ```cpp err::Err load(const std::string &model_path) ``` #### type item doc **type** var **brief** Model type, string type **static** False **readonly** False **C++ defination code**: ```cpp std::string type ``` #### items item doc **type** var **brief** Model config items, different model type has different config items **static** False **readonly** False **C++ defination code**: ```cpp std::map> items ``` ### LayerInfo item doc **brief** NN model layer info **C++ defination code**: ```cpp class LayerInfo ``` #### \\_\\_init\\_\\_ item doc **type** func **brief** LayerInfo constructor **param** **name**: direction [in], layer name
**dtype**: direction [in], layer data type
**shape**: direction [in], layer shape
**static** False **C++ defination code**: ```cpp LayerInfo(const std::string &name \"\", tensor::DType dtype tensor::DType::FLOAT32, std::vector shape std::vector()) ``` #### name item doc **type** var **brief** Layer name **static** False **readonly** False **C++ defination code**: ```cpp std::string name ``` #### dtype item doc **type** var **brief** Layer data type **attention** If model is quantized, this is the real quantized data type like int8 float16,
in most scene, inputs and outputs we actually use float32 in API like forward. **static** False **readonly** False **C++ defination code**: ```cpp tensor::DType dtype ``` #### shape item doc **type** var **brief** Layer shape **static** False **readonly** False **C++ defination code**: ```cpp std::vector shape ``` #### to\\_str item doc **type** func **brief** To string **static** False **C++ defination code**: ```cpp std::string to_str() ``` #### \\_\\_str\\_\\_ item doc **type** func **brief** To string **static** False **C++ defination code**: ```cpp std::string __str__() ``` ### NN item doc **brief** Neural network class **C++ defination code**: ```cpp class NN ``` #### \\_\\_init\\_\\_ item doc **type** func **brief** Neural network constructor **param** **model**: direction [in], model file path, model format can be MUD(model universal describe file) file.
If model_path set, will load model from file, load failed will raise err.Exception.
If model_path not set, you can load model later by load function.
**static** False **C++ defination code**: ```cpp NN(const std::string &model \"\") ``` #### load item doc **type** func **brief** Load model from file **param** **model**: direction [in], model file path, model format can be MUD(model universal describe file) file.
**return** error code, if load success, return err::ERR_NONE **static** False **C++ defination code**: ```cpp err::Err load(const std::string &model) ``` #### loaded item doc **type** func **brief** Is model loaded **return** true if model loaded, else false **static** False **C++ defination code**: ```cpp bool loaded() ``` #### inputs\\_info item doc **type** func **brief** Get model input layer info **return** input layer info **static** False **C++ defination code**: ```cpp std::vector inputs_info() ``` #### outputs\\_info item doc **type** func **brief** Get model output layer info **return** output layer info **static** False **C++ defination code**: ```cpp std::vector outputs_info() ``` #### extra\\_info item doc **type** func **brief** Get model extra info define in MUD file **return** extra info, dict type, key value object, attention: key and value are all string type. **static** False **C++ defination code**: ```cpp std::map extra_info() ``` #### forward item doc **type** func **brief** forward run model, get output of model,\\nthis is specially for MaixPy, not efficient, but easy to use in MaixPy **param** **input**: direction [in], input tensor
**return** output tensor. In C++, you should manually delete tensors in return value and return value. **static** False **C++ defination code**: ```cpp tensor::Tensors *forward(tensor::Tensors &inputs) ``` #### forward\\_image item doc **type** func **brief** forward model, param is image **param** **img**: input image
**mean**: mean value, a list type, e.g. [0.485, 0.456, 0.406], default is empty list means not normalize.
**scale**: scale value, a list type, e.g. [1/0.229, 1/0.224, 1/0.225], default is empty list means not normalize.
**fit**: fit mode, if the image size of input not equal to model's input, it will auto resize use this fit method,
default is image.Fit.FIT_FILL for easy coordinate calculation, but for more accurate result, use image.Fit.FIT_CONTAIN is better.
**return** output tensor. In C++, you should manually delete tensors in return value and return value. **static** False **C++ defination code**: ```cpp tensor::Tensors *forward_image(image::Image &img, std::vector mean std::vector(), std::vector scale std::vector(), image::Fit fit image::Fit::FIT_FILL) ``` ### Object item doc **brief** Object for detect result **C++ defination code**: ```cpp class Object ``` #### \\_\\_init\\_\\_ item doc **type** func **brief** Constructor of Object for detect result **param** **x**: left top x
**y**: left top y
**w**: width
**h**: height
**class_id**: class id
**score**: score
**static** False **C++ defination code**: ```cpp Object(int x 0, int y 0, int w 0, int h 0, int class_id 0, float score 0) ``` #### \\_\\_str\\_\\_ item doc **type** func **brief** Object info to string **return** Object info string **static** False **C++ defination code**: ```cpp std::string to_str() ``` #### x item doc **type** var **brief** Object left top coordinate x **static** False **readonly** False **C++ defination code**: ```cpp int x ``` #### y item doc **type** var **brief** Object left top coordinate y **static** False **readonly** False **C++ defination code**: ```cpp int y ``` #### w item doc **type** var **brief** Object width **static** False **readonly** False **C++ defination code**: ```cpp int w ``` #### h item doc **type** var **brief** Object height **static** False **readonly** False **C++ defination code**: ```cpp int h ``` #### class\\_id item doc **type** var **brief** Object class id **static** False **readonly** False **C++ defination code**: ```cpp int class_id ``` #### score item doc **type** var **brief** Object score **static** False **readonly** False **C++ defination code**: ```cpp float score ```"},"/maixpy/api/maix/image.html":{"title":"maix.image","content":" title: maix.image maix.image module, image related definition and functions > This module is generated from [MaixCDK](https://github.com/sipeed/MaixCDK) > You can use `maix.image` to access this module. ## Module No module ## Enum ### Format item doc **brief** Image formats **attention** for developers, update this enum will also need to update the fmt_size in maix_image.cpp **values** **FMT_RGB888**: RGBRGB...RGB, R at the lowest address
**FMT_BGR888**: BGRBGR...BGR, B at the lowest address
**FMT_RGBA8888**: RGBARGBA...RGBA, R at the lowest address
**FMT_BGRA8888**: BGRABGRA...BGRA, B at the lowest address
**FMT_RGB565**:
**FMT_BGR565**:
**FMT_YUV422SP**: YYY...UVUVUV...UVUV
**FMT_YUV422P**: YYY...UUU...VVV
**FMT_YVU420SP**: YYY...VUVUVU...VUVU, NV21
**FMT_YUV420SP**: YYY...UVUVUV...UVUV, NV12
**FMT_YVU420P**: YYY...VVV...UUU
**FMT_YUV420P**: YYY...UUU...VVV
**FMT_GRAYSCALE**:
**FMT_UNCOMPRESSED_MAX**:
**FMT_COMPRESSED_MIN**:
**FMT_JPEG**:
**FMT_PNG**:
**FMT_COMPRESSED_MAX**:
**FMT_INVALID**: format not valid
**C++ defination code**: ```cpp enum Format { FMT_RGB888 0, // RGBRGB...RGB, R at the lowest address FMT_BGR888, // BGRBGR...BGR, B at the lowest address FMT_RGBA8888, // RGBARGBA...RGBA, R at the lowest address FMT_BGRA8888, // BGRABGRA...BGRA, B at the lowest address FMT_RGB565, FMT_BGR565, FMT_YUV422SP, // YYY...UVUVUV...UVUV FMT_YUV422P, // YYY...UUU...VVV FMT_YVU420SP, // YYY...VUVUVU...VUVU, NV21 FMT_YUV420SP, // YYY...UVUVUV...UVUV, NV12 FMT_YVU420P, // YYY...VVV...UUU FMT_YUV420P, // YYY...UUU...VVV FMT_GRAYSCALE, FMT_UNCOMPRESSED_MAX, // compressed format below, not compressed should define upper FMT_COMPRESSED_MIN, FMT_JPEG, FMT_PNG, FMT_COMPRESSED_MAX, FMT_INVALID 0xFF // format not valid } ``` ### Fit item doc **brief** Object fit method **values** **FIT_NONE**: no object fit, keep original
**FIT_FILL**: width to new width, height to new height, may be stretch
**FIT_CONTAIN**: keep aspect ratio, fill blank area with black color
**FIT_COVER**: keep aspect ratio, crop image to fit new size
**FIT_MAX**:
**C++ defination code**: ```cpp enum Fit { FIT_NONE 1, // no object fit, keep original FIT_FILL 0, // width to new width, height to new height, may be stretch FIT_CONTAIN, // keep aspect ratio, fill blank area with black color FIT_COVER, // keep aspect ratio, crop image to fit new size FIT_MAX } ``` ### ResizeMethod item doc **brief** Resize method **values** **NEAREST**:
**BILINEAR**:
**BICUBIC**:
**AREA**:
**LANCZOS**:
**HAMMING**:
**RESIZE_METHOD_MAX**:
**C++ defination code**: ```cpp enum ResizeMethod { NEAREST 0, BILINEAR, BICUBIC, AREA, LANCZOS, HAMMING, RESIZE_METHOD_MAX } ``` ### ApriltagFamilies item doc **brief** Family of apriltag **values** **TAG16H5**:
**TAG25H7**:
**TAG25H9**:
**TAG36H10**:
**TAG36H11**:
**ARTOOLKIT**:
**C++ defination code**: ```cpp enum ApriltagFamilies { TAG16H5 1, TAG25H7 2, TAG25H9 4, TAG36H10 8, TAG36H11 16, ARTOOLKIT 32 } ``` ### TemplateMatch item doc **brief** Template match method **values** **SEARCH_EX**: Exhaustive search
**SEARCH_DS**: Diamond search
**C++ defination code**: ```cpp enum TemplateMatch { SEARCH_EX, // Exhaustive search SEARCH_DS, // Diamond search } ``` ### CornerDetector item doc **brief** CornerDetector class **values** **CORNER_FAST**:
**CORNER_AGAST**:
**C++ defination code**: ```cpp enum CornerDetector { CORNER_FAST, CORNER_AGAST } ``` ### EdgeDetector item doc **brief** EdgeDetector class **values** **EDGE_CANNY**:
**EDGE_SIMPLE**:
**C++ defination code**: ```cpp enum EdgeDetector { EDGE_CANNY, EDGE_SIMPLE, } ``` ## Variable ### fmt\\_size item doc **brief** Image format size in bytes **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** **{
3,
3,
4,
4,
2,
2,
2,
2,
1.5,
1.5,
1.5,
1.5,
1,
0,
0,
0,
0,
0
}** **readonly** True **C++ defination code**: ```cpp const std::vector fmt_size { 3, 3, 4, 4, 2, 2, 2, 2, 1.5, 1.5, 1.5, 1.5, 1, 0, 0, 0, 0, 0 } ``` ### fmt\\_names item doc **brief** Image format string **value** **{
\"RGB888\",
\"BGR888\",
\"RGBA8888\",
\"BGRA8888\",
\"RGB565\",
\"BGR565\",
\"YUV422SP\",
\"YUV422P\",
\"YVU420SP\",
\"YUV420SP\",
\"YVU420P\"
\"YUV420P\",
\"GRAYSCALE\",
\"MAX\"}** **readonly** True **C++ defination code**: ```cpp const std::vector fmt_names { \"RGB888\", \"BGR888\", \"RGBA8888\", \"BGRA8888\", \"RGB565\", \"BGR565\", \"YUV422SP\", \"YUV422P\", \"YVU420SP\", \"YUV420SP\", \"YVU420P\" \"YUV420P\", \"GRAYSCALE\", \"MAX\"} ``` ### COLOR\\_WHITE item doc **brief** Predefined color white **value** **image::Color::from_rgb(255, 255, 255)** **readonly** True **C++ defination code**: ```cpp const image::Color COLOR_WHITE image::Color::from_rgb(255, 255, 255) ``` ### COLOR\\_BLACK item doc **brief** Predefined color black **value** **image::Color::from_rgb(0, 0, 0)** **readonly** True **C++ defination code**: ```cpp const image::Color COLOR_BLACK image::Color::from_rgb(0, 0, 0) ``` ### COLOR\\_RED item doc **brief** Predefined color red **value** **image::Color::from_rgb(255, 0, 0)** **readonly** True **C++ defination code**: ```cpp const image::Color COLOR_RED image::Color::from_rgb(255, 0, 0) ``` ### COLOR\\_GREEN item doc **brief** Predefined color green **value** **image::Color::from_rgb(0, 255, 0)** **readonly** True **C++ defination code**: ```cpp const image::Color COLOR_GREEN image::Color::from_rgb(0, 255, 0) ``` ### COLOR\\_BLUE item doc **brief** Predefined color blue **value** **image::Color::from_rgb(0, 0, 255)** **readonly** True **C++ defination code**: ```cpp const image::Color COLOR_BLUE image::Color::from_rgb(0, 0, 255) ``` ### COLOR\\_YELLOW item doc **brief** Predefined color yellow **value** **image::Color::from_rgb(255, 255, 0)** **readonly** True **C++ defination code**: ```cpp const image::Color COLOR_YELLOW image::Color::from_rgb(255, 255, 0) ``` ### COLOR\\_PURPLE item doc **brief** Predefined color purple **value** **image::Color::from_rgb(143, 0, 255)** **readonly** True **C++ defination code**: ```cpp const image::Color COLOR_PURPLE image::Color::from_rgb(143, 0, 255) ``` ### COLOR\\_ORANGE item doc **brief** Predefined color orange **value** **image::Color::from_rgb(255, 127, 0)** **readonly** True **C++ defination code**: ```cpp const image::Color COLOR_ORANGE image::Color::from_rgb(255, 127, 0) ``` ### COLOR\\_GRAY item doc **brief** Predefined color gray **value** **image::Color::from_rgb(127, 127, 127)** **readonly** True **C++ defination code**: ```cpp const image::Color COLOR_GRAY image::Color::from_rgb(127, 127, 127) ``` ## Function ### load item doc **brief** Load image from file, and convert to Image object **param** **path**: image file path
**format**: read as this format, if not match, will convert to this format, by default is RGB888
**return** Image object **C++ defination code**: ```cpp image::Image *load(const char *path, image::Format format image::Format::FMT_RGB888) ``` ### load\\_font item doc **brief** Load font from file **param** **name**: font name, used to identify font
**path**: font file path, support ttf, ttc, otf
**size**: font size, font height, by default is 16
**return** error code, err::ERR_NONE is ok, other is error **C++ defination code**: ```cpp err::Err load_font(const std::string &name, const char *path, int size 16) ``` ### set\\_default\\_font item doc **brief** Set default font, if not call this method, default is hershey_plain **param** **name**: font name, supported names can be get by fonts()
**return** error code, err::ERR_NONE is ok, other is error **C++ defination code**: ```cpp err::Err set_default_font(const std::string &name) ``` ### fonts item doc **brief** Get all loaded fonts **return** all loaded fonts, string list type **C++ defination code**: ```cpp std::vector *fonts() ``` ### text\\_size item doc **brief** Get text rendered width and height **param** **text**: text content
**scale**: font scale, by default(value is 1)
**thickness**: text thickness(line width), by default(value is 1)
**return** text rendered width and height, [width, height] **C++ defination code**: ```cpp image::Size text_size(std::string text, float scale 1, int thickness 1, const std::string &font \"\") ``` ### cv2image item doc **brief** OpenCV Mat(numpy array object) to Image object **param** **array**: numpy array object, must be a 3 dim or 2 dim continuous array with shape hwc or hw
**return** Image object **C++ defination code**: ```cpp image::Image *cv2image(py::array_t array, bool bgr true, bool copy true) ``` ### image2cv item doc **brief** Image object to OpenCV Mat(numpy array object) **param** **img**: Image object
**return** numpy array object **C++ defination code**: ```cpp py::array_t image2cv(image::Image *img, bool bgr true, bool copy true) ``` ## Class ### Size item doc **brief** Image size type **C++ defination code**: ```cpp class Size ``` #### \\_\\_init\\_\\_ item doc **type** func **brief** Construct a new Size object **param** **width**: image width
**height**: image height
**static** False **C++ defination code**: ```cpp Size(int width 0, int height 0) ``` #### width item doc **type** var **brief** width of size **static** False **readonly** False **C++ defination code**: ```cpp int width ``` #### height item doc **type** var **brief** height of size **static** False **readonly** False **C++ defination code**: ```cpp int height ``` #### \\_\\_getitem\\_\\_ item doc **type** func **brief** Subscript operator **param** **index**: 0 for width, 1 for height
**return** int& width or height **static** False **C++ defination code**: ```cpp int &__getitem__(int index) ``` #### \\_\\_str\\_\\_ item doc **type** func **brief** to string **static** False **C++ defination code**: ```cpp std::string __str__() ``` ### Line item doc **brief** Line class **C++ defination code**: ```cpp class Line ``` #### \\_\\_init\\_\\_ item doc **type** func **brief** Line constructor **param** **x1**: coordinate x1 of the straight line
**y1**: coordinate y1 of the straight line
**x2**: coordinate x2 of the straight line
**y2**: coordinate y2 of the straight line
**magnitude**: magnitude of the straight line after Hough transformation
**theta**: angle of the straight line after Hough transformation
**rho**: p value of the straight line after Hough transformation
**static** False **C++ defination code**: ```cpp Line(int x1, int y1, int x2, int y2, int magnitude 0, int theta 0, int rho 0) ``` #### x1 item doc **type** func **brief** get x1 of line **return** return x1 of the line, type is int **static** False **C++ defination code**: ```cpp int x1() ``` #### y1 item doc **type** func **brief** get y1 of line **return** return y1 of the line, type is int **static** False **C++ defination code**: ```cpp int y1() ``` #### x2 item doc **type** func **brief** get x2 of line **return** return x2 of the line, type is int **static** False **C++ defination code**: ```cpp int x2() ``` #### y2 item doc **type** func **brief** get y2 of line **return** return y2 of the line, type is int **static** False **C++ defination code**: ```cpp int y2() ``` #### length item doc **type** func **brief** get length of line **return** return length of the line, type is int **static** False **C++ defination code**: ```cpp int length() ``` #### magnitude item doc **type** func **brief** get magnitude of the straight line after Hough transformation **return** return magnitude, type is int **static** False **C++ defination code**: ```cpp int magnitude() ``` #### theta item doc **type** func **brief** get angle of the straight line after Hough transformation (0 179 degrees) **return** return angle, type is int **static** False **C++ defination code**: ```cpp int theta() ``` #### rho item doc **type** func **brief** get p value of the straight line after Hough transformation **return** return p value, type is int **static** False **C++ defination code**: ```cpp int rho() ``` ### Rect item doc **brief** Rect class **C++ defination code**: ```cpp class Rect ``` #### \\_\\_init\\_\\_ item doc **type** func **brief** Rect constructor **param** **corners**: corners of rect
**x**: coordinate x of the straight line
**y**: coordinate y of the straight line
**w**: coordinate w of the straight line
**h**: coordinate h of the straight line
**magnitude**: magnitude of the straight line after Hough transformation
**static** False **C++ defination code**: ```cpp Rect(std::vector> &corners, int x, int y, int w, int h, int magnitude 0) ``` #### corners item doc **type** func **brief** get corners of rect **return** return the coordinate of the rect. **static** False **C++ defination code**: ```cpp std::vector> corners() ``` #### rect item doc **type** func **brief** get rectangle of rect **return** return the rectangle of the rect. format is {x, y, w, h}, type is std::vector **static** False **C++ defination code**: ```cpp std::vector rect() ``` #### x item doc **type** func **brief** get x of rect **return** return x of the rect, type is int **static** False **C++ defination code**: ```cpp int x() ``` #### y item doc **type** func **brief** get y of rect **return** return y of the rect, type is int **static** False **C++ defination code**: ```cpp int y() ``` #### w item doc **type** func **brief** get w of rect **return** return w of the rect, type is int **static** False **C++ defination code**: ```cpp int w() ``` #### h item doc **type** func **brief** get h of rect **return** return h of the rect, type is int **static** False **C++ defination code**: ```cpp int h() ``` #### magnitude item doc **type** func **brief** get magnitude of the straight line after Hough transformation **return** return magnitude, type is int **static** False **C++ defination code**: ```cpp int magnitude() ``` ### Circle item doc **brief** circle class **C++ defination code**: ```cpp class Circle ``` #### \\_\\_init\\_\\_ item doc **type** func **brief** Circle constructor **param** **x**: coordinate x of the circle
**y**: coordinate y of the circle
**r**: coordinate r of the circle
**magnitude**: coordinate y2 of the straight line
**static** False **C++ defination code**: ```cpp Circle(int x, int y, int r, int magnitude) ``` #### x item doc **type** func **brief** get x of circle **return** return x of the circle, type is int **static** False **C++ defination code**: ```cpp int x() ``` #### y item doc **type** func **brief** get y of circle **return** return y of the circle, type is int **static** False **C++ defination code**: ```cpp int y() ``` #### r item doc **type** func **brief** get r of circle **return** return r of the circle, type is int **static** False **C++ defination code**: ```cpp int r() ``` #### magnitude item doc **type** func **brief** get magnitude of the circle after Hough transformation **return** return magnitude, type is int **static** False **C++ defination code**: ```cpp int magnitude() ``` ### Blob item doc **brief** Blob class **C++ defination code**: ```cpp class Blob ``` #### \\_\\_init\\_\\_ item doc **type** func **brief** Blob constructor **param** **rect**: blob rect, type is std::vector
**corners**: blob corners, type is std::vector>
**mini_corners**: blob mini_corners, type is std::vector>
**cx**: blob center x, type is float
**cy**: blob center y, type is float
**pixels**: blob pixels, type is int
**rotation**: blob rotation, type is float
**code**: blob code, type is int
**count**: blob count, type is int
**perimeter**: blob perimeter, type is int
**roundness**: blob roundness, type is float
**x_hist_bins**: blob x_hist_bins, type is std::vector
**y_hist_bins**: blob y_hist_bins, type is std::vector
**static** False **C++ defination code**: ```cpp Blob(std::vector &rect, std::vector> &corners, std::vector> &mini_corners,float cx, float cy, int pixels, float rotation, int code, int count, int perimeter, float roundness, std::vector &x_hist_bins, std::vector &y_hist_bins) ``` #### corners item doc **type** func **brief** get blob corners **return** Returns a list of 4 (x,y) tuples of the 4 corners of the object.
(x0, y0)___________(x1, y1)



___________
(x3, y3) (x2, y2)
note: the order of corners may change **static** False **C++ defination code**: ```cpp std::vector> corners() ``` #### mini\\_corners item doc **type** func **brief** get blob mini corners **return** Returns a list of 4 (x,y) tuples of the 4 corners than bound the min area rectangle of the blob.
(x0, y0)___________(x1, y1)



___________
(x3, y3) (x2, y2)
note: the order of corners may change **static** False **C++ defination code**: ```cpp std::vector> mini_corners() ``` #### rect item doc **type** func **brief** get blob rect **return** Returns the center coordinates and width and height of the rectangle. format is (x, y, w, h)
w
(x, y) ___________

h

___________ **static** False **C++ defination code**: ```cpp std::vector rect() ``` #### x item doc **type** func **brief** get blob x of the upper left coordinate **return** Returns the x coordinate of the upper left corner of the rectangle. **static** False **C++ defination code**: ```cpp int x() ``` #### y item doc **type** func **brief** get blob y of the upper left coordinate **return** Returns the y coordinate of the upper left corner of the rectangle. **static** False **C++ defination code**: ```cpp int y() ``` #### w item doc **type** func **brief** get blob width **return** Returns the blob’s bounding box w coordinate **static** False **C++ defination code**: ```cpp int w() ``` #### h item doc **type** func **brief** get blob height **return** Returns the blob’s bounding box h coordinate **static** False **C++ defination code**: ```cpp int h() ``` #### pixels item doc **type** func **brief** get blob pixels **return** Returns the number of pixels that are part of this blob. **static** False **C++ defination code**: ```cpp int pixels() ``` #### cx item doc **type** func **brief** get blob center x **return** Returns the centroid x position of the blob **static** False **C++ defination code**: ```cpp int cx() ``` #### cy item doc **type** func **brief** get blob center y **return** Returns the centroid y position of the blob **static** False **C++ defination code**: ```cpp int cy() ``` #### cxf item doc **type** func **brief** get blob center x **return** Returns the centroid x position of the blob **static** False **C++ defination code**: ```cpp float cxf() ``` #### cyf item doc **type** func **brief** get blob center y **return** Returns the centroid y position of the blob **static** False **C++ defination code**: ```cpp float cyf() ``` #### rotation item doc **type** func **brief** get blob rotation **return** Returns the rotation of the blob in radians (float). If the blob is like a pencil or pen this value will be unique for 0 180 degrees. **static** False **C++ defination code**: ```cpp float rotation() ``` #### rotation\\_rad item doc **type** func **brief** get blob rotation_rad **return** Returns the rotation of the blob in radians **static** False **C++ defination code**: ```cpp float rotation_rad() ``` #### rotation\\_deg item doc **type** func **brief** get blob rotation_deg **return** Returns the rotation of the blob in degrees. **static** False **C++ defination code**: ```cpp int rotation_deg() ``` #### code item doc **type** func **brief** get blob code **return** Returns a 32 bit binary number with a bit set in it for each color threshold that’s part of this blob **static** False **C++ defination code**: ```cpp int code() ``` #### count item doc **type** func **brief** get blob count **return** Returns the number of blobs merged into this blob. **static** False **C++ defination code**: ```cpp int count() ``` #### perimeter item doc **type** func **brief** get blob merge_cnt **return** Returns the number of pixels on this blob’s perimeter. **static** False **C++ defination code**: ```cpp int perimeter() ``` #### roundness item doc **type** func **brief** get blob roundness **return** Returns a value between 0 and 1 representing how round the object is **static** False **C++ defination code**: ```cpp float roundness() ``` #### elongation item doc **type** func **brief** get blob elongation **returnReturns** a value between 0 and 1 representing how long (not round) the object is **static** False **C++ defination code**: ```cpp float elongation() ``` #### area item doc **type** func **brief** get blob area **return** Returns the area of the bounding box around the blob **static** False **C++ defination code**: ```cpp int area() ``` #### density item doc **type** func **brief** get blob density **return** Returns the density ratio of the blob **static** False **C++ defination code**: ```cpp float density() ``` #### extent item doc **type** func **brief** Alias for blob.density() **return** Returns the density ratio of the blob **static** False **C++ defination code**: ```cpp float extent() ``` #### compactness item doc **type** func **brief** get blob compactness **return** Returns the compactness ratio of the blob **static** False **C++ defination code**: ```cpp float compactness() ``` #### solidity item doc **type** func **brief** get blob solidity **return** Returns the solidity ratio of the blob **static** False **C++ defination code**: ```cpp float solidity() ``` #### convexity item doc **type** func **brief** get blob convexity **return** Returns a value between 0 and 1 representing how convex the object is **static** False **C++ defination code**: ```cpp float convexity() ``` #### x\\_hist\\_bins item doc **type** func **brief** get blob x_hist_bins **return** Returns the x_hist_bins of the blob **static** False **C++ defination code**: ```cpp std::vector x_hist_bins() ``` #### y\\_hist\\_bins item doc **type** func **brief** get blob y_hist_bins **return** Returns the y_hist_bins of the blob **static** False **C++ defination code**: ```cpp std::vector y_hist_bins() ``` #### major\\_axis\\_line item doc **type** func **brief** get blob major_axis_line **return** Returns a line tuple (x1, y1, x2, y2) of the minor axis of the blob. **static** False **C++ defination code**: ```cpp std::vector major_axis_line() ``` #### minor\\_axis\\_line item doc **type** func **brief** get blob minor_axis_line **return** Returns a line tuple (x1, y1, x2, y2) of the minor axis of the blob. **static** False **C++ defination code**: ```cpp std::vector minor_axis_line() ``` #### enclosing\\_circle item doc **type** func **brief** get blob enclosing_circle **return** Returns a circle tuple (x, y, r) of the circle that encloses the min area rectangle of a blob. **static** False **C++ defination code**: ```cpp std::vector enclosing_circle() ``` #### enclosed\\_ellipse item doc **type** func **brief** get blob enclosed_ellipse **return** Returns an ellipse tuple (x, y, rx, ry, rotation) of the ellipse that fits inside of the min area rectangle of a blob. **static** False **C++ defination code**: ```cpp std::vector enclosed_ellipse() ``` ### QRCode item doc **brief** QRCode class **C++ defination code**: ```cpp class QRCode ``` #### \\_\\_init\\_\\_ item doc **type** func **brief** QRCode constructor **param** **rect**: rect of corners, type is std::vector
**corners**: corners of QRCode
**payload**: payload of the QRCode
**version**: version of the QRCode
**ecc_level**: ecc_level of the QRCode
**mask**: mask of the QRCode
**data_type**: data_type of the QRCode
**eci**: eci of the QRCode
**static** False **C++ defination code**: ```cpp QRCode(std::vector &rect, std::vector> &corners, std::string &payload, int version, int ecc_level, int mask, int data_type, int eci) ``` #### corners item doc **type** func **brief** get coordinate of QRCode **return** return the coordinate of the QRCode. **static** False **C++ defination code**: ```cpp std::vector> corners() ``` #### rect item doc **type** func **brief** get rectangle of QRCode **return** return the rectangle of the QRCode. format is {x, y, w, h}, type is std::vector **static** False **C++ defination code**: ```cpp std::vector rect() ``` #### x item doc **type** func **brief** get x of QRCode **return** return x of the QRCode, type is int **static** False **C++ defination code**: ```cpp int x() ``` #### y item doc **type** func **brief** get y of QRCode **return** return y of the QRCode, type is int **static** False **C++ defination code**: ```cpp int y() ``` #### w item doc **type** func **brief** get w of QRCode **return** return w of the QRCode, type is int **static** False **C++ defination code**: ```cpp int w() ``` #### h item doc **type** func **brief** get h of QRCode **return** return h of the QRCode, type is int **static** False **C++ defination code**: ```cpp int h() ``` #### payload item doc **type** func **brief** get QRCode payload **return** return area of the QRCode **static** False **C++ defination code**: ```cpp std::string payload() ``` #### version item doc **type** func **brief** get QRCode version **return** return version of the QRCode **static** False **C++ defination code**: ```cpp int version() ``` #### ecc\\_level item doc **type** func **brief** get QRCode error correction level **return** return error correction level of the QRCode **static** False **C++ defination code**: ```cpp int ecc_level() ``` #### mask item doc **type** func **brief** get QRCode mask **return** return mask of the QRCode **static** False **C++ defination code**: ```cpp int mask() ``` #### data\\_type item doc **type** func **brief** get QRCode dataType **return** return mask of the QRCode **static** False **C++ defination code**: ```cpp int data_type() ``` #### eci item doc **type** func **brief** get QRCode eci **return** return data of the QRCode **static** False **C++ defination code**: ```cpp int eci() ``` #### is\\_numeric item doc **type** func **brief** check QRCode is numeric **return** return true if the result type of the QRCode is numeric **static** False **C++ defination code**: ```cpp bool is_numeric() ``` #### is\\_alphanumeric item doc **type** func **brief** check QRCode is alphanumeric **return** return true if the result type of the QRCode is alphanumeric **static** False **C++ defination code**: ```cpp bool is_alphanumeric() ``` #### is\\_binary item doc **type** func **brief** check QRCode is binary **return** return true if the result type of the QRCode is binary **static** False **C++ defination code**: ```cpp bool is_binary() ``` #### is\\_kanji item doc **type** func **brief** check QRCode is kanji **return** return true if the result type of the QRCode is kanji **static** False **C++ defination code**: ```cpp bool is_kanji() ``` ### AprilTag item doc **brief** AprilTag class **C++ defination code**: ```cpp class AprilTag ``` #### \\_\\_init\\_\\_ item doc **type** func **brief** AprilTag constructor **param** **rect**: Inlucdes the top left corner and the width and height of the rectangle. format is {x, y, w, h}, type is std::vector
**corners**: Includes the four corners of the rectangle. format is {{x0, y0}, {x1, y1}, {x2, y2}, {x3, y3}}, type is std::vector>
**id**: The id of the AprilTag
**famliy**: The family of the AprilTag
**centroid_x**: The x coordinate of the center of the AprilTag
**centroid_y**: The y coordinate of the center of the AprilTag
**rotation**: The rotation of the AprilTag
**decision_margin**: The decision_margin of the AprilTag
**hamming**: The hamming of the AprilTag
**goodness**: The goodness of the AprilTag
**x_translation**: The x_translation of the AprilTag
**y_translation**: The y_translation of the AprilTag
**z_translation**: The z_translation of the AprilTag
**x_rotation**: The x_rotation of the AprilTag
**y_rotation**: The y_rotation of the AprilTag
**z_rotation**: The z_rotation of the AprilTag
**static** False **C++ defination code**: ```cpp AprilTag(std::vector &rect, std::vector> &corners, int id, int famliy, float centroid_x, float centroid_y, float rotation, float decision_margin, int hamming, float goodness, float x_translation, float y_translation, float z_translation, float x_rotation, float y_rotation, float z_rotation) ``` #### corners item doc **type** func **brief** get coordinate of AprilTag **return** return the coordinate of the AprilTag. **static** False **C++ defination code**: ```cpp std::vector> corners() ``` #### rect item doc **type** func **brief** get rectangle of AprilTag **return** return the rectangle of the AprilTag. format is {x, y, w, h}, type is std::vector **static** False **C++ defination code**: ```cpp std::vector rect() ``` #### x item doc **type** func **brief** get x of AprilTag **return** return x of the AprilTag, type is int **static** False **C++ defination code**: ```cpp int x() ``` #### y item doc **type** func **brief** get y of AprilTag **return** return y of the AprilTag, type is int **static** False **C++ defination code**: ```cpp int y() ``` #### w item doc **type** func **brief** get w of AprilTag **return** return w of the AprilTag, type is int **static** False **C++ defination code**: ```cpp int w() ``` #### h item doc **type** func **brief** get h of AprilTag **return** return h of the AprilTag, type is int **static** False **C++ defination code**: ```cpp int h() ``` #### id item doc **type** func **brief** get id of AprilTag **return** return id of the AprilTag, type is int **static** False **C++ defination code**: ```cpp int id() ``` #### family item doc **type** func **brief** get family of AprilTag **return** return family of the AprilTag, type is int **static** False **C++ defination code**: ```cpp int family() ``` #### cx item doc **type** func **brief** get cx of AprilTag **return** return cx of the AprilTag, type is int **static** False **C++ defination code**: ```cpp int cx() ``` #### cxf item doc **type** func **brief** get cxf of AprilTag **return** return cxf of the AprilTag, type is float **static** False **C++ defination code**: ```cpp float cxf() ``` #### cy item doc **type** func **brief** get cy of AprilTag **return** return cy of the AprilTag, type is int **static** False **C++ defination code**: ```cpp int cy() ``` #### cyf item doc **type** func **brief** get cyf of AprilTag **return** return cyf of the AprilTag, type is float **static** False **C++ defination code**: ```cpp float cyf() ``` #### rotation item doc **type** func **brief** get rotation of AprilTag **return** return rotation of the AprilTag, type is float **static** False **C++ defination code**: ```cpp float rotation() ``` #### decision\\_margin item doc **type** func **brief** Get decision_margin of AprilTag **return** Returns the quality of the apriltag match (0.0 1.0) where 1.0 is the best. **static** False **C++ defination code**: ```cpp float decision_margin() ``` #### hamming item doc **type** func **brief** get hamming of AprilTag **return** Returns the number of accepted bit errors for this tag.
return 0, means 0 bit errors will be accepted.
1 is TAG25H7, means up to 1 bit error may be accepted
2 is TAG25H9, means up to 3 bit errors may be accepted
3 is TAG36H10, means up to 3 bit errors may be accepted
4 is TAG36H11, means up to 4 bit errors may be accepted
5 is ARTOOLKIT, means 0 bit errors will be accepted **static** False **C++ defination code**: ```cpp int hamming() ``` #### goodness item doc **type** func **brief** get goodness of AprilTag **return** return goodness of the AprilTag, type is float
Note: This value is always 0.0 for now. **static** False **C++ defination code**: ```cpp float goodness() ``` #### x\\_translation item doc **type** func **brief** get x_translation of AprilTag **return** return x_translation of the AprilTag, type is float **static** False **C++ defination code**: ```cpp float x_translation() ``` #### y\\_translation item doc **type** func **brief** get y_translation of AprilTag **return** return y_translation of the AprilTag, type is float **static** False **C++ defination code**: ```cpp float y_translation() ``` #### z\\_translation item doc **type** func **brief** get z_translation of AprilTag **return** return z_translation of the AprilTag, type is float **static** False **C++ defination code**: ```cpp float z_translation() ``` #### x\\_rotation item doc **type** func **brief** get x_rotation of AprilTag **return** return x_rotation of the AprilTag, type is float **static** False **C++ defination code**: ```cpp float x_rotation() ``` #### y\\_rotation item doc **type** func **brief** get y_rotation of AprilTag **return** return y_rotation of the AprilTag, type is float **static** False **C++ defination code**: ```cpp float y_rotation() ``` #### z\\_rotation item doc **type** func **brief** get z_rotation of AprilTag **return** return z_rotation of the AprilTag, type is float **static** False **C++ defination code**: ```cpp float z_rotation() ``` ### DataMatrix item doc **brief** DataMatrix class **C++ defination code**: ```cpp class DataMatrix ``` #### \\_\\_init\\_\\_ item doc **type** func **brief** DataMatrix constructor **param** **rect**: Inlucdes the top left corner and the width and height of the rectangle. format is {x, y, w, h}, type is std::vector
**corners**: Includes the four corners of the rectangle. format is {{x0, y0}, {x1, y1}, {x2, y2}, {x3, y3}}, type is std::vector>
**payload**: The payload of the DataMatrix
**rotation**: The rotation of the DataMatrix
**rows**: The rows of the DataMatrix
**columns**: The columns of the DataMatrix
**capacity**: The capacity of the DataMatrix
**padding**: The padding of the DataMatrix
**static** False **C++ defination code**: ```cpp DataMatrix(std::vector &rect, std::vector> &corners, std::string &payload, float rotation, int rows, int columns, int capacity, int padding) ``` #### corners item doc **type** func **brief** get coordinate of DataMatrix **return** return the coordinate of the DataMatrix. **static** False **C++ defination code**: ```cpp std::vector> corners() ``` #### rect item doc **type** func **brief** get rectangle of DataMatrix **return** return the rectangle of the DataMatrix. format is {x, y, w, h}, type is std::vector **static** False **C++ defination code**: ```cpp std::vector rect() ``` #### x item doc **type** func **brief** get x of DataMatrix **return** return x of the DataMatrix, type is int **static** False **C++ defination code**: ```cpp int x() ``` #### y item doc **type** func **brief** get y of DataMatrix **return** return y of the DataMatrix, type is int **static** False **C++ defination code**: ```cpp int y() ``` #### w item doc **type** func **brief** get w of DataMatrix **return** return w of the DataMatrix, type is int **static** False **C++ defination code**: ```cpp int w() ``` #### h item doc **type** func **brief** get h of DataMatrix **return** return h of the DataMatrix, type is int **static** False **C++ defination code**: ```cpp int h() ``` #### payload item doc **type** func **brief** get payload of DataMatrix **return** return payload of the DataMatrix, type is std::string **static** False **C++ defination code**: ```cpp std::string payload() ``` #### rotation item doc **type** func **brief** get rotation of DataMatrix **return** return rotation of the DataMatrix, type is float **static** False **C++ defination code**: ```cpp float rotation() ``` #### rows item doc **type** func **brief** get rows of DataMatrix **return** return rows of the DataMatrix, type is int **static** False **C++ defination code**: ```cpp int rows() ``` #### columns item doc **type** func **brief** get columns of DataMatrix **return** return columns of the DataMatrix, type is int **static** False **C++ defination code**: ```cpp int columns() ``` #### capacity item doc **type** func **brief** et capacity of DataMatrix **return** returns how many characters could fit in this data matrix, type is int **static** False **C++ defination code**: ```cpp int capacity() ``` #### padding item doc **type** func **brief** get padding of DataMatrix **return** returns how many unused characters are in this data matrix, type is int **static** False **C++ defination code**: ```cpp int padding() ``` ### BarCode item doc **brief** BarCode class **C++ defination code**: ```cpp class BarCode ``` #### \\_\\_init\\_\\_ item doc **type** func **brief** BarCode constructor **param** **rect**: Inlucdes the top left corner and the width and height of the rectangle. format is {x, y, w, h}, type is std::vector
**corners**: Includes the four corners of the rectangle. format is {{x0, y0}, {x1, y1}, {x2, y2}, {x3, y3}}, type is std::vector>
**payload**: The payload of the BarCode
**type**: The type of the BarCode
**rotation**: The rotation of the BarCode
**quality**: The quality of the BarCode
**static** False **C++ defination code**: ```cpp BarCode(std::vector &rect, std::vector> &corners, std::string &payload, int type, float rotation, int quality) ``` #### corners item doc **type** func **brief** get coordinate of BarCode **return** return the coordinate of the BarCode. **static** False **C++ defination code**: ```cpp std::vector> corners() ``` #### rect item doc **type** func **brief** get rectangle of BarCode **return** return the rectangle of the BarCode. format is {x, y, w, h}, type is std::vector **static** False **C++ defination code**: ```cpp std::vector rect() ``` #### x item doc **type** func **brief** get x of BarCode **return** return x of the BarCode, type is int **static** False **C++ defination code**: ```cpp int x() ``` #### y item doc **type** func **brief** get y of BarCode **return** return y of the BarCode, type is int **static** False **C++ defination code**: ```cpp int y() ``` #### w item doc **type** func **brief** get w of BarCode **return** return w of the BarCode, type is int **static** False **C++ defination code**: ```cpp int w() ``` #### h item doc **type** func **brief** get h of BarCode **return** return h of the BarCode, type is int **static** False **C++ defination code**: ```cpp int h() ``` #### payload item doc **type** func **brief** get payload of BarCode **return** return payload of the BarCode, type is std::string **static** False **C++ defination code**: ```cpp std::string payload() ``` #### type item doc **type** func **brief** get type of BarCode **return** return type of the BarCode, type is int **static** False **C++ defination code**: ```cpp int type() ``` #### rotation item doc **type** func **brief** get rotation of BarCode **return** return rotation of the BarCode, type is float. FIXME: always return 0.0 **static** False **C++ defination code**: ```cpp float rotation() ``` #### quality item doc **type** func **brief** get quality of BarCode **return** return quality of the BarCode, type is int **static** False **C++ defination code**: ```cpp int quality() ``` ### Statistics item doc **brief** Statistics class **C++ defination code**: ```cpp class Statistics ``` #### \\_\\_init\\_\\_ item doc **type** func **brief** Statistics constructor **param** **format**: The statistics source image format
**l_statistics**: The statistics of the L channel. format is {mean, median, mode, std_dev, min, max, lq, uq}, type is std::vector
**a_statistics**: The statistics of the A channel. format is {mean, median, mode, std_dev, min, max, lq, uq}, type is std::vector
**b_statistics**: The statistics of the B channel. format is {mean, median, mode, std_dev, min, max, lq, uq}, type is std::vector
**static** False **C++ defination code**: ```cpp Statistics(image::Format format, std::vector &l_statistics, std::vector &a_statistics, std::vector &b_statistics) ``` #### format item doc **type** func **brief** get format of Statistics source image **return** return format of the Statistics source image, type is image::Format **static** False **C++ defination code**: ```cpp image::Format format() ``` #### l\\_mean item doc **type** func **brief** get L channel mean **return** return L channel mean, type is int **static** False **C++ defination code**: ```cpp int l_mean() ``` #### l\\_median item doc **type** func **brief** get L channel median **return** return L channel median, type is int **static** False **C++ defination code**: ```cpp int l_median() ``` #### l\\_mode item doc **type** func **brief** get L channel mode **return** return L channel mode, type is int **static** False **C++ defination code**: ```cpp int l_mode() ``` #### l\\_std\\_dev item doc **type** func **brief** get L channel std_dev **return** return L channel std_dev, type is int **static** False **C++ defination code**: ```cpp int l_std_dev() ``` #### l\\_min item doc **type** func **brief** get L channel min **return** return L channel min, type is int **static** False **C++ defination code**: ```cpp int l_min() ``` #### l\\_max item doc **type** func **brief** get L channel max **return** return L channel max, type is int **static** False **C++ defination code**: ```cpp int l_max() ``` #### l\\_lq item doc **type** func **brief** get L channel lq **return** return L channel lq, type is int **static** False **C++ defination code**: ```cpp int l_lq() ``` #### l\\_uq item doc **type** func **brief** get L channel uq **return** return L channel uq, type is int **static** False **C++ defination code**: ```cpp int l_uq() ``` #### a\\_mean item doc **type** func **brief** get A channel mean **return** return A channel mean, type is int **static** False **C++ defination code**: ```cpp int a_mean() ``` #### a\\_median item doc **type** func **brief** get A channea median **return** return A channel median, type is int **static** False **C++ defination code**: ```cpp int a_median() ``` #### a\\_mode item doc **type** func **brief** get A channel mode **return** return A channel mode, type is int **static** False **C++ defination code**: ```cpp int a_mode() ``` #### a\\_std\\_dev item doc **type** func **brief** get A channel std_dev **return** return A channel std_dev, type is int **static** False **C++ defination code**: ```cpp int a_std_dev() ``` #### a\\_min item doc **type** func **brief** get A channel min **return** return A channel min, type is int **static** False **C++ defination code**: ```cpp int a_min() ``` #### a\\_max item doc **type** func **brief** get A channel max **return** return A channel max, type is int **static** False **C++ defination code**: ```cpp int a_max() ``` #### a\\_lq item doc **type** func **brief** get A channel lq **return** return A channel lq, type is int **static** False **C++ defination code**: ```cpp int a_lq() ``` #### a\\_uq item doc **type** func **brief** get A channel uq **return** return A channel uq, type is int **static** False **C++ defination code**: ```cpp int a_uq() ``` #### b\\_mean item doc **type** func **brief** get B channel mean **return** return B channel mean, type is int **static** False **C++ defination code**: ```cpp int b_mean() ``` #### b\\_median item doc **type** func **brief** get B channea median **return** return B channel median, type is int **static** False **C++ defination code**: ```cpp int b_median() ``` #### b\\_mode item doc **type** func **brief** get B channel mode **return** return B channel mode, type is int **static** False **C++ defination code**: ```cpp int b_mode() ``` #### b\\_std\\_dev item doc **type** func **brief** get B channel std_dev **return** return B channel std_dev, type is int **static** False **C++ defination code**: ```cpp int b_std_dev() ``` #### b\\_min item doc **type** func **brief** get B channel min **return** return B channel min, type is int **static** False **C++ defination code**: ```cpp int b_min() ``` #### b\\_max item doc **type** func **brief** get B channel max **return** return B channel max, type is int **static** False **C++ defination code**: ```cpp int b_max() ``` #### b\\_lq item doc **type** func **brief** get B channel lq **return** return B channel lq, type is int **static** False **C++ defination code**: ```cpp int b_lq() ``` #### b\\_uq item doc **type** func **brief** get B channel uq **return** return B channel uq, type is int **static** False **C++ defination code**: ```cpp int b_uq() ``` ### Displacement item doc **brief** Displacement class **C++ defination code**: ```cpp class Displacement ``` #### \\_\\_init\\_\\_ item doc **type** func **brief** Displacement constructor **param** **x_translation**: The x_translation of the Displacement
**y_translation**: The y_translation of the Displacement
**rotation**: The rotation of the Displacement
**scale**: The scale of the Displacement
**response**: The response of the Displacement
**static** False **C++ defination code**: ```cpp Displacement(float x_translation, float y_translation, float rotation, float scale, float response) ``` #### x\\_translation item doc **type** func **brief** get x_translation of Displacement **return** return x_translation of the Displacement, type is float **static** False **C++ defination code**: ```cpp float x_translation() ``` #### y\\_translation item doc **type** func **brief** get y_translation of Displacement **return** return y_translation of the Displacement, type is float **static** False **C++ defination code**: ```cpp float y_translation() ``` #### rotation item doc **type** func **brief** get rotation of Displacement **return** return rotation of the Displacement, type is float **static** False **C++ defination code**: ```cpp float rotation() ``` #### scale item doc **type** func **brief** get scale of Displacement **return** return scale of the Displacement, type is float **static** False **C++ defination code**: ```cpp float scale() ``` #### response item doc **type** func **brief** get response of Displacement **return** return response of the Displacement, type is float **static** False **C++ defination code**: ```cpp float response() ``` ### LBPKeyPoint item doc **brief** LBPKeyPoint class **C++ defination code**: ```cpp class LBPKeyPoint ``` #### \\_\\_init\\_\\_ item doc **type** func **brief** LBPKeyPoint constructor **param** **data**: The data of the LBPKeyPoint
**static** False **C++ defination code**: ```cpp LBPKeyPoint(std::valarray &data) ``` ### KeyPoint item doc **brief** KeyPoint class **C++ defination code**: ```cpp class KeyPoint ``` #### \\_\\_init\\_\\_ item doc **type** func **brief** KeyPoint constructor **param** **x**: The x of the KeyPoint
**y**: The y of the KeyPoint
**score**: The score of the KeyPoint
**octave**: The octave of the KeyPoint
**angle**: The angle of the KeyPoint
**matched**: The matched of the KeyPoint
**desc**: The desc of the KeyPoint
**static** False **C++ defination code**: ```cpp KeyPoint(uint16_t x, uint16_t y, uint16_t score, uint16_t octave, uint16_t angle, uint16_t matched, std::vector &desc) ``` ### KPTMatch item doc **brief** KPTMatch class **C++ defination code**: ```cpp class KPTMatch ``` #### \\_\\_init\\_\\_ item doc **type** func **brief** KPTMatch constructor **param** **cx**: The cx of the KPTMatch
**cy**: The cy of the KPTMatch
**x**: The x of the KPTMatch
**y**: The y of the KPTMatch
**w**: The w of the KPTMatch
**h**: The h of the KPTMatch
**score**: The score of the KPTMatch
**theta**: The theta of the KPTMatch
**match**: The match of the KPTMatch
**static** False **C++ defination code**: ```cpp KPTMatch(int cx, int cy, int x, int y, int w, int h, int score, int theta, int match) ``` ### ORBKeyPoint item doc **brief** ORBKeyPoint class **C++ defination code**: ```cpp class ORBKeyPoint ``` #### \\_\\_init\\_\\_ item doc **type** func **brief** ORBKeyPoint constructor **param** **data**: The data of the ORBKeyPoint
**threshold**: The threshold of the ORBKeyPoint
**normalized**: The normalized of the ORBKeyPoint
**static** False **C++ defination code**: ```cpp ORBKeyPoint(std::vector &data, int threshold, bool normalized) ``` #### get\\_data item doc **type** func **brief** get data of ORBKeyPoint **return** return data of the ORBKeyPoint, type is std::vector **static** False **C++ defination code**: ```cpp std::vector get_data() ``` ### HaarCascade item doc **brief** HaarCascade class **C++ defination code**: ```cpp class HaarCascade ``` #### \\_\\_init\\_\\_ item doc **type** func **brief** HaarCascade constructor **param** **data**: The data of the HaarCascade
**threshold**: The threshold of the HaarCascade
**normalized**: The normalized of the HaarCascade
**static** False **C++ defination code**: ```cpp HaarCascade() ``` ### Color item doc **brief** Color class **C++ defination code**: ```cpp class Color ``` #### \\_\\_init\\_\\_ item doc **type** func **brief** Color constructor **param** **alpha**: alpha channel, value range: 0 ~ 1
**static** False **C++ defination code**: ```cpp Color(uint8_t ch1, uint8_t ch2 0, uint8_t ch3 0, float alpha 0, image::Format format image::FMT_GRAYSCALE) ``` #### r item doc **type** var **brief** Color red channel **static** False **readonly** False **C++ defination code**: ```cpp uint8_t r ``` #### g item doc **type** var **brief** Color green channel **static** False **readonly** False **C++ defination code**: ```cpp uint8_t g ``` #### b item doc **type** var **brief** Color blue channel **static** False **readonly** False **C++ defination code**: ```cpp uint8_t b ``` #### alpha item doc **type** var **brief** Color alpha channel, value from 0.0 to 1.0, float value **static** False **readonly** False **C++ defination code**: ```cpp float alpha ``` #### gray item doc **type** var **brief** Color gray channel **static** False **readonly** False **C++ defination code**: ```cpp uint8_t gray ``` #### format item doc **type** var **brief** Color format **static** False **readonly** False **C++ defination code**: ```cpp image::Format format ``` #### hex item doc **type** func **brief** Get color's hex value **static** False **C++ defination code**: ```cpp uint32_t hex() ``` #### from\\_rgb item doc **type** func **brief** Create Color object from RGB channels **static** True **C++ defination code**: ```cpp static image::Color from_rgb(uint8_t r, uint8_t g, uint8_t b) ``` #### from\\_bgr item doc **type** func **brief** Create Color object from BGR channels **static** True **C++ defination code**: ```cpp static image::Color from_bgr(uint8_t b, uint8_t g, uint8_t r) ``` #### from\\_gray item doc **type** func **brief** Create Color object from gray channel **static** True **C++ defination code**: ```cpp static image::Color from_gray(uint8_t gray) ``` #### from\\_rgba item doc **type** func **brief** Create Color object from RGBA channels **param** **alpha**: alpha channel, float value, value range: 0 ~ 1
**static** True **C++ defination code**: ```cpp static image::Color from_rgba(uint8_t r, uint8_t g, uint8_t b, float alpha) ``` #### from\\_bgra item doc **type** func **brief** Create Color object from BGRA channels **param** **alpha**: alpha channel, float value, value range: 0 ~ 1
**static** True **C++ defination code**: ```cpp static image::Color from_bgra(uint8_t b, uint8_t g, uint8_t r, float alpha) ``` #### from\\_hex item doc **type** func **brief** Create Color object from hex value **param** **hex**: hex value, e.g. 0x0000FF00, lower address if first channel
**format**: color format, @see image::Format
**static** True **C++ defination code**: ```cpp static image::Color from_hex(uint32_t hex, image::Format &format) ``` #### to\\_format item doc **type** func **brief** Convert Color format **param** **format**: format want to convert to, @see image::Format, only support RGB888, BGR888, RGBA8888, BGRA8888, GRAYSCALE.
**static** False **C++ defination code**: ```cpp void to_format(const image::Format &format) ``` #### to\\_format2 item doc **type** func **brief** Convert color format and return a new Color object **param** **format**: format want to convert to, @see image::Format, only support RGB888, BGR888, RGBA8888, BGRA8888, GRAYSCALE.
**return** new Color object, you need to delete it manually in C++. **static** False **C++ defination code**: ```cpp image::Color *to_format2(const image::Format &format) ``` ### Image item doc **brief** Image class **C++ defination code**: ```cpp class Image ``` #### \\_\\_init\\_\\_ item doc **type** func **brief** Image constructor **param** **width**: image width, should > 0
**height**: image height, should > 0
**format**: image format @see image::Format
**data**: image data, if data is nullptr, will malloc memory for image data
If the image is in jpeg format, data must be filled in.
**data_size**: image data size, only for compressed format like jpeg png, data_size must be filled in.
**copy**: if true and data is not nullptr, will copy data to new buffer, else will use data directly. default is true to avoid memory leak.
**static** False **C++ defination code**: ```cpp Image(int width, int height, image::Format format image::Format::FMT_RGB888, void *data nullptr, int data_size 1, bool copy true) ``` #### format item doc **type** func **brief** Get image's format **see** image.Format **static** False **C++ defination code**: ```cpp image::Format format() ``` #### size item doc **type** func **brief** Get image's size, [width, height] **static** False **C++ defination code**: ```cpp image::Size size() ``` #### data\\_size item doc **type** func **brief** Get image's data size **static** False **C++ defination code**: ```cpp int data_size() ``` #### width item doc **type** func **brief** Get image's width **static** False **C++ defination code**: ```cpp int width() ``` #### height item doc **type** func **brief** Get image's height **static** False **C++ defination code**: ```cpp int height() ``` #### data item doc **type** func **brief** Get image's data pointer.\\nIn MaixPy is capsule object. **static** False **C++ defination code**: ```cpp void *data() ``` #### \\_\\_str\\_\\_ item doc **type** func **brief** To string method **static** False **C++ defination code**: ```cpp std::string __str__() ``` #### to\\_str item doc **type** func **brief** To string method **static** False **C++ defination code**: ```cpp std::string to_str() ``` #### get\\_pixel item doc **type** func **brief** Get pixel of image **param** **x**: pixel's coordinate x. x must less than image's width
**y**: pixel's coordinate y. y must less than image's height
**rgbtuple**: switch return value method. rgbtuple decides whether to split the return or not. default is false.
**return** pixel value,
According to image format and rgbtuple, return different value:
format is FMT_RGB888, rgbtuple is true, return [R, G, B]; rgbtuple is false, return [RGB]
foramt is FMT_BGR888, rgbtuple is true, return [B, G, R]; rgbtuple is false, return [BGR]
format is FMT_GRAYSCALE, return [GRAY]; **static** False **C++ defination code**: ```cpp std::vector get_pixel(int x, int y, bool rgbtuple false) ``` #### set\\_pixel item doc **type** func **brief** Set pixel of image **param** **x**: pixel's coordinate x. x must less than image's width
**y**: pixel's coordinate y. y must less than image's height
**pixel**: pixel value, according to image format and size of pixel, has different operation:
format is FMT_RGB888, pixel size must be 1 or 3, if size is 1, will split pixel[0] to [R, G, B]; if size is 3, will use pixel directly
format is FMT_BGR888, pixel size must be 1 or 3, if size is 1, will split pixel[0] to [B, G, R]; if size is 3, will use pixel directly
format is FMT_GRAYSCALE, pixel size must be 1, will use pixel directly
**return** error code, Err::ERR_NONE is ok, other is error **static** False **C++ defination code**: ```cpp err::Err set_pixel(int x, int y, std::vector pixel) ``` #### to\\_tensor item doc **type** func **brief** Convert Image object to tensor::Tensor object **param** **chw**: if true, the shape of tensor is [C, H, W], else [H, W, C]
**copy**: if true, will alloc memory for tensor data, else will use the memory of Image object
**return** tensor::Tensor object pointer, an allocated tensor object **static** False **C++ defination code**: ```cpp tensor::Tensor *to_tensor(bool chw false, bool copy true) ``` #### to\\_bytes item doc **type** func **brief** Get image's data and convert to array bytes **param** **copy**: if true, will alloc memory and copy data to new buffer,
else will use the memory of Image object, delete bytes object will not affect Image object,
but delete Image object will make bytes object invalid, it may cause program crash !!!!
So use this param carefully.
**return** image's data bytes, need be delete by caller in C++. **static** False **C++ defination code**: ```cpp Bytes *to_bytes(bool copy true) ``` #### to\\_format item doc **type** func **brief** Convert image to specific format **param** **format**: format want to convert to, @see image::Format, only support RGB888, BGR888, RGBA8888, BGRA8888, GRAYSCALE, JPEG.
**return** new image object. Need be delete by caller in C++. **throw** err.Exception, if two images' format not support, **or already the format**, will raise exception **static** False **C++ defination code**: ```cpp image::Image *to_format(const image::Format &format) ``` #### draw\\_image item doc **type** func **brief** Draw image on this image **param** **x**: left top corner of image point's coordinate x
**y**: left top corner of image point's coordinate y
**img**: image object to draw, the caller's channel must < the args' channel,
e.g. caller is RGB888, args is RGBA8888, will throw exception, but caller is RGBA8888, args is RGB888 or RGBA8888 is ok
**return** this image object self **static** False **C++ defination code**: ```cpp image::Image *draw_image(int x, int y, image::Image &img) ``` #### draw\\_rect item doc **type** func **brief** Fill rectangle color to image **param** **x**: left top corner of rectangle point's coordinate x
**y**: left top corner of rectangle point's coordinate y
**w**: rectangle width
**h**: rectangle height
**color**: rectangle color
**thickness**: rectangle thickness(line width), by default(value is 1), 1 means fill rectangle
**return** this image object self **static** False **C++ defination code**: ```cpp image::Image *draw_rect(int x, int y, int w, int h, const image::Color &color, int thickness 1) ``` #### draw\\_line item doc **type** func **brief** Draw line on image **param** **x1**: start point's coordinate x
**y1**: start point's coordinate y
**x2**: end point's coordinate x
**y2**: end point's coordinate y
**color**: line color @see image::Color
**thickness**: line thickness(line width), by default(value is 1)
**return** this image object self **static** False **C++ defination code**: ```cpp image::Image *draw_line(int x1, int y1, int x2, int y2, const image::Color &color, int thickness 1) ``` #### draw\\_circle item doc **type** func **brief** Draw circle on image **param** **x**: circle center point's coordinate x
**y**: circle center point's coordinate y
**radius**: circle radius
**color**: circle color @see image::Color
**thickness**: circle thickness(line width), by default(value is 1), 1 means fill circle
**return** this image object self **static** False **C++ defination code**: ```cpp image::Image *draw_circle(int x, int y, int radius, const image::Color &color, int thickness 1) ``` #### draw\\_ellipse item doc **type** func **brief** Draw ellipse on image **param** **x**: ellipse center point's coordinate x
**y**: ellipse center point's coordinate y
**a**: ellipse major axis length
**b**: ellipse minor axis length
**angle**: ellipse rotation angle
**start_angle**: ellipse start angle
**end_angle**: ellipse end angle
**color**: ellipse color @see image::Color
**thickness**: ellipse thickness(line width), by default(value is 1), 1 means fill ellipse
**return** this image object self **static** False **C++ defination code**: ```cpp image::Image *draw_ellipse(int x, int y, int a, int b, float angle, float start_angle, float end_angle, const image::Color &color, int thickness 1) ``` #### draw\\_text item doc **type** func **brief** Draw text on image **param** **x**: text left top point's coordinate x
**y**: text left top point's coordinate y
**text**: text content
**color**: text color @see image::Color, default is white
**scale**: font scale, by default(value is 1)
**thickness**: text thickness(line width), if negative, the glyph is filled, by default(value is 1)
**wrap**: if true, will auto wrap text to next line if text width > image width, by default(value is true)
**return** this image object self **static** False **C++ defination code**: ```cpp image::Image *draw_text(int x, int y, const std::string &text, const image::Color &color image::COLOR_WHITE, float scale 1, int thickness 1, bool wrap true, int wrap_space 4, const std::string &font \"\") ``` #### draw\\_arrow item doc **type** func **brief** Draw arrow on image **param** **x0**: start coordinate of the arrow x0
**y0**: start coordinate of the arrow y0
**x1**: end coordinate of the arrow x1
**y1**: end coordinate of the arrow y1
**color**: cross color @see image::Color
**thickness**: cross thickness(line width), by default(value is 1)
**return** this image object self **static** False **C++ defination code**: ```cpp image::Image *draw_arrow(int x0, int y0, int x1, int y1, const image::Color &color, int thickness 1) ``` #### draw\\_edges item doc **type** func **brief** Draw edges on image **param** **corners**: edges, [[x0, y0], [x1, y1], [x2, y2], [x3, y3]]
**color**: edges color @see image::Color
**size**: the circle of radius size. TODO: support in the feature
**thickness**: edges thickness(line width), by default(value is 1)
**fill**: if true, will fill edges, by default(value is false)
**return** this image object self **static** False **C++ defination code**: ```cpp image::Image *draw_edges(std::vector> corners, const image::Color &color, int size 0, int thickness 1, bool fill false) ``` #### draw\\_keypoints item doc **type** func **brief** Draw keypoints on image **param** **keypoints**: keypoints, [x, y, rotation_andle_in_degrees], TODO: rotation_andle_in_degrees support in the feature
**color**: keypoints color @see image::Color
**size**: size of keypoints
**thickness**: keypoints thickness(line width), by default(value is 1)
**fill**: if true, will fill keypoints, by default(value is false)
**return** this image object self **static** False **C++ defination code**: ```cpp image::Image *draw_keypoints(std::vector keypoints, const image::Color &color, int size 10, int thickness 1, bool fill false) ``` #### resize item doc **type** func **brief** Resize image, will create a new resized image object **param** **width**: new width, if value is 1, will use height to calculate aspect ratio
**height**: new height, if value is 1, will use width to calculate aspect ratio
**object_fit**: fill, contain, cover, by default is fill
**method**: resize method, by default is bilinear
**return** Always return a new resized image object even size not change, So in C++ you should take care of the return value to avoid memory leak.
And it's better to judge whether the size has changed before calling this function to make the program more efficient.
e.g.
if img >width() ! width img >height() ! height:
img img >resize(width, height); **static** False **C++ defination code**: ```cpp image::Image *resize(int width, int height, image::Fit object_fit image::Fit::FIT_FILL, image::ResizeMethod method image::ResizeMethod::NEAREST) ``` #### affine item doc **type** func **brief** Affine transform image, will create a new transformed image object **param** **src_points**: three source points, [x1, y1, x2, y2, x3, y3]
**dst_points**: three destination points, [x1, y1, x2, y2, x3, y3]
**width**: new width, if value is 1, will use height to calculate aspect ratio
**height**: new height, if value is 1, will use width to calculate aspect ratio
**method**: resize method, by default is bilinear
**return** new transformed image object **static** False **C++ defination code**: ```cpp image::Image *affine(std::vector src_points, std::vector dst_points, int width 1, int height 1, image::ResizeMethod method image::ResizeMethod::BILINEAR) ``` #### copy item doc **type** func **brief** Copy image, will create a new copied image object **return** new copied image object **static** False **C++ defination code**: ```cpp image::Image *copy() ``` #### crop item doc **type** func **brief** Crop image, will create a new cropped image object **param** **x**: left top corner of crop rectangle point's coordinate x
**y**: left top corner of crop rectangle point's coordinate y
**w**: crop rectangle width
**h**: crop rectangle height
**return** new cropped image object **static** False **C++ defination code**: ```cpp image::Image *crop(int x, int y, int w, int h) ``` #### rotate item doc **type** func **brief** Rotate image, will create a new rotated image object **param** **angle**: anti clock wise rotate angle, if angle is 90 or 270, and width or height is 1, will swap width and height, or will throw exception
**width**: new width, if value is 1, will use height to calculate aspect ratio
**height**: new height, if value is 1, will use width to calculate aspect ratio
**method**: resize method, by default is bilinear
**return** new rotated image object **static** False **C++ defination code**: ```cpp image::Image *rotate(float angle, int width 1, int height 1, image::ResizeMethod method image::ResizeMethod::BILINEAR) ``` #### mean\\_pool item doc **type** func **brief** Finds the mean of x_div * y_div squares in the image and returns the modified image composed of the mean of each square. **param** **x_div**: The width of the squares.
**y_div**: The height of the squares.
**copy**: Select whether to return a new image or modify the original image. default is false.
If true, returns a new image composed of the mean of each square; If false, returns the modified image composed of the mean of each square.
**return** Returns the image after the operation is completed. **static** False **C++ defination code**: ```cpp image::Image *mean_pool(int x_div, int y_div, bool copy false) ``` #### midpoint\\_pool item doc **type** func **brief** Finds the midpoint of x_div * y_div squares in the image and returns the modified image composed of the mean of each square. **param** **x_div**: The width of the squares.
**y_div**: The height of the squares.
**bias**: The bias of the midpoint. default is 0.5.
midpoint value is equal to (max * bias + min * (1 bias))
**copy**: Select whether to return a new image or modify the original image. default is false.
If true, returns a new image composed of the midpoint of each square; If false, returns the modified image composed of the midpoint of each square.
**return** Returns the image after the operation is completed. **static** False **C++ defination code**: ```cpp image::Image *midpoint_pool(int x_div, int y_div, double bias 0.5, bool copy false) ``` #### compress item doc **type** func **brief** JPEG compresses the image in place. **param** **quality**: The quality of the compressed image. default is 95.
**return** Returns the compressed JPEG image **static** False **C++ defination code**: ```cpp image::Image *compress(int quality 95) ``` #### clear item doc **type** func **brief** Sets all pixels in the image to zero **param** **mask**: Mask is another image to use as a pixel level mask for the operation. The mask should be an image with just black or white pixels and should be the same size as the image being operated on.
Only pixels set in the mask are modified. default is None.
**return** Returns the image after the operation is completed. **static** False **C++ defination code**: ```cpp image::Image *clear(image::Image *mask nullptr) ``` #### mask\\_rectange item doc **type** func **brief** Zeros a rectangular part of the image. If no arguments are supplied this method zeros the center of the image. **param** **x**: The x coordinate of the top left corner of the rectangle.
**y**: The y coordinate of the top left corner of the rectangle.
**w**: The width of the rectangle.
**h**: The height of the rectangle.
**return** Returns the image after the operation is completed. **static** False **C++ defination code**: ```cpp image::Image *mask_rectange(int x 1, int y 1, int w 1, int h 1) ``` #### mask\\_circle item doc **type** func **brief** Zeros a circular part of the image. If no arguments are supplied this method zeros the center of the image. **param** **x**: The x coordinate of the center of the circle.
**y**: The y coordinate of the center of the circle.
**radius**: The radius of the circle.
**return** Returns the image after the operation is completed. **static** False **C++ defination code**: ```cpp image::Image *mask_circle(int x 1, int y 1, int radius 1) ``` #### mask\\_ellipse item doc **type** func **brief** Zeros a ellipse part of the image. If no arguments are supplied this method zeros the center of the image. **param** **x**: The x coordinate of the center of the ellipse.
**y**: The y coordinate of the center of the ellipse.
**radius_x**: The radius of the ellipse in the x direction.
**radius_y**: The radius of the ellipse in the y direction.
**rotation_angle_in_degrees**: The rotation angle of the ellipse in degrees.
**return** Returns the image after the operation is completed. **static** False **C++ defination code**: ```cpp image::Image *mask_ellipse(int x 1, int y 1, int radius_x 1, int radius_y 1, float rotation_angle_in_degrees 0) ``` #### binary item doc **type** func **brief** Sets all pixels in the image to black or white depending on if the pixel is inside of a threshold in the threshold list thresholds or not. **param** **thresholds**: You can define multiple thresholds.
For GRAYSCALE format, you can use {{Lmin, Lmax}, ...} to define one or more thresholds.
For RGB888 format, you can use {{Lmin, Lmax, Amin, Amax, Bmin, Bmax}, ...} to define one or more thresholds.
Where the upper case L,A,B represent the L,A,B channels of the LAB image format, and min, max represent the minimum and maximum values of the corresponding channels.
**invert**: If true, the thresholds will be inverted before the operation. default is false.
**zero**: If zero is true, the image will be set the pixels within the threshold to 0, other pixels remain unchanged. If zero is false, the image will be set to black or white. default is false.
**mask**: Mask is another image to use as a pixel level mask for the operation. The mask should be an image with just black or white pixels and should be the same size as the image being operated on.
Only pixels set in the mask are modified. default is None.
**to_bitmap**: If true, the image will be converted to a bitmap image before thresholding. default is false. TODO: support in the feature
**copy**: Select whether to return a new image or modify the original image. default is false.
**return** Returns the image after the operation is completed. **static** False **C++ defination code**: ```cpp image::Image *binary(std::vector> thresholds std::vector>(), bool invert false, bool zero false, image::Image *mask nullptr, bool to_bitmap false, bool copy false) ``` #### invert item doc **type** func **brief** Inverts the image in place. **return** Returns the image after the operation is completed **static** False **C++ defination code**: ```cpp image::Image *invert() ``` #### b\\_and item doc **type** func **brief** Performs a bitwise and operation between the image and the other image. **param** **other**: The other image should be an image and should be the same size as the image being operated on. TODO: support path?
**mask**: Mask is another image to use as a pixel level mask for the operation. The mask should be an image with just black or white pixels and should be the same size as the image being operated on.
Only pixels set in the mask are modified. default is None.
**return** Returns the image after the operation is completed. **static** False **C++ defination code**: ```cpp image::Image *b_and(image::Image *other, image::Image *mask nullptr) ``` #### b\\_nand item doc **type** func **brief** Performs a bitwise nand operation between the image and the other image. **param** **other**: The other image should be an image and should be the same size as the image being operated on. TODO: support path?
**mask**: Mask is another image to use as a pixel level mask for the operation. The mask should be an image with just black or white pixels and should be the same size as the image being operated on.
Only pixels set in the mask are modified. default is None.
**return** Returns the image after the operation is completed. **static** False **C++ defination code**: ```cpp image::Image *b_nand(image::Image *other, image::Image *mask nullptr) ``` #### b\\_or item doc **type** func **brief** Performs a bitwise or operation between the image and the other image. **param** **other**: The other image should be an image and should be the same size as the image being operated on. TODO: support path?
**mask**: Mask is another image to use as a pixel level mask for the operation. The mask should be an image with just black or white pixels and should be the same size as the image being operated on.
Only pixels set in the mask are modified. default is None.
**return** Returns the image after the operation is completed. **static** False **C++ defination code**: ```cpp image::Image *b_or(image::Image *other, image::Image *mask nullptr) ``` #### b\\_nor item doc **type** func **brief** Performs a bitwise nor operation between the image and the other image. **param** **other**: The other image should be an image and should be the same size as the image being operated on. TODO: support path?
**mask**: Mask is another image to use as a pixel level mask for the operation. The mask should be an image with just black or white pixels and should be the same size as the image being operated on.
Only pixels set in the mask are modified. default is None.
**return** Returns the image after the operation is completed. **static** False **C++ defination code**: ```cpp image::Image *b_nor(image::Image *other, image::Image *mask nullptr) ``` #### b\\_xor item doc **type** func **brief** Performs a bitwise xor operation between the image and the other image. **param** **other**: The other image should be an image and should be the same size as the image being operated on. TODO: support path?
**mask**: Mask is another image to use as a pixel level mask for the operation. The mask should be an image with just black or white pixels and should be the same size as the image being operated on.
Only pixels set in the mask are modified. default is None.
**return** Returns the image after the operation is completed. **static** False **C++ defination code**: ```cpp image::Image *b_xor(image::Image *other, image::Image *mask nullptr) ``` #### b\\_xnor item doc **type** func **brief** Performs a bitwise xnor operation between the image and the other image. **param** **other**: The other image should be an image and should be the same size as the image being operated on. TODO: support path?
**mask**: Mask is another image to use as a pixel level mask for the operation. The mask should be an image with just black or white pixels and should be the same size as the image being operated on.
Only pixels set in the mask are modified. default is None.
**return** Returns the image after the operation is completed. **static** False **C++ defination code**: ```cpp image::Image *b_xnor(image::Image *other, image::Image *mask nullptr) ``` #### awb item doc **type** func **brief** Performs an auto white balance operation on the image. TODO: support in the feature **param** **max**: if True uses the white patch algorithm instead. default is false.
**return** Returns the image after the operation is completed. **static** False **C++ defination code**: ```cpp image::Image *awb(bool max false) ``` #### ccm item doc **type** func **brief** Multiples the passed (3x3) or (4x3) floating point color correction matrix with the image.\\nnote: Grayscale format is not support. **param** **matrix**: The color correction matrix to use. 3x3 or 4x3 matrix.
Weights may either be positive or negative, and the sum of each column in the 3x3 matrix should generally be 1.
example:
{
1, 0, 0,
0, 1, 0,
0, 0, 1,
}
Where the last row of the 4x3 matrix is an offset per color channel. If you add an offset you may wish to make the
weights sum to less than 1 to account for the offset.
example:
{
1, 0, 0,
0, 1, 0,
0, 0, 1,
0, 0, 0,
}
**return** Returns the image after the operation is completed. **static** False **C++ defination code**: ```cpp image::Image *ccm(std::vector &matrix) ``` #### gamma item doc **type** func **brief** Quickly changes the image gamma, contrast, and brightness. Create a array whose size is usually 255,\\nand use the parameters gamma, contrast, and brightness to calculate the value of the array, and then map the\\nimage pixel value through the value of the array.\\nThe calculation method for array is: array[array_idx] (powf((array_idx / 255.0), (1 / gamma)) * contrast + brightness) * scale,\\n`powf` is a function used to calculate floating point power.\\n`array` is the array used for mapping.\\n`array_idx` is the index of the array, the maximum value is determined according to the image format, usually 255.\\n`scale` is a constant, the value is determined by the image format, usually 255.\\nMapping method:\\nAssume that a pixel value in the image is 128, then map the pixel value to the value of array[128]\\nUsers can adjust the value of the array through the gamma, contrast, and brightness parameters. **param** **gamma**: The contrast gamma greater than 1.0 makes the image darker in a non linear manner while less than 1.0 makes the image brighter. default is 1.0.
**contrast**: The contrast value greater than 1.0 makes the image brighter in a linear manner while less than 1.0 makes the image darker. default is 1.0.
**brightness**: The brightness value greater than 0.0 makes the image brighter in a constant manner while less than 0.0 makes the image darker. default is 0.0.
**return** Returns the image after the operation is completed. **static** False **C++ defination code**: ```cpp image::Image *gamma(double gamma 1.0, double contrast 1.0, double brightness 0.0) ``` #### gamma\\_corr item doc **type** func **brief** Alias for Image.gamma. **param** **gamma**: The contrast gamma greater than 1.0 makes the image darker in a non linear manner while less than 1.0 makes the image brighter. default is 1.0.
**contrast**: The contrast value greater than 1.0 makes the image brighter in a linear manner while less than 1.0 makes the image darker. default is 1.0.
**brightness**: The brightness value greater than 0.0 makes the image brighter in a constant manner while less than 0.0 makes the image darker. default is 0.0.
**return** Returns the image after the operation is completed. **static** False **C++ defination code**: ```cpp image::Image *gamma_corr(double gamma, double contrast 1.0, double brightness 0.0) ``` #### negate item doc **type** func **brief** Flips (numerically inverts) all pixels values in an image **return** Returns the image after the operation is completed. **static** False **C++ defination code**: ```cpp image::Image *negate() ``` #### replace item doc **type** func **brief** Replaces all pixels in the image with the corresponding pixels in the other image. **param** **other**: The other image should be an image and should be the same size as the image being operated on.
**hmirror**: If true, the image will be horizontally mirrored before the operation. default is false.
**vflip**: If true, the image will be vertically flipped before the operation. default is false.
**transpose**: If true, the image can be used to rotate 90 degrees or 270 degrees.
hmirror false, vflip false, transpose false, the image will not be rotated.
hmirror false, vflip true, transpose true, the image will be rotated 90 degrees.
hmirror true, vflip true, transpose false, the image will be rotated 180 degrees.
hmirror true, vflip false, transpose true, the image will be rotated 270 degrees.
**mask**: Mask is another image to use as a pixel level mask for the operation. The mask should be an image with just black or white pixels and should be the same size as the image being operated on.
Only pixels set in the mask are modified. default is None.
**return** Returns the image after the operation is completed. **static** False **C++ defination code**: ```cpp image::Image *replace(image::Image *other nullptr, bool hmirror false, bool vflip false, bool transpose false, image::Image *mask nullptr) ``` #### set item doc **type** func **brief** Alias for Image::replace. **param** **other**: The other image should be an image and should be the same size as the image being operated on.
**hmirror**: If true, the image will be horizontally mirrored before the operation. default is false.
**vflip**: If true, the image will be vertically flipped before the operation. default is false.
**mask**: Mask is another image to use as a pixel level mask for the operation. The mask should be an image with just black or white pixels and should be the same size as the image being operated on.
Only pixels set in the mask are modified. default is None.
**return** Returns the image after the operation is completed. **static** False **C++ defination code**: ```cpp image::Image *set(image::Image *other, bool hmirror false, bool vflip false, bool transpose false, image::Image *mask nullptr) ``` #### add item doc **type** func **brief** Adds the other image to the image. **param** **other**: The other image should be an image and should be the same size as the image being operated on. TODO: support path?
**mask**: Mask is another image to use as a pixel level mask for the operation. The mask should be an image with just black or white pixels and should be the same size as the image being operated on.
Only pixels set in the mask are modified. default is None.
**return** Returns the image after the operation is completed. **static** False **C++ defination code**: ```cpp image::Image *add(image::Image *other, image::Image *mask nullptr) ``` #### sub item doc **type** func **brief** Subtracts the other image from the image. **param** **other**: The other image should be an image and should be the same size as the image being operated on. TODO: support path?
**reverse**: If true, the image will be reversed before the operation. default is false.
**mask**: Mask is another image to use as a pixel level mask for the operation. The mask should be an image with just black or white pixels and should be the same size as the image being operated on.
Only pixels set in the mask are modified. default is None.
**return** Returns the image after the operation is completed. **static** False **C++ defination code**: ```cpp image::Image *sub(image::Image *other, bool reverse false, image::Image *mask nullptr) ``` #### mul item doc **type** func **brief** Multiplies the image by the other image.\\nNote: This method is meant for image blending and cannot multiply the pixels in the image by a scalar like 2. **param** **other**: The other image should be an image and should be the same size as the image being operated on. TODO: support path?
**invert**: If true, the image will be change the multiplication operation from a*b to 1/((1/a)*(1/b)).
In particular, this lightens the image instead of darkening it (e.g. multiply versus burn operations). default is false.
**mask**: Mask is another image to use as a pixel level mask for the operation. The mask should be an image with just black or white pixels and should be the same size as the image being operated on.
Only pixels set in the mask are modified. default is None.
**return** Returns the image after the operation is completed. **static** False **C++ defination code**: ```cpp image::Image *mul(image::Image *other, bool invert false, image::Image *mask nullptr) ``` #### div item doc **type** func **brief** Divides the image by the other image.\\nThis method is meant for image blending and cannot divide the pixels in the image by a scalar like 2. **param** **other**: The other image should be an image and should be the same size as the image being operated on. TODO: support path?
**invert**: If true, the image will be change the division direction from a/b to b/a. default is false.
**mod**: If true, the image will be change the division operation to the modulus operation. default is false.
**mask**: Mask is another image to use as a pixel level mask for the operation. The mask should be an image with just black or white pixels and should be the same size as the image being operated on.
Only pixels set in the mask are modified. default is None.
**return** Returns the image after the operation is completed. **static** False **C++ defination code**: ```cpp image::Image *div(image::Image *other, bool invert false, bool mod false, image::Image *mask nullptr) ``` #### min item doc **type** func **brief** Caculate the minimum of each pixel in the image and the other image. **param** **other**: The other image should be an image and should be the same size as the image being operated on.
**mask**: Mask is another image to use as a pixel level mask for the operation. The mask should be an image with just black or white pixels and should be the same size as the image being operated on.
Only pixels set in the mask are modified. default is None.
**return** Returns the image after the operation is completed. **static** False **C++ defination code**: ```cpp image::Image *min(image::Image *other, image::Image *mask nullptr) ``` #### max item doc **type** func **brief** Caculate the maximum of each pixel in the image and the other image. **param** **other**: The other image should be an image and should be the same size as the image being operated on.
**mask**: Mask is another image to use as a pixel level mask for the operation. The mask should be an image with just black or white pixels and should be the same size as the image being operated on.
Only pixels set in the mask are modified. default is None.
**return** Returns the image after the operation is completed. **static** False **C++ defination code**: ```cpp image::Image *max(image::Image *other, image::Image *mask nullptr) ``` #### difference item doc **type** func **brief** Caculate the absolute value of the difference between each pixel in the image and the other image. **param** **other**: The other image should be an image and should be the same size as the image being operated on.
**mask**: Mask is another image to use as a pixel level mask for the operation. The mask should be an image with just black or white pixels and should be the same size as the image being operated on.
Only pixels set in the mask are modified. default is None.
**return** Returns the image after the operation is completed. **static** False **C++ defination code**: ```cpp image::Image *difference(image::Image *other, image::Image *mask nullptr) ``` #### blend item doc **type** func **brief** Blends the image with the other image.\\nres alpha * this_img / 256 + (256 alpha) * other_img / 256 **param** **other**: The other image should be an image and should be the same size as the image being operated on.
**alpha**: The alpha value of the blend, the value range is [0, 256],default is 128.
**mask**: Mask is another image to use as a pixel level mask for the operation. The mask should be an image with just black or white pixels and should be the same size as the image being operated on.
Only pixels set in the mask are modified. default is None.
**return** Returns the image after the operation is completed. **static** False **C++ defination code**: ```cpp image::Image *blend(image::Image *other, int alpha 128, image::Image *mask nullptr) ``` #### histeq item doc **type** func **brief** Runs the histogram equalization algorithm on the image. **param** **adaptive**: If true, an adaptive histogram equalization method will be run on the image instead which as generally better results than non adaptive histogram qualization but a longer run time. default is false.
**clip_limit**: Provides a way to limit the contrast of the adaptive histogram qualization. Use a small value for this, like 10, to produce good histogram equalized contrast limited images. default is 1.
**mask**: Mask is another image to use as a pixel level mask for the operation. The mask should be an image with just black or white pixels and should be the same size as the image being operated on.
Only pixels set in the mask are modified. default is None.
**return** Returns the image after the operation is completed. **static** False **C++ defination code**: ```cpp image::Image *histeq(bool adaptive false, int clip_limit 1, image::Image *mask nullptr) ``` #### mean item doc **type** func **brief** Standard mean blurring filter using a box filter.\\nThe parameters offset and invert are valid when threshold is True. **param** **size**: Kernel size. The actual kernel size is ((size * 2) + 1) * ((size * 2) + 1). Use 1(3x3 kernel), 2(5x5 kernel).
**threshold**: If true, which will enable adaptive thresholding of the image which sets pixels to white or black based on a pixel’s brightness in relation to the brightness of the kernel of pixels around them.
default is false.
**offset**: The larger the offset value, the lower brightness pixels on the original image will be set to white. default is 0.
**invert**: If true, the image will be inverted before the operation. default is false.
**mask**: Mask is another image to use as a pixel level mask for the operation. The mask should be an image with just black or white pixels and should be the same size as the image being operated on.
Only pixels set in the mask are modified. default is None.
**return** Returns the image after the operation is completed. **static** False **C++ defination code**: ```cpp image::Image *mean(int size, bool threshold false, int offset 0, bool invert false, image::Image *mask nullptr) ``` #### median item doc **type** func **brief** Runs the median filter on the image. The median filter is the best filter for smoothing surfaces while preserving edges but it is very slow. **param** **size**: Kernel size. The actual kernel size is ((size * 2) + 1) * ((size * 2) + 1). Use 1(3x3 kernel), 2(5x5 kernel).
**percentile**: This parameter controls the percentile of the value used in the kernel. You can set this to 0 for a min filter, 0.25 for a lower quartile filter, 0.75 for an upper quartile filter, and 1.0 for a max filter. default is 0.5.
**threshold**: If true, which will enable adaptive thresholding of the image which sets pixels to white or black based on a pixel’s brightness in relation to the brightness of the kernel of pixels around them.
default is false.
**offset**: The larger the offset value, the lower brightness pixels on the original image will be set to white. default is 0.
**invert**: If true, the image will be inverted before the operation. default is false.
**mask**: Mask is another image to use as a pixel level mask for the operation. The mask should be an image with just black or white pixels and should be the same size as the image being operated on.
Only pixels set in the mask are modified. default is None.
**return** Returns the image after the operation is completed. **static** False **C++ defination code**: ```cpp image::Image *median(int size, double percentile 0.5, bool threshold false, int offset 0, bool invert false, image::Image *mask nullptr) ``` #### mode item doc **type** func **brief** Runs the mode filter on the image by replacing each pixel with the mode of their neighbors. **param** **size**: Kernel size. The actual kernel size is ((size * 2) + 1) * ((size * 2) + 1). Use 1(3x3 kernel), 2(5x5 kernel).
**threshold**: If true, which will enable adaptive thresholding of the image which sets pixels to white or black based on a pixel’s brightness in relation to the brightness of the kernel of pixels around them.
default is false.
**offset**: The larger the offset value, the lower brightness pixels on the original image will be set to white. default is 0.
**invert**: If true, the image will be inverted before the operation. default is false.
**mask**: Mask is another image to use as a pixel level mask for the operation. The mask should be an image with just black or white pixels and should be the same size as the image being operated on.
Only pixels set in the mask are modified. default is None.
**return** Returns the image after the operation is completed. **static** False **C++ defination code**: ```cpp image::Image *mode(int size, bool threshold false, int offset 0, bool invert false, image::Image *mask nullptr) ``` #### midpoint item doc **type** func **brief** Runs the midpoint filter on the image.This filter finds the midpoint (max * bias + min * (1 bias)) of each pixel neighborhood in the image. **param** **size**: Kernel size. The actual kernel size is ((size * 2) + 1) * ((size * 2) + 1). Use 1(3x3 kernel), 2(5x5 kernel).
**bias**: The bias of the midpoint. default is 0.5.
**threshold**: If true, which will enable adaptive thresholding of the image which sets pixels to white or black based on a pixel’s brightness in relation to the brightness of the kernel of pixels around them.
default is false.
**offset**: The larger the offset value, the lower brightness pixels on the original image will be set to white. default is 0.
**invert**: If true, the image will be inverted before the operation. default is false.
**mask**: Mask is another image to use as a pixel level mask for the operation. The mask should be an image with just black or white pixels and should be the same size as the image being operated on.
Only pixels set in the mask are modified. default is None.
**return** Returns the image after the operation is completed. **static** False **C++ defination code**: ```cpp image::Image *midpoint(int size, double bias 0.5, bool threshold false, int offset 0, bool invert false, image::Image *mask nullptr) ``` #### morph item doc **type** func **brief** Convolves the image by a filter kernel. This allows you to do general purpose convolutions on an image. **param** **size**: Kernel size. The actual kernel size is ((size * 2) + 1) * ((size * 2) + 1). Use 1(3x3 kernel), 2(5x5 kernel).
**kernel**: The kernel used for convolution. The kernel should be a list of lists of numbers. The kernel should be the same size as the actual kernel size.
**mul**: This parameter is used to multiply the convolved pixel results. default is auto.
**add**: This parameter is the value to be added to each convolution pixel result. default is 0.0.
**threshold**: If true, which will enable adaptive thresholding of the image which sets pixels to white or black based on a pixel’s brightness in relation to the brightness of the kernel of pixels around them.
default is false.
**offset**: The larger the offset value, the lower brightness pixels on the original image will be set to white. default is 0.
**invert**: If true, the image will be inverted before the operation. default is false.
**mask**: Mask is another image to use as a pixel level mask for the operation. The mask should be an image with just black or white pixels and should be the same size as the image being operated on.
Only pixels set in the mask are modified. default is None.
**return** Returns the image after the operation is completed. **static** False **C++ defination code**: ```cpp image::Image *morph(int size, std::vector kernel, float mul 1, float add 0.0, bool threshold false, int offset 0, bool invert false, image::Image *mask nullptr) ``` #### gaussian item doc **type** func **brief** Convolves the image by a smoothing guassian kernel. **param** **size**: Kernel size. The actual kernel size is ((size * 2) + 1) * ((size * 2) + 1). Use 1(3x3 kernel), 2(5x5 kernel).
**unsharp**: If true, this method will perform an unsharp mask operation instead of gaussian filtering operation, this improves the clarity of image edges. default is false.
**mul**: This parameter is used to multiply the convolved pixel results. default is auto.
**add**: This parameter is the value to be added to each convolution pixel result. default is 0.0.
**threshold**: If true, which will enable adaptive thresholding of the image which sets pixels to white or black based on a pixel’s brightness in relation to the brightness of the kernel of pixels around them.
default is false.
**offset**: The larger the offset value, the lower brightness pixels on the original image will be set to white. default is 0.
**invert**: If true, the image will be inverted before the operation. default is false.
**mask**: Mask is another image to use as a pixel level mask for the operation. The mask should be an image with just black or white pixels and should be the same size as the image being operated on.
Only pixels set in the mask are modified. default is None.
**return** Returns the image after the operation is completed. **static** False **C++ defination code**: ```cpp image::Image *gaussian(int size, bool unsharp false, float mul 1, float add 0.0, bool threshold false, int offset 0, bool invert false, image::Image *mask nullptr) ``` #### laplacian item doc **type** func **brief** Convolves the image by a edge detecting laplacian kernel. **param** **size**: Kernel size. The actual kernel size is ((size * 2) + 1) * ((size * 2) + 1). Use 1(3x3 kernel), 2(5x5 kernel).
**sharpen**: If True, this method will sharpen the image instead of an unthresholded edge detection image. Then increase the kernel size to improve image clarity. default is false.
**mul**: This parameter is used to multiply the convolved pixel results. default is auto.
**add**: This parameter is the value to be added to each convolution pixel result. default is 0.0.
**threshold**: If true, which will enable adaptive thresholding of the image which sets pixels to white or black based on a pixel’s brightness in relation to the brightness of the kernel of pixels around them.
default is false.
**offset**: The larger the offset value, the lower brightness pixels on the original image will be set to white. default is 0.
**invert**: If true, the image will be inverted before the operation. default is false.
**mask**: Mask is another image to use as a pixel level mask for the operation. The mask should be an image with just black or white pixels and should be the same size as the image being operated on.
Only pixels set in the mask are modified. default is None.
**return** Returns the image after the operation is completed. **static** False **C++ defination code**: ```cpp image::Image *laplacian(int size, bool sharpen false, float mul 1, float add 0.0, bool threshold false, int offset 0, bool invert false, image::Image *mask nullptr) ``` #### bilateral item doc **type** func **brief** Convolves the image by a bilateral filter. **param** **size**: Kernel size. The actual kernel size is ((size * 2) + 1) * ((size * 2) + 1). Use 1(3x3 kernel), 2(5x5 kernel).
**color_sigma**: Controls how closely colors are matched using the bilateral filter. default is 0.1.
**space_sigma**: Controls how closely pixels space wise are blurred with each other. default is 1.
**threshold**: If true, which will enable adaptive thresholding of the image which sets pixels to white or black based on a pixel’s brightness in relation to the brightness of the kernel of pixels around them.
default is false.
**offset**: The larger the offset value, the lower brightness pixels on the original image will be set to white. default is 0.
**invert**: If true, the image will be inverted before the operation. default is false.
**mask**: Mask is another image to use as a pixel level mask for the operation. The mask should be an image with just black or white pixels and should be the same size as the image being operated on.
Only pixels set in the mask are modified. default is None.
**return** Returns the image after the operation is completed. **static** False **C++ defination code**: ```cpp image::Image *bilateral(int size, double color_sigma 0.1, double space_sigma 1, bool threshold false, int offset 0, bool invert false, image::Image *mask nullptr) ``` #### linpolar item doc **type** func **brief** Re project’s and image from cartessian coordinates to linear polar coordinates. **param** **reverse**: If true, the image will be reverse polar transformed. default is false.
**return** Returns the image after the operation is completed. **static** False **C++ defination code**: ```cpp image::Image *linpolar(bool reverse false) ``` #### logpolar item doc **type** func **brief** Re project’s and image from cartessian coordinates to log polar coordinates. **param** **reverse**: If true, the image will be reverse polar transformed. default is false.
**return** Returns the image after the operation is completed. **static** False **C++ defination code**: ```cpp image::Image *logpolar(bool reverse false) ``` #### lens\\_corr item doc **type** func **brief** Performs a lens correction operation on the image. TODO: support in the feature **param** **strength**: The strength of the lens correction. default is 1.8.
**zoom**: The zoom of the lens correction. default is 1.0.
**x_corr**: The x correction of the lens correction. default is 0.5.
**y_corr**: The y correction of the lens correction. default is 0.5.
**return** Returns the image after the operation is completed. **static** False **C++ defination code**: ```cpp image::Image *lens_corr(double strength 1.8, double zoom 1.0, double x_corr 0.5, double y_corr 0.5) ``` #### rotation\\_corr item doc **type** func **brief** Performs a rotation correction operation on the image. TODO: support in the feature **param** **x_rotation**: The x rotation of the rotation correction. default is 0.0.
**y_rotation**: The y rotation of the rotation correction. default is 0.0.
**z_rotation**: The z rotation of the rotation correction. default is 0.0.
**x_translation**: The x translation of the rotation correction. default is 0.0.
**y_translation**: The y translation of the rotation correction. default is 0.0.
**zoom**: The zoom of the rotation correction. default is 1.0.
**fov**: The fov of the rotation correction. default is 60.0.
**corners**: The corners of the rotation correction. default is None.
**return** Returns the image after the operation is completed. **static** False **C++ defination code**: ```cpp image::Image *rotation_corr(double x_rotation 0.0, double y_rotation 0.0, double z_rotation 0.0, double x_translation 0.0, double y_translation 0.0, double zoom 1.0, double fov 60.0, std::vector corners std::vector()) ``` #### get\\_histogram item doc **type** func **brief** Gets the histogram of the image. **param** **thresholds**: You can define multiple thresholds.
For GRAYSCALE format, you can use {{Lmin, Lmax}, ...} to define one or more thresholds.
For RGB888 format, you can use {{Lmin, Lmax, Amin, Amax, Bmin, Bmax}, ...} to define one or more thresholds.
Where the upper case L,A,B represent the L,A,B channels of the LAB image format, and min, max represent the minimum and maximum values of the corresponding channels.
**invert**: If true, the thresholds will be inverted before the operation. default is false.
**roi**: The region of interest, input in the format of (x, y, w, h), x and y are the coordinates of the upper left corner, w and h are the width and height of roi.
default is None, means whole image.
**bins**: The number of bins to use for the histogram.
In GRAYSCALE format, setting range is [2, 256], default is 100.
In rgb888 format, setting range is [2, 100], default is 100.
**l_bins**: The number of bins to use for the l channel of the histogram. Only valid in RGB888 format.
If an invalid value is set, bins will be used instead. The setting range is [2, 100], default is 100.
**a_bins**: The number of bins to use for the a channel of the histogram.
Only valid in RGB888 format.The setting range is [2, 256], default is 256.
**b_bins**: The number of bins to use for the b channel of the histogram.
Only valid in RGB888 format. The setting range is [2, 256], default is 256.
**difference**: difference may be set to an image object to cause this method to operate on the difference image between the current image and the difference image object.
default is None.
**return** Returns the histogram of the image **static** False **C++ defination code**: ```cpp std::map> get_histogram(std::vector> thresholds std::vector>(), bool invert false, std::vector roi std::vector(), int bins 1, int l_bins 100, int a_bins 256, int b_bins 256, image::Image *difference nullptr) ``` #### get\\_statistics item doc **type** func **brief** Gets the statistics of the image. TODO: support in the feature **param** **thresholds**: You can define multiple thresholds.
For GRAYSCALE format, you can use {{Lmin, Lmax}, ...} to define one or more thresholds.
For RGB888 format, you can use {{Lmin, Lmax, Amin, Amax, Bmin, Bmax}, ...} to define one or more thresholds.
Where the upper case L,A,B represent the L,A,B channels of the LAB image format, and min, max represent the minimum and maximum values of the corresponding channels.
**invert**: If true, the image will be inverted before the operation. default is false.
**roi**: The region of interest, input in the format of (x, y, w, h), x and y are the coordinates of the upper left corner, w and h are the width and height of roi.
default is None, means whole image.
**bins**: The number of bins to use for the statistics. default is 1.
**l_bins**: The number of bins to use for the l channel of the statistics. default is 1.
**a_bins**: The number of bins to use for the a channel of the statistics. default is 1.
**b_bins**: The number of bins to use for the b channel of the statistics. default is 1.
**difference**: The difference image to use for the statistics. default is None.
**return** Returns the statistics of the image **static** False **C++ defination code**: ```cpp image::Statistics get_statistics(std::vector> thresholds std::vector>(), bool invert false, std::vector roi std::vector(), int bins 1, int l_bins 1, int a_bins 1, int b_bins 1, image::Image *difference nullptr) ``` #### get\\_regression item doc **type** func **brief** Gets the regression of the image. **param** **thresholds**: You can define multiple thresholds.
For GRAYSCALE format, you can use {{Lmin, Lmax}, ...} to define one or more thresholds.
For RGB888 format, you can use {{Lmin, Lmax, Amin, Amax, Bmin, Bmax}, ...} to define one or more thresholds.
Where the upper case L,A,B represent the L,A,B channels of the LAB image format, and min, max represent the minimum and maximum values of the corresponding channels.
**invert**: If true, the image will be inverted before the operation. default is false.
**roi**: The region of interest, input in the format of (x, y, w, h), x and y are the coordinates of the upper left corner, w and h are the width and height of roi.
default is None, means whole image.
**x_stride**: The x stride to use for the regression. default is 2.
**y_stride**: The y stride to use for the regression. default is 1.
**area_threshold**: The area threshold to use for the regression. default is 10.
**pixels_threshold**: The pixels threshold to use for the regression. default is 10.
**robust**: If true, the regression will be robust. default is false.
**return** Returns the regression of the image **static** False **C++ defination code**: ```cpp std::vector get_regression(std::vector> thresholds std::vector>(), bool invert false, std::vector roi std::vector(), int x_stride 2, int y_stride 1, int area_threshold 10, int pixels_threshold 10, bool robust false) ``` #### save item doc **type** func **brief** Save image to file **param** **path**: file path
**quality**: image quality, by default(value is 95), support jpeg and png format
**return** error code, err::ERR_NONE is ok, other is error **static** False **C++ defination code**: ```cpp err::Err save(const char *path, int quality 95) ``` #### flood\\_fill item doc **type** func **brief** Flood fills a region of the image starting from location x, y. **param** **x**: The x coordinate of the seed point.
**y**: The y coordinate of the seed point.
**seed_threshold**: The seed_threshold value controls how different any pixel in the fill area may be from the original starting pixel. default is 0.05.
**floating_threshold**: The floating_threshold value controls how different any pixel in the fill area may be from any neighbor pixels. default is 0.05.
**color**: The color to fill the region with. default is white.
**invert**: If true, the image will be inverted before the operation. default is false.
**clear_background**: If true, the background will be cleared before the operation. default is false.
**mask**: Mask is another image to use as a pixel level mask for the operation. The mask should be an image with just black or white pixels and should be the same size as the image being operated on.
Only pixels set in the mask are modified. default is None. FIXME: the mask image works abnormally
**return** Returns the image after the operation is completed. **static** False **C++ defination code**: ```cpp image::Image *flood_fill(int x, int y, float seed_threshold 0.05, float floating_threshold 0.05, image::Color color image::COLOR_WHITE, bool invert false, bool clear_background false, image::Image *mask nullptr) ``` #### erode item doc **type** func **brief** Erodes the image in place. **param** **size**: Kernel size. The actual kernel size is ((size * 2) + 1) * ((size * 2) + 1). Use 1(3x3 kernel), 2(5x5 kernel).
**threshold**: The number of pixels in the kernel that are not 0. If it is less than or equal to the threshold, set the center pixel to black. default is (kernel_size 1).
**mask**: Mask is another image to use as a pixel level mask for the operation. The mask should be an image with just black or white pixels and should be the same size as the image being operated on.
Only pixels set in the mask are modified. default is None.
**return** Returns the image after the operation is completed. **static** False **C++ defination code**: ```cpp image::Image *erode(int size, int threshold 1, image::Image *mask nullptr) ``` #### dilate item doc **type** func **brief** Dilates the image in place. **param** **size**: Kernel size. The actual kernel size is ((size * 2) + 1) * ((size * 2) + 1). Use 1(3x3 kernel), 2(5x5 kernel).
**threshold**: The number of pixels in the kernel that are not 0. If it is greater than or equal to the threshold, set the center pixel to white. default is 0.
**mask**: Mask is another image to use as a pixel level mask for the operation. The mask should be an image with just black or white pixels and should be the same size as the image being operated on.
Only pixels set in the mask are modified. default is None.
**return** Returns the image after the operation is completed. **static** False **C++ defination code**: ```cpp image::Image *dilate(int size, int threshold 0, image::Image *mask nullptr) ``` #### open item doc **type** func **brief** Performs erosion and dilation on an image in order. **param** **size**: Kernel size. The actual kernel size is ((size * 2) + 1) * ((size * 2) + 1). Use 1(3x3 kernel), 2(5x5 kernel).
**threshold**: As the threshold for erosion and dilation, the actual threshold for erosion is (kernel_size 1 threshold), the actual threshold for dialation is threshold. default is 0.
**mask**: Mask is another image to use as a pixel level mask for the operation. The mask should be an image with just black or white pixels and should be the same size as the image being operated on.
Only pixels set in the mask are modified. default is None.
**return** Returns the image after the operation is completed. **static** False **C++ defination code**: ```cpp image::Image *open(int size, int threshold 0, image::Image *mask nullptr) ``` #### close item doc **type** func **brief** Performs dilation and erosion on an image in order. **param** **size**: Kernel size. The actual kernel size is ((size * 2) + 1) * ((size * 2) + 1). Use 1(3x3 kernel), 2(5x5 kernel).
**threshold**: As the threshold for erosion and dilation, the actual threshold for erosion is (kernel_size 1 threshold), the actual threshold for dialation is threshold. default is 0.
**mask**: Mask is another image to use as a pixel level mask for the operation. The mask should be an image with just black or white pixels and should be the same size as the image being operated on.
Only pixels set in the mask are modified. default is None.
**return** Returns the image after the operation is completed. **static** False **C++ defination code**: ```cpp image::Image *close(int size, int threshold 0, image::Image *mask nullptr) ``` #### top\\_hat item doc **type** func **brief** Returns the image difference of the image and Image.open()’ed image. **param** **size**: Kernel size. The actual kernel size is ((size * 2) + 1) * ((size * 2) + 1). Use 1(3x3 kernel), 2(5x5 kernel).
**threshold**: As the threshold for open method. default is 0.
**mask**: Mask is another image to use as a pixel level mask for the operation. The mask should be an image with just black or white pixels and should be the same size as the image being operated on.
Only pixels set in the mask are modified. default is None.
**return** Returns the image after the operation is completed. **static** False **C++ defination code**: ```cpp image::Image *top_hat(int size, int threshold 0, image::Image *mask nullptr) ``` #### black\\_hat item doc **type** func **brief** Returns the image difference of the image and Image.close()’ed image. **param** **size**: Kernel size. The actual kernel size is ((size * 2) + 1) * ((size * 2) + 1). Use 1(3x3 kernel), 2(5x5 kernel).
**threshold**: As the threshold for close method. default is 0.
**mask**: Mask is another image to use as a pixel level mask for the operation. The mask should be an image with just black or white pixels and should be the same size as the image being operated on.
Only pixels set in the mask are modified. default is None.
**return** Returns the image after the operation is completed. **static** False **C++ defination code**: ```cpp image::Image *black_hat(int size, int threshold 0, image::Image *mask nullptr) ``` #### find\\_blobs item doc **type** func **brief** Finds all blobs in the image and returns a list of image.Blob class which describe each Blob.\\nPlease see the image.Blob object more more information. **param** **thresholds**: You can define multiple thresholds.
For GRAYSCALE format, you can use {{Lmin, Lmax}, ...} to define one or more thresholds.
For RGB888 format, you can use {{Lmin, Lmax, Amin, Amax, Bmin, Bmax}, ...} to define one or more thresholds.
Where the upper case L,A,B represent the L,A,B channels of the LAB image format, and min, max represent the minimum and maximum values of the corresponding channels.
**invert**: if true, will invert thresholds before find blobs, default is false
**roi**: The region of interest, input in the format of (x, y, w, h), x and y are the coordinates of the upper left corner, w and h are the width and height of roi.
default is None, means whole image.
**x_stride**: x stride is the number of x pixels to skip when doing the hough transform. default is 2
**y_stride**: y_stride is the number of y pixels to skip when doing the hough transform. default is 1
**area_threshold**: area threshold, if the blob area is smaller than area_threshold, the blob is not returned, default is 10
**pixels_threshold**: pixels threshold, if the blob pixels is smaller than area_threshold, the blob is not returned,, default is 10.
when x_stride and y_stride is equal to 1, pixels_threshold is equivalent to area_threshold
**merge**: if True merges all not filtered out blobs whos bounding rectangles intersect each other. default is false
**margin**: margin can be used to increase or decrease the size of the bounding rectangles for blobs during the intersection test.
For example, with a margin of 1 blobs whos bounding rectangles are 1 pixel away from each other will be merged. default is 0
**x_hist_bins_max**: if set to non zero populates a histogram buffer in each blob object with an x_histogram projection of all columns in the object. This value then sets the number of bins for that projection.
**y_hist_bins_max**: if set to non zero populates a histogram buffer in each blob object with an y_histogram projection of all rows in the object. This value then sets the number of bins for that projection.
**return** Return the blob when found blobs, format is (blob1, blob2, ...), you can use blob class methods to do more operations. **static** False **C++ defination code**: ```cpp std::vector find_blobs(std::vector> thresholds std::vector>(), bool invert false, std::vector roi std::vector(), int x_stride 2, int y_stride 1, int area_threshold 10, int pixels_threshold 10, bool merge false, int margin 0, int x_hist_bins_max 0, int y_hist_bins_max 0) ``` #### find\\_lines item doc **type** func **brief** Find lines in image **param** **roi**: The region of interest, input in the format of (x, y, w, h), x and y are the coordinates of the upper left corner, w and h are the width and height of roi.
default is None, means whole image.
**x_stride**: x stride is the number of x pixels to skip when doing the hough transform. default is 2
**y_stride**: y_stride is the number of y pixels to skip when doing the hough transform. default is 1
**threshold**: threshold threshold controls what lines are detected from the hough transform. Only lines with a magnitude greater than or equal to threshold are returned.
The right value of threshold for your application is image dependent. default is 1000.
**theta_margin**: theta_margin controls the merging of detected lines. default is 25.
**rho_margin**: rho_margin controls the merging of detected lines. default is 25.
**return** Return the line when found lines, format is (line1, line2, ...), you can use line class methods to do more operations **static** False **C++ defination code**: ```cpp std::vector find_lines(std::vector roi std::vector(), int x_stride 2, int y_stride 1, double threshold 1000, double theta_margin 25, double rho_margin 25) ``` #### find\\_line\\_segments item doc **type** func **brief** Finds all line segments in the image. **param** **roi**: The region of interest, input in the format of (x, y, w, h), x and y are the coordinates of the upper left corner, w and h are the width and height of roi.
default is None, means whole image.
**merge_distance**: The maximum distance between two lines to merge them. default is 0.
**max_theta_difference**: The maximum difference between two lines to merge them. default is 15.
**return** Return the line when found lines, format is (line1, line2, ...), you can use line class methods to do more operations **static** False **C++ defination code**: ```cpp std::vector find_line_segments(std::vector roi std::vector(), int merge_distance 0, int max_theta_difference 15) ``` #### find\\_circles item doc **type** func **brief** Find circles in image **param** **roi**: The region of interest, input in the format of (x, y, w, h), x and y are the coordinates of the upper left corner, w and h are the width and height of roi.
default is None, means whole image.
**x_stride**: x stride is the number of x pixels to skip when doing the hough transform. default is 2
**y_stride**: y_stride is the number of y pixels to skip when doing the hough transform. default is 1
**threshold**: threshold controls what circles are detected from the hough transform. Only circles with a magnitude greater than or equal to threshold are returned.
The right value of threshold for your application is image dependent.
**x_margin**: x_margin controls the merging of detected circles. Circles which are x_margin, y_margin, and r_margin pixels apart are merged. default is 10
**y_margin**: y_margin controls the merging of detected circles. Circles which are x_margin, y_margin, and r_margin pixels apart are merged. default is 10
**r_margin**: r_margin controls the merging of detected circles. Circles which are x_margin, y_margin, and r_margin pixels apart are merged. default is 10
**r_min**: r_min controls the minimum circle radius detected. Increase this to speed up the algorithm. default is 2
**r_max**: r_max controls the maximum circle radius detected. Decrease this to speed up the algorithm. default is min(roi.w / 2, roi.h / 2)
**r_step**: r_step controls how to step the radius detection by. default is 2.
**return** Return the circle when found circles, format is (circle1, circle2, ...), you can use circle class methods to do more operations **static** False **C++ defination code**: ```cpp std::vector find_circles(std::vector roi std::vector(), int x_stride 2, int y_stride 1, int threshold 2000, int x_margin 10, int y_margin 10, int r_margin 10, int r_min 2, int r_max 1, int r_step 2) ``` #### find\\_rects item doc **type** func **brief** Finds all rects in the image. **param** **roi**: The region of interest, input in the format of (x, y, w, h), x and y are the coordinates of the upper left corner, w and h are the width and height of roi.
default is None, means whole image.
**threshold**: The threshold to use for the rects. default is 10000.
**return** Returns the rects of the image **static** False **C++ defination code**: ```cpp std::vector find_rects(std::vector roi std::vector(), int threshold 10000) ``` #### find\\_qrcodes item doc **type** func **brief** Finds all qrcodes in the image. **param** **roi**: The region of interest, input in the format of (x, y, w, h), x and y are the coordinates of the upper left corner, w and h are the width and height of roi.
default is None, means whole image.
**return** Returns the qrcodes of the image **static** False **C++ defination code**: ```cpp std::vector find_qrcodes(std::vector roi std::vector()) ``` #### find\\_apriltags item doc **type** func **brief** Finds all apriltags in the image. **param** **roi**: The region of interest, input in the format of (x, y, w, h), x and y are the coordinates of the upper left corner, w and h are the width and height of roi.
default is None, means whole image.
**families**: The families to use for the apriltags. default is TAG36H11.
**fx**: The camera X focal length in pixels, default is 1.
**fy**: The camera Y focal length in pixels, default is 1.
**cx**: The camera X center in pixels, default is image.width / 2.
**cy**: The camera Y center in pixels, default is image.height / 2.
**return** Returns the apriltags of the image **static** False **C++ defination code**: ```cpp std::vector find_apriltags(std::vector roi std::vector(), image::ApriltagFamilies families image::ApriltagFamilies::TAG36H11, float fx 1, float fy 1, int cx 1, int cy 1) ``` #### find\\_datamatrices item doc **type** func **brief** Finds all datamatrices in the image. **param** **roi**: The region of interest, input in the format of (x, y, w, h), x and y are the coordinates of the upper left corner, w and h are the width and height of roi.
default is None, means whole image.
**effort**: Controls how much time to spend trying to find data matrix matches. default is 200.
**return** Returns the datamatrices of the image **static** False **C++ defination code**: ```cpp std::vector find_datamatrices(std::vector roi std::vector(), int effort 200) ``` #### find\\_barcodes item doc **type** func **brief** Finds all barcodes in the image. **param** **roi**: The region of interest, input in the format of (x, y, w, h), x and y are the coordinates of the upper left corner, w and h are the width and height of roi.
default is None, means whole image.
**return** Returns the barcodes of the image **static** False **C++ defination code**: ```cpp std::vector find_barcodes(std::vector roi std::vector()) ``` #### find\\_displacement item doc **type** func **brief** Finds the displacement between the image and the template. TODO: support in the feature\\nnote: this method must be used on power of 2 image sizes **param** **template_image**: The template image.
**roi**: The region of interest, input in the format of (x, y, w, h), x and y are the coordinates of the upper left corner, w and h are the width and height of roi.
default is None, means whole image.
**template_roi**: The region of interest rectangle (x, y, w, h) to work in. If not specified, it is equal to the image rectangle.
**logpolar**: If true, it will instead find rotation and scale changes between the two images. default is false.
**return** Returns the displacement of the image **static** False **C++ defination code**: ```cpp image::Displacement find_displacement(image::Image &template_image, std::vector roi std::vector(), std::vector template_roi std::vector(), bool logpolar false) ``` #### find\\_template item doc **type** func **brief** Finds the template in the image. **param** **template_image**: The template image.
**threshold**: Threshold is floating point number (0.0 1.0) where a higher threshold prevents false positives while lowering the detection rate while a lower threshold does the opposite.
**roi**: The region of interest, input in the format of (x, y, w, h), x and y are the coordinates of the upper left corner, w and h are the width and height of roi.
default is None, means whole image. Only valid in SEARCH_EX mode.
**step**: The step size to use for the template. default is 2. Only valid in SEARCH_EX mode
**search**: The search method to use for the template. default is SEARCH_EX.
**return** Returns a bounding box tuple (x, y, w, h) for the matching location otherwise None. **static** False **C++ defination code**: ```cpp std::vector find_template(image::Image &template_image, float threshold, std::vector roi std::vector(), int step 2, image::TemplateMatch search image::TemplateMatch::SEARCH_EX) ``` #### find\\_features item doc **type** func **brief** Finds the features in the image. TODO: support in the feature **param** **cascade**: The cascade to use for the features. default is CASCADE_FRONTALFACE_ALT.
**threshold**: The threshold to use for the features. default is 0.5.
**scale**: The scale to use for the features. default is 1.5.
**roi**: The region of interest, input in the format of (x, y, w, h), x and y are the coordinates of the upper left corner, w and h are the width and height of roi.
default is None, means whole image.
**return** Returns the features of the image **static** False **C++ defination code**: ```cpp std::vector find_features(int cascade, float threshold 0.5, float scale 1.5, std::vector roi std::vector()) ``` #### find\\_lbp item doc **type** func **brief** Finds the lbp in the image. TODO: support in the feature. **param** **roi**: The region of interest, input in the format of (x, y, w, h), x and y are the coordinates of the upper left corner, w and h are the width and height of roi.
default is None, means whole image.
**return** Returns the lbp of the image **static** False **C++ defination code**: ```cpp image::LBPKeyPoint find_lbp(std::vector roi std::vector()) ``` #### find\\_keypoints item doc **type** func **brief** Finds the keypoints in the image. TODO: support in the feature. **param** **roi**: The region of interest, input in the format of (x, y, w, h), x and y are the coordinates of the upper left corner, w and h are the width and height of roi.
default is None, means whole image.
**threshold**: The threshold to use for the keypoints. default is 20.
**normalized**: If true, the image will be normalized before the operation. default is false.
**scale_factor**: The scale factor to use for the keypoints. default is 1.5.
**max_keypoints**: The maximum number of keypoints to use for the keypoints. default is 100.
**corner_detector**: The corner detector to use for the keypoints. default is CORNER_AGAST.
**return** Returns the keypoints of the image **static** False **C++ defination code**: ```cpp image::ORBKeyPoint find_keypoints(std::vector roi std::vector(), int threshold 20, bool normalized false, float scale_factor 1.5, int max_keypoints 100, image::CornerDetector corner_detector image::CornerDetector::CORNER_AGAST) ``` #### find\\_edges item doc **type** func **brief** Finds the edges in the image. **param** **edge_type**: The edge type to use for the edges. default is EDGE_CANNY.
**roi**: The region of interest, input in the format of (x, y, w, h), x and y are the coordinates of the upper left corner, w and h are the width and height of roi.
default is None, means whole image.
**threshold**: The threshold to use for the edges. default is 20.
**return** Returns the edges of the image **static** False **C++ defination code**: ```cpp image::Image* find_edges(image::EdgeDetector edge_type, std::vector roi std::vector(), std::vector threshold std::vector({100, 200})) ``` #### find\\_hog item doc **type** func **brief** Finds the hog in the image. TODO: support in the feature **param** **roi**: The region of interest, input in the format of (x, y, w, h), x and y are the coordinates of the upper left corner, w and h are the width and height of roi.
default is None, means whole image.
**size**: The size to use for the hog. default is 8.
**return** Returns the hog of the image **static** False **C++ defination code**: ```cpp image::Image* find_hog(std::vector roi std::vector(), int size 8) ``` #### match\\_lbp\\_descriptor item doc **type** func **brief** Matches the lbp descriptor of the image. TODO: support in the feature **param** **desc1**: The descriptor to use for the match.
**desc2**: The descriptor to use for the match.
**return** Returns the match of the image **static** False **C++ defination code**: ```cpp int match_lbp_descriptor(image::LBPKeyPoint &desc1, image::LBPKeyPoint &desc2) ``` #### match\\_orb\\_descriptor item doc **type** func **brief** Matches the orb descriptor of the image. TODO: support in the feature **param** **desc1**: The descriptor to use for the match.
**desc2**: The descriptor to use for the match.
**threshold**: The threshold to use for the match. default is 95.
**filter_outliers**: If true, the image will be filter_outliers before the operation. default is false.
**return** Returns the match of the image **static** False **C++ defination code**: ```cpp image::KPTMatch match_orb_descriptor(image::ORBKeyPoint &desc1, image::ORBKeyPoint &desc2, int threshold 95, bool filter_outliers false) ```"}} \ No newline at end of file +{"/maixpy/api/index.html":{"title":"MaixPy API -- Maix AI machine vision platform Python API","content":" title: MaixPy API Maix AI machine vision platform Python API **You can read API doc at [MaixPy API on Sipeed Wiki](https://wiki.sipeed.com/maixpy/api/index.html)** If you want to preview API doc offline, build MaixPy, and API doc will be generated in `MaixPy/docs/api/` directory. > For MaixPy developer: This API documentation is generated from the source code, DO NOT edit this file manually! MaixPy API documentation, modules: module brief [maix.err](./maix/err.html) maix.err module [maix.tensor](./maix/tensor.html) maix.tensor module [maix.image](./maix/image.html) maix.image module, image related definition and functions [maix.camera](./maix/camera.html) maix.camera module, access camera device and get image from it [maix.display](./maix/display.html) maix.display module, control display device and show image on it [maix.comm](./maix/comm.html) maix.comm module [maix.thread](./maix/thread.html) maix.thread module [maix.fs](./maix/fs.html) maix.fs module [maix.sys](./maix/sys.html) maix.sys module [maix.time](./maix/time.html) maix.time module [maix.i18n](./maix/i18n.html) maix.i18n module [maix.protocol](./maix/protocol.html) maix.protocol module [maix.example](./maix/example.html) example module, this will be maix.example module in MaixPy, maix::example namespace in MaixCDK [maix.app](./maix/app.html) maix.app module [maix.nn](./maix/nn.html) maix.nn module [maix.peripheral](./maix/peripheral.html) Chip's peripheral driver [maix.touchscreen](./maix/touchscreen.html) maix.touchscreen module "},"/maixpy/api/maix/touchscreen.html":{"title":"maix.touchscreen","content":" title: maix.touchscreen maix.touchscreen module > This module is generated from [MaixCDK](https://github.com/sipeed/MaixCDK) > You can use `maix.touchscreen` to access this module. ## Module No module ## Enum ## Variable ## Function ## Class ### TouchScreen item doc **brief** TouchScreen class **C++ defination code**: ```cpp class TouchScreen ``` #### \\_\\_init\\_\\_ item doc **type** func **brief** Construct a new TouchScreen object **param** **device**: touchscreen device path, you can get devices by list_devices method, by default(value is NULL(None in MaixPy)) means the first device
**open**: If true, touchscreen will automatically call open() after creation. default is true.
**static** False **C++ defination code**: ```cpp TouchScreen(const std::string &device \"\", bool open true) ``` #### open item doc **type** func **brief** open touchscreen device **return** error code, err::ERR_NONE means success, others means failed **static** False **C++ defination code**: ```cpp err::Err open() ``` #### close item doc **type** func **brief** close touchscreen device **return** error code, err::ERR_NONE means success, others means failed **static** False **C++ defination code**: ```cpp err::Err close() ``` #### read item doc **type** func **brief** read touchscreen device **attention** This method will discard same event in buffer, that is:
if too many move event in buffer when call this method, it will only return the last one,
and if read pressed or released event, it will return immediately. **return** Returns a list include x, y, pressed state **static** False **C++ defination code**: ```cpp std::vector read() ``` #### read (overload 1) item doc **type** func **brief** read touchscreen device **attention** This method will return immediately if have event, so it's better to use available() to check if have more event in buffer,
or too much event in buffer when your program call this read() interval is too long will make your program slow. **return** Returns a list include x, y, pressed state **static** False **C++ defination code**: ```cpp std::vector read0() ``` #### available item doc **type** func **brief** If we need to read from touchscreen, for event driven touchscreen means have event or not **param** **timeout**: 1 means block, 0 means no block, >0 means timeout, default is 0, unit is ms.
**return** true if need to read(have event), false if not **static** False **C++ defination code**: ```cpp bool available(int timeout 0) ``` #### is\\_opened item doc **type** func **brief** Check if touchscreen is opened **return** true if touchscreen is opened, false if not **static** False **C++ defination code**: ```cpp bool is_opened() ```"},"/maixpy/api/maix/peripheral/wdt.html":{"title":"maix.peripheral.wdt","content":" title: maix.peripheral.wdt maix.peripheral.wdt module > This module is generated from [MaixCDK](https://github.com/sipeed/MaixCDK) > You can use `maix.peripheral.wdt` to access this module. ## Module No module ## Enum ## Variable ## Function ## Class ### WDT item doc **brief** Peripheral wdt class **C++ defination code**: ```cpp class WDT ``` #### \\_\\_init\\_\\_ item doc **type** func **brief** WDT constructor **param** **id**: direction [in], id of wdt, int type
**feed_ms**: direction [in], feed ms of wdt, int type
**static** False **C++ defination code**: ```cpp WDT(int id, int feed_ms) ``` #### feed item doc **type** func **brief** feed wdt **return** error code, if feed success, return err::ERR_NONE **static** False **C++ defination code**: ```cpp int feed() ``` #### stop item doc **type** func **brief** stop wdt **static** False **C++ defination code**: ```cpp int stop() ``` #### restart item doc **type** func **brief** restart wdt **attention** restart WDT after stop it **static** False **C++ defination code**: ```cpp int restart() ```"},"/maixpy/api/maix/peripheral/spi.html":{"title":"maix.peripheral.spi","content":" title: maix.peripheral.spi maix.peripheral.spi module > This module is generated from [MaixCDK](https://github.com/sipeed/MaixCDK) > You can use `maix.peripheral.spi` to access this module. ## Module No module ## Enum ## Variable ### MASTER\\_MODE item doc **brief** spi master mode **value** **0x1** **readonly** True **C++ defination code**: ```cpp const int MASTER_MODE 0x1 ``` ### SLAVE\\_MODE item doc **brief** spi slave mode **value** **0x2** **readonly** True **C++ defination code**: ```cpp const int SLAVE_MODE 0x2 ``` ### CLOCK\\_MODE\\_0 item doc **brief** clock mode 0 **attention** CPOL 0, CPHA 0
means the idle level of the clock is low, data is captured on the first edge of the SPI clock cycle **value** **0x0** **readonly** True **C++ defination code**: ```cpp const int CLOCK_MODE_0 0x0 ``` ### CLOCK\\_MODE\\_1 item doc **brief** clock mode 1 **attention** CPOL 0, CPHA 1
means the idle level of the clock is low, data is captured on the second edge of the SPI clock cycle **value** **0x1** **readonly** True **C++ defination code**: ```cpp const int CLOCK_MODE_1 0x1 ``` ### CLOCK\\_MODE\\_2 item doc **brief** clock mode 2 **attention** CPOL 1, CPHA 0
means the idle level of the clock is high, data is captured on the first edge of the SPI clock cycle **value** **0x2** **readonly** True **C++ defination code**: ```cpp const int CLOCK_MODE_2 0x2 ``` ### CLOCK\\_MODE\\_3 item doc **brief** clock mode 3 **attention** CPOL 1, CPHA 1
means the idle level of the clock is high, data is captured on the second edge of the SPI clock cycle **value** **0x3** **readonly** True **C++ defination code**: ```cpp const int CLOCK_MODE_3 0x3 ``` ## Function ## Class ### SPI item doc **brief** Peripheral spi class **C++ defination code**: ```cpp class SPI ``` #### \\_\\_init\\_\\_ item doc **type** func **brief** SPI constructor **param** **id**: direction [in], id of spi, int type
**sclk**: direction [in], sclk pin of spi, int type
**mosi**: direction [in], mosi pin of spi, int type
**miso**: direction [in], miso pin of spi, int type
**cs**: direction [in], cs pin of spi, int type
**freq**: direction [in], freq of spi, int type
**use_soft_cs**: direction [in], use_soft_cs of spi, int type
this param is valid in master mode, when use_soft_cs 1, the
cs pin must be operated manually when sending data. default is 1, means use hardware cs
**mode**: direction [in], mode of spi, int type
option:
mode spi.MASTER, means use master mode
mode spi.SLAVE, means use slave mode
defualt is 1, means use spi.MASTER mode
**clock_mode**: direction [in], clock_mode of spi, int type,default is 1
option:
clock_mode spi.CLOCK_MODE_0, @see CLOCK_MODE_0
clock_mode spi.CLOCK_MODE_1, @see CLOCK_MODE_1
clock_mode spi.CLOCK_MODE_2, @see CLOCK_MODE_2
clock_mode spi.CLOCK_MODE_3, @see CLOCK_MODE_3
default is 1, means use CLOCK_MODE_0
**static** False **C++ defination code**: ```cpp SPI(int id, int sclk, int mosi, int miso, int cs, int freq, int use_soft_cs 1, int mode 1, int clock_mode 1) ``` #### cs\\_high item doc **type** func **brief** set cs pin to high level **static** False **C++ defination code**: ```cpp int cs_high() ``` #### cs\\_low item doc **type** func **brief** set cs pin to low level **static** False **C++ defination code**: ```cpp int cs_low() ``` #### read item doc **type** func **brief** read data from spi **param** **read_len**: direction [in], read length, int type
**return** read data, vector type **static** False **C++ defination code**: ```cpp std::vector read(int read_len) ``` #### write item doc **type** func **brief** write data to spi **param** **write_data**: direction [in], write data, vector type
the member range of the list is [0,255]
**return** error code, if write success, return err::ERR_NONE **static** False **C++ defination code**: ```cpp int write(std::vector write_data std::vector{}) ``` #### read\\_write item doc **type** func **brief** set spi status to high level or low level **param** **write_data**: direction [in], write data, vector type
the member range of the list is [0,255]
**read_len**: direction [in], read length, int type
default is 1, means read_len write_data.size()
**return** read data, vector type **static** False **C++ defination code**: ```cpp std::vector read_write( std::vector write_data std::vector{}, int read_len 1) ``` #### is\\_busy item doc **type** func **brief** get busy status of spi **return** busy status, bool type **static** False **C++ defination code**: ```cpp bool is_busy() ```"},"/maixpy/api/maix/peripheral.html":{"title":"maix.peripheral","content":" title: maix.peripheral Chip's peripheral driver > This module is generated from [MaixCDK](https://github.com/sipeed/MaixCDK) > You can use `maix.peripheral` to access this module. ## Module module brief [timer](./peripheral/timer.html) maix.peripheral.timer module [wdt](./peripheral/wdt.html) maix.peripheral.wdt module [pwm](./peripheral/pwm.html) maix.peripheral.pwm module [gpio](./peripheral/gpio.html) maix.peripheral.gpio module [spi](./peripheral/spi.html) maix.peripheral.spi module [uart](./peripheral/uart.html) maix uart peripheral driver [key](./peripheral/key.html) maix.peripheral.key module [i2c](./peripheral/i2c.html) maix.peripheral.i2c module [adc](./peripheral/adc.html) maix.peripheral.adc module ## Enum ## Variable ## Function ## Class"},"/maixpy/api/maix/app.html":{"title":"maix.app","content":" title: maix.app maix.app module > This module is generated from [MaixCDK](https://github.com/sipeed/MaixCDK) > You can use `maix.app` to access this module. ## Module No module ## Enum ## Variable ## Function ### app\\_id item doc **brief** Get current APP ID. **return** APP ID. **C++ defination code**: ```cpp string app_id() ``` ### set\\_app\\_id item doc **brief** Set current APP ID. **param** **app_id**: APP ID.
**C++ defination code**: ```cpp string set_app_id(const string &app_id) ``` ### get\\_apps\\_info\\_path item doc **brief** Get APP info file path. **C++ defination code**: ```cpp string get_apps_info_path() ``` ### get\\_apps\\_info item doc **brief** Get APP info list. **param** **ignore_launcher**: if true, ignore launcher APP. default false.
**ignore_app_store**: if true, ignore app store APP. default false.
**return** APP info list. APP_Info object list. **C++ defination code**: ```cpp vector &get_apps_info(bool ignore_launcher false, bool ignore_app_store false) ``` ### get\\_app\\_data\\_path item doc **brief** Get APP info, APP can store private data in this directory. **return** APP data path \"./data\", just return the data folder in current path because APP executed in app install path or project path.
So, you must execute your program in you project path to use the project/data folder when you debug your APP. **C++ defination code**: ```cpp string get_app_data_path() ``` ### get\\_app\\_path item doc **brief** Get APP path. **param** **app_id**: APP ID, if empty, return current APP path, else return the APP path by app_id.
**return** APP path, just return the current path because APP executed in app install path or project path.
So, you must execute your program in you project path to use the project/data folder when you debug your APP. **C++ defination code**: ```cpp string get_app_path(const string &app_id \"\") ``` ### get\\_tmp\\_path item doc **brief** Get global temporary data path, APPs can use this path as temporary data directory. **return** temporary data path. **C++ defination code**: ```cpp string get_tmp_path() ``` ### get\\_share\\_path item doc **brief** Get data path of share, shared data like picture and video will put in this directory **return** share data path. **C++ defination code**: ```cpp string get_share_path() ``` ### get\\_picture\\_path item doc **brief** Get picture path of share, shared picture will put in this directory **return** share picture path. **C++ defination code**: ```cpp string get_picture_path() ``` ### get\\_video\\_path item doc **brief** Get video path of share, shared video will put in this directory **return** share video path. **C++ defination code**: ```cpp string get_video_path() ``` ### get\\_font\\_path item doc **brief** Get font path of share, shared font will put in this directory **return** share font path. **C++ defination code**: ```cpp string get_font_path() ``` ### get\\_icon\\_path item doc **brief** Get icon path of share, shared icon will put in this directory **return** share icon path. **C++ defination code**: ```cpp string get_icon_path() ``` ### get\\_sys\\_config\\_kv item doc **brief** Get system config item value. **param** **item**: name of setting item, e.g. wifi, language. more see settings APP.
**key**: config key, e.g. for wifi, key can be ssid, for language, key can be locale.
**value**: default value, if not found, return this value.
**from_cache**: if true, read from cache, if false, read from file.
**return** config value, always string type, if not found, return empty string. **C++ defination code**: ```cpp string get_sys_config_kv(const string &item, const string &key, const string &value \"\", bool from_cache true) ``` ### get\\_app\\_config\\_kv item doc **brief** Get APP config item value. **param** **item**: name of setting item, e.g. user_info
**key**: config key, e.g. for user_info, key can be name, age etc.
**value**: default value, if not found, return this value.
**from_cache**: if true, read from cache, if false, read from file.
**return** config value, always string type, if not found, return empty string. **C++ defination code**: ```cpp string get_app_config_kv(const string &item, const string &key, const string &value \"\", bool from_cache true) ``` ### set\\_app\\_config\\_kv item doc **brief** Set APP config item value. **param** **item**: name of setting item, e.g. user_info
**key**: config key, e.g. for user_info, key can be name, age etc.
**value**: config value, always string type.
**write_file**: if true, write to file, if false, just write to cache.
**return** err::Err **C++ defination code**: ```cpp err::Err set_app_config_kv(const string &item, const string &key, const string &value, bool write_file true) ``` ### get\\_app\\_config\\_path item doc **brief** Get APP config path, ini format, so you can use your own ini parser to parse it like `configparser` in Python.\\nAll APP config info is recommended to store in this file. **return** APP config path(ini format). **C++ defination code**: ```cpp string get_app_config_path() ``` ### set\\_exit\\_msg item doc **brief** Set APP exit code and exit message.\\nIf code ! 0, the launcher will show a dialog to user, and display the msg. **param** **code**: exit code, 0 means success, other means error, if code is 0, do nothing.
**msg**: exit message, if code is 0, msg is not used.
**return** exit code, the same as arg @code. **C++ defination code**: ```cpp err::Err set_exit_msg(err::Err code, const string &msg) ``` ### get\\_exit\\_msg item doc **brief** Get APP exit code and exit message. **param** **cache**: if true, read from cache, if false, read from file. default false.
**return** exit return app_id, exit code and exit message. **C++ defination code**: ```cpp tuple get_exit_msg(bool cache false) ``` ### have\\_exit\\_msg item doc **brief** Check if have exit msg **param** **cache**: if true, just check from cache, if false, check from file. default false.
**return** true if have exit msg, false if not. **C++ defination code**: ```cpp bool have_exit_msg(bool cache false) ``` ### switch\\_app item doc **brief** Exit this APP and start another APP(by launcher).\\nCall this API will call set_exit_flag(true), you should check app::need_exit() in your code.\\nAnd exit this APP if app::need_exit() return true. **param** **app_id**: APP ID which will be started. app_id and idx must have one is valid.
**idx**: APP index. app_id and idx must have one is valid.
**C++ defination code**: ```cpp void switch_app(const string &app_id, int idx 1) ``` ### need\\_exit item doc **brief** Shoule this APP exit? **return** true if this APP should exit, false if not. **attention** This API is a function, not a variable. **C++ defination code**: ```cpp bool need_exit() ``` ### running item doc **brief** App should running? The same as !app::need_exit() (not app::need_exit() in MaixPy). **return** true if this APP should running, false if not. **attention** This API is a function, not a variable. **C++ defination code**: ```cpp bool running() ``` ### set\\_exit\\_flag item doc **brief** Set exit flag. You can get exit flag by app.need_exit(). **param** **exit**: true if this APP should exit, false if not.
**C++ defination code**: ```cpp void set_exit_flag(bool exit) ``` ## Class ### Version item doc **brief** APP version **C++ defination code**: ```cpp class Version ``` #### \\_\\_str\\_\\_ item doc **type** func **brief** Convert to string, e.g. 1.0.0 **static** False **C++ defination code**: ```cpp std::string __str__() ``` #### from\\_str item doc **type** func **brief** Convert from string, e.g. \\\"1.0.0\\\" **static** True **C++ defination code**: ```cpp static app::Version from_str(const string &version_str) ``` ### APP\\_Info item doc **brief** APP info **C++ defination code**: ```cpp class APP_Info ``` #### id item doc **type** var **brief** APP id **static** False **readonly** False **C++ defination code**: ```cpp string id ``` #### name item doc **type** var **brief** APP name **static** False **readonly** False **C++ defination code**: ```cpp string name ``` #### icon item doc **type** var **brief** APP icon **static** False **readonly** False **C++ defination code**: ```cpp string icon ``` #### version item doc **type** var **brief** APP version **static** False **readonly** False **C++ defination code**: ```cpp Version version ``` #### exec item doc **type** var **brief** APP exec **static** False **readonly** False **C++ defination code**: ```cpp string exec ``` #### author item doc **type** var **brief** APP author **static** False **readonly** False **C++ defination code**: ```cpp string author ``` #### desc item doc **type** var **brief** APP desc **static** False **readonly** False **C++ defination code**: ```cpp string desc ``` #### names item doc **type** var **brief** APP names **static** False **readonly** False **C++ defination code**: ```cpp map names ``` #### descs item doc **type** var **brief** APP descs **static** False **readonly** False **C++ defination code**: ```cpp map descs ```"},"/maixpy/api/maix/i18n.html":{"title":"maix.i18n","content":" title: maix.i18n maix.i18n module > This module is generated from [MaixCDK](https://github.com/sipeed/MaixCDK) > You can use `maix.i18n` to access this module. ## Module No module ## Enum ## Variable ### locales item doc **brief** i18n locales list **value** **{
\"en\",
\"zh\",
\"zh tw\",
\"ja\"
}** **readonly** False **C++ defination code**: ```cpp static std::vector locales { \"en\", \"zh\", \"zh tw\", \"ja\" } ``` ### names item doc **brief** i18n language names list **value** **{
\"English\",
\"简体中文\",
\"繁體中文\",
\"日本語\"
}** **readonly** True **C++ defination code**: ```cpp const static std::vector names { \"English\", \"简体中文\", \"繁體中文\", \"日本語\" } ``` ## Function ### get\\_locale item doc **brief** Get system config of locale. **return** language locale, e.g. en, zh, zh_CN, zh_TW, etc. **C++ defination code**: ```cpp string get_locale() ``` ### get\\_language\\_name item doc **brief** Get system config of language name. **return** language name, e.g. English, 简体中文, 繁體中文, etc. **C++ defination code**: ```cpp string get_language_name() ``` ## Class ### Trans item doc **brief** Translate helper class. **C++ defination code**: ```cpp class Trans ``` #### \\_\\_init\\_\\_ item doc **type** func **brief** Translate helper class constructor.\\nBy default locale is get by `i18n.get_locale()` function which set by system settings.\\nBut you can also manually set by `set_locale` function temporarily. **param** **locales_dict**: locales dict, e.g. {\"zh\": {\"Confirm\": \"确认\", \"OK\": \"好的\"}, \"en\": {\"Confirm\": \"Confirm\", \"OK\": \"OK\"}}
**static** False **C++ defination code**: ```cpp Trans(const std::map> &locales_dict) ``` #### tr item doc **type** func **brief** Translate string by key. **param** **key**: string key, e.g. \"Confirm\"
**locale**: locale name, if not assign, use default locale set by system settings or set_locale function.
**return** translated string, if find translation, return it, or return key, e.g. \"确认\", \"Confirm\", etc. **static** False **C++ defination code**: ```cpp string tr(const string &key, const string locale \"\") ``` #### set\\_locale item doc **type** func **brief** Set locale temporarily, will not affect system settings. **param** **locale**: locale name, e.g. \"zh\", \"en\", etc. @see maix.i18n.locales
**static** False **C++ defination code**: ```cpp void set_locale(const string &locale) ``` #### get\\_locale item doc **type** func **brief** Get current locale. **return** locale name, e.g. \"zh\", \"en\", etc. @see maix.i18n.locales **static** False **C++ defination code**: ```cpp string get_locale() ```"},"/maixpy/api/maix/peripheral/timer.html":{"title":"maix.peripheral.timer","content":" title: maix.peripheral.timer maix.peripheral.timer module > This module is generated from [MaixCDK](https://github.com/sipeed/MaixCDK) > You can use `maix.peripheral.timer` to access this module. ## Module No module ## Enum ## Variable ## Function ## Class ### TIMER item doc **brief** Peripheral timer class **C++ defination code**: ```cpp class TIMER ``` #### \\_\\_init\\_\\_ item doc **type** func **brief** TIMER constructor **static** False **C++ defination code**: ```cpp TIMER() ```"},"/maixpy/api/maix/peripheral/i2c.html":{"title":"maix.peripheral.i2c","content":" title: maix.peripheral.i2c maix.peripheral.i2c module > This module is generated from [MaixCDK](https://github.com/sipeed/MaixCDK) > You can use `maix.peripheral.i2c` to access this module. ## Module No module ## Enum ## Variable ### SEVEN\\_BIT item doc **brief** 7 bit address mode **value** **0x1** **readonly** True **C++ defination code**: ```cpp const int SEVEN_BIT 0x1 ``` ### TEN\\_BIT item doc **brief** 10 bit address mode **value** **0x2** **readonly** True **C++ defination code**: ```cpp const int TEN_BIT 0x2 ``` ### MASTER item doc **brief** master mode **value** **0x4** **readonly** True **C++ defination code**: ```cpp const int MASTER 0x4 ``` ### SLAVE item doc **brief** slave mode **value** **0x8** **readonly** True **C++ defination code**: ```cpp const int SLAVE 0x8 ``` ### STANDARD\\_SPEED item doc **brief** standard speed mode **value** **0x10** **readonly** True **C++ defination code**: ```cpp const int STANDARD_SPEED 0x10 ``` ### FAST\\_SPEED item doc **brief** fast speed mode **value** **0x20** **readonly** True **C++ defination code**: ```cpp const int FAST_SPEED 0x20 ``` ## Function ## Class ### I2C item doc **brief** Peripheral i2c class **C++ defination code**: ```cpp class I2C ``` #### \\_\\_init\\_\\_ item doc **type** func **brief** I2C Device constructor\\nthis constructor will be export to MaixPy as _maix.example.Example.__init__ **param** **id**: direction [in], i2c index, int type
**scl**: direction [in], sck pin of i2c, int type
**sda**: direction [in], sda pin of i2c, int type
**freq**: direction [in], i2c clock, int type
option:
in the i2c.STANDARD_SPEED mode, range is [0, 100000]
in the i2c.FAST_SPEED mode, range is [0, 400000]
default clock is 1, means use max clock
**mode**: direction [in], mode of i2c, int type.
option:
mode i2c.MASTER, means master mode
mode i2c.SLAVE, means slave mode
**bit**: direction [in], address length of i2c, int type.
option:
bit i2c.SEVEN_BIT, means 7 bit address mode
bit i2c.TEN_BIT, means 10 bit address mode
**speed_mode**: direction [in], speed mode of i2c, int type.
option:
speed_mode i2c.STANDARD_SPEED, means standard speed mode, up to 100kbit/s
speed_mode i2c.FAST_SPEED, means fast speed mode, up to 400kbit/s
**static** False **C++ defination code**: ```cpp I2C(int id, int scl, int sda, int freq 1, int mode 1, int bit 1, int speed_mode 1) ``` #### writeto item doc **type** func **brief** write data to i2c slave **param** **addr**: direction [in], i2c slave address, int type
**data**: direction [in], data to write, vector type.
Note: The member range of the list is [0,255]
**return** if success, return 0, else return 1 **static** False **C++ defination code**: ```cpp int writeto(int addr, std::vector data) ``` #### readfrom item doc **type** func **brief** read data from i2c slave **param** **addr**: direction [in], i2c slave address, int type
**len**: direction [in], data length to read, int type
**return** the list of data read from i2c slave, vector type **static** False **C++ defination code**: ```cpp std::vector readfrom(int addr, int len) ``` #### scan item doc **type** func **brief** scan all i2c address **return** the list of i2c address, vector type **static** False **C++ defination code**: ```cpp std::vector scan() ``` #### writeto\\_mem item doc **type** func **brief** write data to i2c slave **param** **addr**: direction [in], i2c slave address, int type
**start_addr**: direction [in], start address of i2c slave, int type
**data**: direction [in], data to write, vector type.
Note: The member range of the list is [0,255]
**return** if success, return 0, else return 1 **static** False **C++ defination code**: ```cpp int writeto_mem(int addr, int start_addr, std::vector data) ``` #### readfrom\\_mem item doc **type** func **brief** read data from i2c slave **param** **addr**: direction [in], i2c slave address, int type
**start_addr**: direction [in], start address of i2c slave, int type
**len**: direction [in], data length to read, int type
**return** the list of data read from i2c slave, vector type **static** False **C++ defination code**: ```cpp std::vector readfrom_mem(int addr, int start_addr, int len) ```"},"/maixpy/api/maix/peripheral/gpio.html":{"title":"maix.peripheral.gpio","content":" title: maix.peripheral.gpio maix.peripheral.gpio module > This module is generated from [MaixCDK](https://github.com/sipeed/MaixCDK) > You can use `maix.peripheral.gpio` to access this module. ## Module No module ## Enum ## Variable ### IN item doc **brief** GPIO input mode **value** **0x01** **readonly** True **C++ defination code**: ```cpp const int IN 0x01 ``` ### OUT item doc **brief** GPIO output mode **value** **0x2** **readonly** True **C++ defination code**: ```cpp const int OUT 0x2 ``` ### OUT\\_OD item doc **brief** GPIO output open drain mode **value** **0x3** **readonly** True **C++ defination code**: ```cpp const int OUT_OD 0x3 ``` ### PULL\\_NONE item doc **brief** GPIO pull none mode **value** **0x4** **readonly** True **C++ defination code**: ```cpp const int PULL_NONE 0x4 ``` ### PULL\\_UP item doc **brief** GPIO pull up mode **value** **0x5** **readonly** True **C++ defination code**: ```cpp const int PULL_UP 0x5 ``` ### PULL\\_DOWN item doc **brief** GPIO pull down mode **value** **0x6** **readonly** True **C++ defination code**: ```cpp const int PULL_DOWN 0x6 ``` ### OFF item doc **brief** GPIO off **value** **0x0** **readonly** True **C++ defination code**: ```cpp const int OFF 0x0 ``` ### ON item doc **brief** GPIO on **value** **0x1** **readonly** True **C++ defination code**: ```cpp const int ON 0x1 ``` ## Function ## Class ### GPIO item doc **brief** Peripheral gpio class **C++ defination code**: ```cpp class GPIO ``` #### \\_\\_init\\_\\_ item doc **type** func **brief** GPIO constructor **param** **pin**: direction [in], gpio pin. int type.
**mode**: direction [in], gpio mode. int type. default is 1, means gpio.IN
option:
mode gpio.IN, means input mode
mode gpio.OUT, means output mode
mode gpio.OUT_OD, means output open drain mode
**pull**: direction [in], gpio pull. int type. default is determined by actual board.
option:
pull gpio.PULL_NONE, means pull none mode
pull gpio.PULL_UP, means pull up mode
pull gpio.PULL_DOWN, means pull down mode
**static** False **C++ defination code**: ```cpp GPIO(int pin, int mode 1, int pull 1) ``` #### value item doc **type** func **brief** write/read gpio value **param** **value**: direction [in], gpio value. int type.
value 0, means write gpio to low level
value 1, means write gpio to high level
**return** int type
if success, return 0; else return 1 **static** False **C++ defination code**: ```cpp int value(int value 1) ``` #### write item doc **type** func **brief** get gpio write **param** **value**: direction [in], gpio value. int type.
value 0, means write gpio to low level
value 1, means write gpio to high level
value 1 or not set, means read gpio value
**return** int type
when read gpio value, return gpio value
when write gpio value, if success, return 0; else return 1 **static** False **C++ defination code**: ```cpp int write(int value) ``` #### read item doc **type** func **brief** get gpio read **return** int type
return 0, means gpio is low level
return 1, means gpio is high level
return other, means error **static** False **C++ defination code**: ```cpp int read() ``` #### on item doc **type** func **brief** set gpio on **static** False **C++ defination code**: ```cpp void on() ``` #### off item doc **type** func **brief** set gpio off **static** False **C++ defination code**: ```cpp void off() ``` #### high item doc **type** func **brief** set gpio high **static** False **C++ defination code**: ```cpp void high() ``` #### low item doc **type** func **brief** set gpio low **static** False **C++ defination code**: ```cpp void low() ``` #### toggle item doc **type** func **brief** gpio toggle **static** False **C++ defination code**: ```cpp void toggle() ```"},"/maixpy/api/maix/peripheral/pwm.html":{"title":"maix.peripheral.pwm","content":" title: maix.peripheral.pwm maix.peripheral.pwm module > This module is generated from [MaixCDK](https://github.com/sipeed/MaixCDK) > You can use `maix.peripheral.pwm` to access this module. ## Module No module ## Enum ## Variable ## Function ## Class ### PWM item doc **brief** Peripheral pwm class **C++ defination code**: ```cpp class PWM ``` #### \\_\\_init\\_\\_ item doc **type** func **brief** PWM constructor **param** **pin**: direction [in], pwm pin. int type.
**freq**: direction [in], pwm frequency, unit: Hz. int type. default is 1000
**duty**: direction [in], pwm duty. int type. range is [0, 100], default is 1, means set duty to 50
note: you can not set duty and duty_val at the same time
**duty_val**: direction [in], pwm duty value, unit: us. int type. default is 1, means set duty_val to (1000000000 / freq) * 0.5
note: you can not set duty and duty_val at the same time
**align**: direction [in], pwm align. int type. default is 1
**sync**: direction [in], pwm sync. int type. default is false
**static** False **C++ defination code**: ```cpp PWM(int pin, int freq 1000, int duty 1, int duty_val 1, int align 1, bool sync false) ``` #### duty item doc **type** func **brief** set pwm duty **param** **duty**: direction [in], pwm duty. int type. default is 1
duty [0, 100], set duty
duty 1 or not set, return current duty
**return** int type
when get duty, return current duty
when set duty, if success, return 0; else return 1 **static** False **C++ defination code**: ```cpp int duty(int duty 1) ``` #### duty\\_val item doc **type** func **brief** set pwm duty value **param** **duty_val**: direction [in], pwm duty value. int type. default is 1
duty_val [0, 65535], set duty_val
duty_val 1 or not set, return current duty_val
**return** int type
when get duty_val, return current duty_val
when set duty_val, if success, return 0; else return 1 **static** False **C++ defination code**: ```cpp int duty_val(int duty_val 1) ``` #### freq item doc **type** func **brief** set pwm frequency **param** **freq**: direction [in], pwm frequency. int type. default is 1
freq > 0, set freq
freq 1 or not set, return current freq
**return** int type
when get freq, return current freq
when set freq, if success, return 0; else return 1 **static** False **C++ defination code**: ```cpp int freq(int freq 1) ``` #### enable item doc **type** func **brief** set pwm enable **param** **enable**: direction [in], pwm enable. int type. default is 1
enable 0, disable pwm
enable 1, enable pwm
enable 1 or not set, return current enable value
**return** int type
when get enable, return current enable value
when set enable, if success, return 0; else return 1 **static** False **C++ defination code**: ```cpp int enable(int enable 1) ```"},"/maixpy/api/maix/time.html":{"title":"maix.time","content":" title: maix.time maix.time module > This module is generated from [MaixCDK](https://github.com/sipeed/MaixCDK) > You can use `maix.time` to access this module. ## Module No module ## Enum ## Variable ## Function ### time item doc **brief** Get current time in s **return** current time in s, double type **C++ defination code**: ```cpp double time() ``` ### time\\_ms item doc **brief** Get current time in ms **return** current time in ms, uint64_t type **C++ defination code**: ```cpp uint64_t time_ms() ``` ### time\\_s item doc **brief** Get current time in s **return** current time in s, uint64_t type **C++ defination code**: ```cpp uint64_t time_s() ``` ### time\\_us item doc **brief** Get current time in us **return** current time in us, uint64_t type **C++ defination code**: ```cpp uint64_t time_us() ``` ### time\\_diff item doc **brief** Calculate time difference **param** **last**: last time
**now**: current time
**return** time difference **C++ defination code**: ```cpp double time_diff(double last, double now 1) ``` ### sleep item doc **brief** Sleep seconds **param** **s**: seconds, double type
**C++ defination code**: ```cpp void sleep(double s) ``` ### sleep\\_ms item doc **brief** Sleep milliseconds **param** **ms**: milliseconds, uint64_t type
**C++ defination code**: ```cpp void sleep_ms(uint64_t ms) ``` ### sleep\\_us item doc **brief** Sleep microseconds **param** **us**: microseconds, uint64_t type
**C++ defination code**: ```cpp void sleep_us(uint64_t us) ``` ### now item doc **brief** Get current UTC date and time **return** current date and time, DateTime type **C++ defination code**: ```cpp time::DateTime *now() ``` ### localtime item doc **brief** Get local time **return** local time, DateTime type **C++ defination code**: ```cpp time::DateTime *localtime() ``` ### strptime item doc **brief** DateTime from string **param** **str**: date time string
**format**: date time format
**return** DateTime **C++ defination code**: ```cpp time::DateTime *strptime(const std::string &str, const std::string &format) ``` ### gmtime item doc **brief** timestamp to DateTime(time zone is UTC (value 0)) **param** **timestamp**: double timestamp
**return** DateTime **C++ defination code**: ```cpp time::DateTime *gmtime(double timestamp) ``` ## Class ### DateTime item doc **brief** Date and time class **C++ defination code**: ```cpp class DateTime ``` #### year item doc **type** var **brief** Year **static** False **readonly** False **C++ defination code**: ```cpp int year ``` #### month item doc **type** var **brief** Month, 1~12 **static** False **readonly** False **C++ defination code**: ```cpp int month ``` #### day item doc **type** var **brief** Day **static** False **readonly** False **C++ defination code**: ```cpp int day ``` #### hour item doc **type** var **brief** Hour **static** False **readonly** False **C++ defination code**: ```cpp int hour ``` #### minute item doc **type** var **brief** Minute **static** False **readonly** False **C++ defination code**: ```cpp int minute ``` #### second item doc **type** var **brief** Second **static** False **readonly** False **C++ defination code**: ```cpp int second ``` #### microsecond item doc **type** var **brief** Microsecond **static** False **readonly** False **C++ defination code**: ```cpp int microsecond ``` #### yearday item doc **type** var **brief** Year day **static** False **readonly** False **C++ defination code**: ```cpp int yearday ``` #### weekday item doc **type** var **brief** Weekday, 0 is Monday, 6 is Sunday **static** False **readonly** False **C++ defination code**: ```cpp int weekday ``` #### zone item doc **type** var **brief** Time zone **static** False **readonly** False **C++ defination code**: ```cpp float zone ``` #### zone\\_name item doc **type** var **brief** Time zone name **static** False **readonly** False **C++ defination code**: ```cpp std::string zone_name ``` #### \\_\\_init\\_\\_ item doc **type** func **brief** Constructor **param** **year**: year
**month**: month
**day**: day
**hour**: hour
**minute**: minute
**second**: second
**microsecond**: microsecond
**yearday**: year day
**weekday**: weekday
**zone**: time zone
**static** False **C++ defination code**: ```cpp DateTime(int year 0, int month 0, int day 0, int hour 0, int minute 0, int second 0, int microsecond 0, int yearday 0, int weekday 0, int zone 0) ``` #### strftime item doc **type** func **brief** Convert to string **return** date time string **static** False **C++ defination code**: ```cpp std::string strftime(const std::string &format) ``` #### timestamp item doc **type** func **brief** Convert to float timestamp **return** float timestamp **static** False **C++ defination code**: ```cpp double timestamp() ```"},"/maixpy/api/maix/fs.html":{"title":"maix.fs","content":" title: maix.fs maix.fs module > This module is generated from [MaixCDK](https://github.com/sipeed/MaixCDK) > You can use `maix.fs` to access this module. ## Module No module ## Enum ### SEEK item doc **brief** SEEK enums **values** **SEEK_SET**: Seek from beginning of file.
**SEEK_CUR**: Seek from current position.
**SEEK_END**: Seek from end of file.
**C++ defination code**: ```cpp enum SEEK { SEEK_SET 0, // Seek from beginning of file. SEEK_CUR 1, // Seek from current position. SEEK_END 2, // Seek from end of file. } ``` ## Variable ## Function ### isabs item doc **brief** Check if the path is absolute path **param** **path**: path to check
**return** true if path is absolute path **C++ defination code**: ```cpp bool isabs(const std::string &path) ``` ### isdir item doc **brief** Check if the path is a directory, if not exist, throw exception **param** **path**: path to check
**return** true if path is a directory **C++ defination code**: ```cpp bool isdir(const std::string &path) ``` ### isfile item doc **brief** Check if the path is a file, if not exist, throw exception **param** **path**: path to check
**return** true if path is a file **C++ defination code**: ```cpp bool isfile(const std::string &path) ``` ### islink item doc **brief** Check if the path is a link, if not exist, throw exception **param** **path**: path to check
**return** true if path is a link **C++ defination code**: ```cpp bool islink(const std::string &path) ``` ### exists item doc **brief** Check if the path exists **param** **path**: path to check
**return** true if path exists **C++ defination code**: ```cpp bool exists(const std::string &path) ``` ### mkdir item doc **brief** Create a directory recursively **param** **path**: path to create
**exist_ok**: if true, also return true if directory already exists
**recursive**: if true, create directory recursively, otherwise, only create one directory, default is true
**return** err::ERR_NONE(err.Err.ERR_NONE in MaixPy) if success, other error code if failed **C++ defination code**: ```cpp err::Err mkdir(const std::string &path, bool exist_ok true, bool recursive true) ``` ### rmdir item doc **brief** Remove a directory **param** **path**: path to remove
**recursive**: if true, remove directory recursively, otherwise, only remove empty directory, default is false
**return** err::ERR_NONE(err.Err.ERR_NONE in MaixPy) if success, other error code if failed **C++ defination code**: ```cpp err::Err rmdir(const std::string &path, bool recursive false) ``` ### remove item doc **brief** Remove a file **param** **path**: path to remove
**return** err::ERR_NONE(err.Err.ERR_NONE in MaixPy) if success, other error code if failed **C++ defination code**: ```cpp err::Err remove(const std::string &path) ``` ### rename item doc **brief** Rename a file or directory **param** **src**: source path
**dst**: destination path, if destination dirs not exist, will auto create
**return** err::ERR_NONE(err.Err.ERR_NONE in MaixPy) if success, other error code if failed **C++ defination code**: ```cpp err::Err rename(const std::string &src, const std::string &dst) ``` ### getsize item doc **brief** Get file size **param** **path**: path to get size
**return** file size if success, err::Err code if failed **C++ defination code**: ```cpp int getsize(const std::string &path) ``` ### dirname item doc **brief** Get directory name of path **param** **path**: path to get dirname
**return** dirname if success, empty string if failed **C++ defination code**: ```cpp std::string dirname(const std::string &path) ``` ### basename item doc **brief** Get base name of path **param** **path**: path to get basename
**return** basename if success, empty string if failed **C++ defination code**: ```cpp std::string basename(const std::string &path) ``` ### abspath item doc **brief** Get absolute path **param** **path**: path to get absolute path
**return** absolute path if success, empty string if failed **C++ defination code**: ```cpp std::string abspath(const std::string &path) ``` ### getcwd item doc **brief** Get current working directory **return** current working directory absolute path **C++ defination code**: ```cpp std::string getcwd() ``` ### realpath item doc **brief** Get realpath of path **param** **path**: path to get realpath
**return** realpath if success, empty string if failed **C++ defination code**: ```cpp std::string realpath(const std::string &path) ``` ### splitext item doc **brief** Get file extension **param** **path**: path to get extension
**return** extension if success, empty string if failed **C++ defination code**: ```cpp std::string splitext(const std::string &path) ``` ### listdir item doc **brief** List files in directory **param** **path**: path to list
**recursive**: if true, list recursively, otherwise, only list current directory, default is false
**full_path**: if true, return full path, otherwise, only return basename, default is false
**return** files list if success, nullptr if failed **C++ defination code**: ```cpp std::vector *listdir(const std::string &path, bool recursive false, bool full_path false) ``` ### open item doc **brief** Open a file, and return a File object **param** **path**: path to open
**mode**: open mode, support \"r\", \"w\", \"a\", \"r+\", \"w+\", \"a+\", \"rb\", \"wb\", \"ab\", \"rb+\", \"wb+\", \"ab+\"
**return** File object if success(need to delete object manually in C/C++), nullptr if failed **C++ defination code**: ```cpp fs::File *open(const std::string &path, const std::string &mode) ``` ### tempdir item doc **brief** Get temp files directory **return** temp files directory **C++ defination code**: ```cpp std::string tempdir() ``` ## Class ### File item doc **brief** File read write ops **C++ defination code**: ```cpp class File ``` #### open item doc **type** func **brief** Open a file **param** **path**: path to open
**mode**: open mode, support \"r\", \"w\", \"a\", \"r+\", \"w+\", \"a+\", \"rb\", \"wb\", \"ab\", \"rb+\", \"wb+\", \"ab+\"
**return** err::ERR_NONE(err.Err.ERR_NONE in MaixPy) if success, other error code if failed **static** False **C++ defination code**: ```cpp err::Err open(const std::string &path, const std::string &mode) ``` #### close item doc **type** func **brief** Close a file **static** False **C++ defination code**: ```cpp void close() ``` #### read item doc **type** func **brief** Read data from file API2 **param** **size**: max read size
**return** bytes data if success(need delete manually in C/C++), nullptr if failed **static** False **C++ defination code**: ```cpp std::vector *read(int size) ``` #### readline item doc **type** func **brief** Read line from file **return** line if success, empty string if failed. You need to delete the returned object manually in C/C++. **static** False **C++ defination code**: ```cpp std::string *readline() ``` #### write item doc **type** func **brief** Write data to file API2 **param** **buf**: buffer to write
**return** write size if success, err::Err code if failed **static** False **C++ defination code**: ```cpp int write(const std::vector &buf) ``` #### seek item doc **type** func **brief** Seek file position **param** **offset**: offset to seek
**whence**: @see maix.fs.SEEK
**return** new position if success, err::Err code if failed **static** False **C++ defination code**: ```cpp int seek(int offset, int whence) ``` #### tell item doc **type** func **brief** Get file position **return** file position if success, err::Err code if failed **static** False **C++ defination code**: ```cpp int tell() ``` #### flush item doc **type** func **brief** Flush file **return** err::ERR_NONE(err.Err.ERR_NONE in MaixPy) if success, other error code if failed **static** False **C++ defination code**: ```cpp err::Err flush() ```"},"/maixpy/api/maix/comm.html":{"title":"maix.comm","content":" title: maix.comm maix.comm module > This module is generated from [MaixCDK](https://github.com/sipeed/MaixCDK) > You can use `maix.comm` to access this module. ## Module No module ## Enum ## Variable ## Function ## Class ### CommProtocol item doc **brief** Class for communication protocol **C++ defination code**: ```cpp class CommProtocol ``` #### \\_\\_init\\_\\_ item doc **type** func **brief** Construct a new CommProtocol object **param** **buff_size**: buffer size, default to 1024 bytes
**static** False **C++ defination code**: ```cpp CommProtocol(int buff_size 1024) ``` #### get\\_msg item doc **type** func **brief** Read data to buffer, and try to decode it as maix.protocol.MSG object **return** decoded data, if nullptr, means no valid frame found.
Attentioin, delete it after use in C++. **static** False **C++ defination code**: ```cpp protocol::MSG *get_msg() ``` #### resp\\_ok item doc **type** func **brief** Send response ok(success) message **param** **cmd**: CMD value
**body**: response body, can be null
**return** encoded data, if nullptr, means error, and the error code is err.Err.
Attentioin, delete it after use in C++. **static** False **C++ defination code**: ```cpp err::Err resp_ok(uint8_t cmd, Bytes *body nullptr) ``` #### report item doc **type** func **brief** Send report message **param** **cmd**: CMD value
**body**: report body, can be null
**return** encoded data, if nullptr, means error, and the error code is err.Err.
Attentioin, delete it after use in C++. **static** False **C++ defination code**: ```cpp err::Err report(uint8_t cmd, Bytes *body nullptr) ``` #### resp\\_err item doc **type** func **brief** Encode response error message to buffer **param** **cmd**: CMD value
**code**: error code
**msg**: error message
**return** encoded data, if nullptr, means error, and the error code is err.Err.
Attentioin, delete it after use in C++. **static** False **C++ defination code**: ```cpp err::Err resp_err(uint8_t cmd, err::Err code, const std::string &msg) ```"},"/maixpy/api/maix/sys.html":{"title":"maix.sys","content":" title: maix.sys maix.sys module > This module is generated from [MaixCDK](https://github.com/sipeed/MaixCDK) > You can use `maix.sys` to access this module. ## Module No module ## Enum ## Variable ## Function ### os\\_version() item doc **brief** Get system version **return** version string, e.g. \"2024.4.1 13af4b\" **C++ defination code**: ```cpp std::string os_version() ``` ### device\\_name() item doc **brief** Get device name **return** device name, e.g. \"MaixCAM\" **C++ defination code**: ```cpp std::string device_name() ``` ### host\\_name() item doc **brief** Get host name **return** host name, e.g. \"maixcam 2f9f\" **C++ defination code**: ```cpp std::string host_name() ``` ### host\\_domain() item doc **brief** Get host domain **return** host domain, e.g. \"maixcam 2f9f.local\" **C++ defination code**: ```cpp std::string host_domain() ``` ### ip\\_address() item doc **brief** Get ip address **return** ip address, dict type, e.g. {\"eth0\": \"192.168.0.195\", \"wlan0\": \"192.168.0.123\", \"usb0\": \"10.47.159.1\"} **C++ defination code**: ```cpp std::map ip_address() ``` ### mac\\_address() item doc **brief** Get mac address **return** mac address, dict type, e.g. {\"eth0\": \"00:0c:29:2f:9f:00\", \"wlan0\": \"00:0c:29:2f:9f:01\", \"usb0\": \"00:0c:29:2f:9f:02\"} **C++ defination code**: ```cpp std::map mac_address() ``` ### device\\_key() item doc **brief** Get device key, can be unique id of device **return** device key, 32 bytes hex string, e.g. \"1234567890abcdef1234567890abcdef\" **C++ defination code**: ```cpp std::string device_key() ``` ### memory\\_info() item doc **brief** Get memory info **return** memory info, dict type, e.g. {\"total\": 1024, \"used\": 512, \"hw_total\": 256*1024*1024}
total: total memory size in Byte.
used: used memory size in Byte.
hw_total: total memory size in Byte of hardware, the total < hw_total,
OS kernel may reserve some memory for some hardware like camera, npu, display etc. **C++ defination code**: ```cpp std::map memory_info() ``` ### bytes\\_to\\_human(1234) item doc **brief** Bytes to human readable string **param** **bytes:**: bytes size,e.g. 1234B 1234/1024 1.205 KB
**precision:**: decimal precision, default 2
**base:**: base number, default 1024
**unit:**: unit string, e.g. \"B\"
**sep:**: separator string, e.g. \" \"
**return** human readable string, e.g. \"1.21 KB\" **C++ defination code**: ```cpp std::string bytes_to_human(unsigned long long bytes, int precision 2, int base 1024, const std::string &unit \"B\", const std::string &sep \" \") ``` ### cpu\\_freq() item doc **brief** Get CPU frequency **return** CPU frequency, dict type, e.g. {\"cpu0\": 1000000000, \"cpu1\": 1000000000} **C++ defination code**: ```cpp std::map cpu_freq() ``` ### cpu\\_temp() item doc **brief** Get CPU temperature **return** CPU temperature, unit dgree, dict type, e.g. {\"cpu\": 50.0, \"cpu0\": 50, \"cpu1\": 50} **C++ defination code**: ```cpp std::map cpu_temp() ``` ### cpu\\_usage() item doc **brief** Get CPU usage **return** CPU usage, dict type, e.g. {\"cpu\": 50.0, \"cpu0\": 50, \"cpu1\": 50} **C++ defination code**: ```cpp std::map cpu_usage() ``` ### npu\\_freq() item doc **brief** Get NPU frequency **return** NPU frequency, dict type, e.g. {\"npu0\": 500000000} **C++ defination code**: ```cpp std::map npu_freq() ``` ### disk\\_usage() item doc **brief** Get disk usage **param** **path:**: disk path, default \"/\"
**return** disk usage, dict type, e.g. {\"total\": 1024, \"used\": 512} **C++ defination code**: ```cpp std::map disk_usage(const std::string &path \"/\") ``` ### disk\\_partitions() item doc **brief** Get disk partition and mount point info **param** **only_disk**: only return real disk, tempfs sysfs etc. not return, default true.
**return** disk partition and mount point info, list type, e.g. [{\"device\": \"/dev/mmcblk0p1\", \"mountpoint\": \"/mnt/sdcard\", \"fstype\": \"vfat\"}] **C++ defination code**: ```cpp std::vector> disk_partitions(bool only_disk true) ``` ## Class"},"/maixpy/api/maix/display.html":{"title":"maix.display","content":" title: maix.display maix.display module, control display device and show image on it > This module is generated from [MaixCDK](https://github.com/sipeed/MaixCDK) > You can use `maix.display` to access this module. ## Module No module ## Enum ## Variable ## Function ### send\\_to\\_maixvision item doc **brief** Send image to MaixVision work station if connected.\\nIf you want to debug your program an don't want to initialize display, use this method. **param** **img**: image to send, image.Image object
**C++ defination code**: ```cpp void send_to_maixvision(image::Image &img) ``` ## Class ### Display item doc **brief** Display class **C++ defination code**: ```cpp class Display ``` #### \\_\\_init\\_\\_ item doc **type** func **brief** Construct a new Display object **param** **width**: display width, by default(value is 1) means auto detect,
if width > max device supported width, will auto set to max device supported width
**height**: display height, by default(value is 1) means auto detect,
if height > max device supported height, will auto set to max device supported height
**device**: display device name, you can get devices by list_devices method, by default(value is NULL(None in MaixPy)) means the first device
**open**: If true, display will automatically call open() after creation. default is true.
**static** False **C++ defination code**: ```cpp Display(int width 1, int height 1, image::Format format image::FMT_RGB888, const char *device nullptr, bool open true) ``` #### width item doc **type** func **brief** Get display width **return** width **static** False **C++ defination code**: ```cpp int width() ``` #### height item doc **type** func **brief** Get display height **param** **ch**: channel to get, by default(value is 0) means the first channel
**return** height **static** False **C++ defination code**: ```cpp int height() ``` #### size item doc **type** func **brief** Get display size **param** **ch**: channel to get, by default(value is 0) means the first channel
**return** size A list type in MaixPy, [width, height] **static** False **C++ defination code**: ```cpp std::vector size() ``` #### format item doc **type** func **brief** Get display format **return** format **static** False **C++ defination code**: ```cpp image::Format format() ``` #### open item doc **type** func **brief** open display device, if already opened, will return err.ERR_NONE. **param** **width**: display width, default is 1, means auto, mostly means max width of display support
**height**: display height, default is 1, means auto, mostly means max height of display support
**format**: display output format, default is RGB888
**return** error code **static** False **C++ defination code**: ```cpp err::Err open(int width 1, int height 1, image::Format format image::FMT_INVALID) ``` #### close item doc **type** func **brief** close display device **return** error code **static** False **C++ defination code**: ```cpp err::Err close() ``` #### add\\_channel item doc **type** func **brief** Add a new channel and return a new Display object, you can use close() to close this channel. **param** **width**: display width, default is 1, means auto, mostly means max width of display support
**height**: display height, default is 1, means auto, mostly means max height of display support
**format**: display output format, default is RGB888
**open**: If true, display will automatically call open() after creation. default is true.
**return** new Display object **static** False **C++ defination code**: ```cpp display::Display *add_channel(int width 1, int height 1, image::Format format image::FMT_RGB888, bool open true) ``` #### is\\_opened item doc **type** func **brief** check display device is opened or not **return** opened or not, bool type **static** False **C++ defination code**: ```cpp bool is_opened() ``` #### is\\_closed item doc **type** func **brief** check display device is closed or not **return** closed or not, bool type **static** False **C++ defination code**: ```cpp bool is_closed() ``` #### show item doc **type** func **brief** show image on display device, and will also send to MaixVision work station if connected. **param** **img**: image to show, image.Image object,
if the size of image smaller than display size, will show in the center of display;
if the size of image bigger than display size, will auto resize to display size and keep ratio, fill blank with black color.
**fit**: image in screen fit mode, by default(value is image.FIT_CONTAIN), @see image.Fit for more details
e.g. image.FIT_CONTAIN means resize image to fit display size and keep ratio, fill blank with black color.
**return** error code **static** False **C++ defination code**: ```cpp err::Err show(image::Image &img, image::Fit fit image::FIT_CONTAIN) ``` #### device item doc **type** func **brief** Get display device path **return** display device path **static** False **C++ defination code**: ```cpp std::string device() ```"},"/maixpy/api/maix/protocol.html":{"title":"maix.protocol","content":" title: maix.protocol maix.protocol module > This module is generated from [MaixCDK](https://github.com/sipeed/MaixCDK) > You can use `maix.protocol` to access this module. ## Module No module ## Enum ### CMD item doc **brief** protocol cmd, more doc see MaixCDK document's convention doc **note** max app custom CMD value should < CMD_APP_MAX **values** **CMD_APP_MAX**: 200, max app custom CMD value should < CMD_APP_MAX
**CMD_SET_UPLOAD**: set auto upload data mode
**CMD_APP_LIST**:
**CMD_START_APP**:
**CMD_EXIT_APP**:
**CMD_CUR_APP_INFO**:
**CMD_APP_INFO**:
**CMD_KEY**:
**CMD_TOUCH**:
**C++ defination code**: ```cpp enum CMD { CMD_APP_MAX 0xC8, // 200, max app custom CMD value should < CMD_APP_MAX CMD_SET_UPLOAD 0xF8, // set auto upload data mode CMD_APP_LIST 0xF9, CMD_START_APP 0xFA, CMD_EXIT_APP 0xFB, CMD_CUR_APP_INFO 0xFC, CMD_APP_INFO 0xFD, CMD_KEY 0xFE, CMD_TOUCH 0xFF, } ``` ### FLAGS item doc **brief** protocol flags, more doc see MaixCDK document's convention doc **values** **FLAG_REQ**:
**FLAG_RESP**:
**FLAG_IS_RESP_MASK**:
**FLAG_RESP_OK**:
**FLAG_RESP_ERR**:
**FLAG_RESP_OK_MASK**:
**FLAG_REPORT**:
**FLAG_REPORT_MASK**:
**FLAG_VERSION_MASK**:
**C++ defination code**: ```cpp enum FLAGS { FLAG_REQ 0x00, FLAG_RESP 0x80, FLAG_IS_RESP_MASK 0x80, FLAG_RESP_OK 0x40, FLAG_RESP_ERR 0x00, FLAG_RESP_OK_MASK 0x40, FLAG_REPORT 0x20, FLAG_REPORT_MASK 0x20, FLAG_VERSION_MASK 0x03 } ``` ## Variable ### VERSION item doc **brief** protocol version **value** **1** **readonly** True **C++ defination code**: ```cpp const uint8_t VERSION 1 ``` ### HEADER item doc **brief** protocol header **value** **0xBBACCAAA** **readonly** True **C++ defination code**: ```cpp const uint32_t HEADER 0xBBACCAAA ``` ## Function ### crc16\\_IBM item doc **brief** CRC16 IBM **param** **data**: data, bytes type.
**return** CRC16 IBM value, uint16_t type. **C++ defination code**: ```cpp uint16_t crc16_IBM(const Bytes *data) ``` ## Class ### MSG item doc **brief** protocol msg **C++ defination code**: ```cpp class MSG ``` #### version item doc **type** var **brief** protocol version **static** False **readonly** False **C++ defination code**: ```cpp uint8_t version ``` #### resp\\_ok item doc **type** var **brief** Is success response or not, (only for response msg) **static** False **readonly** False **C++ defination code**: ```cpp uint8_t resp_ok ``` #### cmd item doc **type** var **brief** CMD value **static** False **readonly** False **C++ defination code**: ```cpp uint8_t cmd ``` #### is\\_resp item doc **type** var **brief** message is response or not, contrast with is_req **static** False **readonly** False **C++ defination code**: ```cpp bool is_resp ``` #### body\\_len item doc **type** var **brief** Message body length, read only, use set_body() to update **attention** DO NOT manually change this value **static** False **readonly** False **C++ defination code**: ```cpp int body_len ``` #### encode\\_resp\\_ok item doc **type** func **brief** Encode response ok(success) message **param** **body**: response body, can be null
**return** encoded data, if nullptr, means error, and the error code is err.Err **static** False **C++ defination code**: ```cpp Bytes *encode_resp_ok(Bytes *body nullptr) ``` #### encode\\_report item doc **type** func **brief** Encode proactively report message **param** **body**: report body, can be null
**return** encoded data, if nullptr, means error, and the error code is err.Err **static** False **C++ defination code**: ```cpp Bytes *encode_report(Bytes *body nullptr) ``` #### encode\\_resp\\_err item doc **type** func **brief** Encode response error message **param** **code**: error code
**msg**: error message
**return** encoded data, if nullptr, means error, and the error code is err.Err **static** False **C++ defination code**: ```cpp Bytes *encode_resp_err(err::Err code, const std::string &msg) ``` #### set\\_body item doc **type** func **brief** Update message body **param** **body_new**: new body data
**static** False **C++ defination code**: ```cpp void set_body(Bytes *body_new) ``` #### get\\_body item doc **type** func **brief** Get message body **return** message body, bytes type **static** False **C++ defination code**: ```cpp Bytes *get_body() ``` ### Protocol item doc **brief** Communicate protocol **C++ defination code**: ```cpp class Protocol ``` #### \\_\\_init\\_\\_ item doc **type** func **brief** Construct a new Protocol object **param** **buff_size**: Data queue buffer size
**static** False **C++ defination code**: ```cpp Protocol(int buff_size 1024) ``` #### buff\\_size item doc **type** func **brief** Data queue buffer size **static** False **C++ defination code**: ```cpp int buff_size() ``` #### push\\_data item doc **type** func **brief** Add data to data queue **param** **new_data**: new data
**return** error code, maybe err.Err.ERR_BUFF_FULL **static** False **C++ defination code**: ```cpp err::Err push_data(const Bytes *new_data) ``` #### decode item doc **type** func **brief** Decode data in data queue and return a message **param** **new_data**: new data add to data queue, if null, only decode.
**return** decoded message, if nullptr, means no message decoded. **static** False **C++ defination code**: ```cpp protocol::MSG *decode(const Bytes *new_data nullptr) ``` #### encode\\_resp\\_ok item doc **type** func **brief** Encode response ok(success) message to buffer **param** **cmd**: CMD value
**body**: response body, can be null
**return** encoded data, if nullptr, means error, and the error code is err.Err **static** False **C++ defination code**: ```cpp Bytes *encode_resp_ok(uint8_t cmd, Bytes *body nullptr) ``` #### encode\\_report item doc **type** func **brief** Encode proactively report message to buffer **param** **cmd**: CMD value
**body**: report body, can be null
**return** encoded data, if nullptr, means error, and the error code is err.Err **static** False **C++ defination code**: ```cpp Bytes *encode_report(uint8_t cmd, Bytes *body nullptr) ``` #### encode\\_resp\\_err item doc **type** func **brief** Encode response error message to buffer **param** **cmd**: CMD value
**code**: error code
**msg**: error message
**return** encoded data, if nullptr, means error, and the error code is err.Err **static** False **C++ defination code**: ```cpp Bytes *encode_resp_err(uint8_t cmd, err::Err code, const std::string &msg) ```"},"/maixpy/api/maix/tensor.html":{"title":"maix.tensor","content":" title: maix.tensor maix.tensor module > This module is generated from [MaixCDK](https://github.com/sipeed/MaixCDK) > You can use `maix.tensor` to access this module. ## Module No module ## Enum ### DType item doc **brief** Tensor data types **values** **UINT8**:
**INT8**:
**UINT16**:
**INT16**:
**UINT32**:
**INT32**:
**FLOAT16**:
**FLOAT32**:
**FLOAT64**:
**BOOL**:
**DTYPE_MAX**:
**C++ defination code**: ```cpp enum DType { UINT8 0, INT8, UINT16, INT16, UINT32, INT32, FLOAT16, FLOAT32, FLOAT64, BOOL, // STRING, // OBJECT, DTYPE_MAX } ``` ## Variable ### dtype\\_size item doc **brief** Tensor data type size in bytes **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** **{
1, // UINT8
1, // INT8
2, // UINT16
2, // INT16
4, // UINT32
4, // INT32
2, // FLOAT16
4, // FLOAT32
8, // FLOAT64
1, // BOOL
// 1, // STRING
// 1, // OBJECT
0
}** **readonly** True **C++ defination code**: ```cpp const std::vector dtype_size { 1, // UINT8 1, // INT8 2, // UINT16 2, // INT16 4, // UINT32 4, // INT32 2, // FLOAT16 4, // FLOAT32 8, // FLOAT64 1, // BOOL // 1, // STRING // 1, // OBJECT 0 } ``` ### dtype\\_name item doc **brief** Tensor data type name **value** **{
\"uint8\",
\"int8\",
\"uint16\",
\"int16\",
\"uint32\",
\"int32\",
\"float16\",
\"float32\",
\"float64\",
\"bool\",
// \"string\",
// \"object\",
\"invalid\"
}** **readonly** True **C++ defination code**: ```cpp const std::vector dtype_name { \"uint8\", \"int8\", \"uint16\", \"int16\", \"uint32\", \"int32\", \"float16\", \"float32\", \"float64\", \"bool\", // \"string\", // \"object\", \"invalid\" } ``` ## Function ## Class ### Tensor item doc **brief** Tensor class **C++ defination code**: ```cpp class Tensor ``` #### \\_\\_init\\_\\_ item doc **type** func **brief** Tensor constructor **param** **shape**: tensor shape, a int list
**dtype**: tensor element data type, see DType of this module
**data**: pointer to data content, can be nullptr, it will automatically alloc memory
and detroy it when this object is destroyed
**static** False **C++ defination code**: ```cpp Tensor(std::vector shape, tensor::DType dtype, void *data nullptr) ``` #### to\\_str item doc **type** func **brief** To string **static** False **C++ defination code**: ```cpp std::string to_str() ``` #### \\_\\_str\\_\\_ item doc **type** func **brief** To string **static** False **C++ defination code**: ```cpp std::string __str__() ``` #### shape item doc **type** func **brief** get tensor shape **return** tensor shape, a int list **static** False **C++ defination code**: ```cpp std::vector shape() ``` #### expand\\_dims item doc **type** func **brief** expand tensor shape **param** **axis**: axis to expand
**static** False **C++ defination code**: ```cpp void expand_dims(int axis) ``` #### reshape item doc **type** func **brief** reshape tensor shape, if size not match, it will throw an err::Exception **param** **shape**: new shape
**static** False **C++ defination code**: ```cpp void reshape(std::vector shape) ``` #### flatten item doc **type** func **brief** Flatten tensor shape to 1D **static** False **C++ defination code**: ```cpp void flatten() ``` #### dtype item doc **type** func **brief** get tensor data type **return** tensor data type, see DType of this module **static** False **C++ defination code**: ```cpp tensor::DType dtype() ``` #### argmax item doc **type** func **brief** argmax of tensor **param** **axis**: By default, the index is into the flattened array, otherwise along the specified axis., wrong axis will throw an err::Exception
**return** argmax result, you need to delete it after use in C++. **static** False **C++ defination code**: ```cpp tensor::Tensor *argmax(int axis 0xffff) ``` #### argmax1 item doc **type** func **brief** argmax1, flattened data max index **return** argmax result, int type **static** False **C++ defination code**: ```cpp int argmax1() ``` ### Tensors item doc **brief** Tensors **C++ defination code**: ```cpp class Tensors ``` #### \\_\\_init\\_\\_ item doc **type** func **brief** Constructor of Tensors **static** False **C++ defination code**: ```cpp Tensors() ``` #### add\\_tensor item doc **type** func **brief** Add tensor **static** False **C++ defination code**: ```cpp void add_tensor(const std::string &key, tensor::Tensor *tensor, bool copy, bool auto_delete) ``` #### rm\\_tensor item doc **type** func **brief** Remove tensor **static** False **C++ defination code**: ```cpp void rm_tensor(const std::string &key) ``` #### get\\_tensor item doc **type** func **brief** Get tensor by key **static** False **C++ defination code**: ```cpp tensor::Tensor *get_tensor(const std::string &key) ``` #### \\_\\_getitem\\_\\_ item doc **type** func **brief** Operator [] **static** False **C++ defination code**: ```cpp tensor::Tensor *operator[](const std::string &key) ``` #### \\_\\_len\\_\\_ item doc **type** func **brief** Size **static** False **C++ defination code**: ```cpp size_t size() ``` #### get\\_names item doc **type** func **brief** Get names **static** False **C++ defination code**: ```cpp std::vector get_names() ``` #### tensors item doc **type** var **brief** Tensors data, dict type **static** False **readonly** False **C++ defination code**: ```cpp std::map tensors ```"},"/maixpy/api/maix/nn/F.html":{"title":"maix.nn.F","content":" title: maix.nn.F maix.nn.F module > This module is generated from [MaixCDK](https://github.com/sipeed/MaixCDK) > You can use `maix.nn.F` to access this module. ## Module No module ## Enum ## Variable ## Function ### softmax item doc **brief** Softmax, only support 1D tensor, multi dimension tensor will be treated as 1D tensor **param** **tensor**: input tensor
**replace**: change input tensor data directly, if not, will create a new tensor
**throw** If arg error, will raise err.Exception error **return** output tensor, if arg replace is true, return the arg tensor's address.
If not replace, return a new object, so In C++, you should delete it manually in this case! **C++ defination code**: ```cpp tensor::Tensor *softmax(tensor::Tensor *tensor, bool replace) ``` ## Class"},"/maixpy/api/maix/example.html":{"title":"maix.example","content":" title: maix.example example module, this will be maix.example module in MaixPy, maix::example namespace in MaixCDK > This module is generated from [MaixCDK](https://github.com/sipeed/MaixCDK) > You can use `maix.example` to access this module. ## 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**: ```cpp 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**: ```cpp 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**: ```cpp const std::vector 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**: ```cpp int test_var 100 ``` ## Function ### hello 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**: ```cpp 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**: ```cpp example::Example *change_arg_name(example::Example *e) ``` ### change\\_arg\\_name2 item doc **brief** Change arg name example **param** **e**: Example object
**C++ defination code**: ```cpp void change_arg_name2(example::Example &e) ``` ## Class ### Test item doc **brief** Test class **C++ defination code**: ```cpp class Test ``` #### \\_\\_init\\_\\_ item doc **type** func **brief** Test constructor **static** False **C++ defination code**: ```cpp Test() ``` ### Example item doc **brief** Example class\\nthis class will be export to MaixPy as maix.example.Example **C++ defination code**: ```cpp class Example ``` #### \\_\\_init\\_\\_ 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**: ```cpp Example(std::string &name, int age 18, example::Kind pet example::KIND_NONE) ``` #### get\\_name 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**: ```cpp std::string get_name() ``` #### get\\_age 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**: ```cpp int get_age() ``` #### set\\_name item doc **type** func **brief** set name of Example **param** **name**: name of Example, string type
**static** False **C++ defination code**: ```cpp void set_name(std::string name) ``` #### set\\_age 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**: ```cpp void set_age(int age) ``` #### set\\_pet item doc **type** func **brief** Example enum member **attention** **static** False **C++ defination code**: ```cpp void set_pet(example::Kind pet) ``` #### get\\_pet item doc **type** func **brief** Example enum member **static** False **C++ defination code**: ```cpp example::Kind get_pet() ``` #### get\\_list 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**: ```cpp std::vector *get_list(std::vector in) ``` #### get\\_dict 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**: ```cpp std::map get_dict(std::map &in) ``` #### hello 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**: ```cpp static std::string hello(std::string name) ``` #### hello\\_bytes 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**: ```cpp static Bytes *hello_bytes(Bytes &bytes) ``` #### callback 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**: ```cpp static int callback(std::function cb) ``` #### hello\\_dict 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**: ```cpp static std::map *hello_dict(std::map *dict) ``` #### name item doc **type** var **brief** name member of Example **static** False **readonly** False **C++ defination code**: ```cpp 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**: ```cpp 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**: ```cpp static std::string hello_str ``` #### var1 item doc **type** var **brief** Example module readonly variable **static** False **readonly** True **C++ defination code**: ```cpp const std::string var1 \"Example.var1\" ``` #### var2 item doc **type** var **brief** Example module readonly variable **static** False **readonly** True **C++ defination code**: ```cpp std::string var2 \"Example.var2\" ``` #### dict\\_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**: ```cpp static std::map *dict_test() ```"},"/maixpy/api/maix/thread.html":{"title":"maix.thread","content":" title: maix.thread maix.thread module > This module is generated from [MaixCDK](https://github.com/sipeed/MaixCDK) > You can use `maix.thread` to access this module. ## Module No module ## Enum ## Variable ## Function ## Class ### Thread item doc **brief** thread class **C++ defination code**: ```cpp class Thread ``` #### \\_\\_init\\_\\_ item doc **type** func **brief** create thread **param** **func**: direction [in], thread function, one `args` parameter, void* type, no return value
**args**: direction [in], thread function parameter
**static** False **C++ defination code**: ```cpp Thread(std::function func, void *args nullptr) ``` #### join item doc **type** func **brief** wait thread exit **static** False **C++ defination code**: ```cpp void join() ``` #### detach item doc **type** func **brief** detach thread **static** False **C++ defination code**: ```cpp void detach() ``` #### joinable item doc **type** func **brief** Check if thread is joinable **return** true if thread is joinable **static** False **C++ defination code**: ```cpp bool joinable() ```"},"/maixpy/api/maix/err.html":{"title":"maix.err","content":" title: maix.err maix.err module > This module is generated from [MaixCDK](https://github.com/sipeed/MaixCDK) > You can use `maix.err` to access this module. ## Module No module ## Enum ### Err item doc **brief** Maix Error code **values** **ERR_NONE**: No error
**ERR_ARGS**: Invalid arguments
**ERR_NO_MEM**: No memory
**ERR_NOT_IMPL**: Not implemented
**ERR_NOT_READY**: Not ready
**ERR_NOT_INIT**: Not initialized
**ERR_NOT_OPEN**: Not opened
**ERR_NOT_PERMIT**: Not permitted
**ERR_REOPEN**: Re open
**ERR_BUSY**: Busy
**ERR_READ**: Read error
**ERR_WRITE**: Write error
**ERR_TIMEOUT**: Timeout
**ERR_RUNTIME**: Runtime error
**ERR_IO**: IO error
**ERR_NOT_FOUND**: Not found
**ERR_ALREAY_EXIST**: Already exist
**ERR_BUFF_FULL**: Buffer full
**ERR_BUFF_EMPTY**: Buffer empty
**ERR_CANCEL**: Cancel
**ERR_OVERFLOW**: Overflow
**ERR_MAX**:
**C++ defination code**: ```cpp enum Err { // !!! fixed error code, DO NOT change number already defined, only append new error code ERR_NONE 0, // No error ERR_ARGS , // Invalid arguments ERR_NO_MEM , // No memory ERR_NOT_IMPL , // Not implemented ERR_NOT_READY , // Not ready ERR_NOT_INIT , // Not initialized ERR_NOT_OPEN , // Not opened ERR_NOT_PERMIT , // Not permitted ERR_REOPEN , // Re open ERR_BUSY , // Busy ERR_READ , // Read error ERR_WRITE , // Write error ERR_TIMEOUT , // Timeout ERR_RUNTIME , // Runtime error ERR_IO , // IO error ERR_NOT_FOUND , // Not found ERR_ALREAY_EXIST , // Already exist ERR_BUFF_FULL , // Buffer full ERR_BUFF_EMPTY , // Buffer empty ERR_CANCEL , // Cancel ERR_OVERFLOW , // Overflow ERR_MAX, } ``` ## Variable ## Function ### to\\_str item doc **brief** Error code to string **param** **e**: direction [in], error code, err::Err type
**return** error string **C++ defination code**: ```cpp std::string to_str(err::Err e) ``` ### get\\_error item doc **brief** get last error string **return** error string **C++ defination code**: ```cpp std::string& get_error() ``` ### set\\_error item doc **brief** set last error string **param** **str**: direction [in], error string
**C++ defination code**: ```cpp void set_error(const std::string &str) ``` ### check\\_raise item doc **brief** Check error code, if not ERR_NONE, raise err.Exception **param** **e**: direction [in], error code, err::Err type
**msg**: direction [in], error message
**C++ defination code**: ```cpp void check_raise(err::Err e, const std::string &msg \"\") ``` ### check\\_bool\\_raise item doc **brief** Check condition, if false, raise err.Exception **param** **ok**: direction [in], condition, if true, do nothing, if false, raise err.Exception
**msg**: direction [in], error message
**C++ defination code**: ```cpp void check_bool_raise(bool ok, const std::string &msg \"\") ``` ### check\\_null\\_raise item doc **brief** Check NULL pointer, if NULL, raise exception **param** **ptr**: direction [in], pointer
**msg**: direction [in], error message
**C++ defination code**: ```cpp void check_null_raise(void *ptr, const std::string &msg \"\") ``` ## Class ### Exception item doc **brief** Maix Exception **C++ defination code**: ```cpp class Exception : public std::exception ```"},"/maixpy/api/maix/peripheral/uart.html":{"title":"maix.peripheral.uart","content":" title: maix.peripheral.uart maix uart peripheral driver > This module is generated from [MaixCDK](https://github.com/sipeed/MaixCDK) > You can use `maix.peripheral.uart` to access this module. ## Module No module ## Enum ### PARITY item doc **brief** uart parity enum **values** **PARITY_NONE**: no parity
**PARITY_ODD**: odd parity
**PARITY_EVEN**: even parity
**PARITY_MAX**:
**C++ defination code**: ```cpp enum PARITY { PARITY_NONE 0x00, // no parity PARITY_ODD 0x01, // odd parity PARITY_EVEN 0x02, // even parity PARITY_MAX } ``` ### STOP item doc **brief** uart stop bits **values** **STOP_1**: 1 stop bit
**STOP_2**: 2 stop bits
**STOP_1_5**: 1.5 stop bits
**STOP_MAX**:
**C++ defination code**: ```cpp enum STOP { STOP_1 0x01, // 1 stop bit STOP_2 0x02, // 2 stop bits STOP_1_5 0x03, // 1.5 stop bits STOP_MAX } ``` ### BITS item doc **brief** uart stop bits **values** **BITS_5**: 5 data bits
**BITS_6**: 6 data bits
**BITS_7**: 7 data bits
**BITS_8**: 8 data bits
**BITS_MAX**:
**C++ defination code**: ```cpp enum BITS { BITS_5 5, // 5 data bits BITS_6 6, // 6 data bits BITS_7 7, // 7 data bits BITS_8 8, // 8 data bits BITS_MAX } ``` ### FLOW\\_CTRL item doc **brief** uart flow control **values** **FLOW_CTRL_NONE**: no flow control
**FLOW_CTRL_HW**: hardware flow control
**FLOW_CTRL_MAX**:
**C++ defination code**: ```cpp enum FLOW_CTRL { FLOW_CTRL_NONE 0, // no flow control FLOW_CTRL_HW 1, // hardware flow control FLOW_CTRL_MAX } ``` ## Variable ## Function ### list\\_ports item doc **brief** Get supported uart ports. **return** uart ports list, string type. **C++ defination code**: ```cpp std::vector list_ports() ``` ## Class ### UART item doc **brief** maix uart peripheral driver **C++ defination code**: ```cpp class UART : public comm::CommBase ``` #### \\_\\_init\\_\\_ item doc **type** func **brief** UART constructor. You need to call open() to open the device. **param** **port**: uart port. string type, can get it by uart.list_ports().
If empty, will not open device in constructor, default empty.
if not empty, will auto open device in constructor, open fail will throw err.Exception.
**baudrate**: baudrate of uart. int type, default 115200.
**databits**: databits, values @see uart.DATA_BITS
**parity**: parity, values @see uart.PARITY
**stopbits**: stopbits, values @see uart.STOP_BITS
**flow_control**: flow_control, values @see uart.FLOW_CTRL
**static** False **C++ defination code**: ```cpp UART(const std::string &port \"\", int baudrate 115200, uart::BITS databits uart::BITS_8, uart::PARITY parity uart::PARITY_NONE, uart::STOP stopbits uart::STOP_1, uart::FLOW_CTRL flow_ctrl uart::FLOW_CTRL_NONE) ``` #### set\\_port item doc **type** func **brief** Set port **param** **port**: uart port. string type, can get it by uart.list_ports().
**return** set port error code, err.Err type. **static** False **C++ defination code**: ```cpp err::Err set_port(const std::string &port) ``` #### get\\_port item doc **type** func **brief** Get port **return** uart port, string type. **static** False **C++ defination code**: ```cpp std::string get_port() ``` #### set\\_baudrate item doc **type** func **brief** Set baud rate **param** **baudrate**: baudrate of uart. int type, default 115200.
**return** set baud rate error code, err.Err type. **static** False **C++ defination code**: ```cpp err::Err set_baudrate(int baudrate) ``` #### get\\_baudrate item doc **type** func **brief** Get baud rate **return** baud rate, int type. **static** False **C++ defination code**: ```cpp int get_baudrate() ``` #### open item doc **type** func **brief** Open uart device, before open, port must be set in constructor or by set_port().\\nIf already opened, do nothing and return err.ERR_NONE. **return** open device error code, err.Err type. **static** False **C++ defination code**: ```cpp err::Err open() ``` #### is\\_open item doc **type** func **brief** Check if device is opened. **return** true if opened, false if not opened. **static** False **C++ defination code**: ```cpp bool is_open() ``` #### close item doc **type** func **brief** Close uart device, if already closed, do nothing and return err.ERR_NONE. **return** close device error code, err.Err type. **static** False **C++ defination code**: ```cpp err::Err close() ``` #### write\\_str item doc **type** func **brief** Send string data **param** **str**: string data
**return** sent data length, < 0 means error, value is err.Err. **static** False **C++ defination code**: ```cpp int write_str(const std::string &str) ``` #### write item doc **type** func **brief** Send data to uart **param** **data**: direction [in], data to send, bytes type. If you want to send str type, use str.encode() to convert.
**return** sent length, int type, if < 0 means error, value is err.Err. **static** False **C++ defination code**: ```cpp int write(Bytes &data) ``` #### available item doc **type** func **brief** Check if data available or wait data available. **param** **timeout**: unit ms, timeout to wait data, default 0.
0 means check data available and return immediately,
> 0 means wait until data available or timeout.
1 means wait until data available.
**return** available data number, 0 if timeout or no data, <0 if error, value is err.Err, can be err::ERR_IO, err::ERR_CANCEL, err::ERR_NOT_OPEN. **throw** err.Exception if fatal error. **static** False **C++ defination code**: ```cpp int available(int timeout 0) ``` #### read item doc **type** func **brief** Recv data from uart **param** **len**: max data length want to receive, default 1.
1 means read data in uart receive buffer.
>0 means read len data want to receive.
other values is invalid.
**timeout**: unit ms, timeout to receive data, default 0.
0 means read data in uart receive buffer and return immediately,
1 means block until read len data,
>0 means block until read len data or timeout.
**return** received data, bytes type.
Attention, you need to delete the returned object yourself in C++. **static** False **C++ defination code**: ```cpp Bytes *read(int len 1, int timeout 0) ``` #### readline item doc **type** func **brief** Read line from uart, that is read until '\\n' or '\\r\\n'. **param** **timeout**: unit ms, timeout to receive data, default 1 means block until read '\\n' or '\\r\\n'.
> 0 means block until read '\\n' or '\\r\\n' or timeout.
**return** received data, bytes type. If timeout will return the current received data despite not read '\\n' or '\\r\\n'.
e.g. If we want to read b'123\\n', but when we only read b'12', timeout, then return b'12'. **static** False **C++ defination code**: ```cpp Bytes *readline(int timeout 1) ```"},"/maixpy/api/maix/peripheral/key.html":{"title":"maix.peripheral.key","content":" title: maix.peripheral.key maix.peripheral.key module > This module is generated from [MaixCDK](https://github.com/sipeed/MaixCDK) > You can use `maix.peripheral.key` to access this module. ## Module No module ## Enum ### Keys item doc **brief** Keys enum, id the same as linux input.h(input event codes.h) **values** **KEY_NONE**:
**KEY_ESC**:
**KEY_OK**:
**KEY_OPTION**:
**KEY_NEXT**:
**KEY_PREV**:
**C++ defination code**: ```cpp enum Keys{ KEY_NONE 0x000, KEY_ESC 0x001, KEY_OK 0x160, KEY_OPTION 0x165, KEY_NEXT 0x197, KEY_PREV 0x19c } ``` ### State item doc **brief** Key state enum **values** **KEY_RELEASED**:
**KEY_PRESSED**:
**C++ defination code**: ```cpp enum State{ KEY_RELEASED 0, KEY_PRESSED 1, } ``` ## Variable ## Function ### add\\_default\\_listener item doc **brief** Add default listener, if you want to exit app when press ok button, you can just call this function.\\nThis function is auto called in MaixPy' startup code, so you don't need to call it in MaixPy.\\nCreate Key object will auto call rm_default_listener() to cancel the default ok button function.\\nWhen ok button pressed, a SIGINT signal will be raise and call app.set_exit_flag(True). **C++ defination code**: ```cpp void add_default_listener() ``` ### rm\\_default\\_listener item doc **brief** Remove default listener, if you want to cancel the default ok button function(exit app), you can just call this function. **C++ defination code**: ```cpp void rm_default_listener() ``` ## Class ### Key item doc **brief** Key input class **C++ defination code**: ```cpp class Key ``` #### \\_\\_init\\_\\_ item doc **type** func **brief** Key Device constructor **param** **callback**: When key triggered and callback is not empty(empty In MaixPy is None, in C++ is nullptr),
callback will be called with args key(key.Keys) and value(key.State).
If set to null, you can get key value by read() function.
This callback called in a standalone thread, so you can block a while in callback, and you should be carefully when operate shared data.
**open**: auto open device in constructor, if false, you need call open() to open device
**static** False **C++ defination code**: ```cpp Key(std::function callback nullptr, bool open true) ``` #### open item doc **type** func **brief** Open(Initialize) key device, if already opened, will close first and then open. **return** err::Err type, err.Err.ERR_NONE means success **static** False **C++ defination code**: ```cpp err::Err open() ``` #### close item doc **type** func **brief** Close key device **return** err::Err type, err.Err.ERR_NONE means success **static** False **C++ defination code**: ```cpp err::Err close() ``` #### is\\_opened item doc **type** func **brief** Check key device is opened **return** bool type, true means opened, false means closed **static** False **C++ defination code**: ```cpp bool is_opened() ``` #### read item doc **type** func **brief** Read key input, and return key and value, if callback is set, DO NOT call this function manually. **return** list type, first is key(maix.key.Keys), second is value(maix.key.State), if no key input, return [0, 0] **throw** If read failed, will throw maix.err.Exception. **static** False **C++ defination code**: ```cpp std::pair read() ```"},"/maixpy/api/maix/peripheral/adc.html":{"title":"maix.peripheral.adc","content":" title: maix.peripheral.adc maix.peripheral.adc module > This module is generated from [MaixCDK](https://github.com/sipeed/MaixCDK) > You can use `maix.peripheral.adc` to access this module. ## Module No module ## Enum ## Variable ### RES\\_BIT\\_8 item doc **brief** 8 bit resolution, supported by the actual hardware **value** **0x1** **readonly** True **C++ defination code**: ```cpp const int RES_BIT_8 0x1 ``` ### RES\\_BIT\\_10 item doc **brief** 10 bit resolution, supported by the actual hardware **value** **0x2** **readonly** True **C++ defination code**: ```cpp const int RES_BIT_10 0x2 ``` ### RES\\_BIT\\_12 item doc **brief** 12 bit resolution, supported by the actual hardware **value** **0x3** **readonly** True **C++ defination code**: ```cpp const int RES_BIT_12 0x3 ``` ### RES\\_BIT\\_16 item doc **brief** 16 bit resolution, supported by the actual hardware **value** **0x4** **readonly** True **C++ defination code**: ```cpp const int RES_BIT_16 0x4 ``` ## Function ## Class ### ADC item doc **brief** Peripheral adc class **C++ defination code**: ```cpp class ADC ``` #### \\_\\_init\\_\\_ item doc **type** func **brief** ADC constructor **param** **pin**: direction [in], adc pin, int type
**resolution**: direction [in], adc resolution. default is 1, means use default resolution
option:
resolution adc.RES_BIT_8, means 8 bit resolution
resolution adc.RES_BIT_10, means 10 bit resolution
resolution adc.RES_BIT_12, means 12 bit resolution
resolution adc.RES_BIT_16, means 16 bit resolution
the default resolution is determined by actual hardware.
**vref**: direction [in], adc refer voltage. default is 1, means use default refer voltage.
the default vref is determined by actual hardware. range: [0.0, 10.0]
**static** False **C++ defination code**: ```cpp ADC(int pin, int resolution 1, float vref 1) ``` #### read item doc **type** func **brief** read adc value **return** adc data, int type
if resolution is 8 bit, return value range is [0, 255]
if resolution is 10 bit, return value range is [0, 1023]
if resolution is 12 bit, return value range is [0, 4095]
if resolution is 16 bit, return value range is [0, 65535] **static** False **C++ defination code**: ```cpp int read() ``` #### read\\_vol item doc **type** func **brief** read adc voltage **return** adc voltage, float type。the range is [0.0, vref] **static** False **C++ defination code**: ```cpp float read_vol() ```"},"/maixpy/api/maix/camera.html":{"title":"maix.camera","content":" title: maix.camera maix.camera module, access camera device and get image from it > This module is generated from [MaixCDK](https://github.com/sipeed/MaixCDK) > You can use `maix.camera` to access this module. ## Module No module ## Enum ## Variable ## Function ### list\\_devices item doc **brief** List all supported camera devices. **return** Returns the path to the camera device. **C++ defination code**: ```cpp std::vector list_devices() ``` ### set\\_regs\\_enable item doc **brief** Enable set camera registers, default is false, if set to true, will not set camera registers, you can manually set registers by write_reg API. **param** **enable**: enable/disable set camera registers
**C++ defination code**: ```cpp void set_regs_enable(bool enable true) ``` ## Class ### Camera item doc **brief** Camera class **C++ defination code**: ```cpp class Camera ``` #### \\_\\_init\\_\\_ item doc **type** func **brief** Construct a new Camera object **param** **width**: camera width, default is 1, means auto, mostly means max width of camera support
**height**: camera height, default is 1, means auto, mostly means max height of camera support
**format**: camera output format, default is image.Format.FMT_RGB888
**device**: camera device path, you can get devices by list_devices method, by default(value is NULL(None in MaixPy)) means the first device
**fps**: camera fps, default is 1, means auto, mostly means max fps of camera support
**buff_num**: camera buffer number, default is 3, means 3 buffer, one used by user, one used for cache the next frame,
more than one buffer will accelerate image read speed, but will cost more memory.
**open**: If true, camera will automatically call open() after creation. default is true.
**static** False **C++ defination code**: ```cpp Camera(int width 1, int height 1, image::Format format image::FMT_RGB888, const char *device nullptr, int fps 1, int buff_num 3, bool open true) ``` #### get\\_ch\\_nums item doc **type** func **brief** Get the number of channels supported by the camera. **return** Returns the maximum number of channels. **static** False **C++ defination code**: ```cpp int get_ch_nums() ``` #### open item doc **type** func **brief** Open camera and run **param** **width**: camera width, default is 1, means auto, mostly means max width of camera support
**height**: camera height, default is 1, means auto, mostly means max height of camera support
**format**: camera output format, default same as the constructor's format argument
**fps**: camera fps, default is 1, means auto, mostly means max fps of camera support
**buff_num**: camera buffer number, default is 3, means 3 buffer, one used by user, one used for cache the next frame,
more than one buffer will accelerate image read speed, but will cost more memory.
**return** error code, err::ERR_NONE means success, others means failed **static** False **C++ defination code**: ```cpp err::Err open(int width 1, int height 1, image::Format format image::FMT_INVALID, int fps 1, int buff_num 1) ``` #### read item doc **type** func **brief** Get one frame image from camera buffer, must call open method before read.\\nIf open method not called, will call it automatically, if open failed, will throw exception!\\nSo call open method before read is recommended. **param** **buff**: buffer to store image data, if buff is nullptr, will alloc memory automatically.
In MaixPy, default to None, you can create a image.Image object, then pass img.data() to buff.
**block**: block read, default is true, means block util read image successfully,
if set to false, will return nullptr if no image in buffer
**return** image::Image object, if failed, return nullptr, you should delete if manually in C++ **static** False **C++ defination code**: ```cpp image::Image *read(void *buff nullptr, size_t buff_size 0, bool block true) ``` #### clear\\_buff item doc **type** func **brief** Clear buff to ensure the next read image is the latest image **static** False **C++ defination code**: ```cpp void clear_buff() ``` #### skip\\_frames item doc **type** func **brief** Read some frames and drop, this is usually used avoid read not stable image when camera just opened. **param** **num**: number of frames to read and drop
**static** False **C++ defination code**: ```cpp void skip_frames(int num) ``` #### close item doc **type** func **brief** Close camera **static** False **C++ defination code**: ```cpp void close() ``` #### add\\_channel item doc **type** func **brief** Add a new channel and return a new Camera object, you can use close() to close this channel. **param** **width**: camera width, default is 1, means auto, mostly means max width of camera support
**height**: camera height, default is 1, means auto, mostly means max height of camera support
**format**: camera output format, default is RGB888
**fps**: camera fps, default is 1, means auto, mostly means max fps of camera support
**buff_num**: camera buffer number, default is 3, means 3 buffer, one used by user, one used for cache the next frame,
more than one buffer will accelerate image read speed, but will cost more memory.
**open**: If true, camera will automatically call open() after creation. default is true.
**return** new Camera object **static** False **C++ defination code**: ```cpp camera::Camera *add_channel(int width 1, int height 1, image::Format format image::FMT_RGB888, int fps 1, int buff_num 3, bool open true) ``` #### is\\_opened item doc **type** func **brief** Check if camera is opened **return** true if camera is opened, false if not **static** False **C++ defination code**: ```cpp bool is_opened() ``` #### is\\_closed item doc **type** func **brief** check camera device is closed or not **return** closed or not, bool type **static** False **C++ defination code**: ```cpp bool is_closed() ``` #### width item doc **type** func **brief** Get camera width **return** camera width **static** False **C++ defination code**: ```cpp int width() ``` #### height item doc **type** func **brief** Get camera height **return** camera height **static** False **C++ defination code**: ```cpp int height() ``` #### fps item doc **type** func **brief** Get camera fps **return** camera fps **static** False **C++ defination code**: ```cpp int fps() ``` #### format item doc **type** func **brief** Get camera output format **return** camera output format, image::Format object **static** False **C++ defination code**: ```cpp image::Format format() ``` #### buff\\_num item doc **type** func **brief** Get camera buffer number **return** camera buffer number **static** False **C++ defination code**: ```cpp int buff_num() ``` #### hmirror item doc **type** func **brief** Get camera horizontal mirror **return** camera horizontal mirror **static** False **C++ defination code**: ```cpp int hmirror(int value 1) ``` #### vflip item doc **type** func **brief** Get camera vertical flip **return** camera vertical flip **static** False **C++ defination code**: ```cpp int vflip(int value 1) ``` #### exposure item doc **type** func **brief** Get camera exposure **return** camera exposure **static** False **C++ defination code**: ```cpp float exposure(int value 1) ``` #### gain item doc **type** func **brief** Get camera gain **return** camera gain **static** False **C++ defination code**: ```cpp float gain(int value 1) ``` #### device item doc **type** func **brief** Get camera device path **return** camera device path **static** False **C++ defination code**: ```cpp std::string device() ``` #### write\\_reg item doc **type** func **brief** Write camera register **param** **addr**: register address
**data**: register data
**bit_width**: register data bit width, default is 8
**return** error code, err::ERR_NONE means success, others means failed **static** False **C++ defination code**: ```cpp err::Err write_reg(int addr, int data, int bit_width 8) ``` #### read\\_reg item doc **type** func **brief** Read camera register **param** **addr**: register address
**bit_width**: register data bit width, default is 8
**return** register data, 1 means failed **static** False **C++ defination code**: ```cpp int read_reg(int addr, int bit_width 8) ``` #### show\\_colorbar item doc **type** func **brief** Camera output color bar image for test **param** **enable**: enable/disable color bar
**return** error code, err::ERR_NONE means success, others means failed **static** False **C++ defination code**: ```cpp err::Err show_colorbar(bool enable) ```"},"/maixpy/api/maix/nn.html":{"title":"maix.nn","content":" title: maix.nn maix.nn module > This module is generated from [MaixCDK](https://github.com/sipeed/MaixCDK) > You can use `maix.nn` to access this module. ## Module module brief [F](./nn/F.html) maix.nn.F module ## Enum ## Variable ## Function ## Class ### YOLOv5 item doc **brief** YOLOv5 class **C++ defination code**: ```cpp class YOLOv5 ``` #### \\_\\_init\\_\\_ item doc **type** func **brief** Constructor of YOLOv5 class **param** **model**: model path, default empty, you can load model later by load function.
**throw** If model arg is not empty and load failed, will throw err::Exception. **static** False **C++ defination code**: ```cpp YOLOv5(const string &model \"\") ``` #### load item doc **type** func **brief** Load model from file **param** **model**: Model path want to load
**return** err::Err **static** False **C++ defination code**: ```cpp err::Err load(const string &model) ``` #### detect item doc **type** func **brief** Detect objects from image **param** **img**: Image want to detect, if image's size not match model input's, will auto resize with fit method.
**conf_th**: Confidence threshold, default 0.5.
**iou_th**: IoU threshold, default 0.45.
**fit**: Resize method, default image.Fit.FIT_CONTAIN.
**throw** If image format not match model input format, will throw err::Exception. **return** Object list. In C++, you should delete it after use. **static** False **C++ defination code**: ```cpp std::vector *detect(image::Image &img, float conf_th 0.5, float iou_th 0.45, maix::image::Fit fit maix::image::FIT_CONTAIN) ``` #### input\\_size item doc **type** func **brief** Get model input size **return** model input size **static** False **C++ defination code**: ```cpp image::Size input_size() ``` #### input\\_width item doc **type** func **brief** Get model input width **return** model input size of width **static** False **C++ defination code**: ```cpp int input_width() ``` #### input\\_height item doc **type** func **brief** Get model input height **return** model input size of height **static** False **C++ defination code**: ```cpp int input_height() ``` #### input\\_format item doc **type** func **brief** Get input image format **return** input image format, image::Format type. **static** False **C++ defination code**: ```cpp image::Format input_format() ``` #### labels item doc **type** var **brief** Labels list **static** False **readonly** False **C++ defination code**: ```cpp std::vector labels ``` #### label\\_path item doc **type** var **brief** Label file path **static** False **readonly** False **C++ defination code**: ```cpp std::string label_path ``` #### mean item doc **type** var **brief** Get mean value, list type **static** False **readonly** False **C++ defination code**: ```cpp std::vector mean ``` #### scale item doc **type** var **brief** Get scale value, list type **static** False **readonly** False **C++ defination code**: ```cpp std::vector scale ``` #### anchors item doc **type** var **brief** Get anchors **static** False **readonly** False **C++ defination code**: ```cpp std::vector anchors ``` ### Classifier item doc **brief** Classifier **C++ defination code**: ```cpp class Classifier ``` #### \\_\\_init\\_\\_ item doc **type** func **brief** Construct a new Classifier object **param** **model**: MUD model path, if empty, will not load model, you can call load() later.
if not empty, will load model and will raise err::Exception if load failed.
**static** False **C++ defination code**: ```cpp Classifier(const string &model \"\") ``` #### load item doc **type** func **brief** Load model from file, model format is .mud,\\nMUD file should contain [extra] section, have key values:\\n model_type: classifier\\n input_type: rgb or bgr\\n mean: 123.675, 116.28, 103.53\\n scale: 0.017124753831663668, 0.01750700280112045, 0.017429193899782137\\n labels: imagenet_classes.txt **param** **model**: MUD model path
**return** error code, if load failed, return error code **static** False **C++ defination code**: ```cpp err::Err load(const string &model) ``` #### classify item doc **type** func **brief** Forward image to model, get result. Only for image input, use classify_raw for tensor input. **param** **img**: image, format should match model input_type, or will raise err.Exception
**softmax**: if true, will do softmax to result, or will return raw value
**throw** If error occurred, will raise err::Exception, you can find reason in log, mostly caused by args error or hardware error. **return** result, a list of (label, score). In C++, you need to delete it after use. **static** False **C++ defination code**: ```cpp std::vector> *classify(image::Image &img, bool softmax true) ``` #### classify\\_raw item doc **type** func **brief** Forward tensor data to model, get result **param** **data**: tensor data, format should match model input_type, or will raise err.Excetion
**softmax**: if true, will do softmax to result, or will return raw value
**throw** If error occurred, will raise err::Exception, you can find reason in log, mostly caused by args error or hardware error. **return** result, a list of (label, score). In C++, you need to delete it after use. **static** False **C++ defination code**: ```cpp std::vector> *classify_raw(tensor::Tensor &data, bool softmax true) ``` #### input\\_size item doc **type** func **brief** Get model input size, only for image input **return** model input size **static** False **C++ defination code**: ```cpp image::Size input_size() ``` #### input\\_width item doc **type** func **brief** Get model input width, only for image input **return** model input size of width **static** False **C++ defination code**: ```cpp int input_width() ``` #### input\\_height item doc **type** func **brief** Get model input height, only for image input **return** model input size of height **static** False **C++ defination code**: ```cpp int input_height() ``` #### input\\_format item doc **type** func **brief** Get input image format, only for image input **return** input image format, image::Format type. **static** False **C++ defination code**: ```cpp image::Format input_format() ``` #### input\\_shape item doc **type** func **brief** Get input shape, if have multiple input, only return first input shape **return** input shape, list type **static** False **C++ defination code**: ```cpp std::vector input_shape() ``` #### labels item doc **type** var **brief** Labels list **static** False **readonly** False **C++ defination code**: ```cpp std::vector labels ``` #### label\\_path item doc **type** var **brief** Label file path **static** False **readonly** False **C++ defination code**: ```cpp std::string label_path ``` #### mean item doc **type** var **brief** Get mean value, list type **static** False **readonly** False **C++ defination code**: ```cpp std::vector mean ``` #### scale item doc **type** var **brief** Get scale value, list type **static** False **readonly** False **C++ defination code**: ```cpp std::vector scale ``` ### MUD item doc **brief** MUD(model universal describe file) class **C++ defination code**: ```cpp class MUD ``` #### \\_\\_init\\_\\_ item doc **type** func **brief** MUD constructor **param** **model_path**: direction [in], model file path, model format can be MUD(model universal describe file) file.
If model_path set, will load model from file, load failed will raise err.Exception.
If model_path not set, you can load model later by load function.
**static** False **C++ defination code**: ```cpp MUD(const char *model_path nullptr) ``` #### load item doc **type** func **brief** Load model from file **param** **model_path**: direction [in], model file path, model format can be MUD(model universal describe file) file.
**return** error code, if load success, return err::ERR_NONE **static** False **C++ defination code**: ```cpp err::Err load(const std::string &model_path) ``` #### type item doc **type** var **brief** Model type, string type **static** False **readonly** False **C++ defination code**: ```cpp std::string type ``` #### items item doc **type** var **brief** Model config items, different model type has different config items **static** False **readonly** False **C++ defination code**: ```cpp std::map> items ``` ### LayerInfo item doc **brief** NN model layer info **C++ defination code**: ```cpp class LayerInfo ``` #### \\_\\_init\\_\\_ item doc **type** func **brief** LayerInfo constructor **param** **name**: direction [in], layer name
**dtype**: direction [in], layer data type
**shape**: direction [in], layer shape
**static** False **C++ defination code**: ```cpp LayerInfo(const std::string &name \"\", tensor::DType dtype tensor::DType::FLOAT32, std::vector shape std::vector()) ``` #### name item doc **type** var **brief** Layer name **static** False **readonly** False **C++ defination code**: ```cpp std::string name ``` #### dtype item doc **type** var **brief** Layer data type **attention** If model is quantized, this is the real quantized data type like int8 float16,
in most scene, inputs and outputs we actually use float32 in API like forward. **static** False **readonly** False **C++ defination code**: ```cpp tensor::DType dtype ``` #### shape item doc **type** var **brief** Layer shape **static** False **readonly** False **C++ defination code**: ```cpp std::vector shape ``` #### to\\_str item doc **type** func **brief** To string **static** False **C++ defination code**: ```cpp std::string to_str() ``` #### \\_\\_str\\_\\_ item doc **type** func **brief** To string **static** False **C++ defination code**: ```cpp std::string __str__() ``` ### NN item doc **brief** Neural network class **C++ defination code**: ```cpp class NN ``` #### \\_\\_init\\_\\_ item doc **type** func **brief** Neural network constructor **param** **model**: direction [in], model file path, model format can be MUD(model universal describe file) file.
If model_path set, will load model from file, load failed will raise err.Exception.
If model_path not set, you can load model later by load function.
**static** False **C++ defination code**: ```cpp NN(const std::string &model \"\") ``` #### load item doc **type** func **brief** Load model from file **param** **model**: direction [in], model file path, model format can be MUD(model universal describe file) file.
**return** error code, if load success, return err::ERR_NONE **static** False **C++ defination code**: ```cpp err::Err load(const std::string &model) ``` #### loaded item doc **type** func **brief** Is model loaded **return** true if model loaded, else false **static** False **C++ defination code**: ```cpp bool loaded() ``` #### inputs\\_info item doc **type** func **brief** Get model input layer info **return** input layer info **static** False **C++ defination code**: ```cpp std::vector inputs_info() ``` #### outputs\\_info item doc **type** func **brief** Get model output layer info **return** output layer info **static** False **C++ defination code**: ```cpp std::vector outputs_info() ``` #### extra\\_info item doc **type** func **brief** Get model extra info define in MUD file **return** extra info, dict type, key value object, attention: key and value are all string type. **static** False **C++ defination code**: ```cpp std::map extra_info() ``` #### forward item doc **type** func **brief** forward run model, get output of model,\\nthis is specially for MaixPy, not efficient, but easy to use in MaixPy **param** **input**: direction [in], input tensor
**return** output tensor. In C++, you should manually delete tensors in return value and return value. **static** False **C++ defination code**: ```cpp tensor::Tensors *forward(tensor::Tensors &inputs) ``` #### forward\\_image item doc **type** func **brief** forward model, param is image **param** **img**: input image
**mean**: mean value, a list type, e.g. [0.485, 0.456, 0.406], default is empty list means not normalize.
**scale**: scale value, a list type, e.g. [1/0.229, 1/0.224, 1/0.225], default is empty list means not normalize.
**fit**: fit mode, if the image size of input not equal to model's input, it will auto resize use this fit method,
default is image.Fit.FIT_FILL for easy coordinate calculation, but for more accurate result, use image.Fit.FIT_CONTAIN is better.
**return** output tensor. In C++, you should manually delete tensors in return value and return value. **static** False **C++ defination code**: ```cpp tensor::Tensors *forward_image(image::Image &img, std::vector mean std::vector(), std::vector scale std::vector(), image::Fit fit image::Fit::FIT_FILL) ``` ### Object item doc **brief** Object for detect result **C++ defination code**: ```cpp class Object ``` #### \\_\\_init\\_\\_ item doc **type** func **brief** Constructor of Object for detect result **param** **x**: left top x
**y**: left top y
**w**: width
**h**: height
**class_id**: class id
**score**: score
**static** False **C++ defination code**: ```cpp Object(int x 0, int y 0, int w 0, int h 0, int class_id 0, float score 0) ``` #### \\_\\_str\\_\\_ item doc **type** func **brief** Object info to string **return** Object info string **static** False **C++ defination code**: ```cpp std::string to_str() ``` #### x item doc **type** var **brief** Object left top coordinate x **static** False **readonly** False **C++ defination code**: ```cpp int x ``` #### y item doc **type** var **brief** Object left top coordinate y **static** False **readonly** False **C++ defination code**: ```cpp int y ``` #### w item doc **type** var **brief** Object width **static** False **readonly** False **C++ defination code**: ```cpp int w ``` #### h item doc **type** var **brief** Object height **static** False **readonly** False **C++ defination code**: ```cpp int h ``` #### class\\_id item doc **type** var **brief** Object class id **static** False **readonly** False **C++ defination code**: ```cpp int class_id ``` #### score item doc **type** var **brief** Object score **static** False **readonly** False **C++ defination code**: ```cpp float score ```"},"/maixpy/api/maix/image.html":{"title":"maix.image","content":" title: maix.image maix.image module, image related definition and functions > This module is generated from [MaixCDK](https://github.com/sipeed/MaixCDK) > You can use `maix.image` to access this module. ## Module No module ## Enum ### Format item doc **brief** Image formats **attention** for developers, update this enum will also need to update the fmt_size in maix_image.cpp **values** **FMT_RGB888**: RGBRGB...RGB, R at the lowest address
**FMT_BGR888**: BGRBGR...BGR, B at the lowest address
**FMT_RGBA8888**: RGBARGBA...RGBA, R at the lowest address
**FMT_BGRA8888**: BGRABGRA...BGRA, B at the lowest address
**FMT_RGB565**:
**FMT_BGR565**:
**FMT_YUV422SP**: YYY...UVUVUV...UVUV
**FMT_YUV422P**: YYY...UUU...VVV
**FMT_YVU420SP**: YYY...VUVUVU...VUVU, NV21
**FMT_YUV420SP**: YYY...UVUVUV...UVUV, NV12
**FMT_YVU420P**: YYY...VVV...UUU
**FMT_YUV420P**: YYY...UUU...VVV
**FMT_GRAYSCALE**:
**FMT_UNCOMPRESSED_MAX**:
**FMT_COMPRESSED_MIN**:
**FMT_JPEG**:
**FMT_PNG**:
**FMT_COMPRESSED_MAX**:
**FMT_INVALID**: format not valid
**C++ defination code**: ```cpp enum Format { FMT_RGB888 0, // RGBRGB...RGB, R at the lowest address FMT_BGR888, // BGRBGR...BGR, B at the lowest address FMT_RGBA8888, // RGBARGBA...RGBA, R at the lowest address FMT_BGRA8888, // BGRABGRA...BGRA, B at the lowest address FMT_RGB565, FMT_BGR565, FMT_YUV422SP, // YYY...UVUVUV...UVUV FMT_YUV422P, // YYY...UUU...VVV FMT_YVU420SP, // YYY...VUVUVU...VUVU, NV21 FMT_YUV420SP, // YYY...UVUVUV...UVUV, NV12 FMT_YVU420P, // YYY...VVV...UUU FMT_YUV420P, // YYY...UUU...VVV FMT_GRAYSCALE, FMT_UNCOMPRESSED_MAX, // compressed format below, not compressed should define upper FMT_COMPRESSED_MIN, FMT_JPEG, FMT_PNG, FMT_COMPRESSED_MAX, FMT_INVALID 0xFF // format not valid } ``` ### Fit item doc **brief** Object fit method **values** **FIT_NONE**: no object fit, keep original
**FIT_FILL**: width to new width, height to new height, may be stretch
**FIT_CONTAIN**: keep aspect ratio, fill blank area with black color
**FIT_COVER**: keep aspect ratio, crop image to fit new size
**FIT_MAX**:
**C++ defination code**: ```cpp enum Fit { FIT_NONE 1, // no object fit, keep original FIT_FILL 0, // width to new width, height to new height, may be stretch FIT_CONTAIN, // keep aspect ratio, fill blank area with black color FIT_COVER, // keep aspect ratio, crop image to fit new size FIT_MAX } ``` ### ResizeMethod item doc **brief** Resize method **values** **NEAREST**:
**BILINEAR**:
**BICUBIC**:
**AREA**:
**LANCZOS**:
**HAMMING**:
**RESIZE_METHOD_MAX**:
**C++ defination code**: ```cpp enum ResizeMethod { NEAREST 0, BILINEAR, BICUBIC, AREA, LANCZOS, HAMMING, RESIZE_METHOD_MAX } ``` ### ApriltagFamilies item doc **brief** Family of apriltag **values** **TAG16H5**:
**TAG25H7**:
**TAG25H9**:
**TAG36H10**:
**TAG36H11**:
**ARTOOLKIT**:
**C++ defination code**: ```cpp enum ApriltagFamilies { TAG16H5 1, TAG25H7 2, TAG25H9 4, TAG36H10 8, TAG36H11 16, ARTOOLKIT 32 } ``` ### TemplateMatch item doc **brief** Template match method **values** **SEARCH_EX**: Exhaustive search
**SEARCH_DS**: Diamond search
**C++ defination code**: ```cpp enum TemplateMatch { SEARCH_EX, // Exhaustive search SEARCH_DS, // Diamond search } ``` ### CornerDetector item doc **brief** CornerDetector class **values** **CORNER_FAST**:
**CORNER_AGAST**:
**C++ defination code**: ```cpp enum CornerDetector { CORNER_FAST, CORNER_AGAST } ``` ### EdgeDetector item doc **brief** EdgeDetector class **values** **EDGE_CANNY**:
**EDGE_SIMPLE**:
**C++ defination code**: ```cpp enum EdgeDetector { EDGE_CANNY, EDGE_SIMPLE, } ``` ## Variable ### fmt\\_size item doc **brief** Image format size in bytes **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** **{
3,
3,
4,
4,
2,
2,
2,
2,
1.5,
1.5,
1.5,
1.5,
1,
0,
0,
0,
0,
0
}** **readonly** True **C++ defination code**: ```cpp const std::vector fmt_size { 3, 3, 4, 4, 2, 2, 2, 2, 1.5, 1.5, 1.5, 1.5, 1, 0, 0, 0, 0, 0 } ``` ### fmt\\_names item doc **brief** Image format string **value** **{
\"RGB888\",
\"BGR888\",
\"RGBA8888\",
\"BGRA8888\",
\"RGB565\",
\"BGR565\",
\"YUV422SP\",
\"YUV422P\",
\"YVU420SP\",
\"YUV420SP\",
\"YVU420P\"
\"YUV420P\",
\"GRAYSCALE\",
\"MAX\"}** **readonly** True **C++ defination code**: ```cpp const std::vector fmt_names { \"RGB888\", \"BGR888\", \"RGBA8888\", \"BGRA8888\", \"RGB565\", \"BGR565\", \"YUV422SP\", \"YUV422P\", \"YVU420SP\", \"YUV420SP\", \"YVU420P\" \"YUV420P\", \"GRAYSCALE\", \"MAX\"} ``` ### COLOR\\_WHITE item doc **brief** Predefined color white **value** **image::Color::from_rgb(255, 255, 255)** **readonly** True **C++ defination code**: ```cpp const image::Color COLOR_WHITE image::Color::from_rgb(255, 255, 255) ``` ### COLOR\\_BLACK item doc **brief** Predefined color black **value** **image::Color::from_rgb(0, 0, 0)** **readonly** True **C++ defination code**: ```cpp const image::Color COLOR_BLACK image::Color::from_rgb(0, 0, 0) ``` ### COLOR\\_RED item doc **brief** Predefined color red **value** **image::Color::from_rgb(255, 0, 0)** **readonly** True **C++ defination code**: ```cpp const image::Color COLOR_RED image::Color::from_rgb(255, 0, 0) ``` ### COLOR\\_GREEN item doc **brief** Predefined color green **value** **image::Color::from_rgb(0, 255, 0)** **readonly** True **C++ defination code**: ```cpp const image::Color COLOR_GREEN image::Color::from_rgb(0, 255, 0) ``` ### COLOR\\_BLUE item doc **brief** Predefined color blue **value** **image::Color::from_rgb(0, 0, 255)** **readonly** True **C++ defination code**: ```cpp const image::Color COLOR_BLUE image::Color::from_rgb(0, 0, 255) ``` ### COLOR\\_YELLOW item doc **brief** Predefined color yellow **value** **image::Color::from_rgb(255, 255, 0)** **readonly** True **C++ defination code**: ```cpp const image::Color COLOR_YELLOW image::Color::from_rgb(255, 255, 0) ``` ### COLOR\\_PURPLE item doc **brief** Predefined color purple **value** **image::Color::from_rgb(143, 0, 255)** **readonly** True **C++ defination code**: ```cpp const image::Color COLOR_PURPLE image::Color::from_rgb(143, 0, 255) ``` ### COLOR\\_ORANGE item doc **brief** Predefined color orange **value** **image::Color::from_rgb(255, 127, 0)** **readonly** True **C++ defination code**: ```cpp const image::Color COLOR_ORANGE image::Color::from_rgb(255, 127, 0) ``` ### COLOR\\_GRAY item doc **brief** Predefined color gray **value** **image::Color::from_rgb(127, 127, 127)** **readonly** True **C++ defination code**: ```cpp const image::Color COLOR_GRAY image::Color::from_rgb(127, 127, 127) ``` ## Function ### load item doc **brief** Load image from file, and convert to Image object **param** **path**: image file path
**format**: read as this format, if not match, will convert to this format, by default is RGB888
**return** Image object **C++ defination code**: ```cpp image::Image *load(const char *path, image::Format format image::Format::FMT_RGB888) ``` ### load\\_font item doc **brief** Load font from file **param** **name**: font name, used to identify font
**path**: font file path, support ttf, ttc, otf
**size**: font size, font height, by default is 16
**return** error code, err::ERR_NONE is ok, other is error **C++ defination code**: ```cpp err::Err load_font(const std::string &name, const char *path, int size 16) ``` ### set\\_default\\_font item doc **brief** Set default font, if not call this method, default is hershey_plain **param** **name**: font name, supported names can be get by fonts()
**return** error code, err::ERR_NONE is ok, other is error **C++ defination code**: ```cpp err::Err set_default_font(const std::string &name) ``` ### fonts item doc **brief** Get all loaded fonts **return** all loaded fonts, string list type **C++ defination code**: ```cpp std::vector *fonts() ``` ### text\\_size item doc **brief** Get text rendered width and height **param** **text**: text content
**scale**: font scale, by default(value is 1)
**thickness**: text thickness(line width), by default(value is 1)
**return** text rendered width and height, [width, height] **C++ defination code**: ```cpp image::Size text_size(std::string text, float scale 1, int thickness 1, const std::string &font \"\") ``` ### cv2image item doc **brief** OpenCV Mat(numpy array object) to Image object **param** **array**: numpy array object, must be a 3 dim or 2 dim continuous array with shape hwc or hw
**return** Image object **C++ defination code**: ```cpp image::Image *cv2image(py::array_t array, bool bgr true, bool copy true) ``` ### image2cv item doc **brief** Image object to OpenCV Mat(numpy array object) **param** **img**: Image object
**return** numpy array object **C++ defination code**: ```cpp py::array_t image2cv(image::Image *img, bool bgr true, bool copy true) ``` ## Class ### Size item doc **brief** Image size type **C++ defination code**: ```cpp class Size ``` #### \\_\\_init\\_\\_ item doc **type** func **brief** Construct a new Size object **param** **width**: image width
**height**: image height
**static** False **C++ defination code**: ```cpp Size(int width 0, int height 0) ``` #### width item doc **type** var **brief** width of size **static** False **readonly** False **C++ defination code**: ```cpp int width ``` #### height item doc **type** var **brief** height of size **static** False **readonly** False **C++ defination code**: ```cpp int height ``` #### \\_\\_getitem\\_\\_ item doc **type** func **brief** Subscript operator **param** **index**: 0 for width, 1 for height
**return** int& width or height **static** False **C++ defination code**: ```cpp int &__getitem__(int index) ``` #### \\_\\_str\\_\\_ item doc **type** func **brief** to string **static** False **C++ defination code**: ```cpp std::string __str__() ``` ### Line item doc **brief** Line class **C++ defination code**: ```cpp class Line ``` #### \\_\\_init\\_\\_ item doc **type** func **brief** Line constructor **param** **x1**: coordinate x1 of the straight line
**y1**: coordinate y1 of the straight line
**x2**: coordinate x2 of the straight line
**y2**: coordinate y2 of the straight line
**magnitude**: magnitude of the straight line after Hough transformation
**theta**: angle of the straight line after Hough transformation
**rho**: p value of the straight line after Hough transformation
**static** False **C++ defination code**: ```cpp Line(int x1, int y1, int x2, int y2, int magnitude 0, int theta 0, int rho 0) ``` #### x1 item doc **type** func **brief** get x1 of line **return** return x1 of the line, type is int **static** False **C++ defination code**: ```cpp int x1() ``` #### y1 item doc **type** func **brief** get y1 of line **return** return y1 of the line, type is int **static** False **C++ defination code**: ```cpp int y1() ``` #### x2 item doc **type** func **brief** get x2 of line **return** return x2 of the line, type is int **static** False **C++ defination code**: ```cpp int x2() ``` #### y2 item doc **type** func **brief** get y2 of line **return** return y2 of the line, type is int **static** False **C++ defination code**: ```cpp int y2() ``` #### length item doc **type** func **brief** get length of line **return** return length of the line, type is int **static** False **C++ defination code**: ```cpp int length() ``` #### magnitude item doc **type** func **brief** get magnitude of the straight line after Hough transformation **return** return magnitude, type is int **static** False **C++ defination code**: ```cpp int magnitude() ``` #### theta item doc **type** func **brief** get angle of the straight line after Hough transformation (0 179 degrees) **return** return angle, type is int **static** False **C++ defination code**: ```cpp int theta() ``` #### rho item doc **type** func **brief** get p value of the straight line after Hough transformation **return** return p value, type is int **static** False **C++ defination code**: ```cpp int rho() ``` ### Rect item doc **brief** Rect class **C++ defination code**: ```cpp class Rect ``` #### \\_\\_init\\_\\_ item doc **type** func **brief** Rect constructor **param** **corners**: corners of rect
**x**: coordinate x of the straight line
**y**: coordinate y of the straight line
**w**: coordinate w of the straight line
**h**: coordinate h of the straight line
**magnitude**: magnitude of the straight line after Hough transformation
**static** False **C++ defination code**: ```cpp Rect(std::vector> &corners, int x, int y, int w, int h, int magnitude 0) ``` #### corners item doc **type** func **brief** get corners of rect **return** return the coordinate of the rect. **static** False **C++ defination code**: ```cpp std::vector> corners() ``` #### rect item doc **type** func **brief** get rectangle of rect **return** return the rectangle of the rect. format is {x, y, w, h}, type is std::vector **static** False **C++ defination code**: ```cpp std::vector rect() ``` #### x item doc **type** func **brief** get x of rect **return** return x of the rect, type is int **static** False **C++ defination code**: ```cpp int x() ``` #### y item doc **type** func **brief** get y of rect **return** return y of the rect, type is int **static** False **C++ defination code**: ```cpp int y() ``` #### w item doc **type** func **brief** get w of rect **return** return w of the rect, type is int **static** False **C++ defination code**: ```cpp int w() ``` #### h item doc **type** func **brief** get h of rect **return** return h of the rect, type is int **static** False **C++ defination code**: ```cpp int h() ``` #### magnitude item doc **type** func **brief** get magnitude of the straight line after Hough transformation **return** return magnitude, type is int **static** False **C++ defination code**: ```cpp int magnitude() ``` ### Circle item doc **brief** circle class **C++ defination code**: ```cpp class Circle ``` #### \\_\\_init\\_\\_ item doc **type** func **brief** Circle constructor **param** **x**: coordinate x of the circle
**y**: coordinate y of the circle
**r**: coordinate r of the circle
**magnitude**: coordinate y2 of the straight line
**static** False **C++ defination code**: ```cpp Circle(int x, int y, int r, int magnitude) ``` #### x item doc **type** func **brief** get x of circle **return** return x of the circle, type is int **static** False **C++ defination code**: ```cpp int x() ``` #### y item doc **type** func **brief** get y of circle **return** return y of the circle, type is int **static** False **C++ defination code**: ```cpp int y() ``` #### r item doc **type** func **brief** get r of circle **return** return r of the circle, type is int **static** False **C++ defination code**: ```cpp int r() ``` #### magnitude item doc **type** func **brief** get magnitude of the circle after Hough transformation **return** return magnitude, type is int **static** False **C++ defination code**: ```cpp int magnitude() ``` ### Blob item doc **brief** Blob class **C++ defination code**: ```cpp class Blob ``` #### \\_\\_init\\_\\_ item doc **type** func **brief** Blob constructor **param** **rect**: blob rect, type is std::vector
**corners**: blob corners, type is std::vector>
**mini_corners**: blob mini_corners, type is std::vector>
**cx**: blob center x, type is float
**cy**: blob center y, type is float
**pixels**: blob pixels, type is int
**rotation**: blob rotation, type is float
**code**: blob code, type is int
**count**: blob count, type is int
**perimeter**: blob perimeter, type is int
**roundness**: blob roundness, type is float
**x_hist_bins**: blob x_hist_bins, type is std::vector
**y_hist_bins**: blob y_hist_bins, type is std::vector
**static** False **C++ defination code**: ```cpp Blob(std::vector &rect, std::vector> &corners, std::vector> &mini_corners,float cx, float cy, int pixels, float rotation, int code, int count, int perimeter, float roundness, std::vector &x_hist_bins, std::vector &y_hist_bins) ``` #### corners item doc **type** func **brief** get blob corners **return** Returns a list of 4 (x,y) tuples of the 4 corners of the object.
(x0, y0)___________(x1, y1)



___________
(x3, y3) (x2, y2)
note: the order of corners may change **static** False **C++ defination code**: ```cpp std::vector> corners() ``` #### mini\\_corners item doc **type** func **brief** get blob mini corners **return** Returns a list of 4 (x,y) tuples of the 4 corners than bound the min area rectangle of the blob.
(x0, y0)___________(x1, y1)



___________
(x3, y3) (x2, y2)
note: the order of corners may change **static** False **C++ defination code**: ```cpp std::vector> mini_corners() ``` #### rect item doc **type** func **brief** get blob rect **return** Returns the center coordinates and width and height of the rectangle. format is (x, y, w, h)
w
(x, y) ___________

h

___________ **static** False **C++ defination code**: ```cpp std::vector rect() ``` #### x item doc **type** func **brief** get blob x of the upper left coordinate **return** Returns the x coordinate of the upper left corner of the rectangle. **static** False **C++ defination code**: ```cpp int x() ``` #### y item doc **type** func **brief** get blob y of the upper left coordinate **return** Returns the y coordinate of the upper left corner of the rectangle. **static** False **C++ defination code**: ```cpp int y() ``` #### w item doc **type** func **brief** get blob width **return** Returns the blob’s bounding box w coordinate **static** False **C++ defination code**: ```cpp int w() ``` #### h item doc **type** func **brief** get blob height **return** Returns the blob’s bounding box h coordinate **static** False **C++ defination code**: ```cpp int h() ``` #### pixels item doc **type** func **brief** get blob pixels **return** Returns the number of pixels that are part of this blob. **static** False **C++ defination code**: ```cpp int pixels() ``` #### cx item doc **type** func **brief** get blob center x **return** Returns the centroid x position of the blob **static** False **C++ defination code**: ```cpp int cx() ``` #### cy item doc **type** func **brief** get blob center y **return** Returns the centroid y position of the blob **static** False **C++ defination code**: ```cpp int cy() ``` #### cxf item doc **type** func **brief** get blob center x **return** Returns the centroid x position of the blob **static** False **C++ defination code**: ```cpp float cxf() ``` #### cyf item doc **type** func **brief** get blob center y **return** Returns the centroid y position of the blob **static** False **C++ defination code**: ```cpp float cyf() ``` #### rotation item doc **type** func **brief** get blob rotation **return** Returns the rotation of the blob in radians (float). If the blob is like a pencil or pen this value will be unique for 0 180 degrees. **static** False **C++ defination code**: ```cpp float rotation() ``` #### rotation\\_rad item doc **type** func **brief** get blob rotation_rad **return** Returns the rotation of the blob in radians **static** False **C++ defination code**: ```cpp float rotation_rad() ``` #### rotation\\_deg item doc **type** func **brief** get blob rotation_deg **return** Returns the rotation of the blob in degrees. **static** False **C++ defination code**: ```cpp int rotation_deg() ``` #### code item doc **type** func **brief** get blob code **return** Returns a 32 bit binary number with a bit set in it for each color threshold that’s part of this blob **static** False **C++ defination code**: ```cpp int code() ``` #### count item doc **type** func **brief** get blob count **return** Returns the number of blobs merged into this blob. **static** False **C++ defination code**: ```cpp int count() ``` #### perimeter item doc **type** func **brief** get blob merge_cnt **return** Returns the number of pixels on this blob’s perimeter. **static** False **C++ defination code**: ```cpp int perimeter() ``` #### roundness item doc **type** func **brief** get blob roundness **return** Returns a value between 0 and 1 representing how round the object is **static** False **C++ defination code**: ```cpp float roundness() ``` #### elongation item doc **type** func **brief** get blob elongation **returnReturns** a value between 0 and 1 representing how long (not round) the object is **static** False **C++ defination code**: ```cpp float elongation() ``` #### area item doc **type** func **brief** get blob area **return** Returns the area of the bounding box around the blob **static** False **C++ defination code**: ```cpp int area() ``` #### density item doc **type** func **brief** get blob density **return** Returns the density ratio of the blob **static** False **C++ defination code**: ```cpp float density() ``` #### extent item doc **type** func **brief** Alias for blob.density() **return** Returns the density ratio of the blob **static** False **C++ defination code**: ```cpp float extent() ``` #### compactness item doc **type** func **brief** get blob compactness **return** Returns the compactness ratio of the blob **static** False **C++ defination code**: ```cpp float compactness() ``` #### solidity item doc **type** func **brief** get blob solidity **return** Returns the solidity ratio of the blob **static** False **C++ defination code**: ```cpp float solidity() ``` #### convexity item doc **type** func **brief** get blob convexity **return** Returns a value between 0 and 1 representing how convex the object is **static** False **C++ defination code**: ```cpp float convexity() ``` #### x\\_hist\\_bins item doc **type** func **brief** get blob x_hist_bins **return** Returns the x_hist_bins of the blob **static** False **C++ defination code**: ```cpp std::vector x_hist_bins() ``` #### y\\_hist\\_bins item doc **type** func **brief** get blob y_hist_bins **return** Returns the y_hist_bins of the blob **static** False **C++ defination code**: ```cpp std::vector y_hist_bins() ``` #### major\\_axis\\_line item doc **type** func **brief** get blob major_axis_line **return** Returns a line tuple (x1, y1, x2, y2) of the minor axis of the blob. **static** False **C++ defination code**: ```cpp std::vector major_axis_line() ``` #### minor\\_axis\\_line item doc **type** func **brief** get blob minor_axis_line **return** Returns a line tuple (x1, y1, x2, y2) of the minor axis of the blob. **static** False **C++ defination code**: ```cpp std::vector minor_axis_line() ``` #### enclosing\\_circle item doc **type** func **brief** get blob enclosing_circle **return** Returns a circle tuple (x, y, r) of the circle that encloses the min area rectangle of a blob. **static** False **C++ defination code**: ```cpp std::vector enclosing_circle() ``` #### enclosed\\_ellipse item doc **type** func **brief** get blob enclosed_ellipse **return** Returns an ellipse tuple (x, y, rx, ry, rotation) of the ellipse that fits inside of the min area rectangle of a blob. **static** False **C++ defination code**: ```cpp std::vector enclosed_ellipse() ``` ### QRCode item doc **brief** QRCode class **C++ defination code**: ```cpp class QRCode ``` #### \\_\\_init\\_\\_ item doc **type** func **brief** QRCode constructor **param** **rect**: rect of corners, type is std::vector
**corners**: corners of QRCode
**payload**: payload of the QRCode
**version**: version of the QRCode
**ecc_level**: ecc_level of the QRCode
**mask**: mask of the QRCode
**data_type**: data_type of the QRCode
**eci**: eci of the QRCode
**static** False **C++ defination code**: ```cpp QRCode(std::vector &rect, std::vector> &corners, std::string &payload, int version, int ecc_level, int mask, int data_type, int eci) ``` #### corners item doc **type** func **brief** get coordinate of QRCode **return** return the coordinate of the QRCode. **static** False **C++ defination code**: ```cpp std::vector> corners() ``` #### rect item doc **type** func **brief** get rectangle of QRCode **return** return the rectangle of the QRCode. format is {x, y, w, h}, type is std::vector **static** False **C++ defination code**: ```cpp std::vector rect() ``` #### x item doc **type** func **brief** get x of QRCode **return** return x of the QRCode, type is int **static** False **C++ defination code**: ```cpp int x() ``` #### y item doc **type** func **brief** get y of QRCode **return** return y of the QRCode, type is int **static** False **C++ defination code**: ```cpp int y() ``` #### w item doc **type** func **brief** get w of QRCode **return** return w of the QRCode, type is int **static** False **C++ defination code**: ```cpp int w() ``` #### h item doc **type** func **brief** get h of QRCode **return** return h of the QRCode, type is int **static** False **C++ defination code**: ```cpp int h() ``` #### payload item doc **type** func **brief** get QRCode payload **return** return area of the QRCode **static** False **C++ defination code**: ```cpp std::string payload() ``` #### version item doc **type** func **brief** get QRCode version **return** return version of the QRCode **static** False **C++ defination code**: ```cpp int version() ``` #### ecc\\_level item doc **type** func **brief** get QRCode error correction level **return** return error correction level of the QRCode **static** False **C++ defination code**: ```cpp int ecc_level() ``` #### mask item doc **type** func **brief** get QRCode mask **return** return mask of the QRCode **static** False **C++ defination code**: ```cpp int mask() ``` #### data\\_type item doc **type** func **brief** get QRCode dataType **return** return mask of the QRCode **static** False **C++ defination code**: ```cpp int data_type() ``` #### eci item doc **type** func **brief** get QRCode eci **return** return data of the QRCode **static** False **C++ defination code**: ```cpp int eci() ``` #### is\\_numeric item doc **type** func **brief** check QRCode is numeric **return** return true if the result type of the QRCode is numeric **static** False **C++ defination code**: ```cpp bool is_numeric() ``` #### is\\_alphanumeric item doc **type** func **brief** check QRCode is alphanumeric **return** return true if the result type of the QRCode is alphanumeric **static** False **C++ defination code**: ```cpp bool is_alphanumeric() ``` #### is\\_binary item doc **type** func **brief** check QRCode is binary **return** return true if the result type of the QRCode is binary **static** False **C++ defination code**: ```cpp bool is_binary() ``` #### is\\_kanji item doc **type** func **brief** check QRCode is kanji **return** return true if the result type of the QRCode is kanji **static** False **C++ defination code**: ```cpp bool is_kanji() ``` ### AprilTag item doc **brief** AprilTag class **C++ defination code**: ```cpp class AprilTag ``` #### \\_\\_init\\_\\_ item doc **type** func **brief** AprilTag constructor **param** **rect**: Inlucdes the top left corner and the width and height of the rectangle. format is {x, y, w, h}, type is std::vector
**corners**: Includes the four corners of the rectangle. format is {{x0, y0}, {x1, y1}, {x2, y2}, {x3, y3}}, type is std::vector>
**id**: The id of the AprilTag
**famliy**: The family of the AprilTag
**centroid_x**: The x coordinate of the center of the AprilTag
**centroid_y**: The y coordinate of the center of the AprilTag
**rotation**: The rotation of the AprilTag
**decision_margin**: The decision_margin of the AprilTag
**hamming**: The hamming of the AprilTag
**goodness**: The goodness of the AprilTag
**x_translation**: The x_translation of the AprilTag
**y_translation**: The y_translation of the AprilTag
**z_translation**: The z_translation of the AprilTag
**x_rotation**: The x_rotation of the AprilTag
**y_rotation**: The y_rotation of the AprilTag
**z_rotation**: The z_rotation of the AprilTag
**static** False **C++ defination code**: ```cpp AprilTag(std::vector &rect, std::vector> &corners, int id, int famliy, float centroid_x, float centroid_y, float rotation, float decision_margin, int hamming, float goodness, float x_translation, float y_translation, float z_translation, float x_rotation, float y_rotation, float z_rotation) ``` #### corners item doc **type** func **brief** get coordinate of AprilTag **return** return the coordinate of the AprilTag. **static** False **C++ defination code**: ```cpp std::vector> corners() ``` #### rect item doc **type** func **brief** get rectangle of AprilTag **return** return the rectangle of the AprilTag. format is {x, y, w, h}, type is std::vector **static** False **C++ defination code**: ```cpp std::vector rect() ``` #### x item doc **type** func **brief** get x of AprilTag **return** return x of the AprilTag, type is int **static** False **C++ defination code**: ```cpp int x() ``` #### y item doc **type** func **brief** get y of AprilTag **return** return y of the AprilTag, type is int **static** False **C++ defination code**: ```cpp int y() ``` #### w item doc **type** func **brief** get w of AprilTag **return** return w of the AprilTag, type is int **static** False **C++ defination code**: ```cpp int w() ``` #### h item doc **type** func **brief** get h of AprilTag **return** return h of the AprilTag, type is int **static** False **C++ defination code**: ```cpp int h() ``` #### id item doc **type** func **brief** get id of AprilTag **return** return id of the AprilTag, type is int **static** False **C++ defination code**: ```cpp int id() ``` #### family item doc **type** func **brief** get family of AprilTag **return** return family of the AprilTag, type is int **static** False **C++ defination code**: ```cpp int family() ``` #### cx item doc **type** func **brief** get cx of AprilTag **return** return cx of the AprilTag, type is int **static** False **C++ defination code**: ```cpp int cx() ``` #### cxf item doc **type** func **brief** get cxf of AprilTag **return** return cxf of the AprilTag, type is float **static** False **C++ defination code**: ```cpp float cxf() ``` #### cy item doc **type** func **brief** get cy of AprilTag **return** return cy of the AprilTag, type is int **static** False **C++ defination code**: ```cpp int cy() ``` #### cyf item doc **type** func **brief** get cyf of AprilTag **return** return cyf of the AprilTag, type is float **static** False **C++ defination code**: ```cpp float cyf() ``` #### rotation item doc **type** func **brief** get rotation of AprilTag **return** return rotation of the AprilTag, type is float **static** False **C++ defination code**: ```cpp float rotation() ``` #### decision\\_margin item doc **type** func **brief** Get decision_margin of AprilTag **return** Returns the quality of the apriltag match (0.0 1.0) where 1.0 is the best. **static** False **C++ defination code**: ```cpp float decision_margin() ``` #### hamming item doc **type** func **brief** get hamming of AprilTag **return** Returns the number of accepted bit errors for this tag.
return 0, means 0 bit errors will be accepted.
1 is TAG25H7, means up to 1 bit error may be accepted
2 is TAG25H9, means up to 3 bit errors may be accepted
3 is TAG36H10, means up to 3 bit errors may be accepted
4 is TAG36H11, means up to 4 bit errors may be accepted
5 is ARTOOLKIT, means 0 bit errors will be accepted **static** False **C++ defination code**: ```cpp int hamming() ``` #### goodness item doc **type** func **brief** get goodness of AprilTag **return** return goodness of the AprilTag, type is float
Note: This value is always 0.0 for now. **static** False **C++ defination code**: ```cpp float goodness() ``` #### x\\_translation item doc **type** func **brief** get x_translation of AprilTag **return** return x_translation of the AprilTag, type is float **static** False **C++ defination code**: ```cpp float x_translation() ``` #### y\\_translation item doc **type** func **brief** get y_translation of AprilTag **return** return y_translation of the AprilTag, type is float **static** False **C++ defination code**: ```cpp float y_translation() ``` #### z\\_translation item doc **type** func **brief** get z_translation of AprilTag **return** return z_translation of the AprilTag, type is float **static** False **C++ defination code**: ```cpp float z_translation() ``` #### x\\_rotation item doc **type** func **brief** get x_rotation of AprilTag **return** return x_rotation of the AprilTag, type is float **static** False **C++ defination code**: ```cpp float x_rotation() ``` #### y\\_rotation item doc **type** func **brief** get y_rotation of AprilTag **return** return y_rotation of the AprilTag, type is float **static** False **C++ defination code**: ```cpp float y_rotation() ``` #### z\\_rotation item doc **type** func **brief** get z_rotation of AprilTag **return** return z_rotation of the AprilTag, type is float **static** False **C++ defination code**: ```cpp float z_rotation() ``` ### DataMatrix item doc **brief** DataMatrix class **C++ defination code**: ```cpp class DataMatrix ``` #### \\_\\_init\\_\\_ item doc **type** func **brief** DataMatrix constructor **param** **rect**: Inlucdes the top left corner and the width and height of the rectangle. format is {x, y, w, h}, type is std::vector
**corners**: Includes the four corners of the rectangle. format is {{x0, y0}, {x1, y1}, {x2, y2}, {x3, y3}}, type is std::vector>
**payload**: The payload of the DataMatrix
**rotation**: The rotation of the DataMatrix
**rows**: The rows of the DataMatrix
**columns**: The columns of the DataMatrix
**capacity**: The capacity of the DataMatrix
**padding**: The padding of the DataMatrix
**static** False **C++ defination code**: ```cpp DataMatrix(std::vector &rect, std::vector> &corners, std::string &payload, float rotation, int rows, int columns, int capacity, int padding) ``` #### corners item doc **type** func **brief** get coordinate of DataMatrix **return** return the coordinate of the DataMatrix. **static** False **C++ defination code**: ```cpp std::vector> corners() ``` #### rect item doc **type** func **brief** get rectangle of DataMatrix **return** return the rectangle of the DataMatrix. format is {x, y, w, h}, type is std::vector **static** False **C++ defination code**: ```cpp std::vector rect() ``` #### x item doc **type** func **brief** get x of DataMatrix **return** return x of the DataMatrix, type is int **static** False **C++ defination code**: ```cpp int x() ``` #### y item doc **type** func **brief** get y of DataMatrix **return** return y of the DataMatrix, type is int **static** False **C++ defination code**: ```cpp int y() ``` #### w item doc **type** func **brief** get w of DataMatrix **return** return w of the DataMatrix, type is int **static** False **C++ defination code**: ```cpp int w() ``` #### h item doc **type** func **brief** get h of DataMatrix **return** return h of the DataMatrix, type is int **static** False **C++ defination code**: ```cpp int h() ``` #### payload item doc **type** func **brief** get payload of DataMatrix **return** return payload of the DataMatrix, type is std::string **static** False **C++ defination code**: ```cpp std::string payload() ``` #### rotation item doc **type** func **brief** get rotation of DataMatrix **return** return rotation of the DataMatrix, type is float **static** False **C++ defination code**: ```cpp float rotation() ``` #### rows item doc **type** func **brief** get rows of DataMatrix **return** return rows of the DataMatrix, type is int **static** False **C++ defination code**: ```cpp int rows() ``` #### columns item doc **type** func **brief** get columns of DataMatrix **return** return columns of the DataMatrix, type is int **static** False **C++ defination code**: ```cpp int columns() ``` #### capacity item doc **type** func **brief** et capacity of DataMatrix **return** returns how many characters could fit in this data matrix, type is int **static** False **C++ defination code**: ```cpp int capacity() ``` #### padding item doc **type** func **brief** get padding of DataMatrix **return** returns how many unused characters are in this data matrix, type is int **static** False **C++ defination code**: ```cpp int padding() ``` ### BarCode item doc **brief** BarCode class **C++ defination code**: ```cpp class BarCode ``` #### \\_\\_init\\_\\_ item doc **type** func **brief** BarCode constructor **param** **rect**: Inlucdes the top left corner and the width and height of the rectangle. format is {x, y, w, h}, type is std::vector
**corners**: Includes the four corners of the rectangle. format is {{x0, y0}, {x1, y1}, {x2, y2}, {x3, y3}}, type is std::vector>
**payload**: The payload of the BarCode
**type**: The type of the BarCode
**rotation**: The rotation of the BarCode
**quality**: The quality of the BarCode
**static** False **C++ defination code**: ```cpp BarCode(std::vector &rect, std::vector> &corners, std::string &payload, int type, float rotation, int quality) ``` #### corners item doc **type** func **brief** get coordinate of BarCode **return** return the coordinate of the BarCode. **static** False **C++ defination code**: ```cpp std::vector> corners() ``` #### rect item doc **type** func **brief** get rectangle of BarCode **return** return the rectangle of the BarCode. format is {x, y, w, h}, type is std::vector **static** False **C++ defination code**: ```cpp std::vector rect() ``` #### x item doc **type** func **brief** get x of BarCode **return** return x of the BarCode, type is int **static** False **C++ defination code**: ```cpp int x() ``` #### y item doc **type** func **brief** get y of BarCode **return** return y of the BarCode, type is int **static** False **C++ defination code**: ```cpp int y() ``` #### w item doc **type** func **brief** get w of BarCode **return** return w of the BarCode, type is int **static** False **C++ defination code**: ```cpp int w() ``` #### h item doc **type** func **brief** get h of BarCode **return** return h of the BarCode, type is int **static** False **C++ defination code**: ```cpp int h() ``` #### payload item doc **type** func **brief** get payload of BarCode **return** return payload of the BarCode, type is std::string **static** False **C++ defination code**: ```cpp std::string payload() ``` #### type item doc **type** func **brief** get type of BarCode **return** return type of the BarCode, type is int **static** False **C++ defination code**: ```cpp int type() ``` #### rotation item doc **type** func **brief** get rotation of BarCode **return** return rotation of the BarCode, type is float. FIXME: always return 0.0 **static** False **C++ defination code**: ```cpp float rotation() ``` #### quality item doc **type** func **brief** get quality of BarCode **return** return quality of the BarCode, type is int **static** False **C++ defination code**: ```cpp int quality() ``` ### Statistics item doc **brief** Statistics class **C++ defination code**: ```cpp class Statistics ``` #### \\_\\_init\\_\\_ item doc **type** func **brief** Statistics constructor **param** **format**: The statistics source image format
**l_statistics**: The statistics of the L channel. format is {mean, median, mode, std_dev, min, max, lq, uq}, type is std::vector
**a_statistics**: The statistics of the A channel. format is {mean, median, mode, std_dev, min, max, lq, uq}, type is std::vector
**b_statistics**: The statistics of the B channel. format is {mean, median, mode, std_dev, min, max, lq, uq}, type is std::vector
**static** False **C++ defination code**: ```cpp Statistics(image::Format format, std::vector &l_statistics, std::vector &a_statistics, std::vector &b_statistics) ``` #### format item doc **type** func **brief** get format of Statistics source image **return** return format of the Statistics source image, type is image::Format **static** False **C++ defination code**: ```cpp image::Format format() ``` #### l\\_mean item doc **type** func **brief** get L channel mean **return** return L channel mean, type is int **static** False **C++ defination code**: ```cpp int l_mean() ``` #### l\\_median item doc **type** func **brief** get L channel median **return** return L channel median, type is int **static** False **C++ defination code**: ```cpp int l_median() ``` #### l\\_mode item doc **type** func **brief** get L channel mode **return** return L channel mode, type is int **static** False **C++ defination code**: ```cpp int l_mode() ``` #### l\\_std\\_dev item doc **type** func **brief** get L channel std_dev **return** return L channel std_dev, type is int **static** False **C++ defination code**: ```cpp int l_std_dev() ``` #### l\\_min item doc **type** func **brief** get L channel min **return** return L channel min, type is int **static** False **C++ defination code**: ```cpp int l_min() ``` #### l\\_max item doc **type** func **brief** get L channel max **return** return L channel max, type is int **static** False **C++ defination code**: ```cpp int l_max() ``` #### l\\_lq item doc **type** func **brief** get L channel lq **return** return L channel lq, type is int **static** False **C++ defination code**: ```cpp int l_lq() ``` #### l\\_uq item doc **type** func **brief** get L channel uq **return** return L channel uq, type is int **static** False **C++ defination code**: ```cpp int l_uq() ``` #### a\\_mean item doc **type** func **brief** get A channel mean **return** return A channel mean, type is int **static** False **C++ defination code**: ```cpp int a_mean() ``` #### a\\_median item doc **type** func **brief** get A channea median **return** return A channel median, type is int **static** False **C++ defination code**: ```cpp int a_median() ``` #### a\\_mode item doc **type** func **brief** get A channel mode **return** return A channel mode, type is int **static** False **C++ defination code**: ```cpp int a_mode() ``` #### a\\_std\\_dev item doc **type** func **brief** get A channel std_dev **return** return A channel std_dev, type is int **static** False **C++ defination code**: ```cpp int a_std_dev() ``` #### a\\_min item doc **type** func **brief** get A channel min **return** return A channel min, type is int **static** False **C++ defination code**: ```cpp int a_min() ``` #### a\\_max item doc **type** func **brief** get A channel max **return** return A channel max, type is int **static** False **C++ defination code**: ```cpp int a_max() ``` #### a\\_lq item doc **type** func **brief** get A channel lq **return** return A channel lq, type is int **static** False **C++ defination code**: ```cpp int a_lq() ``` #### a\\_uq item doc **type** func **brief** get A channel uq **return** return A channel uq, type is int **static** False **C++ defination code**: ```cpp int a_uq() ``` #### b\\_mean item doc **type** func **brief** get B channel mean **return** return B channel mean, type is int **static** False **C++ defination code**: ```cpp int b_mean() ``` #### b\\_median item doc **type** func **brief** get B channea median **return** return B channel median, type is int **static** False **C++ defination code**: ```cpp int b_median() ``` #### b\\_mode item doc **type** func **brief** get B channel mode **return** return B channel mode, type is int **static** False **C++ defination code**: ```cpp int b_mode() ``` #### b\\_std\\_dev item doc **type** func **brief** get B channel std_dev **return** return B channel std_dev, type is int **static** False **C++ defination code**: ```cpp int b_std_dev() ``` #### b\\_min item doc **type** func **brief** get B channel min **return** return B channel min, type is int **static** False **C++ defination code**: ```cpp int b_min() ``` #### b\\_max item doc **type** func **brief** get B channel max **return** return B channel max, type is int **static** False **C++ defination code**: ```cpp int b_max() ``` #### b\\_lq item doc **type** func **brief** get B channel lq **return** return B channel lq, type is int **static** False **C++ defination code**: ```cpp int b_lq() ``` #### b\\_uq item doc **type** func **brief** get B channel uq **return** return B channel uq, type is int **static** False **C++ defination code**: ```cpp int b_uq() ``` ### Displacement item doc **brief** Displacement class **C++ defination code**: ```cpp class Displacement ``` #### \\_\\_init\\_\\_ item doc **type** func **brief** Displacement constructor **param** **x_translation**: The x_translation of the Displacement
**y_translation**: The y_translation of the Displacement
**rotation**: The rotation of the Displacement
**scale**: The scale of the Displacement
**response**: The response of the Displacement
**static** False **C++ defination code**: ```cpp Displacement(float x_translation, float y_translation, float rotation, float scale, float response) ``` #### x\\_translation item doc **type** func **brief** get x_translation of Displacement **return** return x_translation of the Displacement, type is float **static** False **C++ defination code**: ```cpp float x_translation() ``` #### y\\_translation item doc **type** func **brief** get y_translation of Displacement **return** return y_translation of the Displacement, type is float **static** False **C++ defination code**: ```cpp float y_translation() ``` #### rotation item doc **type** func **brief** get rotation of Displacement **return** return rotation of the Displacement, type is float **static** False **C++ defination code**: ```cpp float rotation() ``` #### scale item doc **type** func **brief** get scale of Displacement **return** return scale of the Displacement, type is float **static** False **C++ defination code**: ```cpp float scale() ``` #### response item doc **type** func **brief** get response of Displacement **return** return response of the Displacement, type is float **static** False **C++ defination code**: ```cpp float response() ``` ### LBPKeyPoint item doc **brief** LBPKeyPoint class **C++ defination code**: ```cpp class LBPKeyPoint ``` #### \\_\\_init\\_\\_ item doc **type** func **brief** LBPKeyPoint constructor **param** **data**: The data of the LBPKeyPoint
**static** False **C++ defination code**: ```cpp LBPKeyPoint(std::valarray &data) ``` ### KeyPoint item doc **brief** KeyPoint class **C++ defination code**: ```cpp class KeyPoint ``` #### \\_\\_init\\_\\_ item doc **type** func **brief** KeyPoint constructor **param** **x**: The x of the KeyPoint
**y**: The y of the KeyPoint
**score**: The score of the KeyPoint
**octave**: The octave of the KeyPoint
**angle**: The angle of the KeyPoint
**matched**: The matched of the KeyPoint
**desc**: The desc of the KeyPoint
**static** False **C++ defination code**: ```cpp KeyPoint(uint16_t x, uint16_t y, uint16_t score, uint16_t octave, uint16_t angle, uint16_t matched, std::vector &desc) ``` ### KPTMatch item doc **brief** KPTMatch class **C++ defination code**: ```cpp class KPTMatch ``` #### \\_\\_init\\_\\_ item doc **type** func **brief** KPTMatch constructor **param** **cx**: The cx of the KPTMatch
**cy**: The cy of the KPTMatch
**x**: The x of the KPTMatch
**y**: The y of the KPTMatch
**w**: The w of the KPTMatch
**h**: The h of the KPTMatch
**score**: The score of the KPTMatch
**theta**: The theta of the KPTMatch
**match**: The match of the KPTMatch
**static** False **C++ defination code**: ```cpp KPTMatch(int cx, int cy, int x, int y, int w, int h, int score, int theta, int match) ``` ### ORBKeyPoint item doc **brief** ORBKeyPoint class **C++ defination code**: ```cpp class ORBKeyPoint ``` #### \\_\\_init\\_\\_ item doc **type** func **brief** ORBKeyPoint constructor **param** **data**: The data of the ORBKeyPoint
**threshold**: The threshold of the ORBKeyPoint
**normalized**: The normalized of the ORBKeyPoint
**static** False **C++ defination code**: ```cpp ORBKeyPoint(std::vector &data, int threshold, bool normalized) ``` #### get\\_data item doc **type** func **brief** get data of ORBKeyPoint **return** return data of the ORBKeyPoint, type is std::vector **static** False **C++ defination code**: ```cpp std::vector get_data() ``` ### HaarCascade item doc **brief** HaarCascade class **C++ defination code**: ```cpp class HaarCascade ``` #### \\_\\_init\\_\\_ item doc **type** func **brief** HaarCascade constructor **param** **data**: The data of the HaarCascade
**threshold**: The threshold of the HaarCascade
**normalized**: The normalized of the HaarCascade
**static** False **C++ defination code**: ```cpp HaarCascade() ``` ### Color item doc **brief** Color class **C++ defination code**: ```cpp class Color ``` #### \\_\\_init\\_\\_ item doc **type** func **brief** Color constructor **param** **alpha**: alpha channel, value range: 0 ~ 1
**static** False **C++ defination code**: ```cpp Color(uint8_t ch1, uint8_t ch2 0, uint8_t ch3 0, float alpha 0, image::Format format image::FMT_GRAYSCALE) ``` #### r item doc **type** var **brief** Color red channel **static** False **readonly** False **C++ defination code**: ```cpp uint8_t r ``` #### g item doc **type** var **brief** Color green channel **static** False **readonly** False **C++ defination code**: ```cpp uint8_t g ``` #### b item doc **type** var **brief** Color blue channel **static** False **readonly** False **C++ defination code**: ```cpp uint8_t b ``` #### alpha item doc **type** var **brief** Color alpha channel, value from 0.0 to 1.0, float value **static** False **readonly** False **C++ defination code**: ```cpp float alpha ``` #### gray item doc **type** var **brief** Color gray channel **static** False **readonly** False **C++ defination code**: ```cpp uint8_t gray ``` #### format item doc **type** var **brief** Color format **static** False **readonly** False **C++ defination code**: ```cpp image::Format format ``` #### hex item doc **type** func **brief** Get color's hex value **static** False **C++ defination code**: ```cpp uint32_t hex() ``` #### from\\_rgb item doc **type** func **brief** Create Color object from RGB channels **static** True **C++ defination code**: ```cpp static image::Color from_rgb(uint8_t r, uint8_t g, uint8_t b) ``` #### from\\_bgr item doc **type** func **brief** Create Color object from BGR channels **static** True **C++ defination code**: ```cpp static image::Color from_bgr(uint8_t b, uint8_t g, uint8_t r) ``` #### from\\_gray item doc **type** func **brief** Create Color object from gray channel **static** True **C++ defination code**: ```cpp static image::Color from_gray(uint8_t gray) ``` #### from\\_rgba item doc **type** func **brief** Create Color object from RGBA channels **param** **alpha**: alpha channel, float value, value range: 0 ~ 1
**static** True **C++ defination code**: ```cpp static image::Color from_rgba(uint8_t r, uint8_t g, uint8_t b, float alpha) ``` #### from\\_bgra item doc **type** func **brief** Create Color object from BGRA channels **param** **alpha**: alpha channel, float value, value range: 0 ~ 1
**static** True **C++ defination code**: ```cpp static image::Color from_bgra(uint8_t b, uint8_t g, uint8_t r, float alpha) ``` #### from\\_hex item doc **type** func **brief** Create Color object from hex value **param** **hex**: hex value, e.g. 0x0000FF00, lower address if first channel
**format**: color format, @see image::Format
**static** True **C++ defination code**: ```cpp static image::Color from_hex(uint32_t hex, image::Format &format) ``` #### to\\_format item doc **type** func **brief** Convert Color format **param** **format**: format want to convert to, @see image::Format, only support RGB888, BGR888, RGBA8888, BGRA8888, GRAYSCALE.
**static** False **C++ defination code**: ```cpp void to_format(const image::Format &format) ``` #### to\\_format2 item doc **type** func **brief** Convert color format and return a new Color object **param** **format**: format want to convert to, @see image::Format, only support RGB888, BGR888, RGBA8888, BGRA8888, GRAYSCALE.
**return** new Color object, you need to delete it manually in C++. **static** False **C++ defination code**: ```cpp image::Color *to_format2(const image::Format &format) ``` ### Image item doc **brief** Image class **C++ defination code**: ```cpp class Image ``` #### \\_\\_init\\_\\_ item doc **type** func **brief** Image constructor **param** **width**: image width, should > 0
**height**: image height, should > 0
**format**: image format @see image::Format
**data**: image data, if data is nullptr, will malloc memory for image data
If the image is in jpeg format, data must be filled in.
**data_size**: image data size, only for compressed format like jpeg png, data_size must be filled in.
**copy**: if true and data is not nullptr, will copy data to new buffer, else will use data directly. default is true to avoid memory leak.
**static** False **C++ defination code**: ```cpp Image(int width, int height, image::Format format image::Format::FMT_RGB888, void *data nullptr, int data_size 1, bool copy true) ``` #### format item doc **type** func **brief** Get image's format **see** image.Format **static** False **C++ defination code**: ```cpp image::Format format() ``` #### size item doc **type** func **brief** Get image's size, [width, height] **static** False **C++ defination code**: ```cpp image::Size size() ``` #### data\\_size item doc **type** func **brief** Get image's data size **static** False **C++ defination code**: ```cpp int data_size() ``` #### width item doc **type** func **brief** Get image's width **static** False **C++ defination code**: ```cpp int width() ``` #### height item doc **type** func **brief** Get image's height **static** False **C++ defination code**: ```cpp int height() ``` #### data item doc **type** func **brief** Get image's data pointer.\\nIn MaixPy is capsule object. **static** False **C++ defination code**: ```cpp void *data() ``` #### \\_\\_str\\_\\_ item doc **type** func **brief** To string method **static** False **C++ defination code**: ```cpp std::string __str__() ``` #### to\\_str item doc **type** func **brief** To string method **static** False **C++ defination code**: ```cpp std::string to_str() ``` #### get\\_pixel item doc **type** func **brief** Get pixel of image **param** **x**: pixel's coordinate x. x must less than image's width
**y**: pixel's coordinate y. y must less than image's height
**rgbtuple**: switch return value method. rgbtuple decides whether to split the return or not. default is false.
**return** pixel value,
According to image format and rgbtuple, return different value:
format is FMT_RGB888, rgbtuple is true, return [R, G, B]; rgbtuple is false, return [RGB]
foramt is FMT_BGR888, rgbtuple is true, return [B, G, R]; rgbtuple is false, return [BGR]
format is FMT_GRAYSCALE, return [GRAY]; **static** False **C++ defination code**: ```cpp std::vector get_pixel(int x, int y, bool rgbtuple false) ``` #### set\\_pixel item doc **type** func **brief** Set pixel of image **param** **x**: pixel's coordinate x. x must less than image's width
**y**: pixel's coordinate y. y must less than image's height
**pixel**: pixel value, according to image format and size of pixel, has different operation:
format is FMT_RGB888, pixel size must be 1 or 3, if size is 1, will split pixel[0] to [R, G, B]; if size is 3, will use pixel directly
format is FMT_BGR888, pixel size must be 1 or 3, if size is 1, will split pixel[0] to [B, G, R]; if size is 3, will use pixel directly
format is FMT_GRAYSCALE, pixel size must be 1, will use pixel directly
**return** error code, Err::ERR_NONE is ok, other is error **static** False **C++ defination code**: ```cpp err::Err set_pixel(int x, int y, std::vector pixel) ``` #### to\\_tensor item doc **type** func **brief** Convert Image object to tensor::Tensor object **param** **chw**: if true, the shape of tensor is [C, H, W], else [H, W, C]
**copy**: if true, will alloc memory for tensor data, else will use the memory of Image object
**return** tensor::Tensor object pointer, an allocated tensor object **static** False **C++ defination code**: ```cpp tensor::Tensor *to_tensor(bool chw false, bool copy true) ``` #### to\\_bytes item doc **type** func **brief** Get image's data and convert to array bytes **param** **copy**: if true, will alloc memory and copy data to new buffer,
else will use the memory of Image object, delete bytes object will not affect Image object,
but delete Image object will make bytes object invalid, it may cause program crash !!!!
So use this param carefully.
**return** image's data bytes, need be delete by caller in C++. **static** False **C++ defination code**: ```cpp Bytes *to_bytes(bool copy true) ``` #### to\\_format item doc **type** func **brief** Convert image to specific format **param** **format**: format want to convert to, @see image::Format, only support RGB888, BGR888, RGBA8888, BGRA8888, GRAYSCALE, JPEG.
**return** new image object. Need be delete by caller in C++. **throw** err.Exception, if two images' format not support, **or already the format**, will raise exception **static** False **C++ defination code**: ```cpp image::Image *to_format(const image::Format &format) ``` #### draw\\_image item doc **type** func **brief** Draw image on this image **param** **x**: left top corner of image point's coordinate x
**y**: left top corner of image point's coordinate y
**img**: image object to draw, the caller's channel must < the args' channel,
e.g. caller is RGB888, args is RGBA8888, will throw exception, but caller is RGBA8888, args is RGB888 or RGBA8888 is ok
**return** this image object self **static** False **C++ defination code**: ```cpp image::Image *draw_image(int x, int y, image::Image &img) ``` #### draw\\_rect item doc **type** func **brief** Fill rectangle color to image **param** **x**: left top corner of rectangle point's coordinate x
**y**: left top corner of rectangle point's coordinate y
**w**: rectangle width
**h**: rectangle height
**color**: rectangle color
**thickness**: rectangle thickness(line width), by default(value is 1), 1 means fill rectangle
**return** this image object self **static** False **C++ defination code**: ```cpp image::Image *draw_rect(int x, int y, int w, int h, const image::Color &color, int thickness 1) ``` #### draw\\_line item doc **type** func **brief** Draw line on image **param** **x1**: start point's coordinate x
**y1**: start point's coordinate y
**x2**: end point's coordinate x
**y2**: end point's coordinate y
**color**: line color @see image::Color
**thickness**: line thickness(line width), by default(value is 1)
**return** this image object self **static** False **C++ defination code**: ```cpp image::Image *draw_line(int x1, int y1, int x2, int y2, const image::Color &color, int thickness 1) ``` #### draw\\_circle item doc **type** func **brief** Draw circle on image **param** **x**: circle center point's coordinate x
**y**: circle center point's coordinate y
**radius**: circle radius
**color**: circle color @see image::Color
**thickness**: circle thickness(line width), by default(value is 1), 1 means fill circle
**return** this image object self **static** False **C++ defination code**: ```cpp image::Image *draw_circle(int x, int y, int radius, const image::Color &color, int thickness 1) ``` #### draw\\_ellipse item doc **type** func **brief** Draw ellipse on image **param** **x**: ellipse center point's coordinate x
**y**: ellipse center point's coordinate y
**a**: ellipse major axis length
**b**: ellipse minor axis length
**angle**: ellipse rotation angle
**start_angle**: ellipse start angle
**end_angle**: ellipse end angle
**color**: ellipse color @see image::Color
**thickness**: ellipse thickness(line width), by default(value is 1), 1 means fill ellipse
**return** this image object self **static** False **C++ defination code**: ```cpp image::Image *draw_ellipse(int x, int y, int a, int b, float angle, float start_angle, float end_angle, const image::Color &color, int thickness 1) ``` #### draw\\_text item doc **type** func **brief** Draw text on image **param** **x**: text left top point's coordinate x
**y**: text left top point's coordinate y
**text**: text content
**color**: text color @see image::Color, default is white
**scale**: font scale, by default(value is 1)
**thickness**: text thickness(line width), if negative, the glyph is filled, by default(value is 1)
**wrap**: if true, will auto wrap text to next line if text width > image width, by default(value is true)
**return** this image object self **static** False **C++ defination code**: ```cpp image::Image *draw_text(int x, int y, const std::string &text, const image::Color &color image::COLOR_WHITE, float scale 1, int thickness 1, bool wrap true, int wrap_space 4, const std::string &font \"\") ``` #### draw\\_arrow item doc **type** func **brief** Draw arrow on image **param** **x0**: start coordinate of the arrow x0
**y0**: start coordinate of the arrow y0
**x1**: end coordinate of the arrow x1
**y1**: end coordinate of the arrow y1
**color**: cross color @see image::Color
**thickness**: cross thickness(line width), by default(value is 1)
**return** this image object self **static** False **C++ defination code**: ```cpp image::Image *draw_arrow(int x0, int y0, int x1, int y1, const image::Color &color, int thickness 1) ``` #### draw\\_edges item doc **type** func **brief** Draw edges on image **param** **corners**: edges, [[x0, y0], [x1, y1], [x2, y2], [x3, y3]]
**color**: edges color @see image::Color
**size**: the circle of radius size. TODO: support in the feature
**thickness**: edges thickness(line width), by default(value is 1)
**fill**: if true, will fill edges, by default(value is false)
**return** this image object self **static** False **C++ defination code**: ```cpp image::Image *draw_edges(std::vector> corners, const image::Color &color, int size 0, int thickness 1, bool fill false) ``` #### draw\\_keypoints item doc **type** func **brief** Draw keypoints on image **param** **keypoints**: keypoints, [x, y, rotation_andle_in_degrees], TODO: rotation_andle_in_degrees support in the feature
**color**: keypoints color @see image::Color
**size**: size of keypoints
**thickness**: keypoints thickness(line width), by default(value is 1)
**fill**: if true, will fill keypoints, by default(value is false)
**return** this image object self **static** False **C++ defination code**: ```cpp image::Image *draw_keypoints(std::vector keypoints, const image::Color &color, int size 10, int thickness 1, bool fill false) ``` #### resize item doc **type** func **brief** Resize image, will create a new resized image object **param** **width**: new width, if value is 1, will use height to calculate aspect ratio
**height**: new height, if value is 1, will use width to calculate aspect ratio
**object_fit**: fill, contain, cover, by default is fill
**method**: resize method, by default is bilinear
**return** Always return a new resized image object even size not change, So in C++ you should take care of the return value to avoid memory leak.
And it's better to judge whether the size has changed before calling this function to make the program more efficient.
e.g.
if img >width() ! width img >height() ! height:
img img >resize(width, height); **static** False **C++ defination code**: ```cpp image::Image *resize(int width, int height, image::Fit object_fit image::Fit::FIT_FILL, image::ResizeMethod method image::ResizeMethod::NEAREST) ``` #### affine item doc **type** func **brief** Affine transform image, will create a new transformed image object **param** **src_points**: three source points, [x1, y1, x2, y2, x3, y3]
**dst_points**: three destination points, [x1, y1, x2, y2, x3, y3]
**width**: new width, if value is 1, will use height to calculate aspect ratio
**height**: new height, if value is 1, will use width to calculate aspect ratio
**method**: resize method, by default is bilinear
**return** new transformed image object **static** False **C++ defination code**: ```cpp image::Image *affine(std::vector src_points, std::vector dst_points, int width 1, int height 1, image::ResizeMethod method image::ResizeMethod::BILINEAR) ``` #### copy item doc **type** func **brief** Copy image, will create a new copied image object **return** new copied image object **static** False **C++ defination code**: ```cpp image::Image *copy() ``` #### crop item doc **type** func **brief** Crop image, will create a new cropped image object **param** **x**: left top corner of crop rectangle point's coordinate x
**y**: left top corner of crop rectangle point's coordinate y
**w**: crop rectangle width
**h**: crop rectangle height
**return** new cropped image object **static** False **C++ defination code**: ```cpp image::Image *crop(int x, int y, int w, int h) ``` #### rotate item doc **type** func **brief** Rotate image, will create a new rotated image object **param** **angle**: anti clock wise rotate angle, if angle is 90 or 270, and width or height is 1, will swap width and height, or will throw exception
**width**: new width, if value is 1, will use height to calculate aspect ratio
**height**: new height, if value is 1, will use width to calculate aspect ratio
**method**: resize method, by default is bilinear
**return** new rotated image object **static** False **C++ defination code**: ```cpp image::Image *rotate(float angle, int width 1, int height 1, image::ResizeMethod method image::ResizeMethod::BILINEAR) ``` #### mean\\_pool item doc **type** func **brief** Finds the mean of x_div * y_div squares in the image and returns the modified image composed of the mean of each square. **param** **x_div**: The width of the squares.
**y_div**: The height of the squares.
**copy**: Select whether to return a new image or modify the original image. default is false.
If true, returns a new image composed of the mean of each square; If false, returns the modified image composed of the mean of each square.
**return** Returns the image after the operation is completed. **static** False **C++ defination code**: ```cpp image::Image *mean_pool(int x_div, int y_div, bool copy false) ``` #### midpoint\\_pool item doc **type** func **brief** Finds the midpoint of x_div * y_div squares in the image and returns the modified image composed of the mean of each square. **param** **x_div**: The width of the squares.
**y_div**: The height of the squares.
**bias**: The bias of the midpoint. default is 0.5.
midpoint value is equal to (max * bias + min * (1 bias))
**copy**: Select whether to return a new image or modify the original image. default is false.
If true, returns a new image composed of the midpoint of each square; If false, returns the modified image composed of the midpoint of each square.
**return** Returns the image after the operation is completed. **static** False **C++ defination code**: ```cpp image::Image *midpoint_pool(int x_div, int y_div, double bias 0.5, bool copy false) ``` #### compress item doc **type** func **brief** JPEG compresses the image in place. **param** **quality**: The quality of the compressed image. default is 95.
**return** Returns the compressed JPEG image **static** False **C++ defination code**: ```cpp image::Image *compress(int quality 95) ``` #### clear item doc **type** func **brief** Sets all pixels in the image to zero **param** **mask**: Mask is another image to use as a pixel level mask for the operation. The mask should be an image with just black or white pixels and should be the same size as the image being operated on.
Only pixels set in the mask are modified. default is None.
**return** Returns the image after the operation is completed. **static** False **C++ defination code**: ```cpp image::Image *clear(image::Image *mask nullptr) ``` #### mask\\_rectange item doc **type** func **brief** Zeros a rectangular part of the image. If no arguments are supplied this method zeros the center of the image. **param** **x**: The x coordinate of the top left corner of the rectangle.
**y**: The y coordinate of the top left corner of the rectangle.
**w**: The width of the rectangle.
**h**: The height of the rectangle.
**return** Returns the image after the operation is completed. **static** False **C++ defination code**: ```cpp image::Image *mask_rectange(int x 1, int y 1, int w 1, int h 1) ``` #### mask\\_circle item doc **type** func **brief** Zeros a circular part of the image. If no arguments are supplied this method zeros the center of the image. **param** **x**: The x coordinate of the center of the circle.
**y**: The y coordinate of the center of the circle.
**radius**: The radius of the circle.
**return** Returns the image after the operation is completed. **static** False **C++ defination code**: ```cpp image::Image *mask_circle(int x 1, int y 1, int radius 1) ``` #### mask\\_ellipse item doc **type** func **brief** Zeros a ellipse part of the image. If no arguments are supplied this method zeros the center of the image. **param** **x**: The x coordinate of the center of the ellipse.
**y**: The y coordinate of the center of the ellipse.
**radius_x**: The radius of the ellipse in the x direction.
**radius_y**: The radius of the ellipse in the y direction.
**rotation_angle_in_degrees**: The rotation angle of the ellipse in degrees.
**return** Returns the image after the operation is completed. **static** False **C++ defination code**: ```cpp image::Image *mask_ellipse(int x 1, int y 1, int radius_x 1, int radius_y 1, float rotation_angle_in_degrees 0) ``` #### binary item doc **type** func **brief** Sets all pixels in the image to black or white depending on if the pixel is inside of a threshold in the threshold list thresholds or not. **param** **thresholds**: You can define multiple thresholds.
For GRAYSCALE format, you can use {{Lmin, Lmax}, ...} to define one or more thresholds.
For RGB888 format, you can use {{Lmin, Lmax, Amin, Amax, Bmin, Bmax}, ...} to define one or more thresholds.
Where the upper case L,A,B represent the L,A,B channels of the LAB image format, and min, max represent the minimum and maximum values of the corresponding channels.
**invert**: If true, the thresholds will be inverted before the operation. default is false.
**zero**: If zero is true, the image will be set the pixels within the threshold to 0, other pixels remain unchanged. If zero is false, the image will be set to black or white. default is false.
**mask**: Mask is another image to use as a pixel level mask for the operation. The mask should be an image with just black or white pixels and should be the same size as the image being operated on.
Only pixels set in the mask are modified. default is None.
**to_bitmap**: If true, the image will be converted to a bitmap image before thresholding. default is false. TODO: support in the feature
**copy**: Select whether to return a new image or modify the original image. default is false.
**return** Returns the image after the operation is completed. **static** False **C++ defination code**: ```cpp image::Image *binary(std::vector> thresholds std::vector>(), bool invert false, bool zero false, image::Image *mask nullptr, bool to_bitmap false, bool copy false) ``` #### invert item doc **type** func **brief** Inverts the image in place. **return** Returns the image after the operation is completed **static** False **C++ defination code**: ```cpp image::Image *invert() ``` #### b\\_and item doc **type** func **brief** Performs a bitwise and operation between the image and the other image. **param** **other**: The other image should be an image and should be the same size as the image being operated on. TODO: support path?
**mask**: Mask is another image to use as a pixel level mask for the operation. The mask should be an image with just black or white pixels and should be the same size as the image being operated on.
Only pixels set in the mask are modified. default is None.
**return** Returns the image after the operation is completed. **static** False **C++ defination code**: ```cpp image::Image *b_and(image::Image *other, image::Image *mask nullptr) ``` #### b\\_nand item doc **type** func **brief** Performs a bitwise nand operation between the image and the other image. **param** **other**: The other image should be an image and should be the same size as the image being operated on. TODO: support path?
**mask**: Mask is another image to use as a pixel level mask for the operation. The mask should be an image with just black or white pixels and should be the same size as the image being operated on.
Only pixels set in the mask are modified. default is None.
**return** Returns the image after the operation is completed. **static** False **C++ defination code**: ```cpp image::Image *b_nand(image::Image *other, image::Image *mask nullptr) ``` #### b\\_or item doc **type** func **brief** Performs a bitwise or operation between the image and the other image. **param** **other**: The other image should be an image and should be the same size as the image being operated on. TODO: support path?
**mask**: Mask is another image to use as a pixel level mask for the operation. The mask should be an image with just black or white pixels and should be the same size as the image being operated on.
Only pixels set in the mask are modified. default is None.
**return** Returns the image after the operation is completed. **static** False **C++ defination code**: ```cpp image::Image *b_or(image::Image *other, image::Image *mask nullptr) ``` #### b\\_nor item doc **type** func **brief** Performs a bitwise nor operation between the image and the other image. **param** **other**: The other image should be an image and should be the same size as the image being operated on. TODO: support path?
**mask**: Mask is another image to use as a pixel level mask for the operation. The mask should be an image with just black or white pixels and should be the same size as the image being operated on.
Only pixels set in the mask are modified. default is None.
**return** Returns the image after the operation is completed. **static** False **C++ defination code**: ```cpp image::Image *b_nor(image::Image *other, image::Image *mask nullptr) ``` #### b\\_xor item doc **type** func **brief** Performs a bitwise xor operation between the image and the other image. **param** **other**: The other image should be an image and should be the same size as the image being operated on. TODO: support path?
**mask**: Mask is another image to use as a pixel level mask for the operation. The mask should be an image with just black or white pixels and should be the same size as the image being operated on.
Only pixels set in the mask are modified. default is None.
**return** Returns the image after the operation is completed. **static** False **C++ defination code**: ```cpp image::Image *b_xor(image::Image *other, image::Image *mask nullptr) ``` #### b\\_xnor item doc **type** func **brief** Performs a bitwise xnor operation between the image and the other image. **param** **other**: The other image should be an image and should be the same size as the image being operated on. TODO: support path?
**mask**: Mask is another image to use as a pixel level mask for the operation. The mask should be an image with just black or white pixels and should be the same size as the image being operated on.
Only pixels set in the mask are modified. default is None.
**return** Returns the image after the operation is completed. **static** False **C++ defination code**: ```cpp image::Image *b_xnor(image::Image *other, image::Image *mask nullptr) ``` #### awb item doc **type** func **brief** Performs an auto white balance operation on the image. TODO: support in the feature **param** **max**: if True uses the white patch algorithm instead. default is false.
**return** Returns the image after the operation is completed. **static** False **C++ defination code**: ```cpp image::Image *awb(bool max false) ``` #### ccm item doc **type** func **brief** Multiples the passed (3x3) or (4x3) floating point color correction matrix with the image.\\nnote: Grayscale format is not support. **param** **matrix**: The color correction matrix to use. 3x3 or 4x3 matrix.
Weights may either be positive or negative, and the sum of each column in the 3x3 matrix should generally be 1.
example:
{
1, 0, 0,
0, 1, 0,
0, 0, 1,
}
Where the last row of the 4x3 matrix is an offset per color channel. If you add an offset you may wish to make the
weights sum to less than 1 to account for the offset.
example:
{
1, 0, 0,
0, 1, 0,
0, 0, 1,
0, 0, 0,
}
**return** Returns the image after the operation is completed. **static** False **C++ defination code**: ```cpp image::Image *ccm(std::vector &matrix) ``` #### gamma item doc **type** func **brief** Quickly changes the image gamma, contrast, and brightness. Create a array whose size is usually 255,\\nand use the parameters gamma, contrast, and brightness to calculate the value of the array, and then map the\\nimage pixel value through the value of the array.\\nThe calculation method for array is: array[array_idx] (powf((array_idx / 255.0), (1 / gamma)) * contrast + brightness) * scale,\\n`powf` is a function used to calculate floating point power.\\n`array` is the array used for mapping.\\n`array_idx` is the index of the array, the maximum value is determined according to the image format, usually 255.\\n`scale` is a constant, the value is determined by the image format, usually 255.\\nMapping method:\\nAssume that a pixel value in the image is 128, then map the pixel value to the value of array[128]\\nUsers can adjust the value of the array through the gamma, contrast, and brightness parameters. **param** **gamma**: The contrast gamma greater than 1.0 makes the image darker in a non linear manner while less than 1.0 makes the image brighter. default is 1.0.
**contrast**: The contrast value greater than 1.0 makes the image brighter in a linear manner while less than 1.0 makes the image darker. default is 1.0.
**brightness**: The brightness value greater than 0.0 makes the image brighter in a constant manner while less than 0.0 makes the image darker. default is 0.0.
**return** Returns the image after the operation is completed. **static** False **C++ defination code**: ```cpp image::Image *gamma(double gamma 1.0, double contrast 1.0, double brightness 0.0) ``` #### gamma\\_corr item doc **type** func **brief** Alias for Image.gamma. **param** **gamma**: The contrast gamma greater than 1.0 makes the image darker in a non linear manner while less than 1.0 makes the image brighter. default is 1.0.
**contrast**: The contrast value greater than 1.0 makes the image brighter in a linear manner while less than 1.0 makes the image darker. default is 1.0.
**brightness**: The brightness value greater than 0.0 makes the image brighter in a constant manner while less than 0.0 makes the image darker. default is 0.0.
**return** Returns the image after the operation is completed. **static** False **C++ defination code**: ```cpp image::Image *gamma_corr(double gamma, double contrast 1.0, double brightness 0.0) ``` #### negate item doc **type** func **brief** Flips (numerically inverts) all pixels values in an image **return** Returns the image after the operation is completed. **static** False **C++ defination code**: ```cpp image::Image *negate() ``` #### replace item doc **type** func **brief** Replaces all pixels in the image with the corresponding pixels in the other image. **param** **other**: The other image should be an image and should be the same size as the image being operated on.
**hmirror**: If true, the image will be horizontally mirrored before the operation. default is false.
**vflip**: If true, the image will be vertically flipped before the operation. default is false.
**transpose**: If true, the image can be used to rotate 90 degrees or 270 degrees.
hmirror false, vflip false, transpose false, the image will not be rotated.
hmirror false, vflip true, transpose true, the image will be rotated 90 degrees.
hmirror true, vflip true, transpose false, the image will be rotated 180 degrees.
hmirror true, vflip false, transpose true, the image will be rotated 270 degrees.
**mask**: Mask is another image to use as a pixel level mask for the operation. The mask should be an image with just black or white pixels and should be the same size as the image being operated on.
Only pixels set in the mask are modified. default is None.
**return** Returns the image after the operation is completed. **static** False **C++ defination code**: ```cpp image::Image *replace(image::Image *other nullptr, bool hmirror false, bool vflip false, bool transpose false, image::Image *mask nullptr) ``` #### set item doc **type** func **brief** Alias for Image::replace. **param** **other**: The other image should be an image and should be the same size as the image being operated on.
**hmirror**: If true, the image will be horizontally mirrored before the operation. default is false.
**vflip**: If true, the image will be vertically flipped before the operation. default is false.
**mask**: Mask is another image to use as a pixel level mask for the operation. The mask should be an image with just black or white pixels and should be the same size as the image being operated on.
Only pixels set in the mask are modified. default is None.
**return** Returns the image after the operation is completed. **static** False **C++ defination code**: ```cpp image::Image *set(image::Image *other, bool hmirror false, bool vflip false, bool transpose false, image::Image *mask nullptr) ``` #### add item doc **type** func **brief** Adds the other image to the image. **param** **other**: The other image should be an image and should be the same size as the image being operated on. TODO: support path?
**mask**: Mask is another image to use as a pixel level mask for the operation. The mask should be an image with just black or white pixels and should be the same size as the image being operated on.
Only pixels set in the mask are modified. default is None.
**return** Returns the image after the operation is completed. **static** False **C++ defination code**: ```cpp image::Image *add(image::Image *other, image::Image *mask nullptr) ``` #### sub item doc **type** func **brief** Subtracts the other image from the image. **param** **other**: The other image should be an image and should be the same size as the image being operated on. TODO: support path?
**reverse**: If true, the image will be reversed before the operation. default is false.
**mask**: Mask is another image to use as a pixel level mask for the operation. The mask should be an image with just black or white pixels and should be the same size as the image being operated on.
Only pixels set in the mask are modified. default is None.
**return** Returns the image after the operation is completed. **static** False **C++ defination code**: ```cpp image::Image *sub(image::Image *other, bool reverse false, image::Image *mask nullptr) ``` #### mul item doc **type** func **brief** Multiplies the image by the other image.\\nNote: This method is meant for image blending and cannot multiply the pixels in the image by a scalar like 2. **param** **other**: The other image should be an image and should be the same size as the image being operated on. TODO: support path?
**invert**: If true, the image will be change the multiplication operation from a*b to 1/((1/a)*(1/b)).
In particular, this lightens the image instead of darkening it (e.g. multiply versus burn operations). default is false.
**mask**: Mask is another image to use as a pixel level mask for the operation. The mask should be an image with just black or white pixels and should be the same size as the image being operated on.
Only pixels set in the mask are modified. default is None.
**return** Returns the image after the operation is completed. **static** False **C++ defination code**: ```cpp image::Image *mul(image::Image *other, bool invert false, image::Image *mask nullptr) ``` #### div item doc **type** func **brief** Divides the image by the other image.\\nThis method is meant for image blending and cannot divide the pixels in the image by a scalar like 2. **param** **other**: The other image should be an image and should be the same size as the image being operated on. TODO: support path?
**invert**: If true, the image will be change the division direction from a/b to b/a. default is false.
**mod**: If true, the image will be change the division operation to the modulus operation. default is false.
**mask**: Mask is another image to use as a pixel level mask for the operation. The mask should be an image with just black or white pixels and should be the same size as the image being operated on.
Only pixels set in the mask are modified. default is None.
**return** Returns the image after the operation is completed. **static** False **C++ defination code**: ```cpp image::Image *div(image::Image *other, bool invert false, bool mod false, image::Image *mask nullptr) ``` #### min item doc **type** func **brief** Caculate the minimum of each pixel in the image and the other image. **param** **other**: The other image should be an image and should be the same size as the image being operated on.
**mask**: Mask is another image to use as a pixel level mask for the operation. The mask should be an image with just black or white pixels and should be the same size as the image being operated on.
Only pixels set in the mask are modified. default is None.
**return** Returns the image after the operation is completed. **static** False **C++ defination code**: ```cpp image::Image *min(image::Image *other, image::Image *mask nullptr) ``` #### max item doc **type** func **brief** Caculate the maximum of each pixel in the image and the other image. **param** **other**: The other image should be an image and should be the same size as the image being operated on.
**mask**: Mask is another image to use as a pixel level mask for the operation. The mask should be an image with just black or white pixels and should be the same size as the image being operated on.
Only pixels set in the mask are modified. default is None.
**return** Returns the image after the operation is completed. **static** False **C++ defination code**: ```cpp image::Image *max(image::Image *other, image::Image *mask nullptr) ``` #### difference item doc **type** func **brief** Caculate the absolute value of the difference between each pixel in the image and the other image. **param** **other**: The other image should be an image and should be the same size as the image being operated on.
**mask**: Mask is another image to use as a pixel level mask for the operation. The mask should be an image with just black or white pixels and should be the same size as the image being operated on.
Only pixels set in the mask are modified. default is None.
**return** Returns the image after the operation is completed. **static** False **C++ defination code**: ```cpp image::Image *difference(image::Image *other, image::Image *mask nullptr) ``` #### blend item doc **type** func **brief** Blends the image with the other image.\\nres alpha * this_img / 256 + (256 alpha) * other_img / 256 **param** **other**: The other image should be an image and should be the same size as the image being operated on.
**alpha**: The alpha value of the blend, the value range is [0, 256],default is 128.
**mask**: Mask is another image to use as a pixel level mask for the operation. The mask should be an image with just black or white pixels and should be the same size as the image being operated on.
Only pixels set in the mask are modified. default is None.
**return** Returns the image after the operation is completed. **static** False **C++ defination code**: ```cpp image::Image *blend(image::Image *other, int alpha 128, image::Image *mask nullptr) ``` #### histeq item doc **type** func **brief** Runs the histogram equalization algorithm on the image. **param** **adaptive**: If true, an adaptive histogram equalization method will be run on the image instead which as generally better results than non adaptive histogram qualization but a longer run time. default is false.
**clip_limit**: Provides a way to limit the contrast of the adaptive histogram qualization. Use a small value for this, like 10, to produce good histogram equalized contrast limited images. default is 1.
**mask**: Mask is another image to use as a pixel level mask for the operation. The mask should be an image with just black or white pixels and should be the same size as the image being operated on.
Only pixels set in the mask are modified. default is None.
**return** Returns the image after the operation is completed. **static** False **C++ defination code**: ```cpp image::Image *histeq(bool adaptive false, int clip_limit 1, image::Image *mask nullptr) ``` #### mean item doc **type** func **brief** Standard mean blurring filter using a box filter.\\nThe parameters offset and invert are valid when threshold is True. **param** **size**: Kernel size. The actual kernel size is ((size * 2) + 1) * ((size * 2) + 1). Use 1(3x3 kernel), 2(5x5 kernel).
**threshold**: If true, which will enable adaptive thresholding of the image which sets pixels to white or black based on a pixel’s brightness in relation to the brightness of the kernel of pixels around them.
default is false.
**offset**: The larger the offset value, the lower brightness pixels on the original image will be set to white. default is 0.
**invert**: If true, the image will be inverted before the operation. default is false.
**mask**: Mask is another image to use as a pixel level mask for the operation. The mask should be an image with just black or white pixels and should be the same size as the image being operated on.
Only pixels set in the mask are modified. default is None.
**return** Returns the image after the operation is completed. **static** False **C++ defination code**: ```cpp image::Image *mean(int size, bool threshold false, int offset 0, bool invert false, image::Image *mask nullptr) ``` #### median item doc **type** func **brief** Runs the median filter on the image. The median filter is the best filter for smoothing surfaces while preserving edges but it is very slow. **param** **size**: Kernel size. The actual kernel size is ((size * 2) + 1) * ((size * 2) + 1). Use 1(3x3 kernel), 2(5x5 kernel).
**percentile**: This parameter controls the percentile of the value used in the kernel. You can set this to 0 for a min filter, 0.25 for a lower quartile filter, 0.75 for an upper quartile filter, and 1.0 for a max filter. default is 0.5.
**threshold**: If true, which will enable adaptive thresholding of the image which sets pixels to white or black based on a pixel’s brightness in relation to the brightness of the kernel of pixels around them.
default is false.
**offset**: The larger the offset value, the lower brightness pixels on the original image will be set to white. default is 0.
**invert**: If true, the image will be inverted before the operation. default is false.
**mask**: Mask is another image to use as a pixel level mask for the operation. The mask should be an image with just black or white pixels and should be the same size as the image being operated on.
Only pixels set in the mask are modified. default is None.
**return** Returns the image after the operation is completed. **static** False **C++ defination code**: ```cpp image::Image *median(int size, double percentile 0.5, bool threshold false, int offset 0, bool invert false, image::Image *mask nullptr) ``` #### mode item doc **type** func **brief** Runs the mode filter on the image by replacing each pixel with the mode of their neighbors. **param** **size**: Kernel size. The actual kernel size is ((size * 2) + 1) * ((size * 2) + 1). Use 1(3x3 kernel), 2(5x5 kernel).
**threshold**: If true, which will enable adaptive thresholding of the image which sets pixels to white or black based on a pixel’s brightness in relation to the brightness of the kernel of pixels around them.
default is false.
**offset**: The larger the offset value, the lower brightness pixels on the original image will be set to white. default is 0.
**invert**: If true, the image will be inverted before the operation. default is false.
**mask**: Mask is another image to use as a pixel level mask for the operation. The mask should be an image with just black or white pixels and should be the same size as the image being operated on.
Only pixels set in the mask are modified. default is None.
**return** Returns the image after the operation is completed. **static** False **C++ defination code**: ```cpp image::Image *mode(int size, bool threshold false, int offset 0, bool invert false, image::Image *mask nullptr) ``` #### midpoint item doc **type** func **brief** Runs the midpoint filter on the image.This filter finds the midpoint (max * bias + min * (1 bias)) of each pixel neighborhood in the image. **param** **size**: Kernel size. The actual kernel size is ((size * 2) + 1) * ((size * 2) + 1). Use 1(3x3 kernel), 2(5x5 kernel).
**bias**: The bias of the midpoint. default is 0.5.
**threshold**: If true, which will enable adaptive thresholding of the image which sets pixels to white or black based on a pixel’s brightness in relation to the brightness of the kernel of pixels around them.
default is false.
**offset**: The larger the offset value, the lower brightness pixels on the original image will be set to white. default is 0.
**invert**: If true, the image will be inverted before the operation. default is false.
**mask**: Mask is another image to use as a pixel level mask for the operation. The mask should be an image with just black or white pixels and should be the same size as the image being operated on.
Only pixels set in the mask are modified. default is None.
**return** Returns the image after the operation is completed. **static** False **C++ defination code**: ```cpp image::Image *midpoint(int size, double bias 0.5, bool threshold false, int offset 0, bool invert false, image::Image *mask nullptr) ``` #### morph item doc **type** func **brief** Convolves the image by a filter kernel. This allows you to do general purpose convolutions on an image. **param** **size**: Kernel size. The actual kernel size is ((size * 2) + 1) * ((size * 2) + 1). Use 1(3x3 kernel), 2(5x5 kernel).
**kernel**: The kernel used for convolution. The kernel should be a list of lists of numbers. The kernel should be the same size as the actual kernel size.
**mul**: This parameter is used to multiply the convolved pixel results. default is auto.
**add**: This parameter is the value to be added to each convolution pixel result. default is 0.0.
**threshold**: If true, which will enable adaptive thresholding of the image which sets pixels to white or black based on a pixel’s brightness in relation to the brightness of the kernel of pixels around them.
default is false.
**offset**: The larger the offset value, the lower brightness pixels on the original image will be set to white. default is 0.
**invert**: If true, the image will be inverted before the operation. default is false.
**mask**: Mask is another image to use as a pixel level mask for the operation. The mask should be an image with just black or white pixels and should be the same size as the image being operated on.
Only pixels set in the mask are modified. default is None.
**return** Returns the image after the operation is completed. **static** False **C++ defination code**: ```cpp image::Image *morph(int size, std::vector kernel, float mul 1, float add 0.0, bool threshold false, int offset 0, bool invert false, image::Image *mask nullptr) ``` #### gaussian item doc **type** func **brief** Convolves the image by a smoothing guassian kernel. **param** **size**: Kernel size. The actual kernel size is ((size * 2) + 1) * ((size * 2) + 1). Use 1(3x3 kernel), 2(5x5 kernel).
**unsharp**: If true, this method will perform an unsharp mask operation instead of gaussian filtering operation, this improves the clarity of image edges. default is false.
**mul**: This parameter is used to multiply the convolved pixel results. default is auto.
**add**: This parameter is the value to be added to each convolution pixel result. default is 0.0.
**threshold**: If true, which will enable adaptive thresholding of the image which sets pixels to white or black based on a pixel’s brightness in relation to the brightness of the kernel of pixels around them.
default is false.
**offset**: The larger the offset value, the lower brightness pixels on the original image will be set to white. default is 0.
**invert**: If true, the image will be inverted before the operation. default is false.
**mask**: Mask is another image to use as a pixel level mask for the operation. The mask should be an image with just black or white pixels and should be the same size as the image being operated on.
Only pixels set in the mask are modified. default is None.
**return** Returns the image after the operation is completed. **static** False **C++ defination code**: ```cpp image::Image *gaussian(int size, bool unsharp false, float mul 1, float add 0.0, bool threshold false, int offset 0, bool invert false, image::Image *mask nullptr) ``` #### laplacian item doc **type** func **brief** Convolves the image by a edge detecting laplacian kernel. **param** **size**: Kernel size. The actual kernel size is ((size * 2) + 1) * ((size * 2) + 1). Use 1(3x3 kernel), 2(5x5 kernel).
**sharpen**: If True, this method will sharpen the image instead of an unthresholded edge detection image. Then increase the kernel size to improve image clarity. default is false.
**mul**: This parameter is used to multiply the convolved pixel results. default is auto.
**add**: This parameter is the value to be added to each convolution pixel result. default is 0.0.
**threshold**: If true, which will enable adaptive thresholding of the image which sets pixels to white or black based on a pixel’s brightness in relation to the brightness of the kernel of pixels around them.
default is false.
**offset**: The larger the offset value, the lower brightness pixels on the original image will be set to white. default is 0.
**invert**: If true, the image will be inverted before the operation. default is false.
**mask**: Mask is another image to use as a pixel level mask for the operation. The mask should be an image with just black or white pixels and should be the same size as the image being operated on.
Only pixels set in the mask are modified. default is None.
**return** Returns the image after the operation is completed. **static** False **C++ defination code**: ```cpp image::Image *laplacian(int size, bool sharpen false, float mul 1, float add 0.0, bool threshold false, int offset 0, bool invert false, image::Image *mask nullptr) ``` #### bilateral item doc **type** func **brief** Convolves the image by a bilateral filter. **param** **size**: Kernel size. The actual kernel size is ((size * 2) + 1) * ((size * 2) + 1). Use 1(3x3 kernel), 2(5x5 kernel).
**color_sigma**: Controls how closely colors are matched using the bilateral filter. default is 0.1.
**space_sigma**: Controls how closely pixels space wise are blurred with each other. default is 1.
**threshold**: If true, which will enable adaptive thresholding of the image which sets pixels to white or black based on a pixel’s brightness in relation to the brightness of the kernel of pixels around them.
default is false.
**offset**: The larger the offset value, the lower brightness pixels on the original image will be set to white. default is 0.
**invert**: If true, the image will be inverted before the operation. default is false.
**mask**: Mask is another image to use as a pixel level mask for the operation. The mask should be an image with just black or white pixels and should be the same size as the image being operated on.
Only pixels set in the mask are modified. default is None.
**return** Returns the image after the operation is completed. **static** False **C++ defination code**: ```cpp image::Image *bilateral(int size, double color_sigma 0.1, double space_sigma 1, bool threshold false, int offset 0, bool invert false, image::Image *mask nullptr) ``` #### linpolar item doc **type** func **brief** Re project’s and image from cartessian coordinates to linear polar coordinates. **param** **reverse**: If true, the image will be reverse polar transformed. default is false.
**return** Returns the image after the operation is completed. **static** False **C++ defination code**: ```cpp image::Image *linpolar(bool reverse false) ``` #### logpolar item doc **type** func **brief** Re project’s and image from cartessian coordinates to log polar coordinates. **param** **reverse**: If true, the image will be reverse polar transformed. default is false.
**return** Returns the image after the operation is completed. **static** False **C++ defination code**: ```cpp image::Image *logpolar(bool reverse false) ``` #### lens\\_corr item doc **type** func **brief** Performs a lens correction operation on the image. TODO: support in the feature **param** **strength**: The strength of the lens correction. default is 1.8.
**zoom**: The zoom of the lens correction. default is 1.0.
**x_corr**: The x correction of the lens correction. default is 0.5.
**y_corr**: The y correction of the lens correction. default is 0.5.
**return** Returns the image after the operation is completed. **static** False **C++ defination code**: ```cpp image::Image *lens_corr(double strength 1.8, double zoom 1.0, double x_corr 0.5, double y_corr 0.5) ``` #### rotation\\_corr item doc **type** func **brief** Performs a rotation correction operation on the image. TODO: support in the feature **param** **x_rotation**: The x rotation of the rotation correction. default is 0.0.
**y_rotation**: The y rotation of the rotation correction. default is 0.0.
**z_rotation**: The z rotation of the rotation correction. default is 0.0.
**x_translation**: The x translation of the rotation correction. default is 0.0.
**y_translation**: The y translation of the rotation correction. default is 0.0.
**zoom**: The zoom of the rotation correction. default is 1.0.
**fov**: The fov of the rotation correction. default is 60.0.
**corners**: The corners of the rotation correction. default is None.
**return** Returns the image after the operation is completed. **static** False **C++ defination code**: ```cpp image::Image *rotation_corr(double x_rotation 0.0, double y_rotation 0.0, double z_rotation 0.0, double x_translation 0.0, double y_translation 0.0, double zoom 1.0, double fov 60.0, std::vector corners std::vector()) ``` #### get\\_histogram item doc **type** func **brief** Gets the histogram of the image. **param** **thresholds**: You can define multiple thresholds.
For GRAYSCALE format, you can use {{Lmin, Lmax}, ...} to define one or more thresholds.
For RGB888 format, you can use {{Lmin, Lmax, Amin, Amax, Bmin, Bmax}, ...} to define one or more thresholds.
Where the upper case L,A,B represent the L,A,B channels of the LAB image format, and min, max represent the minimum and maximum values of the corresponding channels.
**invert**: If true, the thresholds will be inverted before the operation. default is false.
**roi**: The region of interest, input in the format of (x, y, w, h), x and y are the coordinates of the upper left corner, w and h are the width and height of roi.
default is None, means whole image.
**bins**: The number of bins to use for the histogram.
In GRAYSCALE format, setting range is [2, 256], default is 100.
In rgb888 format, setting range is [2, 100], default is 100.
**l_bins**: The number of bins to use for the l channel of the histogram. Only valid in RGB888 format.
If an invalid value is set, bins will be used instead. The setting range is [2, 100], default is 100.
**a_bins**: The number of bins to use for the a channel of the histogram.
Only valid in RGB888 format.The setting range is [2, 256], default is 256.
**b_bins**: The number of bins to use for the b channel of the histogram.
Only valid in RGB888 format. The setting range is [2, 256], default is 256.
**difference**: difference may be set to an image object to cause this method to operate on the difference image between the current image and the difference image object.
default is None.
**return** Returns the histogram of the image **static** False **C++ defination code**: ```cpp std::map> get_histogram(std::vector> thresholds std::vector>(), bool invert false, std::vector roi std::vector(), int bins 1, int l_bins 100, int a_bins 256, int b_bins 256, image::Image *difference nullptr) ``` #### get\\_statistics item doc **type** func **brief** Gets the statistics of the image. TODO: support in the feature **param** **thresholds**: You can define multiple thresholds.
For GRAYSCALE format, you can use {{Lmin, Lmax}, ...} to define one or more thresholds.
For RGB888 format, you can use {{Lmin, Lmax, Amin, Amax, Bmin, Bmax}, ...} to define one or more thresholds.
Where the upper case L,A,B represent the L,A,B channels of the LAB image format, and min, max represent the minimum and maximum values of the corresponding channels.
**invert**: If true, the image will be inverted before the operation. default is false.
**roi**: The region of interest, input in the format of (x, y, w, h), x and y are the coordinates of the upper left corner, w and h are the width and height of roi.
default is None, means whole image.
**bins**: The number of bins to use for the statistics. default is 1.
**l_bins**: The number of bins to use for the l channel of the statistics. default is 1.
**a_bins**: The number of bins to use for the a channel of the statistics. default is 1.
**b_bins**: The number of bins to use for the b channel of the statistics. default is 1.
**difference**: The difference image to use for the statistics. default is None.
**return** Returns the statistics of the image **static** False **C++ defination code**: ```cpp image::Statistics get_statistics(std::vector> thresholds std::vector>(), bool invert false, std::vector roi std::vector(), int bins 1, int l_bins 1, int a_bins 1, int b_bins 1, image::Image *difference nullptr) ``` #### get\\_regression item doc **type** func **brief** Gets the regression of the image. **param** **thresholds**: You can define multiple thresholds.
For GRAYSCALE format, you can use {{Lmin, Lmax}, ...} to define one or more thresholds.
For RGB888 format, you can use {{Lmin, Lmax, Amin, Amax, Bmin, Bmax}, ...} to define one or more thresholds.
Where the upper case L,A,B represent the L,A,B channels of the LAB image format, and min, max represent the minimum and maximum values of the corresponding channels.
**invert**: If true, the image will be inverted before the operation. default is false.
**roi**: The region of interest, input in the format of (x, y, w, h), x and y are the coordinates of the upper left corner, w and h are the width and height of roi.
default is None, means whole image.
**x_stride**: The x stride to use for the regression. default is 2.
**y_stride**: The y stride to use for the regression. default is 1.
**area_threshold**: The area threshold to use for the regression. default is 10.
**pixels_threshold**: The pixels threshold to use for the regression. default is 10.
**robust**: If true, the regression will be robust. default is false.
**return** Returns the regression of the image **static** False **C++ defination code**: ```cpp std::vector get_regression(std::vector> thresholds std::vector>(), bool invert false, std::vector roi std::vector(), int x_stride 2, int y_stride 1, int area_threshold 10, int pixels_threshold 10, bool robust false) ``` #### save item doc **type** func **brief** Save image to file **param** **path**: file path
**quality**: image quality, by default(value is 95), support jpeg and png format
**return** error code, err::ERR_NONE is ok, other is error **static** False **C++ defination code**: ```cpp err::Err save(const char *path, int quality 95) ``` #### flood\\_fill item doc **type** func **brief** Flood fills a region of the image starting from location x, y. **param** **x**: The x coordinate of the seed point.
**y**: The y coordinate of the seed point.
**seed_threshold**: The seed_threshold value controls how different any pixel in the fill area may be from the original starting pixel. default is 0.05.
**floating_threshold**: The floating_threshold value controls how different any pixel in the fill area may be from any neighbor pixels. default is 0.05.
**color**: The color to fill the region with. default is white.
**invert**: If true, the image will be inverted before the operation. default is false.
**clear_background**: If true, the background will be cleared before the operation. default is false.
**mask**: Mask is another image to use as a pixel level mask for the operation. The mask should be an image with just black or white pixels and should be the same size as the image being operated on.
Only pixels set in the mask are modified. default is None. FIXME: the mask image works abnormally
**return** Returns the image after the operation is completed. **static** False **C++ defination code**: ```cpp image::Image *flood_fill(int x, int y, float seed_threshold 0.05, float floating_threshold 0.05, image::Color color image::COLOR_WHITE, bool invert false, bool clear_background false, image::Image *mask nullptr) ``` #### erode item doc **type** func **brief** Erodes the image in place. **param** **size**: Kernel size. The actual kernel size is ((size * 2) + 1) * ((size * 2) + 1). Use 1(3x3 kernel), 2(5x5 kernel).
**threshold**: The number of pixels in the kernel that are not 0. If it is less than or equal to the threshold, set the center pixel to black. default is (kernel_size 1).
**mask**: Mask is another image to use as a pixel level mask for the operation. The mask should be an image with just black or white pixels and should be the same size as the image being operated on.
Only pixels set in the mask are modified. default is None.
**return** Returns the image after the operation is completed. **static** False **C++ defination code**: ```cpp image::Image *erode(int size, int threshold 1, image::Image *mask nullptr) ``` #### dilate item doc **type** func **brief** Dilates the image in place. **param** **size**: Kernel size. The actual kernel size is ((size * 2) + 1) * ((size * 2) + 1). Use 1(3x3 kernel), 2(5x5 kernel).
**threshold**: The number of pixels in the kernel that are not 0. If it is greater than or equal to the threshold, set the center pixel to white. default is 0.
**mask**: Mask is another image to use as a pixel level mask for the operation. The mask should be an image with just black or white pixels and should be the same size as the image being operated on.
Only pixels set in the mask are modified. default is None.
**return** Returns the image after the operation is completed. **static** False **C++ defination code**: ```cpp image::Image *dilate(int size, int threshold 0, image::Image *mask nullptr) ``` #### open item doc **type** func **brief** Performs erosion and dilation on an image in order. **param** **size**: Kernel size. The actual kernel size is ((size * 2) + 1) * ((size * 2) + 1). Use 1(3x3 kernel), 2(5x5 kernel).
**threshold**: As the threshold for erosion and dilation, the actual threshold for erosion is (kernel_size 1 threshold), the actual threshold for dialation is threshold. default is 0.
**mask**: Mask is another image to use as a pixel level mask for the operation. The mask should be an image with just black or white pixels and should be the same size as the image being operated on.
Only pixels set in the mask are modified. default is None.
**return** Returns the image after the operation is completed. **static** False **C++ defination code**: ```cpp image::Image *open(int size, int threshold 0, image::Image *mask nullptr) ``` #### close item doc **type** func **brief** Performs dilation and erosion on an image in order. **param** **size**: Kernel size. The actual kernel size is ((size * 2) + 1) * ((size * 2) + 1). Use 1(3x3 kernel), 2(5x5 kernel).
**threshold**: As the threshold for erosion and dilation, the actual threshold for erosion is (kernel_size 1 threshold), the actual threshold for dialation is threshold. default is 0.
**mask**: Mask is another image to use as a pixel level mask for the operation. The mask should be an image with just black or white pixels and should be the same size as the image being operated on.
Only pixels set in the mask are modified. default is None.
**return** Returns the image after the operation is completed. **static** False **C++ defination code**: ```cpp image::Image *close(int size, int threshold 0, image::Image *mask nullptr) ``` #### top\\_hat item doc **type** func **brief** Returns the image difference of the image and Image.open()’ed image. **param** **size**: Kernel size. The actual kernel size is ((size * 2) + 1) * ((size * 2) + 1). Use 1(3x3 kernel), 2(5x5 kernel).
**threshold**: As the threshold for open method. default is 0.
**mask**: Mask is another image to use as a pixel level mask for the operation. The mask should be an image with just black or white pixels and should be the same size as the image being operated on.
Only pixels set in the mask are modified. default is None.
**return** Returns the image after the operation is completed. **static** False **C++ defination code**: ```cpp image::Image *top_hat(int size, int threshold 0, image::Image *mask nullptr) ``` #### black\\_hat item doc **type** func **brief** Returns the image difference of the image and Image.close()’ed image. **param** **size**: Kernel size. The actual kernel size is ((size * 2) + 1) * ((size * 2) + 1). Use 1(3x3 kernel), 2(5x5 kernel).
**threshold**: As the threshold for close method. default is 0.
**mask**: Mask is another image to use as a pixel level mask for the operation. The mask should be an image with just black or white pixels and should be the same size as the image being operated on.
Only pixels set in the mask are modified. default is None.
**return** Returns the image after the operation is completed. **static** False **C++ defination code**: ```cpp image::Image *black_hat(int size, int threshold 0, image::Image *mask nullptr) ``` #### find\\_blobs item doc **type** func **brief** Finds all blobs in the image and returns a list of image.Blob class which describe each Blob.\\nPlease see the image.Blob object more more information. **param** **thresholds**: You can define multiple thresholds.
For GRAYSCALE format, you can use {{Lmin, Lmax}, ...} to define one or more thresholds.
For RGB888 format, you can use {{Lmin, Lmax, Amin, Amax, Bmin, Bmax}, ...} to define one or more thresholds.
Where the upper case L,A,B represent the L,A,B channels of the LAB image format, and min, max represent the minimum and maximum values of the corresponding channels.
**invert**: if true, will invert thresholds before find blobs, default is false
**roi**: The region of interest, input in the format of (x, y, w, h), x and y are the coordinates of the upper left corner, w and h are the width and height of roi.
default is None, means whole image.
**x_stride**: x stride is the number of x pixels to skip when doing the hough transform. default is 2
**y_stride**: y_stride is the number of y pixels to skip when doing the hough transform. default is 1
**area_threshold**: area threshold, if the blob area is smaller than area_threshold, the blob is not returned, default is 10
**pixels_threshold**: pixels threshold, if the blob pixels is smaller than area_threshold, the blob is not returned,, default is 10.
when x_stride and y_stride is equal to 1, pixels_threshold is equivalent to area_threshold
**merge**: if True merges all not filtered out blobs whos bounding rectangles intersect each other. default is false
**margin**: margin can be used to increase or decrease the size of the bounding rectangles for blobs during the intersection test.
For example, with a margin of 1 blobs whos bounding rectangles are 1 pixel away from each other will be merged. default is 0
**x_hist_bins_max**: if set to non zero populates a histogram buffer in each blob object with an x_histogram projection of all columns in the object. This value then sets the number of bins for that projection.
**y_hist_bins_max**: if set to non zero populates a histogram buffer in each blob object with an y_histogram projection of all rows in the object. This value then sets the number of bins for that projection.
**return** Return the blob when found blobs, format is (blob1, blob2, ...), you can use blob class methods to do more operations. **static** False **C++ defination code**: ```cpp std::vector find_blobs(std::vector> thresholds std::vector>(), bool invert false, std::vector roi std::vector(), int x_stride 2, int y_stride 1, int area_threshold 10, int pixels_threshold 10, bool merge false, int margin 0, int x_hist_bins_max 0, int y_hist_bins_max 0) ``` #### find\\_lines item doc **type** func **brief** Find lines in image **param** **roi**: The region of interest, input in the format of (x, y, w, h), x and y are the coordinates of the upper left corner, w and h are the width and height of roi.
default is None, means whole image.
**x_stride**: x stride is the number of x pixels to skip when doing the hough transform. default is 2
**y_stride**: y_stride is the number of y pixels to skip when doing the hough transform. default is 1
**threshold**: threshold threshold controls what lines are detected from the hough transform. Only lines with a magnitude greater than or equal to threshold are returned.
The right value of threshold for your application is image dependent. default is 1000.
**theta_margin**: theta_margin controls the merging of detected lines. default is 25.
**rho_margin**: rho_margin controls the merging of detected lines. default is 25.
**return** Return the line when found lines, format is (line1, line2, ...), you can use line class methods to do more operations **static** False **C++ defination code**: ```cpp std::vector find_lines(std::vector roi std::vector(), int x_stride 2, int y_stride 1, double threshold 1000, double theta_margin 25, double rho_margin 25) ``` #### find\\_line\\_segments item doc **type** func **brief** Finds all line segments in the image. **param** **roi**: The region of interest, input in the format of (x, y, w, h), x and y are the coordinates of the upper left corner, w and h are the width and height of roi.
default is None, means whole image.
**merge_distance**: The maximum distance between two lines to merge them. default is 0.
**max_theta_difference**: The maximum difference between two lines to merge them. default is 15.
**return** Return the line when found lines, format is (line1, line2, ...), you can use line class methods to do more operations **static** False **C++ defination code**: ```cpp std::vector find_line_segments(std::vector roi std::vector(), int merge_distance 0, int max_theta_difference 15) ``` #### find\\_circles item doc **type** func **brief** Find circles in image **param** **roi**: The region of interest, input in the format of (x, y, w, h), x and y are the coordinates of the upper left corner, w and h are the width and height of roi.
default is None, means whole image.
**x_stride**: x stride is the number of x pixels to skip when doing the hough transform. default is 2
**y_stride**: y_stride is the number of y pixels to skip when doing the hough transform. default is 1
**threshold**: threshold controls what circles are detected from the hough transform. Only circles with a magnitude greater than or equal to threshold are returned.
The right value of threshold for your application is image dependent.
**x_margin**: x_margin controls the merging of detected circles. Circles which are x_margin, y_margin, and r_margin pixels apart are merged. default is 10
**y_margin**: y_margin controls the merging of detected circles. Circles which are x_margin, y_margin, and r_margin pixels apart are merged. default is 10
**r_margin**: r_margin controls the merging of detected circles. Circles which are x_margin, y_margin, and r_margin pixels apart are merged. default is 10
**r_min**: r_min controls the minimum circle radius detected. Increase this to speed up the algorithm. default is 2
**r_max**: r_max controls the maximum circle radius detected. Decrease this to speed up the algorithm. default is min(roi.w / 2, roi.h / 2)
**r_step**: r_step controls how to step the radius detection by. default is 2.
**return** Return the circle when found circles, format is (circle1, circle2, ...), you can use circle class methods to do more operations **static** False **C++ defination code**: ```cpp std::vector find_circles(std::vector roi std::vector(), int x_stride 2, int y_stride 1, int threshold 2000, int x_margin 10, int y_margin 10, int r_margin 10, int r_min 2, int r_max 1, int r_step 2) ``` #### find\\_rects item doc **type** func **brief** Finds all rects in the image. **param** **roi**: The region of interest, input in the format of (x, y, w, h), x and y are the coordinates of the upper left corner, w and h are the width and height of roi.
default is None, means whole image.
**threshold**: The threshold to use for the rects. default is 10000.
**return** Returns the rects of the image **static** False **C++ defination code**: ```cpp std::vector find_rects(std::vector roi std::vector(), int threshold 10000) ``` #### find\\_qrcodes item doc **type** func **brief** Finds all qrcodes in the image. **param** **roi**: The region of interest, input in the format of (x, y, w, h), x and y are the coordinates of the upper left corner, w and h are the width and height of roi.
default is None, means whole image.
**return** Returns the qrcodes of the image **static** False **C++ defination code**: ```cpp std::vector find_qrcodes(std::vector roi std::vector()) ``` #### find\\_apriltags item doc **type** func **brief** Finds all apriltags in the image. **param** **roi**: The region of interest, input in the format of (x, y, w, h), x and y are the coordinates of the upper left corner, w and h are the width and height of roi.
default is None, means whole image.
**families**: The families to use for the apriltags. default is TAG36H11.
**fx**: The camera X focal length in pixels, default is 1.
**fy**: The camera Y focal length in pixels, default is 1.
**cx**: The camera X center in pixels, default is image.width / 2.
**cy**: The camera Y center in pixels, default is image.height / 2.
**return** Returns the apriltags of the image **static** False **C++ defination code**: ```cpp std::vector find_apriltags(std::vector roi std::vector(), image::ApriltagFamilies families image::ApriltagFamilies::TAG36H11, float fx 1, float fy 1, int cx 1, int cy 1) ``` #### find\\_datamatrices item doc **type** func **brief** Finds all datamatrices in the image. **param** **roi**: The region of interest, input in the format of (x, y, w, h), x and y are the coordinates of the upper left corner, w and h are the width and height of roi.
default is None, means whole image.
**effort**: Controls how much time to spend trying to find data matrix matches. default is 200.
**return** Returns the datamatrices of the image **static** False **C++ defination code**: ```cpp std::vector find_datamatrices(std::vector roi std::vector(), int effort 200) ``` #### find\\_barcodes item doc **type** func **brief** Finds all barcodes in the image. **param** **roi**: The region of interest, input in the format of (x, y, w, h), x and y are the coordinates of the upper left corner, w and h are the width and height of roi.
default is None, means whole image.
**return** Returns the barcodes of the image **static** False **C++ defination code**: ```cpp std::vector find_barcodes(std::vector roi std::vector()) ``` #### find\\_displacement item doc **type** func **brief** Finds the displacement between the image and the template. TODO: support in the feature\\nnote: this method must be used on power of 2 image sizes **param** **template_image**: The template image.
**roi**: The region of interest, input in the format of (x, y, w, h), x and y are the coordinates of the upper left corner, w and h are the width and height of roi.
default is None, means whole image.
**template_roi**: The region of interest rectangle (x, y, w, h) to work in. If not specified, it is equal to the image rectangle.
**logpolar**: If true, it will instead find rotation and scale changes between the two images. default is false.
**return** Returns the displacement of the image **static** False **C++ defination code**: ```cpp image::Displacement find_displacement(image::Image &template_image, std::vector roi std::vector(), std::vector template_roi std::vector(), bool logpolar false) ``` #### find\\_template item doc **type** func **brief** Finds the template in the image. **param** **template_image**: The template image.
**threshold**: Threshold is floating point number (0.0 1.0) where a higher threshold prevents false positives while lowering the detection rate while a lower threshold does the opposite.
**roi**: The region of interest, input in the format of (x, y, w, h), x and y are the coordinates of the upper left corner, w and h are the width and height of roi.
default is None, means whole image. Only valid in SEARCH_EX mode.
**step**: The step size to use for the template. default is 2. Only valid in SEARCH_EX mode
**search**: The search method to use for the template. default is SEARCH_EX.
**return** Returns a bounding box tuple (x, y, w, h) for the matching location otherwise None. **static** False **C++ defination code**: ```cpp std::vector find_template(image::Image &template_image, float threshold, std::vector roi std::vector(), int step 2, image::TemplateMatch search image::TemplateMatch::SEARCH_EX) ``` #### find\\_features item doc **type** func **brief** Finds the features in the image. TODO: support in the feature **param** **cascade**: The cascade to use for the features. default is CASCADE_FRONTALFACE_ALT.
**threshold**: The threshold to use for the features. default is 0.5.
**scale**: The scale to use for the features. default is 1.5.
**roi**: The region of interest, input in the format of (x, y, w, h), x and y are the coordinates of the upper left corner, w and h are the width and height of roi.
default is None, means whole image.
**return** Returns the features of the image **static** False **C++ defination code**: ```cpp std::vector find_features(int cascade, float threshold 0.5, float scale 1.5, std::vector roi std::vector()) ``` #### find\\_lbp item doc **type** func **brief** Finds the lbp in the image. TODO: support in the feature. **param** **roi**: The region of interest, input in the format of (x, y, w, h), x and y are the coordinates of the upper left corner, w and h are the width and height of roi.
default is None, means whole image.
**return** Returns the lbp of the image **static** False **C++ defination code**: ```cpp image::LBPKeyPoint find_lbp(std::vector roi std::vector()) ``` #### find\\_keypoints item doc **type** func **brief** Finds the keypoints in the image. TODO: support in the feature. **param** **roi**: The region of interest, input in the format of (x, y, w, h), x and y are the coordinates of the upper left corner, w and h are the width and height of roi.
default is None, means whole image.
**threshold**: The threshold to use for the keypoints. default is 20.
**normalized**: If true, the image will be normalized before the operation. default is false.
**scale_factor**: The scale factor to use for the keypoints. default is 1.5.
**max_keypoints**: The maximum number of keypoints to use for the keypoints. default is 100.
**corner_detector**: The corner detector to use for the keypoints. default is CORNER_AGAST.
**return** Returns the keypoints of the image **static** False **C++ defination code**: ```cpp image::ORBKeyPoint find_keypoints(std::vector roi std::vector(), int threshold 20, bool normalized false, float scale_factor 1.5, int max_keypoints 100, image::CornerDetector corner_detector image::CornerDetector::CORNER_AGAST) ``` #### find\\_edges item doc **type** func **brief** Finds the edges in the image. **param** **edge_type**: The edge type to use for the edges. default is EDGE_CANNY.
**roi**: The region of interest, input in the format of (x, y, w, h), x and y are the coordinates of the upper left corner, w and h are the width and height of roi.
default is None, means whole image.
**threshold**: The threshold to use for the edges. default is 20.
**return** Returns the edges of the image **static** False **C++ defination code**: ```cpp image::Image* find_edges(image::EdgeDetector edge_type, std::vector roi std::vector(), std::vector threshold std::vector({100, 200})) ``` #### find\\_hog item doc **type** func **brief** Finds the hog in the image. TODO: support in the feature **param** **roi**: The region of interest, input in the format of (x, y, w, h), x and y are the coordinates of the upper left corner, w and h are the width and height of roi.
default is None, means whole image.
**size**: The size to use for the hog. default is 8.
**return** Returns the hog of the image **static** False **C++ defination code**: ```cpp image::Image* find_hog(std::vector roi std::vector(), int size 8) ``` #### match\\_lbp\\_descriptor item doc **type** func **brief** Matches the lbp descriptor of the image. TODO: support in the feature **param** **desc1**: The descriptor to use for the match.
**desc2**: The descriptor to use for the match.
**return** Returns the match of the image **static** False **C++ defination code**: ```cpp int match_lbp_descriptor(image::LBPKeyPoint &desc1, image::LBPKeyPoint &desc2) ``` #### match\\_orb\\_descriptor item doc **type** func **brief** Matches the orb descriptor of the image. TODO: support in the feature **param** **desc1**: The descriptor to use for the match.
**desc2**: The descriptor to use for the match.
**threshold**: The threshold to use for the match. default is 95.
**filter_outliers**: If true, the image will be filter_outliers before the operation. default is false.
**return** Returns the match of the image **static** False **C++ defination code**: ```cpp image::KPTMatch match_orb_descriptor(image::ORBKeyPoint &desc1, image::ORBKeyPoint &desc2, int threshold 95, bool filter_outliers false) ```"}} \ No newline at end of file diff --git a/maixpy/static/search_index/index_1.json b/maixpy/static/search_index/index_1.json index 118a8b6..da18cec 100644 --- a/maixpy/static/search_index/index_1.json +++ b/maixpy/static/search_index/index_1.json @@ -1 +1 @@ -{"/maixpy/doc/zh/basic/app.html":{"title":"应用开发和应用商店","content":" title: 应用开发和应用商店 ## 应用生态简介 为了让开发板做到开箱即用,以及方便用户无门槛地使用,以及方便开发者分享自己的有趣应用,并且能有有效的渠道获取到反馈甚至是收益,我们推出了一个简易的应用框架,包括: * **[应用商店](https://maixhub.com/app)**: 开发者上传分享应用,用户无需开发直接下载使用,开发者可以获取到一定的现金收益(来自 MaixHub 官方以及用户打赏)。 * **出厂内置大量应用**: 官方提供了一些常用的应用,比如找色块、AI 物体检测追踪、找二维码、人脸识别等等,用户可以直接使用,也可以作为串口模块直接使用。 * **MaixPy + MaixCDK** 软件开发包:使用 [MaixPy](https://github.com/sipeed/maixpy) 或者 [MaixCDK](https://github.com/sipeed/MaixCDK) 可以用 Python 或者 C/C++ 语言快速开发嵌入式 AI 视觉听觉应用,超高效率实现你的有趣想法。 * **MaixVision** 配套电脑端开发工具: 全新的电脑端代码开发工具,快速上手、调试、运行、上传代码、安装应用到设备,一键式开发,甚至支持图像化积木式编程,小学生也能轻松上手。 大家可以多多关注应用商店,也可以在应用商店中分享自己的应用,大家一起共建活跃的社区。"},"/maixpy/doc/zh/basic/os.html":{"title":"升级和烧录系统","content":" title: 升级和烧录系统 ## 介绍 如果你购买了官方(Sipeed)的带 TF 卡的套餐,一般来说出厂已经烧录好了系统,可以跳过这一步直接使用。 但是为了防止出厂烧录的系统版本过旧,强烈建议先按照教程升级到最新的系统。 ## 如何确认系统是否需要升级 * 在开机后的功能选择界面,点击`设置`,然后点击`设备信息`,可以看到系统的版本号。 * 到[系统发布历史页面]()查看最新系统的版本号以及更新日志,如果在你的版本后有重要更新,建议升级。 > 如果最新系统和当前系统对比只是 MaixPy 固件的常规更新,也可以不升级,在 `设置` 中的 `更新 MaixPy` 中单独更新 `MaixPy` 即可。 ## 获得最新系统 在 [MaixPy 发布页面](https://github.com/sipeed/MaixPy/releases) 找到最新的系统镜像文件,比如`maixcam_os_20240401_maixpy_v4.1.0.xz`。 备用地址: * [Sourceforge](https://sourceforge.net/projects/maixpy/files/) ## 烧录系统到 MaixCAM 参考 [MaixCAM 系统烧录](https://wiki.sipeed.com/hardware/zh/maixcam/os.html) 教程。"},"/maixpy/doc/zh/basic/python_pkgs.html":{"title":"添加额外的 Python 软件包","content":" title: 添加额外的 Python 软件包 ## 简介 MaixPy 基于 Python 语言,提供了大量方便嵌入式应用开发的功能和 API,除此之外,你也可以使用其它的 Python 包来扩展功能。 ## 安装额外的 Python 包 > 注意可能不是所有 Python 包都支持,一般只支持纯 Python 包,不支持 C 扩展包, C 扩展包可能需要你手动在电脑交叉编译(比较复杂,这里就不介绍了)。 ### 方法一: 使用 Python 代码来安装 在 MaixVision 中使用 Python 代码来安装你需要的包,比如: ```python import os os.system(\"pip install 包名\") ``` 要更新一个包,可以使用: ```python import os os.system(\"pip install upgrade 包名\") ``` ### 方法二: 终端使用 pip 命令安装 使用[Linux 基础](./linux_basic.html)中介绍的终端使用方法,使用 `pip install 包名` 安装你需要的包。"},"/maixpy/doc/zh/basic/app_usage.html":{"title":"应用使用说明","content":" title: 应用使用说明 开机后会自动进入应用选择界面,内置各种应用均发布在 [MaixHub 应用商店](https://maixhub.com/app), 可以在这里找到对应应用的介绍和使用说明。 上手用得比较多的是 `设置 > 语言`, 以及 `设置 > WiFi`,`应用商店`应用可以用来升级和安装应用,连接上可以连接互联网的 WiFi 后即可在[MaixHub 应用商店](https://maixhub.com/app)扫码安装应用。 另外,你编写的应用也可以上传到[MaixHub 应用商店](https://maixhub.com/app)分享给其他人使用,质量合格和优秀的应用都会得到官方红包打赏,优秀应用也会得到大家的赞同和支持。 无论是小到一个采集传感器的数据小应用还是功能复杂的应用,让我们一起来创造更多有趣的东西吧!"},"/maixpy/doc/zh/basic/maixpy_upgrade.html":{"title":"更新 MaixPy","content":" title: 更新 MaixPy 有两种方法,如果第一次上手使用,为了降低难度,可以直接使用出厂 TF 卡自带的 MaixPy 固件尝试,以后再考虑更新。 不过因为不知道你拿到手的是什么时候出厂的 TF 卡,所以建议都更新一下系统。 ## 直接更新系统 按照 [升级和烧录系统](./os.html) 中的操作升级到最新的系统,里面就包含了最新的 MaixPy 固件。 ## 只更新 MaixPy 固件 在 [MaixPy 仓库 release 页面](https://github.com/sipeed/MaixPy/releases) 看到最新的版本信息和更新日志,其中包含了 MaixPy 固件信息,以及对应版本使用的系统信息。 如果不想更新系统(因为一般系统变动不大,可以看 MaixPy 更新日志中是否有系统改动相关,再决定是否更新系统),则可以只更新 MaixPy 固件。 * 在设置中设置 WiFi, 让系统联网。 * 点击设置应用中的 `更新 MaixPy` 进行更新。 > 如果你会使用终端, 也可以在终端中使用 `pip install MaixPy U` 来更新 MaixPy。"},"/maixpy/doc/zh/pro/compile_os.html":{"title":"","content":""},"/maixpy/doc/zh/modules/thermal_cam.html":{"title":"","content":""},"/maixpy/doc/zh/modules/tof.html":{"title":"","content":""},"/maixpy/doc/zh/faq.html":{"title":"MaixPy FAQ(常见问题)","content":" title: MaixPy FAQ(常见问题) 此页面列出了 MaixPy 相关的常见问题和解决方案,如果你遇到了问题,请先在这里找寻答案。 如果这个页面找不到答案,可以到 [MaixHub 讨论版块](https://maixhub.com/discussion) 将问题的详细步骤发贴提问。 ## MaixPy v4 和 v1 v3 有什么区别? * MaixPy v4 使用 Python 语言,是吸取了 v1 v3 经验的集大成之作,有更好的配套软件和生态,更多的功能,更简单的使用方式和更完善的文档;硬件有很大提升的同时加个和另外两者的硬件价格想当甚至更便宜;另外也做了兼容 K210 的使用体验和 API,方便用户从 v1 快速迁移到 v4。 * v1 使用了 Micropython 语言,有很多局限性,比如第三方库支持有限;同时受限于 Maix I (K210) 的硬件性能,内存不够用,AI 模型支持有限,很多编解码不支持硬件加速等缺点。 * v3 也是使用了 Python 语言,基于 Maix II Dock (v831) 硬件,硬件 AI 模型支持有限,而且全志的基础生态不够开放,API 也不够完善,此版本仅作为 Maix II Dock (v831)上面使用,不会继续更新。 ## MaixPy 目前只支持 MaixCAM 吗,用其它同款芯片的板子行不行? MaixPy 目前仅支持 MaixCAM 系列板子,其它同款芯片的板子也不支持(包括 Sipeed 的同款芯片板子 比如 LicheeRV Nano),强烈不建议尝试,导致设备损坏(比如冒烟烧屏等)后果自负。 未来 Sipeed 出的 Maix 系列的产品都将继续得到 MaixPy 支持,目前如果 MaixCAM 有什么无法满足的需求,可以到 [MaixHub 讨论版块](https://maixhub.com/discussion) 提出需求或者发送邮件到 support@sipeed.com. ## 可以用除了官方搭配的摄像头或者屏幕以外的自己的摄像头或者屏幕吗? 不建议这样操作,除非你有够丰富的软硬件知识和经验,否则可能导致设备损坏。 官方搭配的配件对应的软硬件是调教过的,表现效果是最好的,上手即可使用,其它配件可能接口不同,驱动不同,软件不同,需要自己去调教,这是一个非常复杂的过程,不建议尝试。 当然,如果你是大佬,我们也欢迎你提交 PR! ## MaixVision 无法搜索到设备? * 确保设备通过 Type C 数据线连接到电脑,设备处于开机状态并且进入了功能选择界面。 * 确保设备驱动已经安装: * Windows 下可以在`设备管理器`中查看是否有 USB 虚拟网卡设备,如果有感叹号则是去动没有安装好,按照[快速开始](./index.html) 中的方法安装驱动即可。 * Linux 下可以通过`ifconfig`或者`ip addr`查看是否有`usb0`设备或者`lsusb`查看所有 USB 设备。 Linux 已经自带去动,所以识别不到检查硬件连接,设备系统是否是最新,以及设备是否已经正常启动即可。 * Mac OS 同 Linux 方法。"},"/maixpy/doc/zh/basic/python.html":{"title":"Python 基础知识","content":" title: Python 基础知识 MaixPy 的教程文档里面就不涉及具体的 Python 语法教程了,因为 Python 的教程实在是太多了,都做得很好,这里只介绍需要学什么,方向和线路指导即可。 ## Python 简介 Python 是一门解释性、面向对象、动态类型的高级编程语言。 * 解释性:不需要编译,直接运行,优点是开发快速,缺点是因为每次运行都要解释一遍代码,运行速度慢一点点,但是往往瓶颈还是开发者写的代码而不是语言本身。 * 面向对象:支持面向对象编程,可以定义类和对象,相比面向过程语言,更容易组织代码。更多自行搜索。 * 动态类型:变量不需要声明类型,可以直接赋值,类型会根据赋值自动确定,这样可以减少代码量,但是也容易出现类型错误,需要开发者自己注意。 总之,对于没有接触过 Python 的开发者来说,Python 非常容易上手,有大量现成的库,开发者群体巨大,开发应用周期短,非常值得学习! ## Python 环境安装 你可以按照你学习的 Python 教程在电脑上安装 Python; 也可以在 MaixVisioin 上连接设备后使用 MaixVision 编程然后在开发板运行。 ## 使用 MaixPy 需要的 Python 基础有哪些? * Python 的基本概念。 * 面向对象编程的基本概念。 * Python 的基本语法,包括: * tab 缩进对齐语法 * 变量、函数、类、对象、注释等 * 控制语句比如 if、for、while 等等 * 模块和导入模块 * 基本数据类型比如 int、float、str、list、dict、tuple 等等 * bytes 和 str 的区别和转换 * 异常处理,try except * 常用的内置函数,比如 print、open、len、range 等等 * 常用的内置模块,比如 os、sys、time、random、math 等等 掌握以上的基础知识就可以顺畅使用 MaixPy 编程了,配合后面的教程和例程,在不懂的时候查询搜索引擎或者官方文档,或者问 ChatGPT 就能顺利完成开发。 ## 对于已经有一门面向对象编程语言经验的开发者 如果你已经会一门面向对象语言比如 C++/Java/C# 等等,那只需要快速浏览一下 Python 的语法,就可以开始使用了。 比如 [菜鸟教程](https://www.runoob.com/python3/python3 tutorial.html) 或者 [Python 官方教程](https://docs.python.org/3/tutorial/index.html)。 或者个人开发者的博客,比如 [哇!是 Python](https://neucrack.com/p/59)。 ## 对于没有面向对象编程经验但是有 C 语言经验的开发者 如果只学了 C,缺乏对面向对象的理解,那么可以先学习一下面向对象的概念,然后再学习 Python,也是比较快的,可以自行搜索视频教程入门。 跟着视频教程入门之后可以看看文档教程,比如 [菜鸟教程](https://www.runoob.com/python3/python3 tutorial.html) 或者 [Python 官方教程](https://docs.python.org/3/tutorial/index.html) 就可以开动了! 在学了入门知识后,就可以按照 MaixPy 的文档和例程开始使用 MaixPy 编程了。 ## 对于编程新手 如果你从未接触过编程,那么你需要重头开始学习 Python,Python 作为入门语言也是比较合适的,具体可以搜一搜视频教程。 在学会了基础语法后,就能按照例程使用 MaixPy 编程了。"},"/maixpy/doc/zh/basic/linux_basic.html":{"title":"Linux 基础知识","content":" title: Linux 基础知识 ## 简介 本章内容对于刚入门的同学来说,可以先跳过此章节,在学会 MaixPy 基础开发后再来学习也是可以的。 最新的 MaixPy 支持的 MaixCAM 硬件支持跑 Linux 系统,所以 MaixPy 底层都是基于 Linux 系统进行开发的。 虽然 Sipeed 开发的 MaixPy 已经为开发者们做了很多工作,即使不知道 Linux 系统知识也能愉快使用,但是以防在某些情况下需要一些底层操作,以及方便未接触过 Linux 的开发者学习,这里写一些 Linux 基础知识。 ## 为什么需要 Linux 系统 具体的原因大家可以自行查阅,这里用通俗的看起来不太专业的话语简单举几个例子方便初学者理解: * 在单片机中,我们的程序是一个死循环程序,用上 Linux 后我们可以同时跑很多程序,每个程序看起来都独立在同时运行,每个程序具体怎么执行的由操作系统实现。 * 基于 Linux 的开发者众多,需要功能和驱动可以很方便地找到,不需要自己再实现一遍。 * 基于 Linux 配套的软件工具丰富,可以很方便地进行开发和调试,比如在本教程没有提到的一些 Linux 通用工具理论上也是可以使用的。 ## 文件系统 什么是文件系统? * 就像电脑的文件系统一样,Linux 上会将硬件磁盘用文件系统进行管理,这样我们可以很方便地向磁盘读写数据。 * 对于学过单片机没有接触过文件系统开发的同学来讲,可以理解为我们有一个 Flash 或者 TF 卡,我们可以通过 API 读写 Flash 存取数据,断电后也能保存数据,但是 Flash 具有读写寿命,我们往往需要写一套程序去保证 Flash 读写寿命,而文件系统就可以理解成这样一套成熟的程序,文件系统帮我们完成了具体如何管理 Flash 空间和读写,我们只需调用文件系统的 API 即可,大大减少了我们的开发工作量并且用成熟的程序保证了稳定性和安全性。 ## 在电脑和设备(开发板)之间传输文件 既然设备有 Linux 和文件系统,那我们怎么发送文件到设备呢? 对于 MaixPy 我们配套了 MaixVision, 在后面的版本也会支持文件管理功能,在此之前可以用下面的方法: 这里我们主要介绍通过网络传输的方式,其它方式可自行探索`传输文件到 Linux`: * 确保设备和电脑连接到了同一个局域网,比如: * MaixCAM 的 USB 口连接到电脑会创建一个虚拟网卡,在电脑端的设备管理器就能看到,设备的 IP 可以在设备的`设置 >设备信息`中看到设备名和 IP。 * 也可以在设备`设置 >WiFi`中连接到和电脑相同的局域网。 * 电脑使用 SCP 或者 SFTP 协议传输文件到设备,具体的软件有很多,具体的软件和使用方法可以自行搜索,比如: * 在 Windows 上可以使用 WinSCP 或者 FileZilla,或者 scp 命令等。 * 在 Linux 上可以使用 FileZilla 或者 scp 命令 等。 * 在 Mac 上可以使用 FileZilla 或者 scp 命令 等。 ## 终端和命令行 终端就是通过`终端`这个软件与 Linux 系统进行通信和操作的工具,类似于 Windows 的`cmd`或者`PowerShell`。 比如我们可以在电脑的 Window 系统中的 powershell 或者 Linux系统中的 终端 工具中输入`ssh root@maixcam xxxx.local` 这里具体的名字在设备的`设置 >设备信息`中可以看到,这样我们就可以通过终端连接到设备了(用户名和密码都是`root`)。 然后我们通过输入命令来操作设备,比如`ls`命令可以列出设备文件系统中当前目录下的文件, `cd` 用来切换当前所在的目录(就像电脑文件管理中点击文件夹切换目录一样), ```shell cd / # 切换到根目录 ls # 显示当前目录(根目录)下的所有文件 ``` 然后会显示类似下面的内容: ```shell bin lib media root tmp boot lib64 mnt run usr dev linuxrc opt sbin var etc lost+found proc sys ``` 更多命令学习请自行搜索`Linux 命令行使用教程`,这里只是为了让初学者知道基本概念,这样有开发者提到时可以知道是什么意思。"},"/maixpy/doc/zh/basic/maixvision.html":{"title":"MaixVision -- MaixPy 编程 + 图形化积木编程","content":" title: MaixVision MaixPy 编程 + 图形化积木编程 ## 简介 MaixVision 是专为 Maix 生态打造的一款开发者编程工具,支持 MaixPy 编程和图形化积木编程,同时支持在线运行和调试,以及实时预览图像,可以同步设备显示屏的图像,方便调试和开发。 以及支持打包应用和安装应用到设备,方便用户一键生成、安装应用。 同时还集成一些方便开发的小工具,比如文件管理,阈值编辑器,二维码生成等等。 ## 使用 MaixPy 编程和在线运行 按照[快速开始](../index.html)的步骤连接设备,我们可以很方便地使用 MaixPy 编程和在线运行。 ## 实时预览图像 MaixPy 提供`display`模块,可以将图像显示到屏幕上,同时,在调用`display`模块的`show`方法时,会将图像发送到 MaixVision 显示,比如代码: ```python from maix import display, camera cam camera.Camera(640, 480) disp display.Display() while 1: disp.show(cam.read()) ``` 这里我们用摄像头读取了图像,然后通过`disp.show()`方法将图像显示到屏幕上,同时也会发送到 MaixVision 显示。 当我们点击了右上角的`暂停`按钮,就会停止发送图像到 MaixVision 显示。 ## 计算图像的直方图 在上一步中我们可以在 MaixVision 中实时看到图像,我们用鼠标框选一个区域,图像下方就能看到这个区域的直方图了,选择不同的颜色表示方法,可以看到不同的颜色通道的直方图。 这个功能方便我们在做某些图像处理算法时找到一些合适的参数。 ## 使用图形化积木编程 开发中,敬请期待。 ## 区分`设备文件系统`和`电脑文件系统` 这里我们有一个比较重要的概念需要掌握:**分清楚`设备文件系统`和`电脑文件系统`**。 * **电脑文件系统**:运行在电脑上,在 MaixVision 中打开文件或者工程都是打开的电脑里面的文件,保存也是自动保存到电脑的文件系统。 * **设备文件系统**:程序运行时会将程序发送到设备上运行,所以代码里面使用的文件都是从设备文件系统读取。 所以常见的问题是有同学在电脑上保存了文件`D:\\data\\a.jpg`,然后在设备上使用这个文件`img image.load(\"D:\\data\\a.jpg\")`,这样当然是找不到文件的,因为设备上没有`D:\\data\\a.jpg`这个文件。 具体如何将电脑的文件发送到设备上,参考下面的章节。 ## 传输文件到设备 开发中,敬请期待。 目前可以用其它工具代替: 先知道设备的 ip 地址或者设备名称,MaixVision 就可以搜索到, 或者在设备`设置 >系统信息`中看到,比如类似 `maixcam xxxx.local` 或者 `192.168.0.123`。 用户名和密码都是 `root`, 使用 `SFTP` 协议传输文件,端口号是 `22`。 然后不同系统下都有很多好用的软件: ### Windows 下 使用 [WinSCP](https://winscp.net/eng/index.php) 或者 [FileZilla](https://filezilla project.org/) 等工具连接设备,将文件传输到设备上,选择 `SFTP` 协议填写设备和账号信息连接即可。 具体不懂的可以自行搜索。 ### Linux 下 终端使用 `scp` 命令传输文件到设备上,比如: ```bash scp /path/to/your/file.py root@maixcam xxxx.local:/root ``` ### Mac 下 * **方法一**:终端使用 `scp` 命令传输文件到设备上,比如: ```bash scp /path/to/your/file.py root@maixcam xxxx.local:/root ``` * **方法二**:使用 [FileZilla](https://filezilla project.org/) 等工具连接设备,将文件传输到设备上,选择 `SFTP` 协议填写设备和账号信息连接即可。"},"/maixpy/doc/zh/source_code/faq.html":{"title":"MaixPy Source Code FAQ","content":"MaixPy Source Code FAQ ## subprocess.CalledProcessError: Command '('lsb_release', ' a')' returned non zero exit status 1. Edit `/usr/bin/lsb_release` as root, change the first line from `#!/usr/bin/python3` to `python3`. Then compile again and it should work. ## ImportError: arg(): could not convert default argument 'format: maix::image::Format' in method '.__init__' into a Python object (type not registered yet?) Pybind11 need you to register `image::Format` first, then you can use it in `camera::Camera`, to we must fist define `image::Format` in generated `build/maixpy_wrapper.cpp` source file. To achieve this, edit `components/maix/headers_priority.txt`, the depended on should be placed before the one use it. e.g. ``` maix_image.hpp maix_camera.hpp ```"},"/maixpy/doc/zh/source_code/build.html":{"title":"MaixPy develop source code guide","content":" title: MaixPy develop source code guide ## Get source code ```shell git clone https://github.com/sipeed/MaixPy cd MaixPy ``` ## Build and pack to wheel ```shell python setup.py bdist_wheel maixcam ``` `maixcam` Can be replaced with other board config, see [setup.py]([./configs](https://github.com/sipeed/MaixPy/blob/main/setup.py)) 's `platform_names` variable. After build success, you will find wheel file in `dist` directory, use `pip install U MaixPy****.wheel` on your device to install or upgrade. > `python setup.py bdist_wheel maixcam skip build` will not execute build command and only pack wheel, so you can use `maixcdk menuconfig` and `maixcdk build` first to customize building. ## Build manually ```shell maixcdk build ``` ## Run test after modify source code * First, build source code by ```shell maixcdk build ``` * If build for PC self(platform `linux`): Then execute `./run.sh your_test_file_name.py` to run python script. ```shell cd test ./run.sh examples/hello_maix.py ``` * If cross compile for borad: * The fastest way is copy `maix` dir to device's `/usr/lib/python3.11/site packages/` directory, then run script on device. * Or pack wheel and install on device by `pip install U MaixPy****.wheel`, then run script on device. ## Preview documentation locally Documentation in [docs](https://github.com/sipeed/MaixPy/tree/main/docs) directory, use `Markdown` format, you can use [teedoc](https://github.com/teedoc/teedoc) to generate web version documentation. And the API doc is generated when build MaixPy firmware, **if you don't build MaixPy, the API doc will be empty**. ```shell pip install teedoc U cd docs teedoc install i https://pypi.tuna.tsinghua.edu.cn/simple teedoc serve ``` Then visit `http://127.0.0.1:2333` to preview documentation on web browser. ## For developers who want to contribute See [MaixPy develop source code guide](./contribute.html) If you encounter any problems when use source code, please refer to [FAQ](./faq.html) first."},"/maixpy/doc/zh/source_code/maixcdk.html":{"title":"切换到 MaixCDK 使用 C/C++ 开发应用","content":" title: 切换到 MaixCDK 使用 C/C++ 开发应用 除了使用 MaixPy 开发,还有对应的 C/C++ SDK 可以使用,项目名称为 [MaixCDK](https://github.com/sipeed/MaixCDK)。 ## MaixCDK 介绍 MaixPy 基于 MaixCDK 构建,MaixPy 的大多数 API 都是基于 MaixCDK 的 API 自动生成的,所以 MaixPy 有的功能 MaixCDK 都包含。 如果你更熟悉 C/C++ 编程,或者需要更高的性能,可以使用 MaixCDK 进行开发。 ## MaixCDK 使用 MaixCDK 代码仓库地址:[github.com/sipeed/MaixCDK](https://github.com/sipeed/MaixCDK), 你可以在这里找到 MaixCDK 的代码和文档。"},"/maixpy/doc/zh/source_code/add_c_module.html":{"title":"","content":""},"/maixpy/doc/zh/peripheral/gpio.html":{"title":"","content":""},"/maixpy/doc/zh/peripheral/uart.html":{"title":"","content":""},"/maixpy/doc/zh/peripheral/pwm.html":{"title":"","content":""},"/maixpy/doc/zh/modules/acc.html":{"title":"","content":""},"/maixpy/doc/zh/audio/recognize.html":{"title":"","content":""},"/maixpy/doc/zh/index.html":{"title":"MaixPy 快速开始","content":" title: MaixPy 快速开始
MaixPy 唯一官网: wiki.sipeed.com/maixpy
MaixPy 例程和源码: github.com/sipeed/MaixPy

> 关于 MaixPy 介绍请看 [MaixPy 官网首页](../../index.html) ## 获得 MaixCAM 设备 在 [Sipeed 淘宝](https://sipeed.taobao.com) 或者 [Sipeed 速卖通](https://sipeed.aliexpress.com) 店铺购买 MaixCAM 开发板。 **建议购买带 `TF 卡`、`摄像头`、`2.3寸触摸屏`、`外壳`、`Type C一转二小板`、`4P串口座子+线`的套餐**,方便后续使用和开发,**后面的教程都默认你已经有了这些配件**(包括屏幕)。 另外需要准备一根 `Type C` 数据线,尽量买质量好点的防止供电和连接不稳定。 >! 注意,目前只支持 MaixCAM 开发板,其它同型号芯片的开发板均不支持,包括 Sipeed 的同型号芯片开发板,请注意不要买错造成不必要的时间和金钱浪费。 ## 上手体验 插入套餐里面的 TF 卡,使用 `Type C` 数据线连接 `MaixCAM` 设备给设备供电,等待设备开机,开机会进入功能选择界面。 > 如果屏幕没有显示,请确认购买了配套的 TF 卡,如果确认有 TF 卡,可以尝试[更新系统](./basic/os.html)。 > 如果你没有购买 TF 卡套餐,你需要按照[升级和烧录系统](./basic/os.html)的方法烧录最新的系统到 TF 卡。 开机后可以看到功能选择界面,在设置中可以切换语言,可以自行尝试内置的各种应用和功能。 ## 作为串口模块使用 内置的各种应用可以直接当成串口模块使用,比如`找色块`、`找人脸`、`找二维码`等等, > 如果是想把设备当成主控使用(或者你还不懂什么是串口模块)可以跳过这一步。 使用方法: * 硬件连接: 可以给设备接上`Type C一转二小板`,这样我们就能将设备通过串口连接到你的主控上了,比如`Arduino`、`树莓派`、`STM32`等等。 * 打开你想用的应用,比如二维码识别,当设备扫描到二维码就会通过串口把结果发送给你的主控了。 > 发送的串口波特率是 `115200`,数据格式是 `8N1`,协议遵循 [Maix 串口通信协议标准](https://wiki.sipeed.com/maixcdk/docs/doc/convention/protoco.md),可以在[MaixHub APP](https://maixhub.com/app) 找到对应的应用介绍查看协议。 ## 准备连接电脑和设备 为了后面电脑(PC)能和 设备(MaixCAM)通信,我们要让它们在同一个局域网内,提供了两种方式: * **方法一**:无线连接, 设备使用 WiFi 连接到电脑连接的同一个路由器或者 WiFi 热点下: 在设备的`设置 > WiFi 设置`中连接到你的 WiFi 即可。 * **方法二**:有线连接, 设备通过 USB 线连接到电脑,设备会虚拟成一个 USB 网卡,这样和电脑就通过 USB 在同一局域网了。 方案二在不同电脑系统中有不同设置方法: * **Linux**: 无需额外设置,插上 USB 线即可, 使用 `ifconfig` 或者 `ip addr` 查看到 `usb0` 网卡 * **Windows**: 可以先确认`网络适配器`里面是否多了一个 RNDIS 设备,如果有就直接能用。否则需要手动安装 RNDIS 网卡驱动: * 打开电脑的`设备管理器`。 * 然后在`其它设备`里面找个一个带问号的 RNDIS 设备,右键选择`更新驱动程序`。 * 选择`浏览计算机以查找驱动程序`,然后选择`让我从计算机上的可用驱动程序列表中选择`。 * 选择`网络适配器`,然后点击`下一步`。 * 左边选择`Microsoft`,右边选择`远程 NDIS 兼容设备`,然后点击`下一步`, 选择`是`。 * 装好后的效果 ![RNDIS](../../static/image/rndis_windows.jpg) * **MacOS**: 无需额外设置,插上 USB 线即可, 使用 `ifconfig` 或者 `ip addr` 查看到 `usb0` 网卡 ## 开发环境准备 * 下载 [MaixVision](https://wiki.sipeed.com/maixvision) 并安装。 * 使用 Type C 连接设备和电脑,打开 MaixVision,点击左下角的`“连接”`按钮,会自动搜索设备,稍等一下就能看到设备,点击设备有点的连接按钮以连接设备。 如果没有扫描到设备,你也可以在设备的 `设置 > 设备信息` 中查看设备的 IP 地址手动输入。 这里有 MaixVision 的使用示例视频: ## 运行例程 点击 MaixVision 左侧的`示例代码`,选择一个例程,点击左下角`运行`按钮将代码发送到设备上运行。 比如: * `hello.py`,点击`运行`按钮,就能看到 MaixVision 终端有来自设备打印的`Hello MaixPy!`了。 * `camera_display.py`,这个例程会打开摄像头并在屏幕上显示摄像头的画面。 ```python from maix import camera, display, app disp display.Display() # 构造一个显示对象,并初始化屏幕 cam camera.Camera(640, 480) # 构造一个摄像头对象,手动设置了分辨率为 640x480, 并初始化摄像头 while not app.need_exit(): # 一直循环,直到程序退出(可以通过按下设备的功能按键退出或者 MaixVision 点击停止按钮退出) img cam.read() # 读取摄像头画面保存到 img 变量,可以通过 print(img) 来打印 img 的详情 disp.show(img) # 将 img 显示到屏幕上 ``` * `yolov5.py` 会检测摄像头画面中的物体框出来并显示到屏幕上,支持 80 种物体的检测,具体请看[YOLOv5 物体检测](./vision/yolov5.html)。 其它例程可以自行尝试。 ## 安装应用到设备 上面是在设备中运行代码,`MaixVision` 断开后代码就会停止运行,如果想让代码出现在开机菜单中,可以打包成应用安装到设备上。 点击 `MaixVision` 左下侧的安装应用按钮,填写应用信息,会将应用安装到设备上,然后在设备上就能看到应用了。 也可以选择打包应用,将你的应用分享到[MaixHub 应用商店](https://maixhub.com/app)。 > 默认例程没有显式编写退出功能,进入应用后按下设备的功能按键即可退出应用。(对于 MaixCAM 是 user 键) 如果想让程序开机自启动,可以在 `设置 > 开机启动` 中设置。 ## 下一步 看到这里,如果你觉得不错,**请务必来 [github](https://github.com/sipeed/MaixPy) 给 MaixPy 开源项目点一个 star(需要先登录 github), 你的 star 和认同是我们不断维护和添加新功能的动力!** 到这里你已经体验了一遍使用和开发流程了,接下来可以学习 `MaixPy` 语法和功能相关的内容,请按照左边的目录进行学习,如果遇到 `API` 使用问题,可以在[API 文档](/api/)中查找。 学习前最好带着自己学习的目的学,比如做一个有趣的小项目,这样学习效果会更好,项目和经验都可以分享到[MaixHub 分享广场](https://maixhub.com/share),会获得现金奖励哦! ## 分享交流 * **[MaixHub 项目和经验分享](https://maixhub.com/share)** :分享你的项目和经验,获得现金打赏,获得官方打赏的基本要求: * **可复现型**:较为完整的项目制作复现过程。 * **炫耀型**:无详细的项目复现过程,但是项目展示效果吸引人。 * Bug 解决经验型:解决了某个难题的过程和具体解决方法分享。 * [MaixPy 官方论坛](https://maixhub.com/discussion/maixpy)(提问和交流) * QQ 群: (建议在 QQ 群提问前先发个帖,方便群友快速了解你需要了什么问题,复现过程是怎样的) * MaixPy (v4) AI 视觉交流大群: 862340358 * Telegram: [MaixPy](https://t.me/maixpy)。 * 商业合作或批量购买请联系 support@sipeed.com 。"},"/maixpy/doc/zh/vision/self_learn_detector.html":{"title":"","content":""},"/maixpy/doc/zh/vision/apriltag.html":{"title":"","content":""},"/maixpy/doc/zh/vision/self_learn_classifier.html":{"title":"","content":""},"/maixpy/doc/zh/vision/object_track.html":{"title":"","content":""},"/maixpy/doc/zh/source_code/contribute.html":{"title":"参与 MaixPy 文档修改和贡献代码","content":" title: 参与 MaixPy 文档修改和贡献代码 ## 参与 MaixPy 文档修改 * 点击要修改的文档右上角的`编辑本页`按钮,进入 github 源文档页面。 * 保证已经登录了 GitHub 账号。 * 在 github 预案文档页面点击右上角铅笔按钮修改文档内容。 * github 会提示需要 fork 一份到自己的仓库,点击 fork 按钮。 > 这一步就是将 MaixPy 源码仓库复刻一份到你自己的账号下,这样你就可以自由修改了。 * 修改文档内容,然后在页面底部填写修改说明,点击提交修改。 * 然后在你的仓库中找到 Pull requests 按钮,点击创建一个 Pull requests。 * 然后在弹出的页面中填写修改说明,点击提交 Pull requests,其它人和管理员就可以在[Pull requests 页面](https://github.com/sipeed/MaixPy/pulls)看到你的修改了。 * 等待管理员审核通过后,你的修改就会合并到 MaixPy 源码仓库中了。 * 合并成功后,文档会自动更新到 [MaixPy 官方文档](https://wiki.sipeed.com/maixpy)。 > 文档经过 CDN 缓存了的,可能需要等待一段时间才能看到更新,紧急更新可以联系管理员手动刷新。 > 也可以访问 [en.wiki.sipeed.com/maixpy](https://en.wiki.sipeed.com/maixpy) 查看 github pages 服务版本,这个是没有缓存实时更新的。 ## 参与 MaixPy 代码贡献 * 访问 MaixPy 代码仓库地址:[github.com/sipeed/MaixPy](https://github.com/sipeed/MaixPy) * 在修改代码前最好先创建一个 [issue](https://github.com/sipeed/MaixPy/issues) ,描述你要修改的内容让大家知道你的想法和计划,这样大家可以参与修改讨论,以免重复劳动。 * 点击右上角的 fork 按钮,将 MaixPy 代码仓库复刻一份到你自己的账号下。 * 然后在你的账号下 clone 一份代码到本地。 * 修改代码后提交到你的仓库中。 * 然后在你的仓库中找到 Pull requests 按钮,点击创建一个 Pull requests。 * 然后在弹出的页面中填写修改说明,点击提交 Pull requests,其它人和管理员就可以在[Pull requests 页面](https://github.com/sipeed/MaixPy/pulls)看到你的修改了。 * 等待管理员审核通过后,你的修改就会合并到 MaixPy 源码仓库中了。 > 需要注意的是 MaixPy 的代码大多数是从 [MaixCDK](https://github.com/sipeed/MaixCDK) 自动生成的,所以如果你修改 C/C++ 源码,很有可能你需要先修改这个仓库。"},"/maixpy/doc/zh/peripheral/wdt.html":{"title":"","content":""},"/maixpy/doc/zh/peripheral/spi.html":{"title":"","content":""},"/maixpy/doc/zh/peripheral/i2c.html":{"title":"","content":""},"/maixpy/doc/zh/vision/display.html":{"title":"MaixPy 屏幕使用","content":" title: MaixPy 屏幕使用 update: date: 2024 03 31 author: neucrack version: 1.0.0 content: 初版文档 ## 简介 MaixPy 提供了`display`模块,可以将图像显示到屏幕上,同时,也可以将图像发送到 MaixVision 显示,方便调试和开发。 ## 使用屏幕 * 导入`display`模块: ```python from maix import display ``` * 创建一个`Display`对象: ```python disp display.Display() ``` * 显示图像: ```python disp.show(img) ``` 这里`img`对象是`maix.image.Image`对象,可以通过`camera`模块的`read`方法获取,也可以通过`image`模块的`load`方法加载文件系统中的图像,也可以通过`image`模块的`Image`类创建一个空白图像。 比如: ```python from maix import image, display disp display.Display() img image.load(\"/root/dog.jpg\") disp.show(img) ``` 这里需要先把`dog.jpg`文件传到设备的`/root`目录下。 显示文字: ```python from maix import image, display disp display.Display() img image.Image(320, 240) img.draw_rectangle(0, 0, disp.width(), disp.height(), color image.Color.from_rgb(255, 0, 0), thickness 1) img.draw_rectangle(10, 10, 100, 100, color image.Color.from_rgb(255, 0, 0)) img.draw_string(10, 10, \"Hello MaixPy!\", color image.Color.from_rgb(255, 255, 255)) disp.show(img) ``` 从摄像头读取图像并显示: ```python from maix import camera, display, app disp display.Display() cam camera.Camera(320, 240) while not app.need_exit(): img cam.read() disp.show(img) ``` > 这里用了一个`while not app.need_exit():` 是方便程序在其它地方调用`app.set_exit_flag()`方法后退出循环。 ## 显示到 MaixVision 在使用 MaixVision 运行代码时,能够将图像显示到 MaixVision 上,方便调试和开发。 在调用`show`方法时,会自动压缩图像并发送到 MaixVision 显示。 当然,如果你没有屏幕,或者为了节省内存不想初始化屏幕,也可以直接调用`image.Image`对象的`send_to_maixvision`方法发送图像到 MaixVision 显示。 ```python from maix import image img image.Image(320, 240) img.draw_rectangle(0, 0, img.width(), img.height(), color image.Color.from_rgb(255, 0, 0), thickness 1) img.draw_rectangle(10, 10, 100, 100, color image.Color.from_rgb(255, 0, 0)) img.draw_string(10, 10, \"Hello MaixPy!\", color image.Color.from_rgb(255, 255, 255)) img.send_to_maixvision() ``` ## 更多 API 更多 API 请看 API 文档的 [display](../../../api/maix/display.html) 部分。"},"/maixpy/doc/zh/vision/body_key_points.html":{"title":"","content":""},"/maixpy/doc/zh/vision/qrcode.html":{"title":"","content":""},"/maixpy/doc/zh/vision/classify.html":{"title":"","content":""},"/maixpy/doc/zh/vision/image_ops.html":{"title":"","content":""},"/maixpy/doc/zh/vision/maixhub_train.html":{"title":"","content":""},"/maixpy/doc/zh/vision/ai.html":{"title":"","content":""},"/maixpy/doc/zh/vision/yolov5.html":{"title":"","content":""},"/maixpy/doc/zh/vision/face_recognize.html":{"title":"","content":""},"/maixpy/doc/zh/vision/camera.html":{"title":"","content":""},"/maixpy/doc/zh/vision/find_blobs.html":{"title":"","content":""}} \ No newline at end of file +{"/maixpy/doc/zh/basic/app.html":{"title":"应用开发和应用商店","content":" title: 应用开发和应用商店 ## 应用生态简介 为了让开发板做到开箱即用,以及方便用户无门槛地使用,以及方便开发者分享自己的有趣应用,并且能有有效的渠道获取到反馈甚至是收益,我们推出了一个简易的应用框架,包括: * **[应用商店](https://maixhub.com/app)**: 开发者上传分享应用,用户无需开发直接下载使用,开发者可以获取到一定的现金收益(来自 MaixHub 官方以及用户打赏)。 * **出厂内置大量应用**: 官方提供了一些常用的应用,比如找色块、AI 物体检测追踪、找二维码、人脸识别等等,用户可以直接使用,也可以作为串口模块直接使用。 * **MaixPy + MaixCDK** 软件开发包:使用 [MaixPy](https://github.com/sipeed/maixpy) 或者 [MaixCDK](https://github.com/sipeed/MaixCDK) 可以用 Python 或者 C/C++ 语言快速开发嵌入式 AI 视觉听觉应用,超高效率实现你的有趣想法。 * **MaixVision** 配套电脑端开发工具: 全新的电脑端代码开发工具,快速上手、调试、运行、上传代码、安装应用到设备,一键式开发,甚至支持图像化积木式编程,小学生也能轻松上手。 大家可以多多关注应用商店,也可以在应用商店中分享自己的应用,大家一起共建活跃的社区。"},"/maixpy/doc/zh/basic/os.html":{"title":"升级和烧录系统","content":" title: 升级和烧录系统 ## 介绍 如果你购买了官方(Sipeed)的带 TF 卡的套餐,一般来说出厂已经烧录好了系统,可以跳过这一步直接使用。 但是为了防止出厂烧录的系统版本过旧,强烈建议先按照教程升级到最新的系统。 ## 如何确认系统是否需要升级 * 在开机后的功能选择界面,点击`设置`,然后点击`设备信息`,可以看到系统的版本号。 * 到[系统发布历史页面]()查看最新系统的版本号以及更新日志,如果在你的版本后有重要更新,建议升级。 > 如果最新系统和当前系统对比只是 MaixPy 固件的常规更新,也可以不升级,在 `设置` 中的 `更新 MaixPy` 中单独更新 `MaixPy` 即可。 ## 获得最新系统 在 [MaixPy 发布页面](https://github.com/sipeed/MaixPy/releases) 找到最新的系统镜像文件,比如`maixcam_os_20240401_maixpy_v4.1.0.xz`。 备用地址: * [Sourceforge](https://sourceforge.net/projects/maixpy/files/) ## 烧录系统到 MaixCAM 参考 [MaixCAM 系统烧录](https://wiki.sipeed.com/hardware/zh/maixcam/os.html) 教程。"},"/maixpy/doc/zh/basic/python_pkgs.html":{"title":"添加额外的 Python 软件包","content":" title: 添加额外的 Python 软件包 ## 简介 MaixPy 基于 Python 语言,提供了大量方便嵌入式应用开发的功能和 API,除此之外,你也可以使用其它的 Python 包来扩展功能。 ## 安装额外的 Python 包 > 注意可能不是所有 Python 包都支持,一般只支持纯 Python 包,不支持 C 扩展包, C 扩展包可能需要你手动在电脑交叉编译(比较复杂,这里就不介绍了)。 ### 方法一: 使用 Python 代码来安装 在 MaixVision 中使用 Python 代码来安装你需要的包,比如: ```python import os os.system(\"pip install 包名\") ``` 要更新一个包,可以使用: ```python import os os.system(\"pip install upgrade 包名\") ``` ### 方法二: 终端使用 pip 命令安装 使用[Linux 基础](./linux_basic.html)中介绍的终端使用方法,使用 `pip install 包名` 安装你需要的包。"},"/maixpy/doc/zh/basic/app_usage.html":{"title":"应用使用说明","content":" title: 应用使用说明 开机后会自动进入应用选择界面,内置各种应用均发布在 [MaixHub 应用商店](https://maixhub.com/app), 可以在这里找到对应应用的介绍和使用说明。 上手用得比较多的是 `设置 > 语言`, 以及 `设置 > WiFi`,`应用商店`应用可以用来升级和安装应用,连接上可以连接互联网的 WiFi 后即可在[MaixHub 应用商店](https://maixhub.com/app)扫码安装应用。 另外,你编写的应用也可以上传到[MaixHub 应用商店](https://maixhub.com/app)分享给其他人使用,质量合格和优秀的应用都会得到官方红包打赏,优秀应用也会得到大家的赞同和支持。 无论是小到一个采集传感器的数据小应用还是功能复杂的应用,让我们一起来创造更多有趣的东西吧!"},"/maixpy/doc/zh/vision/yolov5.html":{"title":"","content":""},"/maixpy/doc/zh/vision/face_recognize.html":{"title":"","content":""},"/maixpy/doc/zh/vision/camera.html":{"title":"","content":""},"/maixpy/doc/zh/vision/find_blobs.html":{"title":"","content":""},"/maixpy/doc/zh/faq.html":{"title":"MaixPy FAQ(常见问题)","content":" title: MaixPy FAQ(常见问题) 此页面列出了 MaixPy 相关的常见问题和解决方案,如果你遇到了问题,请先在这里找寻答案。 如果这个页面找不到答案,可以到 [MaixHub 讨论版块](https://maixhub.com/discussion) 将问题的详细步骤发贴提问。 ## MaixPy v4 和 v1 v3 有什么区别? * MaixPy v4 使用 Python 语言,是吸取了 v1 v3 经验的集大成之作,有更好的配套软件和生态,更多的功能,更简单的使用方式和更完善的文档;硬件有很大提升的同时加个和另外两者的硬件价格想当甚至更便宜;另外也做了兼容 K210 的使用体验和 API,方便用户从 v1 快速迁移到 v4。 * v1 使用了 Micropython 语言,有很多局限性,比如第三方库支持有限;同时受限于 Maix I (K210) 的硬件性能,内存不够用,AI 模型支持有限,很多编解码不支持硬件加速等缺点。 * v3 也是使用了 Python 语言,基于 Maix II Dock (v831) 硬件,硬件 AI 模型支持有限,而且全志的基础生态不够开放,API 也不够完善,此版本仅作为 Maix II Dock (v831)上面使用,不会继续更新。 ## MaixPy 目前只支持 MaixCAM 吗,用其它同款芯片的板子行不行? MaixPy 目前仅支持 MaixCAM 系列板子,其它同款芯片的板子也不支持(包括 Sipeed 的同款芯片板子 比如 LicheeRV Nano),强烈不建议尝试,导致设备损坏(比如冒烟烧屏等)后果自负。 未来 Sipeed 出的 Maix 系列的产品都将继续得到 MaixPy 支持,目前如果 MaixCAM 有什么无法满足的需求,可以到 [MaixHub 讨论版块](https://maixhub.com/discussion) 提出需求或者发送邮件到 support@sipeed.com. ## 可以用除了官方搭配的摄像头或者屏幕以外的自己的摄像头或者屏幕吗? 不建议这样操作,除非你有够丰富的软硬件知识和经验,否则可能导致设备损坏。 官方搭配的配件对应的软硬件是调教过的,表现效果是最好的,上手即可使用,其它配件可能接口不同,驱动不同,软件不同,需要自己去调教,这是一个非常复杂的过程,不建议尝试。 当然,如果你是大佬,我们也欢迎你提交 PR! ## MaixVision 无法搜索到设备? * 确保设备通过 Type C 数据线连接到电脑,设备处于开机状态并且进入了功能选择界面。 * 确保设备驱动已经安装: * Windows 下可以在`设备管理器`中查看是否有 USB 虚拟网卡设备,如果有感叹号则是去动没有安装好,按照[快速开始](./index.html) 中的方法安装驱动即可。 * Linux 下可以通过`ifconfig`或者`ip addr`查看是否有`usb0`设备或者`lsusb`查看所有 USB 设备。 Linux 已经自带去动,所以识别不到检查硬件连接,设备系统是否是最新,以及设备是否已经正常启动即可。 * Mac OS 同 Linux 方法。"},"/maixpy/doc/zh/basic/python.html":{"title":"Python 基础知识","content":" title: Python 基础知识 MaixPy 的教程文档里面就不涉及具体的 Python 语法教程了,因为 Python 的教程实在是太多了,都做得很好,这里只介绍需要学什么,方向和线路指导即可。 ## Python 简介 Python 是一门解释性、面向对象、动态类型的高级编程语言。 * 解释性:不需要编译,直接运行,优点是开发快速,缺点是因为每次运行都要解释一遍代码,运行速度慢一点点,但是往往瓶颈还是开发者写的代码而不是语言本身。 * 面向对象:支持面向对象编程,可以定义类和对象,相比面向过程语言,更容易组织代码。更多自行搜索。 * 动态类型:变量不需要声明类型,可以直接赋值,类型会根据赋值自动确定,这样可以减少代码量,但是也容易出现类型错误,需要开发者自己注意。 总之,对于没有接触过 Python 的开发者来说,Python 非常容易上手,有大量现成的库,开发者群体巨大,开发应用周期短,非常值得学习! ## Python 环境安装 你可以按照你学习的 Python 教程在电脑上安装 Python; 也可以在 MaixVisioin 上连接设备后使用 MaixVision 编程然后在开发板运行。 ## 使用 MaixPy 需要的 Python 基础有哪些? * Python 的基本概念。 * 面向对象编程的基本概念。 * Python 的基本语法,包括: * tab 缩进对齐语法 * 变量、函数、类、对象、注释等 * 控制语句比如 if、for、while 等等 * 模块和导入模块 * 基本数据类型比如 int、float、str、list、dict、tuple 等等 * bytes 和 str 的区别和转换 * 异常处理,try except * 常用的内置函数,比如 print、open、len、range 等等 * 常用的内置模块,比如 os、sys、time、random、math 等等 掌握以上的基础知识就可以顺畅使用 MaixPy 编程了,配合后面的教程和例程,在不懂的时候查询搜索引擎或者官方文档,或者问 ChatGPT 就能顺利完成开发。 ## 对于已经有一门面向对象编程语言经验的开发者 如果你已经会一门面向对象语言比如 C++/Java/C# 等等,那只需要快速浏览一下 Python 的语法,就可以开始使用了。 比如 [菜鸟教程](https://www.runoob.com/python3/python3 tutorial.html) 或者 [Python 官方教程](https://docs.python.org/3/tutorial/index.html)。 或者个人开发者的博客,比如 [哇!是 Python](https://neucrack.com/p/59)。 ## 对于没有面向对象编程经验但是有 C 语言经验的开发者 如果只学了 C,缺乏对面向对象的理解,那么可以先学习一下面向对象的概念,然后再学习 Python,也是比较快的,可以自行搜索视频教程入门。 跟着视频教程入门之后可以看看文档教程,比如 [菜鸟教程](https://www.runoob.com/python3/python3 tutorial.html) 或者 [Python 官方教程](https://docs.python.org/3/tutorial/index.html) 就可以开动了! 在学了入门知识后,就可以按照 MaixPy 的文档和例程开始使用 MaixPy 编程了。 ## 对于编程新手 如果你从未接触过编程,那么你需要重头开始学习 Python,Python 作为入门语言也是比较合适的,具体可以搜一搜视频教程。 在学会了基础语法后,就能按照例程使用 MaixPy 编程了。"},"/maixpy/doc/zh/basic/linux_basic.html":{"title":"Linux 基础知识","content":" title: Linux 基础知识 ## 简介 本章内容对于刚入门的同学来说,可以先跳过此章节,在学会 MaixPy 基础开发后再来学习也是可以的。 最新的 MaixPy 支持的 MaixCAM 硬件支持跑 Linux 系统,所以 MaixPy 底层都是基于 Linux 系统进行开发的。 虽然 Sipeed 开发的 MaixPy 已经为开发者们做了很多工作,即使不知道 Linux 系统知识也能愉快使用,但是以防在某些情况下需要一些底层操作,以及方便未接触过 Linux 的开发者学习,这里写一些 Linux 基础知识。 ## 为什么需要 Linux 系统 具体的原因大家可以自行查阅,这里用通俗的看起来不太专业的话语简单举几个例子方便初学者理解: * 在单片机中,我们的程序是一个死循环程序,用上 Linux 后我们可以同时跑很多程序,每个程序看起来都独立在同时运行,每个程序具体怎么执行的由操作系统实现。 * 基于 Linux 的开发者众多,需要功能和驱动可以很方便地找到,不需要自己再实现一遍。 * 基于 Linux 配套的软件工具丰富,可以很方便地进行开发和调试,比如在本教程没有提到的一些 Linux 通用工具理论上也是可以使用的。 ## 文件系统 什么是文件系统? * 就像电脑的文件系统一样,Linux 上会将硬件磁盘用文件系统进行管理,这样我们可以很方便地向磁盘读写数据。 * 对于学过单片机没有接触过文件系统开发的同学来讲,可以理解为我们有一个 Flash 或者 TF 卡,我们可以通过 API 读写 Flash 存取数据,断电后也能保存数据,但是 Flash 具有读写寿命,我们往往需要写一套程序去保证 Flash 读写寿命,而文件系统就可以理解成这样一套成熟的程序,文件系统帮我们完成了具体如何管理 Flash 空间和读写,我们只需调用文件系统的 API 即可,大大减少了我们的开发工作量并且用成熟的程序保证了稳定性和安全性。 ## 在电脑和设备(开发板)之间传输文件 既然设备有 Linux 和文件系统,那我们怎么发送文件到设备呢? 对于 MaixPy 我们配套了 MaixVision, 在后面的版本也会支持文件管理功能,在此之前可以用下面的方法: 这里我们主要介绍通过网络传输的方式,其它方式可自行探索`传输文件到 Linux`: * 确保设备和电脑连接到了同一个局域网,比如: * MaixCAM 的 USB 口连接到电脑会创建一个虚拟网卡,在电脑端的设备管理器就能看到,设备的 IP 可以在设备的`设置 >设备信息`中看到设备名和 IP。 * 也可以在设备`设置 >WiFi`中连接到和电脑相同的局域网。 * 电脑使用 SCP 或者 SFTP 协议传输文件到设备,具体的软件有很多,具体的软件和使用方法可以自行搜索,比如: * 在 Windows 上可以使用 WinSCP 或者 FileZilla,或者 scp 命令等。 * 在 Linux 上可以使用 FileZilla 或者 scp 命令 等。 * 在 Mac 上可以使用 FileZilla 或者 scp 命令 等。 ## 终端和命令行 终端就是通过`终端`这个软件与 Linux 系统进行通信和操作的工具,类似于 Windows 的`cmd`或者`PowerShell`。 比如我们可以在电脑的 Window 系统中的 powershell 或者 Linux系统中的 终端 工具中输入`ssh root@maixcam xxxx.local` 这里具体的名字在设备的`设置 >设备信息`中可以看到,这样我们就可以通过终端连接到设备了(用户名和密码都是`root`)。 然后我们通过输入命令来操作设备,比如`ls`命令可以列出设备文件系统中当前目录下的文件, `cd` 用来切换当前所在的目录(就像电脑文件管理中点击文件夹切换目录一样), ```shell cd / # 切换到根目录 ls # 显示当前目录(根目录)下的所有文件 ``` 然后会显示类似下面的内容: ```shell bin lib media root tmp boot lib64 mnt run usr dev linuxrc opt sbin var etc lost+found proc sys ``` 更多命令学习请自行搜索`Linux 命令行使用教程`,这里只是为了让初学者知道基本概念,这样有开发者提到时可以知道是什么意思。"},"/maixpy/doc/zh/basic/maixvision.html":{"title":"MaixVision -- MaixPy 编程 + 图形化积木编程","content":" title: MaixVision MaixPy 编程 + 图形化积木编程 ## 简介 MaixVision 是专为 Maix 生态打造的一款开发者编程工具,支持 MaixPy 编程和图形化积木编程,同时支持在线运行和调试,以及实时预览图像,可以同步设备显示屏的图像,方便调试和开发。 以及支持打包应用和安装应用到设备,方便用户一键生成、安装应用。 同时还集成一些方便开发的小工具,比如文件管理,阈值编辑器,二维码生成等等。 ## 使用 MaixPy 编程和在线运行 按照[快速开始](../index.html)的步骤连接设备,我们可以很方便地使用 MaixPy 编程和在线运行。 ## 实时预览图像 MaixPy 提供`display`模块,可以将图像显示到屏幕上,同时,在调用`display`模块的`show`方法时,会将图像发送到 MaixVision 显示,比如代码: ```python from maix import display, camera cam camera.Camera(640, 480) disp display.Display() while 1: disp.show(cam.read()) ``` 这里我们用摄像头读取了图像,然后通过`disp.show()`方法将图像显示到屏幕上,同时也会发送到 MaixVision 显示。 当我们点击了右上角的`暂停`按钮,就会停止发送图像到 MaixVision 显示。 ## 计算图像的直方图 在上一步中我们可以在 MaixVision 中实时看到图像,我们用鼠标框选一个区域,图像下方就能看到这个区域的直方图了,选择不同的颜色表示方法,可以看到不同的颜色通道的直方图。 这个功能方便我们在做某些图像处理算法时找到一些合适的参数。 ## 使用图形化积木编程 开发中,敬请期待。 ## 区分`设备文件系统`和`电脑文件系统` 这里我们有一个比较重要的概念需要掌握:**分清楚`设备文件系统`和`电脑文件系统`**。 * **电脑文件系统**:运行在电脑上,在 MaixVision 中打开文件或者工程都是打开的电脑里面的文件,保存也是自动保存到电脑的文件系统。 * **设备文件系统**:程序运行时会将程序发送到设备上运行,所以代码里面使用的文件都是从设备文件系统读取。 所以常见的问题是有同学在电脑上保存了文件`D:\\data\\a.jpg`,然后在设备上使用这个文件`img image.load(\"D:\\data\\a.jpg\")`,这样当然是找不到文件的,因为设备上没有`D:\\data\\a.jpg`这个文件。 具体如何将电脑的文件发送到设备上,参考下面的章节。 ## 传输文件到设备 开发中,敬请期待。 目前可以用其它工具代替: 先知道设备的 ip 地址或者设备名称,MaixVision 就可以搜索到, 或者在设备`设置 >系统信息`中看到,比如类似 `maixcam xxxx.local` 或者 `192.168.0.123`。 用户名和密码都是 `root`, 使用 `SFTP` 协议传输文件,端口号是 `22`。 然后不同系统下都有很多好用的软件: ### Windows 下 使用 [WinSCP](https://winscp.net/eng/index.php) 或者 [FileZilla](https://filezilla project.org/) 等工具连接设备,将文件传输到设备上,选择 `SFTP` 协议填写设备和账号信息连接即可。 具体不懂的可以自行搜索。 ### Linux 下 终端使用 `scp` 命令传输文件到设备上,比如: ```bash scp /path/to/your/file.py root@maixcam xxxx.local:/root ``` ### Mac 下 * **方法一**:终端使用 `scp` 命令传输文件到设备上,比如: ```bash scp /path/to/your/file.py root@maixcam xxxx.local:/root ``` * **方法二**:使用 [FileZilla](https://filezilla project.org/) 等工具连接设备,将文件传输到设备上,选择 `SFTP` 协议填写设备和账号信息连接即可。"},"/maixpy/doc/zh/modules/acc.html":{"title":"","content":""},"/maixpy/doc/zh/audio/recognize.html":{"title":"","content":""},"/maixpy/doc/zh/index.html":{"title":"MaixPy 快速开始","content":" title: MaixPy 快速开始
MaixPy 唯一官网: wiki.sipeed.com/maixpy
MaixPy 例程和源码: github.com/sipeed/MaixPy

> 关于 MaixPy 介绍请看 [MaixPy 官网首页](../../index.html) ## 获得 MaixCAM 设备 在 [Sipeed 淘宝](https://sipeed.taobao.com) 或者 [Sipeed 速卖通](https://sipeed.aliexpress.com) 店铺购买 MaixCAM 开发板。 **建议购买带 `TF 卡`、`摄像头`、`2.3寸触摸屏`、`外壳`、`Type C一转二小板`、`4P串口座子+线`的套餐**,方便后续使用和开发,**后面的教程都默认你已经有了这些配件**(包括屏幕)。 另外需要准备一根 `Type C` 数据线,尽量买质量好点的防止供电和连接不稳定。 >! 注意,目前只支持 MaixCAM 开发板,其它同型号芯片的开发板均不支持,包括 Sipeed 的同型号芯片开发板,请注意不要买错造成不必要的时间和金钱浪费。 ## 上手体验 插入套餐里面的 TF 卡,使用 `Type C` 数据线连接 `MaixCAM` 设备给设备供电,等待设备开机,开机会进入功能选择界面。 > 如果屏幕没有显示,请确认购买了配套的 TF 卡,如果确认有 TF 卡,可以尝试[更新系统](./basic/os.html)。 > 如果你没有购买 TF 卡套餐,你需要按照[升级和烧录系统](./basic/os.html)的方法烧录最新的系统到 TF 卡。 开机后可以看到功能选择界面,在设置中可以切换语言,可以自行尝试内置的各种应用和功能。 ## 作为串口模块使用 内置的各种应用可以直接当成串口模块使用,比如`找色块`、`找人脸`、`找二维码`等等, > 如果是想把设备当成主控使用(或者你还不懂什么是串口模块)可以跳过这一步。 使用方法: * 硬件连接: 可以给设备接上`Type C一转二小板`,这样我们就能将设备通过串口连接到你的主控上了,比如`Arduino`、`树莓派`、`STM32`等等。 * 打开你想用的应用,比如二维码识别,当设备扫描到二维码就会通过串口把结果发送给你的主控了。 > 发送的串口波特率是 `115200`,数据格式是 `8N1`,协议遵循 [Maix 串口通信协议标准](https://wiki.sipeed.com/maixcdk/docs/doc/convention/protoco.md),可以在[MaixHub APP](https://maixhub.com/app) 找到对应的应用介绍查看协议。 ## 准备连接电脑和设备 为了后面电脑(PC)能和 设备(MaixCAM)通信,我们要让它们在同一个局域网内,提供了两种方式: * **方法一**:无线连接, 设备使用 WiFi 连接到电脑连接的同一个路由器或者 WiFi 热点下: 在设备的`设置 > WiFi 设置`中连接到你的 WiFi 即可。 * **方法二**:有线连接, 设备通过 USB 线连接到电脑,设备会虚拟成一个 USB 网卡,这样和电脑就通过 USB 在同一局域网了。 方案二在不同电脑系统中有不同设置方法: * **Linux**: 无需额外设置,插上 USB 线即可, 使用 `ifconfig` 或者 `ip addr` 查看到 `usb0` 网卡 * **Windows**: 可以先确认`网络适配器`里面是否多了一个 RNDIS 设备,如果有就直接能用。否则需要手动安装 RNDIS 网卡驱动: * 打开电脑的`设备管理器`。 * 然后在`其它设备`里面找个一个带问号的 RNDIS 设备,右键选择`更新驱动程序`。 * 选择`浏览计算机以查找驱动程序`,然后选择`让我从计算机上的可用驱动程序列表中选择`。 * 选择`网络适配器`,然后点击`下一步`。 * 左边选择`Microsoft`,右边选择`远程 NDIS 兼容设备`,然后点击`下一步`, 选择`是`。 * 装好后的效果 ![RNDIS](../../static/image/rndis_windows.jpg) * **MacOS**: 无需额外设置,插上 USB 线即可, 使用 `ifconfig` 或者 `ip addr` 查看到 `usb0` 网卡 ## 开发环境准备 * 下载 [MaixVision](https://wiki.sipeed.com/maixvision) 并安装。 * 使用 Type C 连接设备和电脑,打开 MaixVision,点击左下角的`“连接”`按钮,会自动搜索设备,稍等一下就能看到设备,点击设备有点的连接按钮以连接设备。 如果没有扫描到设备,你也可以在设备的 `设置 > 设备信息` 中查看设备的 IP 地址手动输入。 这里有 MaixVision 的使用示例视频: ## 运行例程 点击 MaixVision 左侧的`示例代码`,选择一个例程,点击左下角`运行`按钮将代码发送到设备上运行。 比如: * `hello.py`,点击`运行`按钮,就能看到 MaixVision 终端有来自设备打印的`Hello MaixPy!`了。 * `camera_display.py`,这个例程会打开摄像头并在屏幕上显示摄像头的画面。 ```python from maix import camera, display, app disp display.Display() # 构造一个显示对象,并初始化屏幕 cam camera.Camera(640, 480) # 构造一个摄像头对象,手动设置了分辨率为 640x480, 并初始化摄像头 while not app.need_exit(): # 一直循环,直到程序退出(可以通过按下设备的功能按键退出或者 MaixVision 点击停止按钮退出) img cam.read() # 读取摄像头画面保存到 img 变量,可以通过 print(img) 来打印 img 的详情 disp.show(img) # 将 img 显示到屏幕上 ``` * `yolov5.py` 会检测摄像头画面中的物体框出来并显示到屏幕上,支持 80 种物体的检测,具体请看[YOLOv5 物体检测](./vision/yolov5.html)。 其它例程可以自行尝试。 ## 安装应用到设备 上面是在设备中运行代码,`MaixVision` 断开后代码就会停止运行,如果想让代码出现在开机菜单中,可以打包成应用安装到设备上。 点击 `MaixVision` 左下侧的安装应用按钮,填写应用信息,会将应用安装到设备上,然后在设备上就能看到应用了。 也可以选择打包应用,将你的应用分享到[MaixHub 应用商店](https://maixhub.com/app)。 > 默认例程没有显式编写退出功能,进入应用后按下设备的功能按键即可退出应用。(对于 MaixCAM 是 user 键) 如果想让程序开机自启动,可以在 `设置 > 开机启动` 中设置。 ## 下一步 看到这里,如果你觉得不错,**请务必来 [github](https://github.com/sipeed/MaixPy) 给 MaixPy 开源项目点一个 star(需要先登录 github), 你的 star 和认同是我们不断维护和添加新功能的动力!** 到这里你已经体验了一遍使用和开发流程了,接下来可以学习 `MaixPy` 语法和功能相关的内容,请按照左边的目录进行学习,如果遇到 `API` 使用问题,可以在[API 文档](/api/)中查找。 学习前最好带着自己学习的目的学,比如做一个有趣的小项目,这样学习效果会更好,项目和经验都可以分享到[MaixHub 分享广场](https://maixhub.com/share),会获得现金奖励哦! ## 分享交流 * **[MaixHub 项目和经验分享](https://maixhub.com/share)** :分享你的项目和经验,获得现金打赏,获得官方打赏的基本要求: * **可复现型**:较为完整的项目制作复现过程。 * **炫耀型**:无详细的项目复现过程,但是项目展示效果吸引人。 * Bug 解决经验型:解决了某个难题的过程和具体解决方法分享。 * [MaixPy 官方论坛](https://maixhub.com/discussion/maixpy)(提问和交流) * QQ 群: (建议在 QQ 群提问前先发个帖,方便群友快速了解你需要了什么问题,复现过程是怎样的) * MaixPy (v4) AI 视觉交流大群: 862340358 * Telegram: [MaixPy](https://t.me/maixpy)。 * 商业合作或批量购买请联系 support@sipeed.com 。"},"/maixpy/doc/zh/source_code/contribute.html":{"title":"参与 MaixPy 文档修改和贡献代码","content":" title: 参与 MaixPy 文档修改和贡献代码 ## 参与 MaixPy 文档修改 * 点击要修改的文档右上角的`编辑本页`按钮,进入 github 源文档页面。 * 保证已经登录了 GitHub 账号。 * 在 github 预案文档页面点击右上角铅笔按钮修改文档内容。 * github 会提示需要 fork 一份到自己的仓库,点击 fork 按钮。 > 这一步就是将 MaixPy 源码仓库复刻一份到你自己的账号下,这样你就可以自由修改了。 * 修改文档内容,然后在页面底部填写修改说明,点击提交修改。 * 然后在你的仓库中找到 Pull requests 按钮,点击创建一个 Pull requests。 * 然后在弹出的页面中填写修改说明,点击提交 Pull requests,其它人和管理员就可以在[Pull requests 页面](https://github.com/sipeed/MaixPy/pulls)看到你的修改了。 * 等待管理员审核通过后,你的修改就会合并到 MaixPy 源码仓库中了。 * 合并成功后,文档会自动更新到 [MaixPy 官方文档](https://wiki.sipeed.com/maixpy)。 > 文档经过 CDN 缓存了的,可能需要等待一段时间才能看到更新,紧急更新可以联系管理员手动刷新。 > 也可以访问 [en.wiki.sipeed.com/maixpy](https://en.wiki.sipeed.com/maixpy) 查看 github pages 服务版本,这个是没有缓存实时更新的。 ## 参与 MaixPy 代码贡献 * 访问 MaixPy 代码仓库地址:[github.com/sipeed/MaixPy](https://github.com/sipeed/MaixPy) * 在修改代码前最好先创建一个 [issue](https://github.com/sipeed/MaixPy/issues) ,描述你要修改的内容让大家知道你的想法和计划,这样大家可以参与修改讨论,以免重复劳动。 * 点击右上角的 fork 按钮,将 MaixPy 代码仓库复刻一份到你自己的账号下。 * 然后在你的账号下 clone 一份代码到本地。 * 修改代码后提交到你的仓库中。 * 然后在你的仓库中找到 Pull requests 按钮,点击创建一个 Pull requests。 * 然后在弹出的页面中填写修改说明,点击提交 Pull requests,其它人和管理员就可以在[Pull requests 页面](https://github.com/sipeed/MaixPy/pulls)看到你的修改了。 * 等待管理员审核通过后,你的修改就会合并到 MaixPy 源码仓库中了。 > 需要注意的是 MaixPy 的代码大多数是从 [MaixCDK](https://github.com/sipeed/MaixCDK) 自动生成的,所以如果你修改 C/C++ 源码,很有可能你需要先修改这个仓库。"},"/maixpy/doc/zh/peripheral/wdt.html":{"title":"","content":""},"/maixpy/doc/zh/peripheral/spi.html":{"title":"","content":""},"/maixpy/doc/zh/peripheral/i2c.html":{"title":"","content":""},"/maixpy/doc/zh/peripheral/gpio.html":{"title":"","content":""},"/maixpy/doc/zh/peripheral/uart.html":{"title":"","content":""},"/maixpy/doc/zh/peripheral/pwm.html":{"title":"","content":""},"/maixpy/doc/zh/basic/maixpy_upgrade.html":{"title":"更新 MaixPy","content":" title: 更新 MaixPy 有两种方法,如果第一次上手使用,为了降低难度,可以直接使用出厂 TF 卡自带的 MaixPy 固件尝试,以后再考虑更新。 不过因为不知道你拿到手的是什么时候出厂的 TF 卡,所以建议都更新一下系统。 ## 直接更新系统 按照 [升级和烧录系统](./os.html) 中的操作升级到最新的系统,里面就包含了最新的 MaixPy 固件。 ## 只更新 MaixPy 固件 在 [MaixPy 仓库 release 页面](https://github.com/sipeed/MaixPy/releases) 看到最新的版本信息和更新日志,其中包含了 MaixPy 固件信息,以及对应版本使用的系统信息。 如果不想更新系统(因为一般系统变动不大,可以看 MaixPy 更新日志中是否有系统改动相关,再决定是否更新系统),则可以只更新 MaixPy 固件。 * 在设置中设置 WiFi, 让系统联网。 * 点击设置应用中的 `更新 MaixPy` 进行更新。 > 如果你会使用终端, 也可以在终端中使用 `pip install MaixPy U` 来更新 MaixPy。"},"/maixpy/doc/zh/pro/compile_os.html":{"title":"","content":""},"/maixpy/doc/zh/modules/thermal_cam.html":{"title":"","content":""},"/maixpy/doc/zh/modules/tof.html":{"title":"","content":""},"/maixpy/doc/zh/source_code/faq.html":{"title":"MaixPy Source Code FAQ","content":"MaixPy Source Code FAQ ## subprocess.CalledProcessError: Command '('lsb_release', ' a')' returned non zero exit status 1. Edit `/usr/bin/lsb_release` as root, change the first line from `#!/usr/bin/python3` to `python3`. Then compile again and it should work. ## ImportError: arg(): could not convert default argument 'format: maix::image::Format' in method '.__init__' into a Python object (type not registered yet?) Pybind11 need you to register `image::Format` first, then you can use it in `camera::Camera`, to we must fist define `image::Format` in generated `build/maixpy_wrapper.cpp` source file. To achieve this, edit `components/maix/headers_priority.txt`, the depended on should be placed before the one use it. e.g. ``` maix_image.hpp maix_camera.hpp ```"},"/maixpy/doc/zh/source_code/build.html":{"title":"MaixPy develop source code guide","content":" title: MaixPy develop source code guide ## Get source code ```shell git clone https://github.com/sipeed/MaixPy cd MaixPy ``` ## Build and pack to wheel ```shell python setup.py bdist_wheel maixcam ``` `maixcam` Can be replaced with other board config, see [setup.py]([./configs](https://github.com/sipeed/MaixPy/blob/main/setup.py)) 's `platform_names` variable. After build success, you will find wheel file in `dist` directory, use `pip install U MaixPy****.wheel` on your device to install or upgrade. > `python setup.py bdist_wheel maixcam skip build` will not execute build command and only pack wheel, so you can use `maixcdk menuconfig` and `maixcdk build` first to customize building. ## Build manually ```shell maixcdk build ``` ## Run test after modify source code * First, build source code by ```shell maixcdk build ``` * If build for PC self(platform `linux`): Then execute `./run.sh your_test_file_name.py` to run python script. ```shell cd test ./run.sh examples/hello_maix.py ``` * If cross compile for borad: * The fastest way is copy `maix` dir to device's `/usr/lib/python3.11/site packages/` directory, then run script on device. * Or pack wheel and install on device by `pip install U MaixPy****.wheel`, then run script on device. ## Preview documentation locally Documentation in [docs](https://github.com/sipeed/MaixPy/tree/main/docs) directory, use `Markdown` format, you can use [teedoc](https://github.com/teedoc/teedoc) to generate web version documentation. And the API doc is generated when build MaixPy firmware, **if you don't build MaixPy, the API doc will be empty**. ```shell pip install teedoc U cd docs teedoc install i https://pypi.tuna.tsinghua.edu.cn/simple teedoc serve ``` Then visit `http://127.0.0.1:2333` to preview documentation on web browser. ## For developers who want to contribute See [MaixPy develop source code guide](./contribute.html) If you encounter any problems when use source code, please refer to [FAQ](./faq.html) first."},"/maixpy/doc/zh/source_code/maixcdk.html":{"title":"切换到 MaixCDK 使用 C/C++ 开发应用","content":" title: 切换到 MaixCDK 使用 C/C++ 开发应用 除了使用 MaixPy 开发,还有对应的 C/C++ SDK 可以使用,项目名称为 [MaixCDK](https://github.com/sipeed/MaixCDK)。 ## MaixCDK 介绍 MaixPy 基于 MaixCDK 构建,MaixPy 的大多数 API 都是基于 MaixCDK 的 API 自动生成的,所以 MaixPy 有的功能 MaixCDK 都包含。 如果你更熟悉 C/C++ 编程,或者需要更高的性能,可以使用 MaixCDK 进行开发。 ## MaixCDK 使用 MaixCDK 代码仓库地址:[github.com/sipeed/MaixCDK](https://github.com/sipeed/MaixCDK), 你可以在这里找到 MaixCDK 的代码和文档。"},"/maixpy/doc/zh/source_code/add_c_module.html":{"title":"","content":""},"/maixpy/doc/zh/vision/self_learn_detector.html":{"title":"","content":""},"/maixpy/doc/zh/vision/apriltag.html":{"title":"","content":""},"/maixpy/doc/zh/vision/self_learn_classifier.html":{"title":"","content":""},"/maixpy/doc/zh/vision/object_track.html":{"title":"","content":""},"/maixpy/doc/zh/vision/display.html":{"title":"MaixPy 屏幕使用","content":" title: MaixPy 屏幕使用 update: date: 2024 03 31 author: neucrack version: 1.0.0 content: 初版文档 ## 简介 MaixPy 提供了`display`模块,可以将图像显示到屏幕上,同时,也可以将图像发送到 MaixVision 显示,方便调试和开发。 ## 使用屏幕 * 导入`display`模块: ```python from maix import display ``` * 创建一个`Display`对象: ```python disp display.Display() ``` * 显示图像: ```python disp.show(img) ``` 这里`img`对象是`maix.image.Image`对象,可以通过`camera`模块的`read`方法获取,也可以通过`image`模块的`load`方法加载文件系统中的图像,也可以通过`image`模块的`Image`类创建一个空白图像。 比如: ```python from maix import image, display disp display.Display() img image.load(\"/root/dog.jpg\") disp.show(img) ``` 这里需要先把`dog.jpg`文件传到设备的`/root`目录下。 显示文字: ```python from maix import image, display disp display.Display() img image.Image(320, 240) img.draw_rectangle(0, 0, disp.width(), disp.height(), color image.Color.from_rgb(255, 0, 0), thickness 1) img.draw_rectangle(10, 10, 100, 100, color image.Color.from_rgb(255, 0, 0)) img.draw_string(10, 10, \"Hello MaixPy!\", color image.Color.from_rgb(255, 255, 255)) disp.show(img) ``` 从摄像头读取图像并显示: ```python from maix import camera, display, app disp display.Display() cam camera.Camera(320, 240) while not app.need_exit(): img cam.read() disp.show(img) ``` > 这里用了一个`while not app.need_exit():` 是方便程序在其它地方调用`app.set_exit_flag()`方法后退出循环。 ## 显示到 MaixVision 在使用 MaixVision 运行代码时,能够将图像显示到 MaixVision 上,方便调试和开发。 在调用`show`方法时,会自动压缩图像并发送到 MaixVision 显示。 当然,如果你没有屏幕,或者为了节省内存不想初始化屏幕,也可以直接调用`image.Image`对象的`send_to_maixvision`方法发送图像到 MaixVision 显示。 ```python from maix import image img image.Image(320, 240) img.draw_rectangle(0, 0, img.width(), img.height(), color image.Color.from_rgb(255, 0, 0), thickness 1) img.draw_rectangle(10, 10, 100, 100, color image.Color.from_rgb(255, 0, 0)) img.draw_string(10, 10, \"Hello MaixPy!\", color image.Color.from_rgb(255, 255, 255)) img.send_to_maixvision() ``` ## 更多 API 更多 API 请看 API 文档的 [display](../../../api/maix/display.html) 部分。"},"/maixpy/doc/zh/vision/body_key_points.html":{"title":"","content":""},"/maixpy/doc/zh/vision/qrcode.html":{"title":"","content":""},"/maixpy/doc/zh/vision/classify.html":{"title":"","content":""},"/maixpy/doc/zh/vision/image_ops.html":{"title":"","content":""},"/maixpy/doc/zh/vision/maixhub_train.html":{"title":"","content":""},"/maixpy/doc/zh/vision/ai.html":{"title":"","content":""}} \ No newline at end of file diff --git a/maixpy/static/search_index/index_3.json b/maixpy/static/search_index/index_3.json index 61c066f..a957165 100644 --- a/maixpy/static/search_index/index_3.json +++ b/maixpy/static/search_index/index_3.json @@ -1 +1 @@ -{"/maixpy/index.html":{"title":"MaixPy","content":" title: MaixPy id: home_page

MaixPy (v4)

快速落地 AI 视觉、听觉应用

[![GitHub Repo stars](https://img.shields.io/github/stars/sipeed/MaixPy?style social)](https://github.com/sipeed/MaixPy/stargazers)[![Apache 2.0](https://img.shields.io/badge/license Apache%20v2.0 orange.svg)](\"https://github.com/sipeed/MaixPy/blob/main/LICENSE.html)[![PyPI](https://img.shields.io/pypi/v/maixpy.svg)](https://pypi.python.org/pypi/maixpy/)[![PyPI Downloads](https://img.shields.io/pypi/dm/maixpy?label pypi%20downloads)](https://pypi.org/project/maixpy/)![GitHub repo size](https://img.shields.io/github/repo size/sipeed/maixpy) [![Build MaixCAM](https://github.com/sipeed/MaixPy/actions/workflows/build_maixcam.yml/badge.svg)](https://github.com/sipeed/MaixPy/actions/workflows/build_maixcam.yml)[![Trigger wiki](https://github.com/sipeed/MaixPy/actions/workflows/trigger_wiki.yml/badge.svg)](https://github.com/sipeed/MaixPy/actions/workflows/trigger_wiki.yml)
[English](./en/) 中文
> MaixPy v1 (Maix I K210) 用户请查看 MaixPy v1 文档。 MaixPy v4 不支持 Maix I Maix II 系列硬件,请更新到 [MaixCAM](https://wiki.sipeed.com/maixcam) 硬件平台。 > 喜欢 MaixPy 请到 GitHub 给 [ MaixPy 源码](https://github.com/sipeed/MaixPy) 点个 Star ⭐️ 以鼓励我们开发更多功能。

简易的 API 设计, 10 行代码进行 AI 图像识别:

```python from maix import camera, display, image, nn classifier nn.Classifier(model \"/root/models/mobilenetv2.mud\") cam camera.Camera(classifier.input_width(), classifier.input_height(), classifier.input_format()) dis display.Display() while 1: img cam.read() res classifier.classify(img) max_idx, max_prob res[0] msg f\"{max_prob:5.2f}: {classifier.labels[max_idx]}\" img.draw_string(10, 10, msg, image.COLOR_RED) dis.show(img) ```

硬件外设控制,不在话下:

串口收发: ```python from maix import uart ports uart.list_ports() serial uart.UART(ports[0], 115200) serial.write_str(\"hello world\") print(\"received:\", serial.read(timeout 2000)) ```
I2C 收发: ```python from maix import i2c devices i2c.scan() dev1 i2c.I2C(devices[0], freq 100000) dev1.writeto(0x12, b'hello') print(\"received:\", dev1.readfrom(0x12, 5)) ```

便捷的 MaixVision 工作站

简化开发环境,让开发更简单快速:

在线 AI 训练平台 MaixHub

无需 AI 基础和昂贵的训练设备,一键训练模型,一键部署到 MaixCAM。 ## 性能强劲 MaixCAM 硬件平台 ![MaixCAM](/static/image/maixcam.png)
* **CPU**: 1GHz RISC V(Linux)/ARM A53 + 700MHz RISC V(RTOS) + 25~300MHz 8051(Low Power) > 大核 RISC V 和 ARM A53 二选一运行,MaixPy 使用 RISC V 核心。 * **NPU**: 1Tops@INT8 NPU, 支持 BF16,支持 YOLOv5 YOLOv8 等。 * **内存**: 256MB DDR3。 * **通信**: USB2.0/WiFi6/BLE5.4。 * **外设**: IIC/PWM/SPI/UART/WDT/GPIO/ADC * **多媒体**:4M 摄像头,2.3\" 552x368 高清电容触摸屏,H.264/H.265/MJPEG 2K 硬件编解码。 * **价格**: [169 元 / 249 元。](https://wiki.sipeed.com/store) (缺货时咨询店家) 更多细节看: [MaixCAM](https://wiki.sipeed.com/maixcam) > 注意,目前只支持 MaixCAM 开发板,其它同型号芯片的开发板均不支持,包括 Sipeed 的同型号芯片开发板,请注意不要买错造成不必要的时间和金钱浪费。
## 特性介绍 以下为部分功能简介,更多请看[文档](/doc/zh/index.html)、[应用商店](https://maixhub.com/app) 或者社区分享[MaixHub](https://maixhub.com/share)。

Python + MaixVision IDE

简单的API,带有硬件加速,包含许多库,如numpy,opencv,MaixVision IDE 编程

C++版本

MaixCDK C++版本的SDK,与MaixPy的API相同

作为串口模块

其它 MCU 通过串口命令控制

APP商店

将您的APP分享给社区,并一键安装APPs

提供 MaixPy v1 兼容 API

快速从MaixPy v1(K210)迁移到MaixPy v4

AI 分类

识别物体类别

AI 对象检测

识别物体类别和坐标

AI 人脸识别

识别不同人脸特征

AI 人体关键点检测

姿态识别、体感游戏

AI 自学习分类器

无需在PC上训练,在设备上瞬间学习任意物体

AI 自学习检测器

无需在PC上训练,在设备上瞬间学习任意物体

AI 物体轨迹跟踪

轨迹追踪,流量统计

AI 监控,串流

安防监控,可串流,甚至可以向直播平台 比如 Bilibili.com 直播

查找颜色

查找颜色斑点

巡线

小车巡线,物流搬运

QR码和AprilTag

识别QR码和AprilTag

OCR

识别图片中的字符,旧物数字化

语音识别

实时连续语音识别

桌面监视器

监视PC信息,如CPU,内存,网络等。

天气站

监视天气信息,如温度,湿度等。

热红外摄像头

选配摄像头,温度图像获取/测量

HDMI 捕获视频

选配,通过 HDMI 捕获图像,作为服务器监控(KVM)、外挂 AI、推流设备等

## 谁在用 MaixPy? * **AI 算法工程师**: 轻松将你的 AI 模型部署到嵌入式设备。 > MaixPy 提供了易于使用的 API 来访问 NPU,以及帮助你开发 AI 模型的文档。 * **STEM**:想要教学生 AI 和嵌入式开发的老师。 > MaixPy 提供了易于使用的 API,PC 工具,在线 AI 训练服务... 让你专注于教授 AI,而不是硬件和复杂的软件使用。 * **创客**: 想要制作一些酷炫的项目,但不想学习复杂的硬件和软件。 > MaixPy 提供了 Python API,所以你需要做的就是学习基础 Python 语法,而 MaixPy 的 API 非常易于使用,你甚至可以在几分钟内完成你的项目。 * **工程师**: 想要做一些项目,但希望尽快有一个原型。 > MaixPy 易于构建项目,并提供相应的 C++ SDK,所以你可以直接使用 MaixPy 来部署或在几分钟内将 Python 代码转换为 C++。 * **学生**: 想要学习 AI,嵌入式开发。 > 我们提供了许多文档和教程,以及大量开源代码,帮助你找到学习路线,并逐步成长。从简单的 Python 编程到视觉,AI,音频,Linux,RTOS等。 * **企业**: 想要开发 AI 视觉产品,但没有时间或工程师来开发复杂的嵌入式系统。 > 使用 MaixPy 甚至图形编程来开发你的产品,不需要更多的员工和时间。例如,向你的生产线添加一个 AI QA 系统,或者根据你的需求向你的办公室添加一个 AI 安全监控器。 * **竞赛者**: 想要赢得比赛的比赛人们。 > MaixPy 集成了许多功能,易于使用,加快你作品产出速度,以在有限的时间内赢得比赛,国内常见比赛都有很多同学使用 MaixPy 赢得比赛。 ## 性能对比 相比上两代 Maix 系列产品有限的 NPU 算子支持和内存限制,MaixCAM 在保持超高性价比的同时,性能和体验有了很大的提升,强烈建议升级到最新的 MaixCAM 以及 MaixPy v4。 特征 Maix I K210 Maix II v831 MaixCAM CPU 400MHz RISC V x2 800MHz ARM7 **1GHz RISC V(Linux)
700MHz RISC V(RTOS)
25~300MHz 8051(Low Power)** 内存 6MB SRAM 64MB DDR2 **256MB DDR3** NPU 0.25Tops@INT8
official says 1T but... 0.25Tops@INT8 **1Tops@INT8** Encoder ✖ 1080p@30fps **2K@30fps** 屏幕 2.4\" 320x240 1.3\" 240x240 **2.28\" 552x368** / 5\" 1280x720 / 7\" 1280x800 / 10“ 1280x800 触摸屏 ✖ ✖ **2.3\" 552x368** 摄像头 30W 200W **500W** WiFi 2.4G 2.4G **WiFi6** 2.4G/5G USB ✖ **USB2.0** **USB2.0** 以太网 ✖ 100M(选配) 100M(选配) SD 卡接口 SPI **SDIO** **SDIO** BLE ✖ ✖ **BLE5.4** 操作系统 RTOS Tina Linux **Linux + RTOS** 编程语言 C / C++ / MicroPython C / C++ / **Python3** C / **C++ / Python3** Software MaixPy MaixPy3 **MaixCDK + MaixPy v4 + opencv + numpy + ...** PC 软件 MaixPy IDE MaixPy3 IDE **MaixVision** Workstation 文档 ⭐️⭐️⭐️⭐️ ⭐️⭐️⭐️ 🌟🌟🌟🌟🌟 在线 AI 训练 ⭐️⭐️⭐️ ⭐️⭐️⭐️⭐️ 🌟🌟🌟🌟🌟 官方应用 ⭐️⭐️ ⭐️⭐️⭐️ 🌟🌟🌟🌟🌟 AI 分类(224x224) MobileNetv1 50fps
MobileNetv2 ✖
Resnet ✖ MobileNet ✖
Resnet18 20fps
Resnet50 ✖ MobileNetv2 **130fps**
Resnet18 **62fps**
Resnet50 **28fps** AI 检测 YOLOv2(224x224) 15fps YOLOv2(224x224) 15fps **YOLOv5s(224x224) 100fps
YOLOv5s(320x256) 70fps
YOLOv5s(640x640) 15fps
YOLOv8n(640x640) 23fps** 易用性 ⭐️⭐️⭐️⭐️ ⭐️⭐️⭐️ 🌟🌟🌟🌟🌟 ## Maix 生态 ![](/static/image/maix_ecosystem.png) ## MaixPy v1, MaixPy3 and MaixPy v4 有什么区别? * MaixPy v1 使用 MicroPython 编程语言,仅支持 Sipeed Maix I K210 系列硬件,有限的第三方包。 * MaixPy3 专为 Sipeed Maix II Dock v831 设计,不是长期支持版本。 * MaixPy v4 使用 Python 编程语言,因此我们可以直接使用许多包。MaixPy v4 支持 Sipeed 的新硬件平台,这是一个长期支持版本,未来的硬件平台将支持这个版本。MaixPy v4 有一个 MaixPy v1 兼容的 API,所以你可以快速将你的 MaixPy v1 项目迁移到 MaixPy v4。 (MaixPy v4 不支持 Maix I K210 系列,如果你正在使用 Maix I K210 系列,建议升级硬件平台以使用此版本,以获得更多功能和更好的性能。) ## 开源协议 所有在本仓库中的文件都遵循 [Apache License 2.0 Sipeed Ltd.](https://github.com/sipeed/maixpy/blob/main/LICENSE) 协议,除了第三方库或者有自己的协议。 ## 社区 * 项目分享: [maixhub.com/share](https://maixhub.com/share) * 讨论: [maixhub.com/discussion](https://maixhub.com/discussion) * QQ 群: 862340358 * Telegram: [t.me/maixpy](https://t.me/maixpy)"},"/maixpy/404.html":{"title":"","content":" layout: 404.html "}} \ No newline at end of file +{"/maixpy/index.html":{"title":"MaixPy","content":" title: MaixPy id: home_page

MaixPy (v4)

快速落地 AI 视觉、听觉应用

[![GitHub Repo stars](https://img.shields.io/github/stars/sipeed/MaixPy?style social)](https://github.com/sipeed/MaixPy)[![Apache 2.0](https://img.shields.io/badge/license Apache%20v2.0 orange.svg)](\"https://github.com/sipeed/MaixPy/blob/main/LICENSE.html)[![PyPI](https://img.shields.io/pypi/v/maixpy.svg)](https://pypi.python.org/pypi/maixpy/)[![PyPI Downloads](https://img.shields.io/pypi/dm/maixpy?label pypi%20downloads)](https://pypi.org/project/maixpy/)[![GitHub repo size](https://img.shields.io/github/repo size/sipeed/maixpy)](https://github.com/sipeed/MaixPy) [![Build MaixCAM](https://github.com/sipeed/MaixPy/actions/workflows/build_maixcam.yml/badge.svg)](https://github.com/sipeed/MaixPy/actions/workflows/build_maixcam.yml)[![Trigger wiki](https://github.com/sipeed/MaixPy/actions/workflows/trigger_wiki.yml/badge.svg)](https://github.com/sipeed/MaixPy/actions/workflows/trigger_wiki.yml)
[English](./en/) 中文
> MaixPy v1 (Maix I K210) 用户请查看 MaixPy v1 文档。 MaixPy v4 不支持 Maix I Maix II 系列硬件,请更新到 [MaixCAM](https://wiki.sipeed.com/maixcam) 硬件平台。 > 喜欢 MaixPy 请到 GitHub 给 [ MaixPy 源码](https://github.com/sipeed/MaixPy) 点个 Star ⭐️ 以鼓励我们开发更多功能。

简易的 API 设计, 10 行代码进行 AI 图像识别:

```python from maix import camera, display, image, nn classifier nn.Classifier(model \"/root/models/mobilenetv2.mud\") cam camera.Camera(classifier.input_width(), classifier.input_height(), classifier.input_format()) dis display.Display() while 1: img cam.read() res classifier.classify(img) max_idx, max_prob res[0] msg f\"{max_prob:5.2f}: {classifier.labels[max_idx]}\" img.draw_string(10, 10, msg, image.COLOR_RED) dis.show(img) ```

硬件外设控制,不在话下:

串口收发: ```python from maix import uart ports uart.list_ports() serial uart.UART(ports[0], 115200) serial.write_str(\"hello world\") print(\"received:\", serial.read(timeout 2000)) ```
I2C 收发: ```python from maix import i2c devices i2c.scan() dev1 i2c.I2C(devices[0], freq 100000) dev1.writeto(0x12, b'hello') print(\"received:\", dev1.readfrom(0x12, 5)) ```

便捷的 MaixVision 工作站

简化开发环境,让开发更简单快速:

在线 AI 训练平台 MaixHub

无需 AI 基础和昂贵的训练设备,一键训练模型,一键部署到 MaixCAM。 ## 性能强劲 MaixCAM 硬件平台 ![MaixCAM](/static/image/maixcam.png)
* **CPU**: 1GHz RISC V(Linux)/ARM A53 + 700MHz RISC V(RTOS) + 25~300MHz 8051(Low Power) > 大核 RISC V 和 ARM A53 二选一运行,MaixPy 使用 RISC V 核心。 * **NPU**: 1Tops@INT8 NPU, 支持 BF16,支持 YOLOv5 YOLOv8 等。 * **内存**: 256MB DDR3。 * **通信**: USB2.0/WiFi6/BLE5.4。 * **外设**: IIC/PWM/SPI/UART/WDT/GPIO/ADC * **多媒体**:4M 摄像头,2.3\" 552x368 高清电容触摸屏,H.264/H.265/MJPEG 2K 硬件编解码。 * **价格**: [169 元 / 249 元。](https://wiki.sipeed.com/store) (缺货时咨询店家) 更多细节看: [MaixCAM](https://wiki.sipeed.com/maixcam) > 注意,目前只支持 MaixCAM 开发板,其它同型号芯片的开发板均不支持,包括 Sipeed 的同型号芯片开发板,请注意不要买错造成不必要的时间和金钱浪费。
## 特性介绍 以下为部分功能简介,更多请看[文档](/doc/zh/index.html)、[应用商店](https://maixhub.com/app) 或者社区分享[MaixHub](https://maixhub.com/share)。

Python + MaixVision IDE

简单的API,带有硬件加速,包含许多库,如numpy,opencv,MaixVision IDE 编程

C++版本

MaixCDK C++版本的SDK,与MaixPy的API相同

作为串口模块

其它 MCU 通过串口命令控制

APP商店

将您的APP分享给社区,并一键安装APPs

提供 MaixPy v1 兼容 API

快速从MaixPy v1(K210)迁移到MaixPy v4

AI 分类

识别物体类别

AI 对象检测

识别物体类别和坐标

AI 人脸识别

识别不同人脸特征

AI 人体关键点检测

姿态识别、体感游戏

AI 自学习分类器

无需在PC上训练,在设备上瞬间学习任意物体

AI 自学习检测器

无需在PC上训练,在设备上瞬间学习任意物体

AI 物体轨迹跟踪

轨迹追踪,流量统计

AI 监控,串流

安防监控,可串流,甚至可以向直播平台 比如 Bilibili.com 直播

查找颜色

查找颜色斑点

巡线

小车巡线,物流搬运

QR码和AprilTag

识别QR码和AprilTag

OCR

识别图片中的字符,旧物数字化

语音识别

实时连续语音识别

桌面监视器

监视PC信息,如CPU,内存,网络等。

天气站

监视天气信息,如温度,湿度等。

热红外摄像头

选配摄像头,温度图像获取/测量

HDMI 捕获视频

选配,通过 HDMI 捕获图像,作为服务器监控(KVM)、外挂 AI、推流设备等

## 谁在用 MaixPy? * **AI 算法工程师**: 轻松将你的 AI 模型部署到嵌入式设备。 > MaixPy 提供了易于使用的 API 来访问 NPU,以及帮助你开发 AI 模型的文档。 * **STEM**:想要教学生 AI 和嵌入式开发的老师。 > MaixPy 提供了易于使用的 API,PC 工具,在线 AI 训练服务... 让你专注于教授 AI,而不是硬件和复杂的软件使用。 * **创客**: 想要制作一些酷炫的项目,但不想学习复杂的硬件和软件。 > MaixPy 提供了 Python API,所以你需要做的就是学习基础 Python 语法,而 MaixPy 的 API 非常易于使用,你甚至可以在几分钟内完成你的项目。 * **工程师**: 想要做一些项目,但希望尽快有一个原型。 > MaixPy 易于构建项目,并提供相应的 C++ SDK,所以你可以直接使用 MaixPy 来部署或在几分钟内将 Python 代码转换为 C++。 * **学生**: 想要学习 AI,嵌入式开发。 > 我们提供了许多文档和教程,以及大量开源代码,帮助你找到学习路线,并逐步成长。从简单的 Python 编程到视觉,AI,音频,Linux,RTOS等。 * **企业**: 想要开发 AI 视觉产品,但没有时间或工程师来开发复杂的嵌入式系统。 > 使用 MaixPy 甚至图形编程来开发你的产品,不需要更多的员工和时间。例如,向你的生产线添加一个 AI QA 系统,或者根据你的需求向你的办公室添加一个 AI 安全监控器。 * **竞赛者**: 想要赢得比赛的比赛人们。 > MaixPy 集成了许多功能,易于使用,加快你作品产出速度,以在有限的时间内赢得比赛,国内常见比赛都有很多同学使用 MaixPy 赢得比赛。 ## 性能对比 相比上两代 Maix 系列产品有限的 NPU 算子支持和内存限制,MaixCAM 在保持超高性价比的同时,性能和体验有了很大的提升,强烈建议升级到最新的 MaixCAM 以及 MaixPy v4。 特征 Maix I K210 Maix II v831 MaixCAM CPU 400MHz RISC V x2 800MHz ARM7 **1GHz RISC V(Linux)
700MHz RISC V(RTOS)
25~300MHz 8051(Low Power)** 内存 6MB SRAM 64MB DDR2 **256MB DDR3** NPU 0.25Tops@INT8
official says 1T but... 0.25Tops@INT8 **1Tops@INT8** Encoder ✖ 1080p@30fps **2K@30fps** 屏幕 2.4\" 320x240 1.3\" 240x240 **2.28\" 552x368** / 5\" 1280x720 / 7\" 1280x800 / 10“ 1280x800 触摸屏 ✖ ✖ **2.3\" 552x368** 摄像头 30W 200W **500W** WiFi 2.4G 2.4G **WiFi6** 2.4G/5G USB ✖ **USB2.0** **USB2.0** 以太网 ✖ 100M(选配) 100M(选配) SD 卡接口 SPI **SDIO** **SDIO** BLE ✖ ✖ **BLE5.4** 操作系统 RTOS Tina Linux **Linux + RTOS** 编程语言 C / C++ / MicroPython C / C++ / **Python3** C / **C++ / Python3** Software MaixPy MaixPy3 **MaixCDK + MaixPy v4 + opencv + numpy + ...** PC 软件 MaixPy IDE MaixPy3 IDE **MaixVision** Workstation 文档 ⭐️⭐️⭐️⭐️ ⭐️⭐️⭐️ 🌟🌟🌟🌟🌟 在线 AI 训练 ⭐️⭐️⭐️ ⭐️⭐️⭐️⭐️ 🌟🌟🌟🌟🌟 官方应用 ⭐️⭐️ ⭐️⭐️⭐️ 🌟🌟🌟🌟🌟 AI 分类(224x224) MobileNetv1 50fps
MobileNetv2 ✖
Resnet ✖ MobileNet ✖
Resnet18 20fps
Resnet50 ✖ MobileNetv2 **130fps**
Resnet18 **62fps**
Resnet50 **28fps** AI 检测 YOLOv2(224x224) 15fps YOLOv2(224x224) 15fps **YOLOv5s(224x224) 100fps
YOLOv5s(320x256) 70fps
YOLOv5s(640x640) 15fps
YOLOv8n(640x640) 23fps** 易用性 ⭐️⭐️⭐️⭐️ ⭐️⭐️⭐️ 🌟🌟🌟🌟🌟 ## Maix 生态 ![](/static/image/maix_ecosystem.png) ## MaixPy v1, MaixPy3 and MaixPy v4 有什么区别? * MaixPy v1 使用 MicroPython 编程语言,仅支持 Sipeed Maix I K210 系列硬件,有限的第三方包。 * MaixPy3 专为 Sipeed Maix II Dock v831 设计,不是长期支持版本。 * MaixPy v4 使用 Python 编程语言,因此我们可以直接使用许多包。MaixPy v4 支持 Sipeed 的新硬件平台,这是一个长期支持版本,未来的硬件平台将支持这个版本。MaixPy v4 有一个 MaixPy v1 兼容的 API,所以你可以快速将你的 MaixPy v1 项目迁移到 MaixPy v4。 (MaixPy v4 不支持 Maix I K210 系列,如果你正在使用 Maix I K210 系列,建议升级硬件平台以使用此版本,以获得更多功能和更好的性能。) ## 开源协议 所有在本仓库中的文件都遵循 [Apache License 2.0 Sipeed Ltd.](https://github.com/sipeed/maixpy/blob/main/LICENSE) 协议,除了第三方库或者有自己的协议。 ## 社区 * 项目分享: [maixhub.com/share](https://maixhub.com/share) * 讨论: [maixhub.com/discussion](https://maixhub.com/discussion) * QQ 群: 862340358 * Telegram: [t.me/maixpy](https://t.me/maixpy)"},"/maixpy/404.html":{"title":"","content":" layout: 404.html "}} \ No newline at end of file diff --git a/maixpy/static/search_index/index_4.json b/maixpy/static/search_index/index_4.json index 4f5d75d..1f146aa 100644 --- a/maixpy/static/search_index/index_4.json +++ b/maixpy/static/search_index/index_4.json @@ -1 +1 @@ -{"/maixpy/en/index.html":{"title":"MaixPy","content":" title: MaixPy id: home_page

MaixPy (v4)

Easily create AI projects with Python on edge device

[![GitHub Repo stars](https://img.shields.io/github/stars/sipeed/MaixPy?style social)](https://github.com/sipeed/MaixPy/stargazers)[![Apache 2.0](https://img.shields.io/badge/license Apache%20v2.0 orange.svg)](\"https://github.com/sipeed/MaixPy/blob/main/LICENSE.html)[![PyPI](https://img.shields.io/pypi/v/maixpy.svg)](https://pypi.python.org/pypi/maixpy/)[![PyPI Downloads](https://img.shields.io/pypi/dm/maixpy?label pypi%20downloads)](https://pypi.org/project/maixpy/)![GitHub repo size](https://img.shields.io/github/repo size/sipeed/maixpy) [![Build MaixCAM](https://github.com/sipeed/MaixPy/actions/workflows/build_maixcam.yml/badge.svg)](https://github.com/sipeed/MaixPy/actions/workflows/build_maixcam.yml)[![Trigger wiki](https://github.com/sipeed/MaixPy/actions/workflows/trigger_wiki.yml/badge.svg)](https://github.com/sipeed/MaixPy/actions/workflows/trigger_wiki.yml)
English [中文](/)
> MaixPy v1 (Maix I K210) refer to MaixPy v1 doc。 MaixPy v4 not support Maix I Maix II, please upgrade to [MaixCAM](https://wiki.sipeed.com/maixcam) 硬件平台。 > Give a star ⭐️ to [ MaixPy source code](https://github.com/sipeed/MaixPy) on GitHub to let us known you love it, and encourage us to add more features.

Easy to use API, AI vision classify in 10 lines

```python from maix import camera, display, image, nn classifier nn.Classifier(model \"/root/models/mobilenetv2.mud\") cam camera.Camera(classifier.input_width(), classifier.input_height(), classifier.input_format()) dis display.Display() while 1: img cam.read() res classifier.classify(img) max_idx, max_prob res[0] msg f\"{max_prob:5.2f}: {classifier.labels[max_idx]}\" img.draw_string(10, 10, msg, image.COLOR_RED) dis.show(img) ```

Hardware peripheral control:

Serial send and receive: ```python from maix import uart ports uart.list_ports() serial uart.UART(ports[0], 115200) serial.write_str(\"hello world\") print(\"received:\", serial.read(timeout 2000)) ```
I2C send and receive: ```python from maix import i2c devices i2c.scan() dev1 i2c.I2C(devices[0], freq 100000) dev1.writeto(0x12, b'hello') print(\"received:\", dev1.readfrom(0x12, 5)) ```

MaixVision Workstation

Simplify the development environment, make development easier and faster:

Online AI training platform MaixHub

One click training AI model and deployment to MaixCAM even you have no AI knowledge and expensive training equipment. ## Powerful MaixCAM hardware platform ![MaixCAM](/static/image/maixcam.png)
* **CPU**: 1GHz RISC V(Linux)/ARM A53 + 700MHz RISC V(RTOS) + 25~300MHz 8051(Low Power) > Big core can choose one of RISC V and ARM A53. * **NPU**: 1Tops@INT8 NPU, support BF16, support YOLOv5 YOLOv8 etc. * **Memory**: 256MB DDR3. * **Connecting**: USB2.0/WiFi6/BLE5.4. * **Peripheral**: IIC/PWM/SPI/UART/WDT/ADC * **MultiMedia**: 4M Camera, 2.3\" 552x368 Touchscreen, H.264/H.265/MJPEG codec. * **Price**: [169/249 RMB](https://wiki.sipeed.com/store) (out of stock, please consult the store) More detalils: [MaixCAM](https://wiki.sipeed.com/maixcam) > Attention, only MaixCAM is supported, other boards with the same chip are not supported, including Sipeed's boards with the same chip, please be careful not to waste time and money by buying the wrong one.
## Features Below are some of the features, for more please see the [documentation](/doc/en/index.html), [app store](https://maixhub.com/app) or community sharing [MaixHub](https://maixhub.com/share).

Python + MaixVision IDE

Simple API, with hardware acceleration, including many libraries, such as numpy, opencv, MaixVision IDE programming

C++ Version

MaixCDK C++ version SDK,API the same as MaixPy's

As a serial module

Other MCU control by serial command

App Store

Share your APP to community, and one click install APPs.

MaixPy v1 compatible package

Quickly migrate from MaixPy v1(K210) to MaixPy v4

AI Classifier

Classify object type

AI Object Detection

Classify object type and position

AI Face Recognition

Recognize different face

AI Body Keypoint Detection

Pose recognition, body sense game

AI Self Learning Classifier

No need to train on PC, learning any object on device in a flash

AI Self Learning Detector

No need to train on PC, learning any object on device in a flash

AI Object Tracking

Trajectory tracking, traffic statistics

AI Monitor, Stream

Security monitor, can stream, even can live to platforms like Bilibili.com

Find Blobs

Find color blobs

Line Tracking

Car line tracking, logistics handling

QR Code and AprilTag

Recognize QR code and AprilTag

OCR

Recognize characters in the image, digitize old items

Speech Recognition

Real time continuous speech recognition

Desktop Monitor

Monitor PC information, such as CPU, memory, network, etc.

Weather Station

Monitor weather information, such as temperature, humidity, etc.

Thermal Camera

Optional camera, temprature image capture/measure

HDMI Capture Video

Optional, Capture HDMI image, as server monitor(KVM), external AI, streaming device etc.

## Who are using MaixPy? * **AI Algorithm Engineer** who want to deploy your AI model to embedded devices. > MaixPy provide easy to use API to access NPU, and docs to help you develop your AI model. * **STEM** teacher who want to teach AI and embeded to students. > MaixPy provide easy to use API, PC tools, online AI train service ... Let you focus on teaching AI, not the hardware and complicated software usage. * **Maker** who want to make some cool projects but don't want to learn complicated hardware and software. > MaixPy provide Python API, so all you need is learn basic Python syntax, and MaixPy's API is so easy to use, you can make your project even in a few minutes. * **Engineer** who want to make some projects but want a prototype as soon as possible. > MaixPy is easy to build projects, and provide corresponding C++ SDK, so you can directly use MaixPy to deploy or transfer Python code to C++ in a few minutes. * **Students** who want to learn AI, embedded development. > We provide many docs and tutorials, and lot of open source code, to help you find learning route, and grow up step by step. From simple Python programming to `Vision`, `AI`, `Audio`, `Linux`, `RTOS` etc. * **Enterprise** who want to develop AI vision products but have no time or engineers to develop complicated embedded system. > Use MaixPy even graphic programming to develop your products with no more employees and time. For example, add a AI QA system to your production line, or add a AI security monitor to your office as your demand. * **Contestants** who want to win the competition. > MaixPy integrate many functions and easy to use, fasten your work to win the competition in limited time. There are already many contestants win the competition with MaixPy. ## Performance comparison K210 and v831 are outdated, they have many limitations in memory, performance, NPU operators missing etc.
No matter you are using them or new comer, it's recommended to upgrade to MaixCAM and MaixPy v4.
Here's the comparison between them: Feature Maix I K210 Maix II v831 MaixCAM CPU 400MHz RISC V x2 800MHz ARM7 **1GHz RISC V(Linux)
700MHz RISC V(RTOS)
25~300MHz 8051(Low Power)** Memory 6MB SRAM 64MB DDR2 **256MB DDR3** NPU 0.25Tops@INT8
official says 1T but... 0.25Tops@INT8 **1Tops@INT8** Encoder ✖ 1080p@30fps **2K@30fps** Screen 2.4\" 320x240 1.3\" 240x240 **2.28\" 552x368** / 5\" 1280x720 / 7\" 1280x800 / 10“ 1280x800 TouchScreen ✖ ✖ **2.3\" 552x368** Camera 30W 200W **500W** WiFi 2.4G 2.4G **WiFi6** 2.4G/5G USB ✖ **USB2.0** **USB2.0** Eth ✖ 100M(Optional) 100M(Optional) SD Interface SPI **SDIO** **SDIO** BLE ✖ ✖ **BLE5.4** OS RTOS Tina Linux **Linux + RTOS** Language C / C++ / MicroPython C / C++ / **Python3** C / **C++ / Python3** Software MaixPy MaixPy3 **MaixCDK + MaixPy v4 + opencv + numpy + ...** PC software MaixPy IDE MaixPy3 IDE **MaixVision** Workstation Docs ⭐️⭐️⭐️⭐️ ⭐️⭐️⭐️ 🌟🌟🌟🌟🌟 Online AI train ⭐️⭐️⭐️ ⭐️⭐️⭐️⭐️ 🌟🌟🌟🌟🌟 Official APPs ⭐️⭐️ ⭐️⭐️⭐️ 🌟🌟🌟🌟🌟 AI classify(224x224) MobileNetv1 50fps
MobileNetv2 ✖
Resnet ✖ MobileNet ✖
Resnet18 20fps
Resnet50 ✖ MobileNetv2 **130fps**
Resnet18 **62fps**
Resnet50 **28fps** AI detect YOLOv2(224x224) 15fps YOLOv2(224x224) 15fps **YOLOv5s(224x224) 100fps
YOLOv5s(320x256) 70fps
YOLOv5s(640x640) 15fps
YOLOv8n(640x640) 23fps** Ease of use ⭐️⭐️⭐️⭐️ ⭐️⭐️⭐️ 🌟🌟🌟🌟🌟 ## Maix ecosystem ![](/static/image/maix_ecosystem.png) ## What difference between MaixPy v1, MaixPy3 and MaixPy v4? * MaixPy v1 use MicroPython programming language, only support Sipeed Maix I K210 series hardware, have limited third party packages. * MaixPy3 is designed for Sipeed Maix II Dock v831, not a long term support version. * MaixPy v4 use Python programming language, so there's much package we can use directly. MaixPy v4 support new hardware platforms of Sipeed, it's a long term support version, the future's hardware platforms will support this version. MaixPy v4 have a MaixPy v1 compatible API, so you can quickly migrate your MaixPy v1 project to MaixPy v4. (MaixPy v4 Will not support Maix I K210 series, if you are using Maix I K210 series, it's recommended to upgrade hardware platform to use this to get more features and better performance.) ## License All files in this repository are under the terms of the [Apache License 2.0 Sipeed Ltd.](./LICENSE) except the third party libraries or have their own license. ## Community * Project sharing: [maixhub.com/share](https://maixhub.com/share) * Discussion: [maixhub.com/discussion](https://maixhub.com/discussion) * QQ group: 862340358 * Telegram: [t.me/maixpy](https://t.me/maixpy)"},"/maixpy/en/no_translate.html":{"title":"no translation","content":" title: no translation class: md_page
This page not translated yet
Please visit
"}} \ No newline at end of file +{"/maixpy/en/index.html":{"title":"MaixPy","content":" title: MaixPy id: home_page

MaixPy (v4)

Easily create AI projects with Python on edge device

[![GitHub Repo stars](https://img.shields.io/github/stars/sipeed/MaixPy?style social)](https://github.com/sipeed/MaixPy)[![Apache 2.0](https://img.shields.io/badge/license Apache%20v2.0 orange.svg)](\"https://github.com/sipeed/MaixPy/blob/main/LICENSE.html)[![PyPI](https://img.shields.io/pypi/v/maixpy.svg)](https://pypi.python.org/pypi/maixpy/)[![PyPI Downloads](https://img.shields.io/pypi/dm/maixpy?label pypi%20downloads)](https://pypi.org/project/maixpy/)[![GitHub repo size](https://img.shields.io/github/repo size/sipeed/maixpy)](https://github.com/sipeed/MaixPy) [![Build MaixCAM](https://github.com/sipeed/MaixPy/actions/workflows/build_maixcam.yml/badge.svg)](https://github.com/sipeed/MaixPy/actions/workflows/build_maixcam.yml)[![Trigger wiki](https://github.com/sipeed/MaixPy/actions/workflows/trigger_wiki.yml/badge.svg)](https://github.com/sipeed/MaixPy/actions/workflows/trigger_wiki.yml)
English [中文](/)
> MaixPy v1 (Maix I K210) refer to MaixPy v1 doc。 MaixPy v4 not support Maix I Maix II, please upgrade to [MaixCAM](https://wiki.sipeed.com/maixcam) 硬件平台。 > Give a star ⭐️ to [ MaixPy source code](https://github.com/sipeed/MaixPy) on GitHub to let us known you love it, and encourage us to add more features.

Easy to use API, AI vision classify in 10 lines

```python from maix import camera, display, image, nn classifier nn.Classifier(model \"/root/models/mobilenetv2.mud\") cam camera.Camera(classifier.input_width(), classifier.input_height(), classifier.input_format()) dis display.Display() while 1: img cam.read() res classifier.classify(img) max_idx, max_prob res[0] msg f\"{max_prob:5.2f}: {classifier.labels[max_idx]}\" img.draw_string(10, 10, msg, image.COLOR_RED) dis.show(img) ```

Hardware peripheral control:

Serial send and receive: ```python from maix import uart ports uart.list_ports() serial uart.UART(ports[0], 115200) serial.write_str(\"hello world\") print(\"received:\", serial.read(timeout 2000)) ```
I2C send and receive: ```python from maix import i2c devices i2c.scan() dev1 i2c.I2C(devices[0], freq 100000) dev1.writeto(0x12, b'hello') print(\"received:\", dev1.readfrom(0x12, 5)) ```

MaixVision Workstation

Simplify the development environment, make development easier and faster:

Online AI training platform MaixHub

One click training AI model and deployment to MaixCAM even you have no AI knowledge and expensive training equipment. ## Powerful MaixCAM hardware platform ![MaixCAM](/static/image/maixcam.png)
* **CPU**: 1GHz RISC V(Linux)/ARM A53 + 700MHz RISC V(RTOS) + 25~300MHz 8051(Low Power) > Big core can choose one of RISC V and ARM A53. * **NPU**: 1Tops@INT8 NPU, support BF16, support YOLOv5 YOLOv8 etc. * **Memory**: 256MB DDR3. * **Connecting**: USB2.0/WiFi6/BLE5.4. * **Peripheral**: IIC/PWM/SPI/UART/WDT/ADC * **MultiMedia**: 4M Camera, 2.3\" 552x368 Touchscreen, H.264/H.265/MJPEG codec. * **Price**: [169/249 RMB](https://wiki.sipeed.com/store) (out of stock, please consult the store) More detalils: [MaixCAM](https://wiki.sipeed.com/maixcam) > Attention, only MaixCAM is supported, other boards with the same chip are not supported, including Sipeed's boards with the same chip, please be careful not to waste time and money by buying the wrong one.
## Features Below are some of the features, for more please see the [documentation](/doc/en/index.html), [app store](https://maixhub.com/app) or community sharing [MaixHub](https://maixhub.com/share).

Python + MaixVision IDE

Simple API, with hardware acceleration, including many libraries, such as numpy, opencv, MaixVision IDE programming

C++ Version

MaixCDK C++ version SDK,API the same as MaixPy's

As a serial module

Other MCU control by serial command

App Store

Share your APP to community, and one click install APPs.

MaixPy v1 compatible package

Quickly migrate from MaixPy v1(K210) to MaixPy v4

AI Classifier

Classify object type

AI Object Detection

Classify object type and position

AI Face Recognition

Recognize different face

AI Body Keypoint Detection

Pose recognition, body sense game

AI Self Learning Classifier

No need to train on PC, learning any object on device in a flash

AI Self Learning Detector

No need to train on PC, learning any object on device in a flash

AI Object Tracking

Trajectory tracking, traffic statistics

AI Monitor, Stream

Security monitor, can stream, even can live to platforms like Bilibili.com

Find Blobs

Find color blobs

Line Tracking

Car line tracking, logistics handling

QR Code and AprilTag

Recognize QR code and AprilTag

OCR

Recognize characters in the image, digitize old items

Speech Recognition

Real time continuous speech recognition

Desktop Monitor

Monitor PC information, such as CPU, memory, network, etc.

Weather Station

Monitor weather information, such as temperature, humidity, etc.

Thermal Camera

Optional camera, temprature image capture/measure

HDMI Capture Video

Optional, Capture HDMI image, as server monitor(KVM), external AI, streaming device etc.

## Who are using MaixPy? * **AI Algorithm Engineer** who want to deploy your AI model to embedded devices. > MaixPy provide easy to use API to access NPU, and docs to help you develop your AI model. * **STEM** teacher who want to teach AI and embeded to students. > MaixPy provide easy to use API, PC tools, online AI train service ... Let you focus on teaching AI, not the hardware and complicated software usage. * **Maker** who want to make some cool projects but don't want to learn complicated hardware and software. > MaixPy provide Python API, so all you need is learn basic Python syntax, and MaixPy's API is so easy to use, you can make your project even in a few minutes. * **Engineer** who want to make some projects but want a prototype as soon as possible. > MaixPy is easy to build projects, and provide corresponding C++ SDK, so you can directly use MaixPy to deploy or transfer Python code to C++ in a few minutes. * **Students** who want to learn AI, embedded development. > We provide many docs and tutorials, and lot of open source code, to help you find learning route, and grow up step by step. From simple Python programming to `Vision`, `AI`, `Audio`, `Linux`, `RTOS` etc. * **Enterprise** who want to develop AI vision products but have no time or engineers to develop complicated embedded system. > Use MaixPy even graphic programming to develop your products with no more employees and time. For example, add a AI QA system to your production line, or add a AI security monitor to your office as your demand. * **Contestants** who want to win the competition. > MaixPy integrate many functions and easy to use, fasten your work to win the competition in limited time. There are already many contestants win the competition with MaixPy. ## Performance comparison K210 and v831 are outdated, they have many limitations in memory, performance, NPU operators missing etc.
No matter you are using them or new comer, it's recommended to upgrade to MaixCAM and MaixPy v4.
Here's the comparison between them: Feature Maix I K210 Maix II v831 MaixCAM CPU 400MHz RISC V x2 800MHz ARM7 **1GHz RISC V(Linux)
700MHz RISC V(RTOS)
25~300MHz 8051(Low Power)** Memory 6MB SRAM 64MB DDR2 **256MB DDR3** NPU 0.25Tops@INT8
official says 1T but... 0.25Tops@INT8 **1Tops@INT8** Encoder ✖ 1080p@30fps **2K@30fps** Screen 2.4\" 320x240 1.3\" 240x240 **2.28\" 552x368** / 5\" 1280x720 / 7\" 1280x800 / 10“ 1280x800 TouchScreen ✖ ✖ **2.3\" 552x368** Camera 30W 200W **500W** WiFi 2.4G 2.4G **WiFi6** 2.4G/5G USB ✖ **USB2.0** **USB2.0** Eth ✖ 100M(Optional) 100M(Optional) SD Interface SPI **SDIO** **SDIO** BLE ✖ ✖ **BLE5.4** OS RTOS Tina Linux **Linux + RTOS** Language C / C++ / MicroPython C / C++ / **Python3** C / **C++ / Python3** Software MaixPy MaixPy3 **MaixCDK + MaixPy v4 + opencv + numpy + ...** PC software MaixPy IDE MaixPy3 IDE **MaixVision** Workstation Docs ⭐️⭐️⭐️⭐️ ⭐️⭐️⭐️ 🌟🌟🌟🌟🌟 Online AI train ⭐️⭐️⭐️ ⭐️⭐️⭐️⭐️ 🌟🌟🌟🌟🌟 Official APPs ⭐️⭐️ ⭐️⭐️⭐️ 🌟🌟🌟🌟🌟 AI classify(224x224) MobileNetv1 50fps
MobileNetv2 ✖
Resnet ✖ MobileNet ✖
Resnet18 20fps
Resnet50 ✖ MobileNetv2 **130fps**
Resnet18 **62fps**
Resnet50 **28fps** AI detect YOLOv2(224x224) 15fps YOLOv2(224x224) 15fps **YOLOv5s(224x224) 100fps
YOLOv5s(320x256) 70fps
YOLOv5s(640x640) 15fps
YOLOv8n(640x640) 23fps** Ease of use ⭐️⭐️⭐️⭐️ ⭐️⭐️⭐️ 🌟🌟🌟🌟🌟 ## Maix ecosystem ![](/static/image/maix_ecosystem.png) ## What difference between MaixPy v1, MaixPy3 and MaixPy v4? * MaixPy v1 use MicroPython programming language, only support Sipeed Maix I K210 series hardware, have limited third party packages. * MaixPy3 is designed for Sipeed Maix II Dock v831, not a long term support version. * MaixPy v4 use Python programming language, so there's much package we can use directly. MaixPy v4 support new hardware platforms of Sipeed, it's a long term support version, the future's hardware platforms will support this version. MaixPy v4 have a MaixPy v1 compatible API, so you can quickly migrate your MaixPy v1 project to MaixPy v4. (MaixPy v4 Will not support Maix I K210 series, if you are using Maix I K210 series, it's recommended to upgrade hardware platform to use this to get more features and better performance.) ## License All files in this repository are under the terms of the [Apache License 2.0 Sipeed Ltd.](./LICENSE) except the third party libraries or have their own license. ## Community * Project sharing: [maixhub.com/share](https://maixhub.com/share) * Discussion: [maixhub.com/discussion](https://maixhub.com/discussion) * QQ group: 862340358 * Telegram: [t.me/maixpy](https://t.me/maixpy)"},"/maixpy/en/no_translate.html":{"title":"no translation","content":" title: no translation class: md_page
This page not translated yet
Please visit
"}} \ No newline at end of file diff --git a/maixpy_en/index.html b/maixpy_en/index.html new file mode 100644 index 0000000..fa6a867 --- /dev/null +++ b/maixpy_en/index.html @@ -0,0 +1,780 @@ + + + + + + + + + + + + + + + + + + MaixPy - MaixPy + + + + + + + + + + +
+
+
+ +
+ +
+ +
+
+ MaixPy Banner +
+

MaixPy (v4)

+

Easily create AI projects with Python on edge device

+
+ +
+

GitHub Repo starsApache 2.0PyPIPyPI - DownloadsGitHub repo size Build MaixCAMTrigger wiki

+
+
+

English | 中文

+
+
+
+

MaixPy-v1 (Maix-I K210) refer to MaixPy-v1 doc。 MaixPy v4 not support Maix-I Maix-II, please upgrade to MaixCAM 硬件平台。
+Give a star ⭐️ to MaixPy source code on GitHub to let us known you love it, and encourage us to add more features.

+
+
+
+
+

Easy-to-use API, AI vision classify in 10 lines

+ +
from maix import camera, display, image, nn
+
+classifier = nn.Classifier(model="/root/models/mobilenetv2.mud")
+cam = camera.Camera(classifier.input_width(), classifier.input_height(), classifier.input_format())
+dis = display.Display()
+
+while 1:
+    img = cam.read()
+    res = classifier.classify(img)
+    max_idx, max_prob = res[0]
+    msg = f"{max_prob:5.2f}: {classifier.labels[max_idx]}"
+    img.draw_string(10, 10, msg, image.COLOR_RED)
+    dis.show(img)
+
+
+ +
+ +
+

Hardware peripheral control:

+
+
+

Serial send and receive:

+ +
from maix import uart
+
+ports = uart.list_ports()
+
+serial = uart.UART(ports[0], 115200)
+serial.write_str("hello world")
+print("received:", serial.read(timeout = 2000))
+
+
+
+

I2C send and receive:

+ +
from maix import i2c
+
+devices = i2c.scan()
+
+dev1 = i2c.I2C(devices[0], freq=100000)
+dev1.writeto(0x12, b'hello')
+print("received:", dev1.readfrom(0x12, 5))
+
+
+
+
+ + +

MaixVision Workstation

+

Simplify the development environment, make development easier and faster:

+ +

Online AI training platform MaixHub

+

One-click training AI model and deployment to MaixCAM even you have no AI knowledge and expensive training equipment.

+ + +

Powerful MaixCAM hardware platform

+

MaixCAM

+
+
    +
  • CPU: 1GHz RISC-V(Linux)/ARM A53 + 700MHz RISC-V(RTOS) + 25~300MHz 8051(Low Power)
  • +
+
+

Big core can choose one of RISC-V and ARM A53.

+
+
    +
  • NPU: 1Tops@INT8 NPU, support BF16, support YOLOv5 YOLOv8 etc.
  • +
  • Memory: 256MB DDR3.
  • +
  • Connecting: USB2.0/WiFi6/BLE5.4.
  • +
  • Peripheral: IIC/PWM/SPI/UART/WDT/ADC
  • +
  • MultiMedia: 4M Camera, 2.3" 552x368 Touchscreen, H.264/H.265/MJPEG codec.
  • +
  • Price: 169/249 RMB (out of stock, please consult the store)
  • +
+

More detalils: MaixCAM

+
+

Attention, only MaixCAM is supported, other boards with the same chip are not supported, including Sipeed's boards with the same chip, please be careful not to waste time and money by buying the wrong one.

+
+ +
+

Features

+

Below are some of the features, for more please see the documentation, app store or community sharing MaixHub.

+
+
+
+ +

Python + MaixVision IDE

+

Simple API, with hardware acceleration, including many libraries, such as numpy, opencv, MaixVision IDE programming

+
+
+
+
+
+
+ +

C++ Version

+

MaixCDK C++ version SDK,API the same as MaixPy's

+
+
+
+
+
+
+ +

As a serial module

+

Other MCU control by serial command

+
+
+
+
+
+
+ +

App Store

+

Share your APP to community, and one-click install APPs.

+
+
+
+
+
+
+ +

MaixPy-v1 compatible package

+

Quickly migrate from MaixPy-v1(K210) to MaixPy-v4

+
+
+
+
+
+
+ +

AI Classifier

+

Classify object type

+
+
+
+
+
+
+ +

AI Object Detection

+

Classify object type and position

+
+
+
+
+
+
+ +

AI Face Recognition

+

Recognize different face

+
+
+
+
+
+
+ +

AI Body Keypoint Detection

+

Pose recognition, body sense game

+
+
+
+
+
+
+ +

AI Self Learning Classifier

+

No need to train on PC, learning any object on device in a flash

+
+
+
+
+
+
+ +

AI Self Learning Detector

+

No need to train on PC, learning any object on device in a flash

+
+
+
+
+
+
+ +

AI Object Tracking

+

Trajectory tracking, traffic statistics

+
+
+
+
+
+
+ +

AI Monitor, Stream

+

Security monitor, can stream, even can live to platforms like Bilibili.com

+
+
+
+
+
+
+ +

Find Blobs

+

Find color blobs

+
+
+
+
+
+
+ +

Line Tracking

+

Car line tracking, logistics handling

+
+
+
+
+
+
+ +

QR Code and AprilTag

+

Recognize QR code and AprilTag

+
+
+
+
+
+
+ +

OCR

+

Recognize characters in the image, digitize old items

+
+
+
+
+
+
+ +

Speech Recognition

+

Real-time continuous speech recognition

+
+
+
+
+
+
+ +

Desktop Monitor

+

Monitor PC information, such as CPU, memory, network, etc.

+
+
+
+
+
+
+ +

Weather Station

+

Monitor weather information, such as temperature, humidity, etc.

+
+
+
+
+
+
+ +

Thermal Camera

+

Optional camera, temprature image capture/measure

+
+
+
+
+
+
+ +

HDMI Capture Video

+

Optional, Capture HDMI image, as server monitor(KVM), external AI, streaming device etc.

+
+
+
+
+
+
+

Who are using MaixPy?

+
    +
  • AI Algorithm Engineer who want to deploy your AI model to embedded devices.
  • +
+
+

MaixPy provide easy-to-use API to access NPU, and docs to help you develop your AI model.

+
+
    +
  • STEM teacher who want to teach AI and embeded to students.
  • +
+
+

MaixPy provide easy-to-use API, PC tools, online AI train service ... Let you focus on teaching AI, not the hardware and complicated software usage.

+
+
    +
  • Maker who want to make some cool projects but don't want to learn complicated hardware and software.
  • +
+
+

MaixPy provide Python API, so all you need is learn basic Python syntax, and MaixPy's API is so easy to use, you can make your project even in a few minutes.

+
+
    +
  • Engineer who want to make some projects but want a prototype as soon as possible.
  • +
+
+

MaixPy is easy to build projects, and provide corresponding C++ SDK, so you can directly use MaixPy to deploy or transfer Python code to C++ in a few minutes.

+
+
    +
  • Students who want to learn AI, embedded development.
  • +
+
+

We provide many docs and tutorials, and lot of open source code, to help you find learning route, and grow up step by step. From simple Python programming to Vision, AI, Audio, Linux, RTOS etc.

+
+
    +
  • Enterprise who want to develop AI vision products but have no time or engineers to develop complicated embedded system.
  • +
+
+

Use MaixPy even graphic programming to develop your products with no more employees and time. For example, add a AI QA system to your production line, or add a AI security monitor to your office as your demand.

+
+
    +
  • Contestants who want to win the competition.
  • +
+
+

MaixPy integrate many functions and easy to use, fasten your work to win the competition in limited time. There are already many contestants win the competition with MaixPy.

+
+

Performance comparison

+

K210 and v831 are outdated, they have many limitations in memory, performance, NPU operators missing etc.

+No matter you are using them or new comer, it's recommended to upgrade to MaixCAM and MaixPy v4.

+

Here's the comparison between them:

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
FeatureMaix-I K210Maix-II v831MaixCAM
CPU400MHz RISC-V x2800MHz ARM71GHz RISC-V(Linux)
700MHz RISC-V(RTOS)
25~300MHz 8051(Low Power)
Memory6MB SRAM64MB DDR2256MB DDR3
NPU0.25Tops@INT8
official says 1T but...
0.25Tops@INT81Tops@INT8
Encoder1080p@30fps2K@30fps
Screen2.4" 320x2401.3" 240x2402.28" 552x368 / 5" 1280x720 / 7" 1280x800 / 10“ 1280x800
TouchScreen2.3" 552x368
Camera30W200W500W
WiFi2.4G2.4GWiFi6 2.4G/5G
USBUSB2.0USB2.0
Eth100M(Optional)100M(Optional)
SD InterfaceSPISDIOSDIO
BLEBLE5.4
OSRTOSTina LinuxLinux + RTOS
LanguageC / C++ / MicroPythonC / C++ / Python3C / C++ / Python3
SoftwareMaixPyMaixPy3MaixCDK + MaixPy v4 + opencv + numpy + ...
PC softwareMaixPy IDEMaixPy3 IDEMaixVision Workstation
Docs⭐️⭐️⭐️⭐️⭐️⭐️⭐️🌟🌟🌟🌟🌟
Online AI train⭐️⭐️⭐️⭐️⭐️⭐️⭐️🌟🌟🌟🌟🌟
Official APPs⭐️⭐️⭐️⭐️⭐️🌟🌟🌟🌟🌟
AI classify(224x224)MobileNetv1 50fps
MobileNetv2 ✖
Resnet ✖
MobileNet ✖
Resnet18 20fps
Resnet50 ✖
MobileNetv2 130fps
Resnet18 62fps
Resnet50 28fps
AI detectYOLOv2(224x224) 15fpsYOLOv2(224x224) 15fpsYOLOv5s(224x224) 100fps
YOLOv5s(320x256) 70fps
YOLOv5s(640x640) 15fps
YOLOv8n(640x640) 23fps
Ease of use⭐️⭐️⭐️⭐️⭐️⭐️⭐️🌟🌟🌟🌟🌟
+

Maix ecosystem

+

+

What difference between MaixPy v1, MaixPy3 and MaixPy v4?

+
    +
  • MaixPy v1 use MicroPython programming language, only support Sipeed Maix-I K210 series hardware, have limited third-party packages.
  • +
  • MaixPy3 is designed for Sipeed Maix-II-Dock v831, not a long-term support version.
  • +
  • MaixPy v4 use Python programming language, so there's much package we can use directly. MaixPy v4 support new hardware platforms of Sipeed, it's a long-term support version, the future's hardware platforms will support this version. MaixPy v4 have a MaixPy-v1 compatible API, so you can quickly migrate your MaixPy v1 project to MaixPy v4.
  • +
+

(MaixPy v4 Will not support Maix-I K210 series, if you are using Maix-I K210 series, it's recommended to upgrade hardware platform to use this to get more features and better performance.)

+

License

+

All files in this repository are under the terms of the Apache License 2.0 Sipeed Ltd. except the third-party libraries or have their own license.

+

Community

+ + + +
+
+ + +
+ + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file