ssid: SSID of AP password: password of AP, if no password, leave it empty. wait: wait for got IP or failed or timeout. timeout: connect timeout internal, unit second.
+
+
+
return
+
If success, return err.Err.ERR_NONE, else means failed.
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.
+
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. copy_result: If set true, will copy result to a new variable; else will use a internal memory, you can only use it until to the next forward. Default true to avoid problems, you can set it to false manually to make speed faster.
return
@@ -1683,7 +1686,7 @@
forward_image
C++ defination code:
-
tensor::Tensors *forward_image(image::Image &img, std::vector<float> mean = std::vector<float>(), std::vector<float> scale = std::vector<float>(), image::Fit fit = image::Fit::FIT_FILL)
+
tensor::Tensors *forward_image(image::Image &img, std::vector<float> mean = std::vector<float>(), std::vector<float> scale = std::vector<float>(), image::Fit fit = image::Fit::FIT_FILL, bool copy_result = true)
In order to make the development board ready to use out of the box, make it easy for users to use without barriers, enable developers to share their interesting applications, and provide effective channels for receiving feedback and even profits, we have launched a simple application framework, including:
+
+
App Store: Developers can upload and share applications, which users can download and use without needing to develop them. Developers can receive certain cash rewards (from MaixHub or user tips).
+
Pre-installed Apps: The official provides some commonly used applications, such as color block detection, AI object detection tracking, QR code scanning, face recognition, etc., which users can use directly or use as serial module.
+
MaixPy + MaixCDK Software Development Kit: Using MaixPy or MaixCDK, you can quickly develop embedded AI visual and audio applications in Python or C/C++, efficiently realizing your interesting ideas.
+
MaixVision Desktop Development Tool: A brand-new desktop code development tool for quick start, debugging, running, uploading code, installing applications to devices, one-click development, and even support for graphical block-based programming, making it easy for elementary school students to get started.
+
+
Everyone is welcome to pay attention to the App Store and share their applications in the store to build a vibrant community together.
+
Packaging Applications
+
Using MaixPy + MaixVison makes it easy to develop, package, and install applications:
+
+
Develop applications with MaixPy in MaixVision, which can be a single file or a project directory.
+
Connect the device.
+
Click the "Install" button at the bottom-left corner of MaixVision, fill in the basic information of the application in the popup window, where the ID is used to identify the application. A device cannot simultaneously install different applications with the same ID, so the ID should be different from the IDs of applications on MaixHub. The application name can be duplicated. You can also upload an icon.
+
Click "Package Application" to package the application into an installer. If you want to upload it to the MaixHub App Store, you can use this packaged file.
+
Click "Install Application" to install the packaged application on the device.
+
Disconnect from the device, and you will see your application in the device's app selection interface. Simply click on it to run the application.
+
+
+
If you develop with MaixCDK, you can use maixcdk release to package an application. Refer to the MaixCDK documentation for specifics.
+
+
Exiting Applications
+
If you have developed a relatively simple application without a user interface and a back button, you can exit the application by pressing the device's function button (usually labeled as USER, FUNC, or OK) or the back button (if available, MaixCAM does not have this button by default).
+
Basic Guidelines for Application Development
+
+
Since touchscreens are standard, it is recommended to create a simple interface with touch interaction. You can refer to examples for implementation methods.
+
Avoid making interfaces and buttons too small, as MaixCAM default screen is 2.3 inches with 552x368 resolution and high PPI. Make sure fingers can easily tap without making mistakes.
+
Implement a simple serial interaction for the main functionality of each application based on the serial protocol (see example). This way, users can directly use it as a serial module. For instance, in a face detection application, you can output coordinates via serial port when a face is detected.
After powering on, it will automatically enter the application selection interface, where various built-in applications are available in the MaixHub App Store. Here you can find descriptions and instructions for using each corresponding application.
+
The commonly used settings are Settings -> Language, as well as Settings -> WiFi. The App Store application can be used for upgrading and installing applications. Once connected to a WiFi network that has internet access, you can scan and install applications from the MaixHub App Store.
+
Moreover, applications you develop can also be uploaded to the MaixHub App Store to share with others. High-quality and outstanding applications will receive official red envelope rewards, and excellent applications will gain recognition and support from everyone.
+
Whether it's a simple application for collecting sensor data or a complex function application, let's work together to create more interesting things!
For beginners just starting out, you can skip this chapter for now and come back to it after mastering the basics of MaixPy development.
+
The latest MaixPy supports running Linux on the MaixCAM hardware, so the underlying MaixPy development is based on the Linux system. Although Sipeed has done a lot of work for developers with MaixPy, making it possible to enjoy using it without knowledge of the Linux system, there might be situations where some low-level operations are necessary or for the convenience of developers unfamiliar with Linux. In this section, we will cover some basic Linux knowledge.
+
Why Linux System is Needed
+
Specific reasons can be researched individually. Here are a few examples in simplified terms that may not sound too technical but are easy for beginners to understand:
+
+
In microcontrollers, our program is usually a loop, but with Linux, we can run multiple programs simultaneously, each appearing to run independently, where the actual execution is handled by the operating system.
+
With a large community of Linux-based developers, required functionalities and drivers can be easily found without the need to implement them from scratch.
+
Linux offers a rich set of accompanying software tools for convenient development and debugging. Some Linux common tools not mentioned in this tutorial can theoretically be used as well.
+
+
File System
+
What is a file system?
+
+
Similar to a computer's file system, Linux manages hardware disks using a file system, making it easy for us to read and write data to the disk.
+
For students who have learned about microcontrollers but not familiar with file system development, imagine having a Flash or TF card where data can be read and written through APIs even after power loss. However, Flash has read/write limitations, requiring a program to ensure its longevity. A file system is like a mature program that manages the Flash space and read/write operations. By calling the file system's APIs, we can significantly reduce development work and ensure stability and security with proven programs.
+
+
Transferring Files between Computer and Device (Development Board)
+
Since the device has Linux and a file system, how do we send files to it?
+
For MaixPy, we offer MaixVision for file management in future versions. Before that, you can use the following method:
+
Here we mainly discuss transferring files through the network. Other methods can be explored on your own by searching for "transferring files to Linux":
+
+
Ensure the device and computer are connected to the same local network, for example:
+
When the MaixCAM's USB port is connected to the computer, a virtual network card is created which can be seen in the device manager on the computer, and the device's IP can be found in the device's Settings -> Device Information.
+
Alternatively, connect to the same local network on the device through Settings -> WiFi.
+
+
+
Use SCP or SFTP protocols on the computer to transfer files to the device. There are many specific software options and methods, such as:
+
On Windows, you can use WinSCP, FileZilla, or the scp command.
+
On Linux, use FileZilla or the scp command.
+
On Mac, use FileZilla or the scp command.
+
+
+
+
Terminal and Command Line
+
The terminal is a tool for communicating with and operating the Linux system, similar to Windows' cmd or PowerShell.
+
For example, we can enter ssh root@maixcam-xxxx.local in the Terminal tool on a Windows system with PowerShell or on a Linux system. You can find the specific name in the device's Settings->Device Information, which allows us to connect to the device through the terminal (both username and password are root).
+
Then, we can operate the device by entering commands. For instance, the ls command can list the files in the current directory of the device, while cd is used to switch to a different directory (similar to clicking folders in file management on a computer),
+
+
cd / # Switch to the root directory
+ls # Display all files in the current directory (root directory)
+
+
This will display similar content as below:
+
+
bin lib media root tmp
+boot lib64 mnt run usr
+dev linuxrc opt sbin var
+etc lost+found proc sys
+
+
For more command learning, please search for Linux command line usage tutorials on your own. This is just to introduce beginners to basic concepts so that when developers mention them, they can understand what they mean.
There are two methods to begin with. If you are new to this and want to keep things simple, you can try using the pre-installed MaixPy firmware on the TF card that comes with the device. You can consider updating it later.
+
However, since we don't know when the TF card you received was manufactured, it is recommended to update the system.
+
Updating the System Directly
+
Follow the steps in Upgrading and Flashing the System to upgrade to the latest system, which already includes the newest MaixPy firmware.
+
Updating Only the MaixPy Firmware
+
Check the latest version information and release notes in the MaixPy repository release page. It includes details about the MaixPy firmware and the system information corresponding to each version.
+
If you prefer not to update the system (since system changes are usually minimal, you can check if there are any system-related changes in the MaixPy update notes before deciding whether to update the system), you can simply update the MaixPy firmware.
+
+
Set up WiFi in the settings to connect the system to the internet.
+
Click on Update MaixPy in the settings app to proceed with the update.
+
+
+
If you are comfortable using the terminal, you can also update MaixPy by using pip install MaixPy -U in the terminal.
MaixVision is a developer programming tool specifically designed for the Maix ecosystem, supporting MaixPy programming and graphical block programming. It also supports online running, debugging, and real-time image preview, allowing the synchronization of the device display screen for easy debugging and development.
+
It also supports packaging applications and installing them on devices, making it convenient for users to generate and install applications with a single click.
+
Additionally, it integrates some handy development tools, such as file management, threshold editors, QR code generators, and more.
+
Using MaixPy Programming and Online Running
+
By following the steps in the Quick Start, we can easily use MaixPy programming and run programs online.
+
Real-time Image Preview
+
MaixPy provides a display module, which can display images on the screen. When calling the show method of the display module, the image will be sent to MaixVision for display in real-time, for example:
+
+
from maix import display, camera
+
+cam = camera.Camera(640, 480)
+disp = display.Display()
+while 1:
+ disp.show(cam.read())
+
+
Here, we capture an image using the camera, and then display it on the screen using disp.show(), which will also transmit the image to MaixVision for display.
+
By clicking the Pause button in the top right corner, the transmission of the image to MaixVision display will stop.
+
Computing the Histogram of an Image
+
In the previous step, we could see the image in real-time on MaixVision. By selecting a region with the mouse, we can view the histogram of that area below the image. Choosing different color representation methods allows us to see histograms of different color channels. This feature helps us find suitable parameters when working on image processing algorithms.
+
Using Graphical Block Programming
+
Currently in development, stay tuned for updates.
+
Distinguishing Between Device File System and Computer File System
+
An important concept to grasp here is distinguishing between the Computer File System and Device File System:
+
+
Computer File System: This operates on the computer. Opening files or projects in MaixVision accesses files stored on the computer. Any changes are automatically saved to the computer's file system.
+
Device File System: When a program runs, it sends files to the device for execution. Therefore, files accessed within the code are read from the device's file system.
+
+
A common issue arises when a file is saved on the computer at D:\data\a.jpg, and then the file is referenced on the device like img = image.load("D:\data\a.jpg"). This file cannot be found on the device because there is no D:\data\a.jpg file stored there.
+
For specific instructions on transferring computer files to the device, please refer to the following section.
+
Transferring Files to the Device
+
Currently in development. In the meantime, you can use alternative tools:
+
Begin by knowing the device's IP address or device name, which MaixVision can search for, or check in the device's Settings -> System Information, where you might find something similar to maixcam-xxxx.local or 192.168.0.123. The username and password are both root, and the file transfer protocol is SFTP with port number 22.
+
There are various user-friendly software options available for different operating systems:
+
For Windows
+
Use tools like WinSCP or FileZilla to connect to the device via SFTP. Provide the necessary device and account information to establish the connection.
+
For further guidance, perform a quick online search.
+
For Linux
+
Use the scp command in the terminal to transfer files to the device, for example:
Method 2: Use tools like FileZilla to connect to the device, transfer the files to the device, choose the SFTP protocol, fill in the device and account information, and connect.
If you have purchased the official (Sipeed) package with a TF card, typically the system has already been pre-programmed at the factory and can be used directly without further steps.
+
However, to avoid using an outdated version of the pre-programmed system, it is highly recommended to first upgrade to the latest system following the tutorial.
+
How to Confirm if System Upgrade is Needed
+
+
Upon booting up to the main menu, click on Settings, then Device Info to check the system's version number.
+
+
Visit the MaixPy Release History page to review the update logs, which contain information on MaixPy firmware and system image updates. If there are significant updates after your current version, it is advisable to upgrade.
+
+
If the latest system update only includes routine MaixPy firmware updates compared to your current system, you may choose not to upgrade. You can simply update MaixPy separately in Settings under Update MaixPy.
+
+
+
+
Obtaining the Latest System
+
Visit the MaixPy Release page to find the latest system image file, such as maixcam_os_20240401_maixpy_v4.1.0.xz.
The tutorial documentation of MaixPy does not delve into specific Python syntax tutorials because there are already too many excellent Python tutorials available. Here, we only introduce what needs to be learned, provide guidance on directions and paths.
+
Introduction to Python
+
Python is an interpreted, object-oriented, dynamically typed high-level programming language.
+
+
Interpreted: It does not require compilation, runs directly. The advantage is rapid development, while a minor drawback is the slower execution speed due to code interpretation on each run. However, most often, the bottleneck lies in the developer's code rather than the language itself.
+
Object-oriented: It supports object-oriented programming, allowing the definition of classes and objects. Compared to procedural languages, it is easier to organize code. For more details, please search independently.
+
Dynamically typed: Variables do not need to declare types, can be assigned directly, and the type will be automatically determined based on the assignment. This reduces code volume, but can also lead to type errors, requiring the developer's attention.
+
+
In conclusion, for developers unfamiliar with Python, it is very easy to get started as Python offers plenty of ready-to-use libraries, a large developer community, short application development cycles, making it highly worthwhile to learn!
+
Python Environment Setup
+
You can install Python on your computer according to the Python tutorial you are following for learning.
+Alternatively, you can connect to a device via MaixVision on MaixVision and then run the program on the development board.
+
What Python Basics are Needed to Use MaixPy?
+
+
Basic concepts of Python.
+
Basic concepts of object-oriented programming.
+
Basic syntax of Python, including:
+
Tab indentation alignment syntax.
+
Variables, functions, classes, objects, comments, etc.
+
Control statements such as if, for, while, etc.
+
Modules and importing modules.
+
Basic data types such as int, float, str, list, dict, tuple, etc.
+
Difference between bytes and str, and conversion.
+
Exception handling, try-except.
+
Common built-in functions like print, open, len, range, etc.
+
Common built-in modules like os, sys, time, random, math, etc.
+
+
+
+
Mastering the above foundational knowledge will enable you to smoothly program with MaixPy. With the help of subsequent tutorials and examples, if unsure, you can refer to search engines, official documentation, or ask ChatGPT to successfully complete your development tasks.
+
For Developers Experienced in Another Object-Oriented Programming Language
+
If you are already proficient in an object-oriented language like C++/Java/C#, you simply need to quickly review Python syntax before starting to use it.
Alternatively, you can explore individual developers' blogs, such as Wow! It's Python.
+
For Developers with C Language Experience but No Object-Oriented Programming Experience
+
If you only know C and lack understanding of object-oriented concepts, you can start by learning about object-oriented programming concepts before diving into Python. It's relatively quick and you can search for video tutorials for entry-level guidance.
+
After following introductory video tutorials, you can then refer to documentation tutorials such as Runoob Tutorial or the Python Official Tutorial to get started!
+
Once you have acquired the basic knowledge, you can start using MaixPy for programming based on the documentation and examples.
+
For Programming Beginners
+
If you have never dealt with programming before, you will need to start learning Python from scratch. Python is also quite suitable as an introductory language. You can search for video tutorials for specific guidance.
+
After mastering the basic syntax, you will be able to use MaixPy for programming by following examples provided.
MaixPy is based on the Python language and provides a wide range of functionalities and APIs for embedded application development. In addition to this, you can also use other Python packages to extend its functionality.
+
Installing Additional Python Packages
+
+
Please note that not all Python packages are supported. Generally, only pure Python packages are supported, not C extension packages. C extension packages may require you to manually cross-compile them on a computer (which is quite complex and won't be covered here).
+
+
Method 1: Installing Using Python Code
+
You can install the package you need in MaixVision using Python code, for example:
+
+
import os
+os.system("pip install package_name")
+
+
To update a package, you can use:
+
+
import os
+os.system("pip install --upgrade package_name")
+
+
Method 2: Installing Using the Terminal and pip Command
+
Follow the terminal usage method introduced in Linux Basics and use pip install package_name to install the package you need.
This page lists common questions and solutions related to MaixPy. If you encounter any issues, please search for answers here first.
+If you cannot find an answer on this page, you can post your question with detailed steps on the MaixHub Discussion Forum.
+
MaixVision cannot find the device?
+
First, confirm whether the connection method is WiFi or USB cable.
+WiFi:
+
+
Ensure that WiFi is correctly connected and has obtained an IP address. You can view the ip in Settings -> Device Info or Settings -> WiFi.
+
+
USB Cable:
+
+
Ensure that the device is connected to the computer via a Type-C data cable, and the device is powered on and has entered the function selection interface.
+
Ensure that the device driver is installed:
+
On Windows, check if there is a USB virtual network adapter device in Device Manager. If there is an exclamation mark, it means the driver is not installed properly. Follow the instructions in Quick Start to install the driver.
+
On Linux, you can check if there is a usb0 device by running ifconfig or ip addr, or check all USB devices with lsusb. Linux already includes the driver, so if the device is not recognized, check the hardware connection, ensure the device system is up-to-date, and ensure the device has booted up properly.
+
On macOS, follow the same steps as Linux.
+
+
+
Additionally, check the quality of the USB cable and try using a high-quality cable.
+
Additionally, check the quality of the computer's USB port. For example, some small form factor PCs have poor EMI design on their USB ports, and connecting a good quality USB hub may allow the device to work. You can also try a different USB port or a different computer.
+
+
MaixVision camera example shows choppy video
+
The default GC4653 camera has a maximum frame rate of 30 frames per second (FPS). Under normal circumstances, the MaixVision display should not appear choppy to the naked eye. If choppiness occurs, first consider transmission issues:
+
+
Check the network connection quality, such as WiFi.
+
If using a USB connection, check the USB cable quality, computer USB port quality, and try using a different computer, USB port, or USB cable for comparison.
+
+
What is the difference between MaixPy v4 and v1/v3?
+
+
MaixPy v4 uses the Python language and is the culmination of the experiences from v1 and v3, offering better supporting software and ecosystem, more features, simpler usage, and more comprehensive documentation. While the hardware has significant improvements, the pricing is even more affordable compared to the other two versions. Additionally, it provides compatibility with the K210 user experience and API, making it easier for users to migrate quickly from v1 to v4.
+
v1 used the Micropython language and had many limitations, such as limited third-party library support. Additionally, due to the hardware performance limitations of the Maix-I (K210), there was not enough memory, limited AI model support, and lack of hardware acceleration for many codecs.
+
v3 also used the Python language and was based on the Maix-II-Dock (v831) hardware. However, the hardware had limited AI model support, and the Allwinner ecosystem was not open enough, with an incomplete API. This version was only intended for use with the Maix-II-Dock (v831) and will not receive further updates.
+
+
Does MaixPy currently only support MaixCAM, or can it work with other boards using the same chipset?
+
MaixPy currently only supports the MaixCAM series of boards. Other boards using the same chipset, including Sipeed's boards like the LicheeRV-Nano, are not supported. It is strongly recommended not to attempt using MaixPy with other boards, as it may result in device damage (such as smoke or screen burn), for which you will be solely responsible.
+
In the future, Sipeed's Maix series of products will continue to be supported by MaixPy. If you have any needs that cannot be met by MaixCAM, you can post your requirements on the MaixHub Discussion Forum or send an email to support@sipeed.com.
+
Can I use a camera or screen other than the officially bundled ones?
+
It is not recommended to use cameras or screens other than the officially bundled ones, unless you have sufficient software and hardware knowledge and experience. Otherwise, it may result in device damage.
+
The officially bundled accessories have been fine-tuned for both software and hardware, ensuring the best performance and allowing for out-of-the-box usage. Other accessories may have different interfaces, drivers, and software, requiring you to calibrate them yourself, which is an extremely complex process.
+
However, if you are an expert, we welcome you to submit a pull request!
It is recommended to purchase the bundle with a TF card, camera, 2.3-inch touchscreen, case, Type-C data cable, Type-C one-to-two mini board, and 4P serial port socket+cable, which will be convenient for later use and development. The following tutorials assume that you already have these accessories (including the screen).
+
If you did not purchase a TF card, you will need to prepare a TF card reader to flash the system.
+
+
Note that currently only the MaixCAM development board is supported. Other development boards with the same chip are not supported, including Sipeed's development boards with the same chip. Please be careful not to purchase the wrong board, which could result in unnecessary waste of time and money.
+
+
Getting Started
+
Prepare the TF Image Card and Insert it into the Device
+
If the package you purchased includes a TF card, it already contains the factory image. If the TF card was not installed in the device at the factory, you will first need to carefully open the case (be careful not to tear the ribbon cables inside) and then insert the TF card. Additionally, since the firmware from the factory may be outdated, you can follow the instructions on Upgrading and Flashing the System to upgrade the system to the latest version.
+
If you did not purchase a TF card, you need to flash the system onto a self-provided TF card. Please refer to Upgrading and Flashing the System for the flashing method, and then install it on the board.
+
Power On
+
Use a Type-C data cable to connect the MaixCAM device and power it on. Wait for the device to boot up and enter the function selection interface.
+
+
If the screen does not display:
+
+
Please confirm that you purchased the bundled TF card. If you confirm that you have a TF card and it is inserted into the device, you can try updating to the latest system.
+
If you did not purchase the TF card bundle, you need to follow the instructions in Upgrading and Flashing the System to flash the latest system onto the TF card.
+
Also, ensure that the screen and camera cables are not loose. The screen cable can easily come off when opening the case, so be careful.
+
+
Connect to the Network
+
For the first run, you need to connect to the network, as you will need it later to activate the device and use the IDE.
+
+
On the device, click Settings, select WiFi, and click the Scan button to start scanning for nearby WiFi. You can click several times to refresh the list.
+
Find your WiFi hotspot. If you don't have a router, you can use your phone as a hotspot.
+
Enter the password and click the Connect button to connect.
+
Wait for the IP address to be obtained. This may take 10 to 30 seconds. If the interface does not refresh, you can exit the WiFi function and re-enter to check, or you can also see the IP information in Settings -> Device Info.
+
+
Update the Runtime Libraries
+
This step is very important!!! If this step is not done properly, other applications and functions may not work (e.g., they may crash).
+
+
First, ensure that you have completed the previous step of connecting to WiFi and have obtained an IP address to access the internet.
+
On the device, click Settings, and select Install Runtime Libraries.
+
After the installation is complete, you will see that it has been updated to the latest version. Then exit.
+
+
If it shows Request failed or 请求失败 (Request failed), please first check if the network is connected. You need to be able to connect to the internet. If it still doesn't work, please take a photo and contact customer service for assistance.
+
Use Built-in Applications
+
Many applications are built-in, such as Find Blobs, AI Detector, Line Follower, etc. For example, Find Blobs:
+
+
Please explore other applications on your own. More applications will be updated in the future. For usage documentation and application updates, please see the MaixHub App Store.
+
Note: The applications only include a part of the functionality that MaixPy can achieve. Using MaixPy, you can create even more features.
+
Use as a Serial Module
+
+
If you want to use the device as the main controller (or if you don't understand what a serial module is), you can skip this step.
+
+
The built-in applications can be used directly as serial modules, such as Find Blobs, Find Faces, Find QR Codes, etc.
+
Usage:
+
+
Hardware connection: You can connect the device to the Type-C one-to-two mini board, which allows you to connect the device via serial to your main controller, such as Arduino, Raspberry Pi, STM32, etc.
+
Open the application you want to use, such as QR code recognition. When the device scans a QR code, it will send the result to your main controller via serial.
+
+
+
The serial baud rate is 115200, the data format is 8N1, and the protocol follows the Maix Serial Communication Protocol Standard. You can find the corresponding application introduction on the MaixHub APP to view the protocol.
+
+
Prepare to Connect the Computer and Device
+
To allow the computer (PC) and the device (MaixCAM) to communicate later, we need to have them on the same local area network. Two methods are provided:
+
+
Method 1 (strongly recommended): Wireless connection. The device uses WiFi to connect to the same router or WiFi hotspot as the computer. You can connect to your WiFi in the device's Settings -> WiFi Settings.
+
Method 2: Wired connection. The device connects to the computer via a USB cable, and the device will act as a virtual USB network card, allowing it to be on the same local area network as the computer via USB.
+
+
+
Method 2 may encounter some problems due to the need for USB and drivers, so it is recommended to start with WiFi instead. You can find common issues in the FAQ.
+
+
+Method 2 has different setup methods on different computer systems, click to expand
+
+
Linux: No additional setup is required. Just plug in the USB cable. Use ifconfig or ip addr to view the usb0 network card. Note that the IP address you see here, e.g., 10.131.167.100, is the computer's IP. The device's IP is the last octet changed to 1, i.e., 10.131.167.1.
+
Windows: You can first confirm if a RNDIS device has been added in the Network Adapters. If so, you can use it directly. Otherwise, you need to manually install the RNDIS network card driver:
+
Open the computer's Device Manager.
+
Then find a RNDIS device with a question mark under Other Devices, right-click and select Update Driver Software.
+
Select Browse my computer for driver software.
+
Select Let me pick from a list of available drivers on my computer.
+
Select Network Adapters, then click Next.
+
On the left, select Microsoft, on the right, select Remote NDIS Compatible Device, then click Next, and select Yes.
+
After installation, the effect is as follows:
+
+
+
+
MacOS: No additional setup is required. Just plug in the USB cable. Use ifconfig or ip addr to view the usb0 network card. Note that the IP address you see here, e.g., 10.131.167.100, is the computer's IP. The device's IP is the last octet changed to 1, i.e., 10.131.167.1.
Connect the device and computer with a Type-C cable, open MaixVision, and click the "Connect" button in the bottom left corner. It will automatically search for devices. After a short wait, you will see the device, and you can click the connect button next to it to connect to the device.
+
+
If no device is detected, you can also manually enter the device's IP address in the device's Settings -> Device Info. You can also find solutions in the FAQ.
+
After a successful connection, the function selection interface on the device will disappear, and the screen will turn black, releasing all hardware resources. If there is still an image displayed, you can disconnect and reconnect.
+
Here is a video example of using MaixVision:
+
+
Run Examples
+
Click Example Code on the left side of MaixVision, select an example, and click the Run button in the bottom left to send the code to the device for execution.
+
For example:
+
+
hello_maix.py: Click the Run button, and you will see messages printed from the device in the MaixVision terminal, as well as an image in the upper right corner.
+
camera_display.py: This example will open the camera and display the camera view on the screen.
+
+
+
from maix import camera, display, app
+
+disp = display.Display() # Construct a display object and initialize the screen
+cam = camera.Camera(640, 480) # Construct a camera object, manually set the resolution to 640x480, and initialize the camera
+while not app.need_exit(): # Keep looping until the program exits (you can exit by pressing the function key on the device or clicking the stop button in MaixVision)
+ img = cam.read() # Read the camera view and save it to the variable img, you can print(img) to print the details of img
+ disp.show(img) # Display img on the screen
+
+
+
yolov5.py will detect objects in the camera view, draw bounding boxes around them, and display them on the screen. It supports detection of 80 object types. For more details, please see YOLOv5 Object Detection.
+
+
You can try other examples on your own.
+
+
If you encounter image display stuttering when using the camera examples, it may be due to poor network connectivity, or the quality of the USB cable or the host's USB being too poor. You can try changing the connection method or replacing the cable, host USB port, or computer.
+
+
Install Applications on the Device
+
The above examples run code on the device, but the code will stop running when MaixVision is disconnected. If you want the code to appear in the boot menu, you can package it as an application and install it on the device.
+
Click the Install App button in the bottom left corner of MaixVision, fill in the application information, and the application will be installed on the device. Then you will be able to see the application on the device.
+ You can also choose to package the application and share your application to the MaixHub App Store.
+
+
The default examples do not explicitly write an exit function, so you can exit the application by pressing the function key on the device. (For MaixCAM, it is the user key.)
+
+
If you want the program to start automatically on boot, you can set it in Settings -> Boot Startup.
+
Next Steps
+
If you like what you've seen so far, please be sure to give the MaixPy open-source project a star on GitHub (you need to log in to GitHub first). Your star and recognition is the motivation for us to continue maintaining and adding new features!
+
Up to this point, you've experienced the usage and development workflow. Next, you can learn about MaixPy syntax and related features. Please follow the left sidebar to learn. If you have any questions about using the API, you can look it up in the API documentation.
+
It's best to learn with a specific purpose in mind, such as working on an interesting small project. This way, the learning effect will be better. You can share your projects and experiences on the MaixHub Share Plaza and receive cash rewards!
+
Share and Discuss
+
+
MaixHub Project and Experience Sharing: Share your projects and experiences, and receive cash rewards. The basic requirements for receiving official rewards are:
+
Reproducible: A relatively complete process for reproducing the project.
+
Showcase: No detailed project reproduction process, but an attractive project demonstration.
+
Bug-solving experience: Sharing the process and specific solution for resolving a particular issue.
Sometimes we need to execute a function efficiently, and the speed of Python cannot meet the requirements. In such cases, we can use C/C++ or other compiled languages to implement the function.
+
General Function Encapsulation
+
If the function you want to encapsulate does not depend on other functionalities of MaixPy, you can directly use the general method of adding C/C++ modules with Python, such as ffi, ctype, etc. You can search for relevant methods online.
+
+
Welcome to contribute methods via PR
+
+
If Your Module Needs to Depend on Other Basic APIs of MaixPy
+
You need to learn how to compile and use MaixCDK first, because MaixPy is generated from MaixCDK APIs. Some functionalities in MaixPy are also available in MaixCDK, and then... TODO
maixcam Can be replaced with other board config, see 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
+
+
maixcdk build
+
+
Run test after modify source code
+
+
First, build source code by
+
+
+
maixcdk build
+
+
+
If build for PC self(platform linux):
+
+
Then execute ./run.sh your_test_file_name.py to run python script.
+
+
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 directory, use Markdown format, you can use 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.
Click the "Edit this page" button in the top right corner of the documentation you want to modify to enter the GitHub source documentation page.
+
Make sure you are logged in to your GitHub account.
+
Click the pencil icon in the top right corner of the GitHub preview documentation page to modify the content.
+
GitHub will prompt you to fork a copy to your own repository. Click the "Fork" button.
+
+
+
This step forks the MaixPy source code repository to your own account, allowing you to freely modify it.
+
+
+
Modify the documentation content, then fill in the modification description at the bottom of the page, and click "Commit changes".
+
Then find the "Pull requests" button in your repository and click to create a new Pull request.
+
In the pop-up page, fill in the modification description and click "Submit Pull request". Others and administrators can then see your modifications on the Pull requests page.
+
Wait for the administrator to review and approve, and your modifications will be merged into the MaixPy source code repository.
+
After the merge is successful, the documentation will be automatically updated to the MaixPy official documentation.
+
+
+
Due to CDN caching, it may take some time to see the update. For urgent updates, you can contact the administrator for manual refreshing.
+You can also visit en.wiki.sipeed.com/maixpy to view the GitHub Pages service version, which is updated in real-time without caching.
Before modifying the code, it is best to create an issue first, describing the content you want to modify to let others know your ideas and plans, so that everyone can participate in the modification discussion and avoid duplication of effort.
+
Click the "Fork" button in the top right corner to fork a copy of the MaixPy code repository to your own account.
+
Then clone a copy of the code from your account to your local machine.
+
After modifying the code, commit it to your repository.
+
Then find the "Pull requests" button in your repository and click to create a new Pull request.
+
In the pop-up page, fill in the modification description and click "Submit Pull request". Others and administrators can then see your modifications on the Pull requests page.
+
Wait for the administrator to review and approve, and your modifications will be merged into the MaixPy source code repository.
+
+
+
Note that most of the MaixPy code is automatically generated from MaixCDK, so if you modify the C/C++ source code, you may need to modify this repository first.
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 '<class 'maix._maix.camera.Camera'>.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.
In addition to developing with MaixPy, there is also a corresponding C/C++ SDK available, called MaixCDK.
+
Introduction to MaixCDK
+
MaixPy is built on top of MaixCDK, and most of MaixPy's APIs are automatically generated based on MaixCDK's APIs. Therefore, any functionality available in MaixPy is also included in MaixCDK.
+If you are more familiar with C/C++ programming or require higher performance, you can use MaixCDK for development.
+
Using MaixCDK
+
The MaixCDK code repository is located at github.com/sipeed/MaixCDK, where you can find the MaixCDK code and documentation.
Sometimes it is necessary to send images to a server or push video from a camera to a server. Here, we provide the simplest method, which is to compress images into JPEG format and send them one by one to the server.
+
Note, this is a very basic method and not a formal way to stream video. It is also not suitable for high-resolution, high-frame-rate video streams, as it involves sending images one by one. For more efficient video streaming, please use the RTSP or RTMP modules discussed later.
+
How to Use
+
+
from maix import image
+import requests
+
+# create image
+img = image.Image(640, 480, image.Format.FMT_RGB)
+# draw something
+img.draw_rect(60, 60, 80, 80, image.Color.from_rgb(255, 0, 0))
+
+# convert to jpeg
+jpeg = img.to_format(image.Format.FMT_JPEG) # image.Format.FMT_PNG
+# get jpeg bytes
+jpeg_bytes = jpeg.to_bytes()
+
+# faster way, borrow memory from jpeg object,
+# but be careful, when jpeg object is deleted, jpeg_bytes object MUST NOT be used, or program will crash
+# jpeg_bytes = jpeg.to_bytes(copy = False)
+
+# send image binary bytes to server
+url = "http://192.168.0.123:8080/upload"
+res = requests.post(url, data=jpeg_bytes)
+print(res.status_code)
+print(res.text)
+
+
As you can see, the image is first converted into JPEG format, and then the binary data of the JPEG image is sent to the server via TCP.
Then, the visual AI we use is generally based on the deep neural network learning method. If you are interested, you can check out Deep Neural Network (DNN) Basics.
+
Using Visual AI in MaixPy
+
Using visual AI in MaixPy is very simple. By default, commonly used AI models are provided, and you can use them directly without having to train the models yourself. You can find the maixcam models in the MaixHub Model Library.
+
Additionally, the underlying APIs have been well-encapsulated, and you only need to make simple calls to implement them.
+
If you want to train your own model, you can start with MaixHub Online Training. On the online platform, you can train models just by clicking, without the need to purchase expensive machines, set up complex development environments, or write code, making it very suitable for beginners and also for experienced users who are too lazy to read code.
+
Generally, once you have obtained the model file, you can transfer it to the device and call the MaixPy API to use it. The specific calling methods are discussed in the following sections.
img is the camera image obtained through cam.read()
+
img.resize(160, 120) is used to scale down the image to a smaller size, allowing the algorithm to compute faster with a smaller image
+
new_img.find_apriltags(families = families) is used to find Apriltag labels, and the query results are saved in apriltags for further processing. The families parameter is used to select the Apriltag family, defaulting to image.ApriltagFamilies.TAG36H11
+
+
+
Process the recognized label results and display them on the screen
+
+
for a in apriltags:
+ # Get position information (and map coordinates to the original image)
+ x = int(a.x() * x_scale)
+ y = int(a.y() * y_scale)
+ w = int(a.w() * x_scale)
+ corners = a.corners()
+ for i in range(4):
+ corners[i][0] = int(corners[i][0] * x_scale)
+ corners[i][1] = int(corners[i][1] * y_scale)
+
+ # Display
+ for i in range(4):
+ img.draw_line(corners[i][0], corners[i][1], corners[(i + 1) % 4][0], corners[(i + 1) % 4][1], image.COLOR_RED)
+ img.draw_string(x + w, y, "id: " + str(a.id()), image.COLOR_RED)
+ img.draw_string(x + w, y + 15, "family: " + str(a.family()), image.COLOR_RED)
+ img.draw_string(x + w, y + 30, "rotation : " + str(180 * a.rotation() // 3.1415), image.COLOR_RED)
+
+
+
Iterate through the members of apriltags, which is the result of scanning Apriltag labels through img.find_apriltags(). If no labels are found, the members of apriltags will be empty.
+
x_scale and y_scale are used to map coordinates. Since new_img is a scaled-down image, the coordinates of the Apriltag need to be mapped to be drawn correctly on the original image img.
+
a.corners() is used to get the coordinates of the four vertices of the detected label, and img.draw_line() uses these four vertex coordinates to draw the shape of the label.
+
img.draw_string is used to display the label content, where a.x() and a.y() are used to get the x and y coordinates of the top-left corner of the label, a.id() is used to get the label ID, a.family() is used to get the label family type, and a.rotation() is used to get the rotation angle of the label.
+
+
+
+
Common Parameter Explanations
+
Here are explanations for common parameters. If you can't find parameters to implement your application, you may need to consider using other algorithms or extending the required functionality based on the current algorithm's results.
+
+
+
+
Parameter
+
Description
+
Example
+
+
+
+
+
roi
+
Set the rectangular region for the algorithm to compute. roi=[x, y, w, h], where x and y represent the coordinates of the top-left corner of the rectangle, and w and h represent the width and height of the rectangle. The default is the entire image.
+
Compute the region with coordinates (50,50) and a width and height of 100: img.find_apriltags(roi=[50, 50, 100, 100])
+
+
+
families
+
Apriltag label family type
+
Scan for labels from the TAG36H11 family: img.find_apriltags(families = image.ApriltagFamilies.TAG36H11)
+
+
+
+
This article introduces common methods. For more API information, please refer to the image section of the API documentation.
Using MaixPy, you can easily detect the coordinates of human joint keypoints, which can be used for pose estimation such as sitting posture detection, motion-controlled game input, and more.
+
Usage
+
Using the maix.nn.BodyKeyPoints class in MaixPy, you can easily implement this functionality:
For the MaixCAM, it comes with a pre-installed GC4653 camera, or an optional OS04A10 camera or global shutter camera, and even an HDMI to MIPI module, all of which can be directly used with simple API calls.
+
API Documentation
+
This article introduces common methods. For more API usage, refer to the documentation of the maix.camera module.
+
Camera Switching
+
Different cameras use different drivers, and the correct driver needs to be selected in the system.
+
TODO: How to switch between cameras, such as between GC4653 and OS04A10.
+
Getting Images from the Camera
+
Using MaixPy to easily get images:
+
+
from maix import camera
+
+cam = camera.Camera(640, 480)
+
+while 1:
+ img = cam.read()
+ print(img)
+
+
Here we import the camera module from the maix module, then create a Camera object, specifying the width and height of the image. Then, in a loop, we continuously read the images. The default output is in RGB format. If you need BGR format or other formats, please refer to the API documentation.
+
Skipping Initial Frames
+
During the brief initialization period of the camera, the image acquisition may not be stable, resulting in strange images. You can use the skip_frames function to skip the initial few frames:
+
+
cam = camera.Camera(640, 480)
+cam.skip_frames(30) # Skip the first 30 frames
+
+
Displaying Images
+
MaixPy provides the display module, which can conveniently display images:
For example, if there are two images in front of you, one with an apple and the other with an airplane, the task of object classification is to input these two images into an AI model one by one. The model will then output two results, one for apple and one for airplane.
+
Using Object Classification in MaixPy
+
MaixPy provides a pre-trained 1000 classification model based on the imagenet dataset, which can be used directly:
This post is contributed by the community user dragonforward
+
+
+
This blog will show you how to deploy your own YOLOv5s model (the author demonstrates a hard hat model) step by step from scratch. The training part refers to the author's previous work, and those who have already trained their models can skip this part, although there are some differences.
+
+
Obtain Custom-Trained YOLOv5s ONNX Model
+
Prepare Custom Dataset (The author uses the VOC dataset)
+
+
Dataset Directory Structure is as follows:
+
+
+
└─VOC2028: Custom dataset
+ ├─Annotations Stores the dataset label files in XML format
+ ├─ImageSets Dataset split files
+ │ └─Main
+ ├─JPEGImages Stores the dataset images
+
+
+
Split the Dataset
+
+
Execute python3 split_train_val.py in the split_train_val.py file path, and you will get the following directory structure:
+
+
└─VOC2028: Custom dataset
+ ├─Annotations Stores the dataset label files in XML format
+ ├─ImageSets Dataset split files
+ │ └─Main test.txt
+ └─test.txt
+ └─train.txt
+ └─val.txt
+ ├─JPEGImages Stores the dataset images
+ ├─split_train_val.py Python file for splitting the dataset
+
+
split_train_val.py file code:
+
+
# -*- coding: utf-8 -*-
+"""
+Author: dragonforward
+Description: Split into training, validation, and test sets in the ratio of 8:1:1, 8 for training, 1 for validation, and 1 for testing.
+"""
+import os
+import random
+import argparse
+
+parser = argparse.ArgumentParser()
+# Address of the XML files, modify according to your data. XML files are usually stored in Annotations
+parser.add_argument('--xml_path', default='Annotations/', type=str, help='input xml label path')
+# Dataset split, choose the address under your data's ImageSets/Main
+parser.add_argument('--txt_path', default='ImageSets/Main/', type=str, help='output txt label path')
+opt = parser.parse_args()
+
+train_percent = 0.8 # Proportion of the training set
+val_percent = 0.1 # Proportion of the validation set
+test_persent = 0.1 # Proportion of the test set
+
+xmlfilepath = opt.xml_path
+txtsavepath = opt.txt_path
+total_xml = os.listdir(xmlfilepath)
+
+if not os.path.exists(txtsavepath):
+ os.makedirs(txtsavepath)
+
+num = len(total_xml)
+list = list(range(num))
+
+t_train = int(num * train_percent)
+t_val = int(num * val_percent)
+
+train = random.sample(list, t_train)
+num1 = len(train)
+for i in range(num1):
+ list.remove(train[i])
+
+
+val_test = [i for i in list if not i in train]
+val = random.sample(val_test, t_val)
+num2 = len(val)
+for i in range(num2):
+ list.remove(val[i])
+
+
+file_train = open(txtsavepath + '/train.txt', 'w')
+file_val = open(txtsavepath + '/val.txt', 'w')
+file_test = open(txtsavepath + '/test.txt', 'w')
+
+for i in train:
+ name = total_xml[i][:-4] + '\n'
+ file_train.write(name)
+
+for i in val:
+ name = total_xml[i][:-4] + '\n'
+ file_val.write(name)
+
+for i in list:
+ name = total_xml[i][:-4] + '\n'
+ file_test.write(name)
+
+
+file_train.close()
+file_val.close()
+file_test.close()
+
+
+
Convert VOC to labels to obtain label files
+
+
Directory structure:
+
+
└─VOC2028: Custom dataset
+ ├─Annotations Stores the dataset label files in XML format
+ ├─ImageSets Dataset split files
+ │ └─Main
+ ├─JPEGImages Stores the dataset images
+ └─labels YOLOv5 treats this folder as the training annotation folder
+└─voc_label.py
+
+
the voc_label.py file code:
+
+
# -*- coding: utf-8 -*-
+import xml.etree.ElementTree as ET
+import os
+
+sets = ['train', 'val', 'test'] # If your Main folder doesn't have test.txt, remove 'test'
+classes = ["hat", "people"] # Change to your own classes, VOC dataset has the following 20 classes
+# classes = ["brickwork", "coil","rebar"] # Change to your own classes, VOC dataset has the following 20 classes
+# classes = ["aeroplane", 'bicycle', 'bird', 'boat', 'bottle', 'bus', 'car', 'cat', 'chair', 'cow', 'diningtable', 'dog',
+# 'horse', 'motorbike', 'person', 'pottedplant', 'sheep', 'sofa', 'train', 'tvmonitor'] # class names
+# abs_path = os.getcwd() /root/yolov5/data/voc_label.py
+abs_path = '/root/yolov5/data/'
+
+def convert(size, box):
+ dw = 1. / (size[0])
+ dh = 1. / (size[1])
+ x = (box[0] + box[1]) / 2.0 - 1
+ y = (box[2] + box[3]) / 2.0 - 1
+ w = box[1] - box[0]
+ h = box[3] - box[2]
+ x = x * dw
+ w = w * dw
+ y = y * dh
+ h = h * dh
+ return x, y, w, h
+
+
+def convert_annotation(image_id):
+ in_file = open(abs_path + '/VOC2028/Annotations/%s.xml' % (image_id), encoding='UTF-8')
+ out_file = open(abs_path + '/VOC2028/labels/%s.txt' % (image_id), 'w')
+ tree = ET.parse(in_file)
+ root = tree.getroot()
+ size = root.find('size')
+ w = int(size.find('width').text)
+ h = int(size.find('height').text)
+ for obj in root.iter('object'):
+ difficult = obj.find('difficult').text
+ # difficult = obj.find('Difficult').text
+ cls = obj.find('name').text
+ if cls not in classes or int(difficult) == 1:
+ continue
+ cls_id = classes.index(cls)
+ xmlbox = obj.find('bndbox')
+ b = (float(xmlbox.find('xmin').text), float(xmlbox.find('xmax').text), float(xmlbox.find('ymin').text),
+ float(xmlbox.find('ymax').text))
+ b1, b2, b3, b4 = b
+ # Bounding box correction
+ if b2 > w:
+ b2 = w
+ if b4 > h:
+ b4 = h
+ b = (b1, b2, b3, b4)
+ bb = convert((w, h), b)
+ out_file.write(str(cls_id) + " " + " ".join([str(a) for a in bb]) + '\n')
+
+
+for image_set in sets:
+ if not os.path.exists(abs_path + '/VOC2028/labels/'):
+ os.makedirs(abs_path + '/VOC2028/labels/')
+
+ image_ids = open(abs_path + '/VOC2028/ImageSets/Main/%s.txt' % (image_set)).read().strip().split()
+ list_file = open(abs_path + '/VOC2028/%s.txt' % (image_set), 'w')
+ for image_id in image_ids:
+ list_file.write(abs_path + '/VOC2028/JPEGImages/%s.jpg\n' % (image_id)) # Either complete the path yourself, or only writing half may cause an error
+ convert_annotation(image_id)
+ list_file.close()
+
Export the ONNX model. Since the school server is currently in class, they can allocate me a computer only after their class is over. So I used the local conda environment on my laptop to export it. The reason for using -imgsz 224 320 is that it is more suitable for the screen. I also tried 640_640, but the camera reported an error, suggesting that it should be 640_480. Then I saw that the Sipeed YOLOv5s was 320*224, so I kept it consistent with theirs.
Download from the following URL
+https://github.com/sophgo/tpu-mlir/releases/tag/v1.7
+tpu-mlir-resource.tar and tpu_mlir-1.7-py3-none-any.whl
+
+
+
The reason for pulling the latest version is that I failed with version 3.1, as the tools are constantly being updated, so it's better to keep up with the latest version. You can see in the image below that I also tried version 3.1.
+
+
+
docker pull sophgo/tpuc_dev:latest
+
+After entering the container, copy the two prepared files to the workspace directory
+
+root@3d517bc7f51f:/workspace/model_yolov5s# cd ..
+root@3d517bc7f51f:/workspace# ls
+model_yolov5s tpu-mlir-resource tpu-mlir-resource.tar tpu_mlir-1.7-py3-none-any.whl
+root@3d517bc7f51f:/workspace#
+
+Choose one of the following two options, I recommend the second one for offline installation
+pip install tpu_mlir[all] or pip install tpu_mlir-*-py3-none-any.whl[all]
+The author chose the second option
+pip install tpu_mlir-1.7-py3-none-any.whl
+And install all its dependencies
+pip install tpu_mlir-1.7-py3-none-any.whl[all]
+Extract
+tar -xvf tpu-mlir-resource.tar
+Rename the folder
+mv regression/ tpu-mlir-resource/
+
+
+mkdir model_yolov5s && cd model_yolov5s
+
+cp -rf ../tpu_mlir_resource/dataset/COCO2017 .
+cp -rf ../tpu_mlir_resource/image .
+
+
+Transfer the previously prepared 100 images, one test image, and the ONNX model to the following location
+root@3d517bc7f51f:/workspace# cd model_yolov5s/
+root@3d517bc7f51f:/workspace/model_yolov5s# ls
+COCO2017 image workspace yolov5n_hat.onnx yolov5s_hat.onnx
+root@3d517bc7f51f:/workspace/model_yolov5s# cd COCO2017/
+root@3d517bc7f51f:/workspace/model_yolov5s/COCO2017# ls
+000000.jpg 000011.jpg 000022.jpg 000032.jpg 000042.jpg 000053.jpg 000066.jpg 000076.jpg 000086.jpg 000096.jpg
+000002.jpg 000012.jpg 000023.jpg 000033.jpg 000043.jpg 000054.jpg 000067.jpg 000077.jpg 000087.jpg 000101.jpg
+000003.jpg 000013.jpg 000024.jpg 000034.jpg 000044.jpg 000055.jpg 000068.jpg 000078.jpg 000088.jpg 000102.jpg
+000004.jpg 000014.jpg 000025.jpg 000035.jpg 000045.jpg 000058.jpg 000069.jpg 000079.jpg 000089.jpg 000103.jpg
+000005.jpg 000015.jpg 000026.jpg 000036.jpg 000046.jpg 000059.jpg 000070.jpg 000080.jpg 000090.jpg 000104.jpg
+000006.jpg 000016.jpg 000027.jpg 000037.jpg 000048.jpg 000061.jpg 000071.jpg 000081.jpg 000091.jpg 000105.jpg
+000007.jpg 000017.jpg 000028.jpg 000038.jpg 000049.jpg 000062.jpg 000072.jpg 000082.jpg 000092.jpg 000106.jpg
+000008.jpg 000019.jpg 000029.jpg 000039.jpg 000050.jpg 000063.jpg 000073.jpg 000083.jpg 000093.jpg 000107.jpg
+000009.jpg 000020.jpg 000030.jpg 000040.jpg 000051.jpg 000064.jpg 000074.jpg 000084.jpg 000094.jpg 000108.jpg
+000010.jpg 000021.jpg 000031.jpg 000041.jpg 000052.jpg 000065.jpg 000075.jpg 000085.jpg 000095.jpg 000109.jpg
+root@3d517bc7f51f:/workspace/model_yolov5s/COCO2017# ls -l | grep "^-" | wc -l
+100
+root@3d517bc7f51f:/workspace/model_yolov5s/COCO2017#
+
+You can use ls -l | grep "^-" | wc -l to check the number of images. The author replaced the 100 helmet images and the test image in the COCO2017 folder.
+
+Go back to model_yolov5s
+root@3d517bc7f51f:/workspace/model_yolov5s/COCO2017# cd ..
+root@3d517bc7f51f:/workspace/model_yolov5s# ls
+COCO2017 image workspace yolov5n_hat.onnx yolov5s_hat.onnx
+root@3d517bc7f51f:/workspace/model_yolov5s#
+
+Next
+mkdir workspace && cd workspace
+Execute the following command to convert ONNX to MLIR (remember to replace output_names with your own)
+model_transform \
+--model_name yolov5s \
+--model_def ../yolov5s_hat.onnx \
+--input_shapes [[1,3,224,320]] \
+--mean 0.0,0.0,0.0 \
+--scale 0.0039216,0.0039216,0.0039216 \
+--keep_aspect_ratio \
+--pixel_format rgb \
+--output_names onnx::Shape_329,onnx::Shape_439,onnx::Shape_384 \
+--test_input ../image/hat.jpg \
+--test_result yolov5s_top_outputs.npz \
+--mlir yolov5s.mlir
+
+Execute the following command to convert MLIR to INT8 model, before converting to INT8 model, you need to run calibration to obtain the calibration table
+run_calibration yolov5s.mlir \
+--dataset ../COCO2017 \
+--input_num 100 \
+-o yolov5s_cali_table
+Then execute the following
+model_deploy \
+--mlir yolov5s.mlir \
+--quantize INT8 \
+--calibration_table yolov5s_cali_table \
+--processor cv181x \
+--test_input yolov5s_in_f32.npz \
+--test_reference yolov5s_top_outputs.npz \
+--tolerance 0.85,0.45 \
+--model yolov5s_cv181x_int8_sym.cvimodel
+
+Finally, you will get the following:
+root@3d517bc7f51f:/workspace/model_yolov5s/workspace# ls
+_weight_map.csv yolov5s_cv181x_int8_sym.cvimodel yolov5s_origin.mlir
+build_flag.json yolov5s_cv181x_int8_sym_final.mlir yolov5s_top_f32_all_origin_weight.npz
+final_opt.onnx yolov5s_cv181x_int8_sym_tensor_info.txt yolov5s_top_f32_all_weight.npz
+yolov5s.mlir yolov5s_cv181x_int8_sym_tpu.mlir yolov5s_top_outputs.npz
+yolov5s_cali_table yolov5s_in_f32.npz yolov5s_tpu_addressed_cv181x_int8_sym_weight.npz
+yolov5s_cv181x_int8_sym yolov5s_opt.onnx.prototxt yolov5s_tpu_addressed_cv181x_int8_sym_weight_fix.npz
+root@3d517bc7f51f:/workspace/model_yolov5s/workspace#
+
+
Through the above steps, you can obtain the quantized model that can be deployed to the development board.
+
Explanation:
+The reason why it's cv181x is because I tried it first and got the following
+
+
-- [I] load cvimodel from: /root/models/yolov5n.cvimodel
+cvimodel built for cv180x CANNOT run on platform cv181x
+failed to parse cvimodel
+
+
MaixPy provides the display module, which can display images on the screen, and can also send images to MaixVision for display, facilitating debugging and development.
+
API Documentation
+
This document introduces commonly used methods. For more APIs, please refer to the display section of the API documentation.
+
Using the Screen
+
+
Import the display module:
+
+
+
from maix import display
+
+
+
Create a Display object:
+
+
+
disp = display.Display()
+
+
+
Display an image:
+
+
+
disp.show(img)
+
+
Here, the img object is a maix.image.Image object, which can be obtained through the read method of the camera module, or loaded from an image file in the file system using the load method of the image module, or created as a blank image using the Image class of the image module.
Here, while not app.need_exit(): is used to facilitate exiting the loop when the app.set_exit_flag() method is called elsewhere.
+
+
Adjusting Backlight Brightness
+
You can manually adjust the backlight brightness in the system's "Settings" app. If you want to adjust the backlight brightness programmatically, you can use the set_backlight method, with the parameter being the brightness percentage, ranging from 0 to 100:
+
+
disp.set_backlight(50)
+
+
Note that when the program exits and returns to the app selection interface, the backlight brightness will automatically revert to the system setting.
+
Displaying on MaixVision
+
When running code in MaixVision, images can be displayed on MaixVision for easier debugging and development.
+
When calling the show method, the image will be automatically compressed and sent to MaixVision for display.
+
Of course, if you don't have a screen, or to save memory by not initializing the screen, you can also directly call the send_to_maixvision method of the image.Image object to send the image to MaixVision for display.
Face recognition is the process of identifying the location of faces in the current image and determining who they are.
+In addition to detecting faces, face recognition generally involves a database of known and unknown individuals.
+
Recognition Principle
+
+
Use an AI model to detect faces and obtain the coordinates and coordinates of facial features.
+
Use the coordinates of facial features to perform affine transformation on the face in the image, aligning it to a standard face shape, making it easier for the model to extract facial features.
+
Use a feature extraction model to extract facial feature values.
+
Compare the extracted feature values with the recorded facial feature values in the database (calculate the cosine distance between the saved and current facial feature values, and find the smallest distance match in the database. If the distance is smaller than a set threshold, it is considered to be the same person in the database.)
+
+
Using MaixPy
+
The MaixPy maix.nn module provides an API for face recognition, which can be used directly, and the model is also built-in. You can also download it from the MaixHub Model Zoo (filter for the corresponding hardware platform, such as maixcam).
+
Recognition:
+
+
from maix import nn
+
+recognizer = nn.Face_Recognizer(model="/root/models/face_recognizer.mud")
+if os.path.exists("/root/faces.bin"):
+ recognizer.load_faces("/root/faces.bin")
+cam = camera.Camera(recognizer.input_width(), recognizer.input_height(), recognizer.input_format())
+dis = display.Display()
+
+while 1:
+ img = cam.read()
+ faces = recognizer.recognize(img)
+ for obj in faces:
+ img.draw_rect(obj.x, obj.y, obj.w, obj.h, color = image.COLOR_RED)
+ msg = f'{recognizer.labels[obj.class_id]}: {obj.score:.2f}'
+ img.draw_string(obj.x, obj.y, msg, color = image.COLOR_RED)
+ dis.show(img)
+
+
When running this code for the first time, you will find that it can detect faces, but it doesn't recognize anyone. We need to enter the add face mode to learn faces first.
+For example, we can learn faces when the user presses a button:
+
+
faces = recognizer.detect_faces(img)
+for face in faces:
+ print(face)
+ # Here we consider the case where there are multiple faces in one image
+ # You can decide whether to add the face to the database based on the coordinates of `face`
+ recognizer.add_face(face)
+recognizer.save_(faces)("/too/faces.bin")
+
This article will introduce how to use MaixPy to find color blobs and how to use the default application of MaixCam to find color blobs.
+
In vision applications, finding color blobs is a very common requirement, such as robots finding color blobs, automated production lines finding color blobs, etc., which requires identifying specific color areas in the image and obtaining information such as the position and size of these areas.
+
Using MaixPy to Find Blobs
+
The maix.image.Image module in MaixPy provides the find_blobs method, which can conveniently find color blobs.
+
How to Find Blobs
+
A simple example to find color blobs and draw bounding boxes:
+
+
from maix import image, camera, display
+
+cam = camera.Camera(320, 240)
+disp = display.Display()
+
+# Select the corresponding configuration based on the color of the blob
+thresholds = [[0, 80, 40, 80, 10, 80]] # red
+# thresholds = [[0, 80, -120, -10, 0, 30]] # green
+# thresholds = [[0, 80, 30, 100, -120, -60]] # blue
+
+while 1:
+ img = cam.read()
+ blobs = img.find_blobs(thresholds, pixels_threshold=500)
+ for blob in blobs:
+ img.draw_rect(blob[0], blob[1], blob[2], blob[3], image.COLOR_GREEN)
+ disp.show(img)
+
+
Steps:
+
+
Import the image, camera, and display modules
+
+
from maix import image, camera, display
+
+
+
Initialize the camera and display
+
+
cam = camera.Camera(320, 240) # Initialize the camera with an output resolution of 320x240 in RGB format
+disp = display.Display()
+
+
+
Get the image from the camera and display it
+
+
while 1:
+ img = cam.read()
+ disp.show(img)
+
+
+
Call the find_blobs method to find color blobs in the camera image and draw them on the screen
img is the camera image obtained through cam.read(). When initialized with cam = camera.Camera(320, 240), the img object is an RGB image with a resolution of 320x240.
+
img.find_blobs is used to find color blobs. thresholds is a list of color thresholds, where each element is a color threshold. Multiple thresholds can be passed in to find multiple colors simultaneously. Each color threshold is in the format [L_MIN, L_MAX, A_MIN, A_MAX, B_MIN, B_MAX], where L, A, and B are the three channels in the LAB color space. The L channel represents brightness, the A channel represents the red-green component, and the B channel represents the blue-yellow component. pixels_threshold is a pixel count threshold used to filter out unwanted small blobs.
+
img.draw_rect is used to draw bounding boxes around the color blobs. blob[0], blob[1], blob[1], and blob[1] represent the x-coordinate of the top-left corner of the blob, the y-coordinate of the top-left corner of the blob, the width of the blob, and the height of the blob, respectively.
+
+
+
+
Common Parameter Explanations
+
Here are explanations of commonly used parameters. If you cannot find parameters that can implement your application, you may need to consider using other algorithms or extending the required functionality based on the current algorithm's results.
+
+
+
+
Parameter
+
Description
+
Example
+
+
+
+
+
thresholds
+
Thresholds based on the LAB color space, thresholds=[[l_min, l_max, a_min, a_max, b_min, b_max]], representing: Brightness range [l_min, l_max] Green to red component range [a_min, a_max] Blue to yellow component range [b_min, b_max] Multiple thresholds can be set simultaneously
+
Set two thresholds to detect red and green img.find_blobs(thresholds=[[0, 80, 40, 80, 10, 80], [0, 80, -120, -10, 0, 30]]) Red threshold is [0, 80, 40, 80, 10, 80] Green threshold is [0, 80, -120, -10, 0, 30]
+
+
+
invert
+
Enable threshold inversion, when enabled, the passed thresholds are inverted. Default is False.
Set the rectangular region for the algorithm to compute, roi=[x, y, w, h], where x and y represent the coordinates of the top-left corner of the rectangle, and w and h represent the width and height of the rectangle, respectively. The default is the entire image.
+
Compute the region at (50, 50) with a width and height of 100 img.find_blobs(roi=[50, 50, 100, 100])
+
+
+
area_threshold
+
Filter out blobs with a pixel area smaller than area_threshold, in units of pixels. The default is 10. This parameter can be used to filter out some useless small blobs.
+
Filter out blobs with an area smaller than 1000 img.find_blobs(area_threshold=1000)
+
+
+
pixels_threshold
+
Filter out blobs with fewer valid pixels than pixels_threshold. The default is 10. This parameter can be used to filter out some useless small blobs.
+
Filter out blobs with fewer than 1000 valid pixels img.find_blobs(pixels_threshold=1000)
+
+
+
+
This article introduces commonly used methods. For more APIs, please see the image section of the API documentation.
+
Using the Find Blobs App
+
To quickly verify the find blobs functionality, you can first use the find blobs application provided by MaixCam to experience the effect of finding color blobs.
+
Usage
+
Open the device, select the Find Blobs app, then select the color to be recognized from the bottom options or customize a color, and you can recognize the corresponding color. At the same time, the serial port will also output the recognized coordinates and color information.
+
+
Detailed Explanation
+
The app interface is as follows:
+
+
Using Default Configuration
+
The find blobs app provides four default configurations: red, green, blue, and user. red, green, and blue are used to find red, green, and blue color blobs, respectively, while user is mainly provided for user-defined color blob finding. The method for customizing configurations is described below. For a quick experience, you can switch to the corresponding configuration by clicking the buttons at the bottom of the interface.
+
Finding Custom Color Blobs
+
The app provides two ways to find custom color blobs: using adaptive LAB thresholds and manually setting LAB thresholds.
+
1. Finding Color Blobs with Adaptive LAB Thresholds
+
Steps:
+
+
Click the options icon in the bottom-left corner to enter configuration mode.
+
Point the camera at the object you need to find, click on the target object on the screen, and the left side will display a rectangular frame of the object's color and show the LAB values of that color.
+
Click on the appearing rectangular frame, and the system will automatically set the LAB thresholds. At this point, the image will outline the edges of the object.
+
+
2. Manually Setting LAB Thresholds to Find Color Blobs
+
Manual setting allows for more precise targeting of the desired color blobs.
+
Steps:
+
+
Click the options icon in the bottom-left corner to enter configuration mode.
+
Point the camera at the object you need to find, click on the target object on the screen, and the left side will display a rectangular frame of the object's color and show the LAB values of that color.
+
Click on the bottom options L Min, L Max, A Min, A Max, B Min, B Max. After clicking, a slider will appear on the right side to set the value for that option. These values correspond to the minimum and maximum values of the L, A, and B channels in the LAB color format, respectively.
+
Referring to the LAB values of the object color calculated in step 2, adjust L Min, L Max, A Min, A Max, B Min, B Max to appropriate values to identify the corresponding color blobs. For example, if LAB = (20, 50, 80), since L=20, to accommodate a certain range, set L Min=10 and L Max=30. Similarly, since A=50, set A Min=40 and A Max=60. Since B=80, set B Min=70 and B Max=90.
+
+
Getting Detection Data via Serial Protocol
+
The find blobs app supports reporting information about detected color blobs via the serial port (default baud rate is 115200).
+
Since only one report message is sent, we can illustrate the content of the report message with an example.
+
For instance, if the report message is:
+
+
shellCopy code
+
+AA CA AC BB 14 00 00 00 E1 08 EE 00 37 00 15 01 F7 FF 4E 01 19 00 27 01 5A 00 A7 20
+
+
+
AA CA AC BB: Protocol header, content is fixed
+
14 00 00 00: Data length, the total length excluding the protocol header and data length
+
E1: Flag, used to identify the serial message flag
+
08: Command type, for the find blobs app application, this value is fixed at 0x08
+
EE 00 37 00 15 01 F7 FF 4E 01 19 00 27 01 5A 00: Coordinates of the four vertices of the found color blob, with each value represented by 2 bytes in little-endian format. EE 00 and 37 00 represent the first vertex coordinate as (238, 55), 15 01 and F7 FF represent the second vertex coordinate as (277, -9), 4E 01 and 19 00 represent the third vertex coordinate as (334, 25), 27 01 and 5A 00 represent the fourth vertex coordinate as (295, 90).
+
A7 20: CRC checksum value, used to verify if the frame data has errors during transmission.
+
+
About the LAB Color Space
+
The LAB color space, like the RGB color space, is a way to represent colors. LAB can represent all colors visible to the human eye. If you need to learn more about LAB, you can search for relevant articles online, which will provide more details. However, for you, it should be sufficient to understand why LAB is advantageous for MaixPy.
+
Advantages of LAB for MaixPy:
+
+
The color gamut of the LAB color space is larger than that of RGB, so it can completely replace RGB.
+
In the LAB color space, since the L channel is the brightness channel, we often set it to a relatively large range (commonly [0, 80]), and when coding, we mainly focus on the A and B channels. This can save a lot of time spent struggling with how to select color thresholds.
+
The color perception in the LAB color space is more uniform and easier to debug with code. For example, if you only need to find red color blobs, you can fix the values of the L and B channels and only adjust the value of the A channel (in cases where high color accuracy is not required). For RGB channels, you generally need to adjust all three R, G, and B channels simultaneously to find suitable thresholds.
Images play a very important role in visual applications. Whether it's a picture or a video, since a video is essentially a series of frames, image processing is the foundation of visual applications.
+
API Documentation
+
This document introduces common methods. For more APIs, refer to the documentation of the maix.image module.
+
Image Formats
+
MaixPy provides a basic image module image, where the most important part is the image.Image class, which is used for image creation and various basic image operations, as well as image loading and saving.
+
There are many image formats, and we generally use image.Format.FMT_RGB888 or image.Format.FMT_RGBA8888 or image.Format.FMT_GRAYSCALE or image.Format.FMT_BGR888, etc.
+
We all know that the three colors RGB can synthesize any color, so in most cases, we use image.Format.FMT_RGB888, which is sufficient. RGB888 is RGB packed in memory, i.e., the arrangement in memory is:
+pixel1_red, pixel1_green, pixel1_blue, pixel2_red, pixel2_green, pixel2_blue, ... arranged in sequence.
+
Creating an Image
+
Creating an image is very simple, you only need to specify the width and height of the image, and the image format:
320 is the width of the image, 240 is the height of the image, and image.Format.FMT_RGB888 is the format of the image. The format parameter can be omitted, and the default is image.Format.FMT_RGB888.
+
Here, you can get the width, height, and format of the image using img.width(), img.height(), and img.format().
+
Displaying on the Screen
+
MaixPy provides the maix.display.Display class, which can conveniently display images:
Note that here, since there is no image data, a black image is displayed. See the following sections for how to modify the image.
+
Reading Images from the File System
+
MaixPy provides the maix.image.load method, which can read images from the file system:
+
+
from maix import image
+
+img = image.load("/root/image.jpg")
+print(img)
+
+
Note that here, /root/image.jpg has been transferred to the board in advance. You can refer to the previous tutorials for the method.
+It supports jpg and png image formats.
+
Saving Images to the File System
+
MaixPy's maix.image.Image provides the save method, which can save images to the file system:
+
+
from maix import image
+
+img = image.Image(320, 240, image.Format.FMT_RGB888)
+
+# do something with img
+img.save("/root/image.jpg")
+
+
Drawing Rectangles
+
image.Image provides the draw_rect method, which can draw rectangles on the image:
Here, the parameters are: x, y, w, h, color. x and y are the coordinates of the top-left corner of the rectangle, w and h are the width and height of the rectangle, and color is the color of the rectangle, which can be created using the image.Color.from_rgb method.
+You can specify the line width of the rectangle using thickness, which defaults to 1.
+
You can also draw a solid rectangle by passing thickness=-1:
Here, the parameters are: x, y, text, color. x and y are the coordinates of the top-left corner of the text, text is the text to be written, and color is the color of the text, which can be created using the image.Color.from_rgb method.
+
You can also enlarge the font by passing the scale parameter:
Here, the parameters are: x1, y1, x2, y2, color. x1 and y1 are the coordinates of the starting point of the line, x2 and y2 are the coordinates of the end point of the line, and color is the color of the line, which can be created using the image.Color.from_rgb method.
+
Drawing Circles
+
image.Image provides the draw_circle method, which can draw circles on the image:
Here, the parameters are: x, y, r, color. x and y are the coordinates of the center of the circle, r is the radius, and color is the color of the circle, which can be created using the image.Color.from_rgb method.
+
Resizing Images
+
image.Image provides the resize method, which can resize images:
image.Image provides the affine method, which can perform affine transformations. By providing the coordinates of three or more points in the current image and the corresponding coordinates in the target image, you can automatically perform operations such as rotation, scaling, and translation on the image to transform it into the target image:
This draws three red keypoints at the coordinates (10, 10), (100, 10), and (10, 100). The size of the keypoints is 10, the line width is 1, and they are not filled.
+
Drawing Crosses
+
image.Image provides the draw_cross method, which can draw crosses on the image:
This draws a red cross at the coordinate (100, 100). The extension size of the cross is 5, so the length of the line segment is 2 * size + thickness, and the line width is 1.
+
Drawing Arrows
+
image.Image provides the draw_arrow method, which can draw arrows on the image:
Here, to_bytes returns a new bytes object, which is independent memory and does not affect the original image.
+The image.Image constructor can directly construct an image object from bytes data by passing the data parameter. Note that the new image is also independent memory and does not affect data.
+
Since memory copying is involved, this method is relatively time-consuming and should not be used frequently.
+
+
If you want to optimize your program without copying (not recommended for casual use, as poorly written code can easily cause crashes), please refer to the API documentation.
+
+
More Basic API Usage
+
For more API usage, please refer to the documentation of the maix.image module.
MaixHub offers the functionality to train AI models online, directly within a browser. This eliminates the need for expensive hardware, complex development environments, or coding skills, making it highly suitable for beginners as well as experts who prefer not to delve into code.
+
Basic Steps to Train a Model Using MaixHub
+
Identify the Data and Model Types
+
To train an AI model, you first need to determine the type of data and model. As of April 2024, MaixHub provides models for image data including Object Classification Models and Object Detection Models. Object classification models are simpler than object detection models, as the latter require marking the position of objects within images, which can be more cumbersome. Object classification merely requires identifying what is in the image without needing coordinates, making it simpler and recommended for beginners.
+
Collect Data
+
As discussed in AI basics, training a model requires a dataset for the AI to learn from. For image training, you need to create a dataset and upload images to it.
+
Ensure the device is connected to the internet (WiFi).
+Open the MaixHub app on your device and choose to collect data to take photos and upload them directly to MaixHub. You need to create a dataset on MaixHub first, then click on device upload data, which will display a QR code. Scan this QR code with your device to connect to MaixHub.
+
It's important to distinguish between training and validation datasets. To ensure the performance during actual operation matches the training results, the validation dataset must be of the same image quality as those taken during actual operation. It's also advisable to use images taken by the device for the training set. If using internet images, restrict them to the training set only, as the closer the dataset is to actual operational conditions, the better.
+
Annotate Data
+
For classification models, images are annotated during upload by selecting the appropriate category for each image.
+
For object detection models, after uploading, you need to manually annotate each image by marking the coordinates, size, and category of the objects to be recognized.
+This annotation process can also be done offline on your own computer using software like labelimg, then imported into MaixHub using the dataset import feature.
+Utilize shortcuts during annotation to speed up the process. MaixHub will also add more annotation aids and automatic annotation tools in the future (there is already an automatic annotation tool available for videos that you can try).
+
Train the Model
+
Select training parameters, choose the corresponding device platform, select maixcam, and wait in the training queue. You can monitor the training progress in real-time and wait for it to complete.
+
Deploy the Model
+
Once training is complete, you can use the deploy function in the MaixHub app on your device to scan a code and deploy.
+The device will automatically download and run the model, storing it locally for future use.
+
If you find the recognition results satisfactory, you can share the model to the model library with a single click for others to use.
+
How to Use
+
Please visit MaixHub to register an account, then log in. There are video tutorials on the homepage for learning.
+
Note that if the tutorial uses the M2dock development board, the process is similar for MaixCAM, although the MaixHub application on the device might differ slightly. The overall process is the same, so please apply the knowledge flexibly.
This article explains how to use MaixPy for QR code recognition.
+
Using MaixPy to Recognize QR Codes
+
MaixPy's maix.image.Image includes the find_qrcodes method for QR code recognition.
+
How to Recognize QR Codes
+
A simple example that recognizes QR codes and draws a bounding box:
+
+
from maix import image, camera, display
+
+cam = camera.Camera(320, 240)
+disp = display.Display()
+
+while True:
+ img = cam.read()
+ qrcodes = img.find_qrcodes()
+ for qr in qrcodes:
+ corners = qr.corners()
+ for i in range(4):
+ img.draw_line(corners[i][0], corners[i][1], corners[(i + 1) % 4][0], corners[(i + 1) % 4][1], image.COLOR_RED)
+ img.draw_string(qr.x(), qr.y() - 15, qr.payload(), image.COLOR_RED)
+ disp.show(img)
+
+
Steps:
+
+
Import the image, camera, and display modules:
+
+
from maix import image, camera, display
+
+
+
Initialize the camera and display:
+
+
cam = camera.Camera(320, 240) # Initialize the camera with a resolution of 320x240 in RGB format
+disp = display.Display()
+
+
+
Capture and display images from the camera:
+
+
while True:
+ img = cam.read()
+ disp.show(img)
+
+
+
Use the find_qrcodes method to detect QR codes in the camera image:
+
+
qrcodes = img.find_qrcodes()
+
+
+
img is the camera image captured by cam.read(). When initialized as cam = camera.Camera(320, 240), the img object is a 320x240 resolution RGB image.
+
img.find_qrcodes searches for QR codes and saves the results in qrcodes for further processing.
+
+
+
Process and display the results of QR code recognition on the screen:
+
+
for qr in qrcodes:
+ corners = qr.corners()
+ for i in range(4):
+ img.draw_line(corners[i][0], corners[i][1], corners[(i + 1) % 4][0], corners[(i + 1) % 4][1], image.COLOR_RED)
+ img.draw_string(qr.x(), qr.y() - 15, qr.payload(), image.COLOR_RED)
+
+
+
qrcodes contains the results from img.find_qrcodes(). If no QR codes are found, qrcodes will be empty.
+
qr.corners() retrieves the coordinates of the four corners of the detected QR code. img.draw_line() uses these coordinates to draw the QR code outline.
+
img.draw_string displays information about the QR code content and position. qr.x() and qr.y() retrieve the x and y coordinates of the QR code's top-left corner, and qr.payload() retrieves the content of the QR code.
+
+
+
+
Common Parameter Explanation
+
List common parameters and their explanations. If you cannot find parameters that fit your application, consider whether to use a different algorithm or extend the functionality based on the current algorithm's results.
+
+
+
+
Parameter
+
Description
+
Example
+
+
+
+
+
roi
+
Sets the rectangular area for the algorithm to compute, where roi=[x, y, w, h], x and y denote the top-left coordinates of the rectangle, and w and h denote the width and height of the rectangle, defaulting to the entire image.
+
Compute the area with coordinates (50,50) and width and height of 100: img.find_qrcodes(roi=[50, 50, 100, 100])
+
+
+
+
This article introduces common methods. For more API details, refer to the image section of the API documentation.
Typically, to recognize new categories, it is necessary to collect a new dataset and train on a computer, which can be cumbersome and complex. This method eliminates the need for computer-based training, allowing for immediate learning of new objects directly on the device, suitable for less complex scenarios.
+
For example, if there are a drink bottle and a mobile phone in front of you, take a photo of each to serve as the basis for two categories. Then, collect several photos from different angles of each item, extract their features and save them. During recognition, the image's features are compared with the saved feature values, and the closest match determines the classification.
+
Using the Self-Learning Classifier in MaixPy
+
Steps:
+
+
Collect n classification images.
+
Collect n*m images, m images for each category, order does not matter.
+
Start learning.
+
Recognize images and output results.
+
+
Simplified version of the code, for the full version please refer to the complete code in the example.
Similar to the self-learning classifier, the self-learning detector does not require training. Simply taking a few photos of the object to be detected can enable detection, which is very useful in simple detection scenarios.
+Unlike the self-learning classifier, since it is a detector, it will provide the coordinates and size of the object.
Object detection refers to identifying the position and category of targets in an image or video, such as detecting objects like apples and airplanes in a picture, and marking the position of these objects.
+
Unlike classification, object detection includes positional information, so the result is usually a rectangular box that frames the location of the object.
+
Using Object Detection in MaixPy
+
MaixPy comes with the YOLOv5 model by default, which can be used directly:
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.
ImportError: arg(): could not convert default argument 'format: maix::image::Format' in method '<class 'maix._maix.camera.Camera'>.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.
diff --git a/maixpy/sitemap.xml b/maixpy/sitemap.xml
index 662db9bf..3b1eedb9 100644
--- a/maixpy/sitemap.xml
+++ b/maixpy/sitemap.xml
@@ -2,223 +2,229 @@
https://wiki.sipeed.com/maixpy/api/maix/err.html
- 2024-04-24
+ 2024-04-29weekly1.0https://wiki.sipeed.com/maixpy/api/maix/util.html
- 2024-04-24
+ 2024-04-29weekly1.0https://wiki.sipeed.com/maixpy/api/maix/peripheral.html
- 2024-04-24
+ 2024-04-29weekly1.0
- https://wiki.sipeed.com/maixpy/api/maix/rtsp.html
- 2024-04-24
+ https://wiki.sipeed.com/maixpy/api/maix/peripheral/wdt.html
+ 2024-04-29weekly1.0
- https://wiki.sipeed.com/maixpy/api/maix/sys.html
- 2024-04-24
+ https://wiki.sipeed.com/maixpy/api/maix/peripheral/spi.html
+ 2024-04-29weekly1.0
- https://wiki.sipeed.com/maixpy/api/maix/display.html
- 2024-04-24
+ https://wiki.sipeed.com/maixpy/api/maix/peripheral/timer.html
+ 2024-04-29weekly1.0
- https://wiki.sipeed.com/maixpy/api/maix/camera.html
- 2024-04-24
+ https://wiki.sipeed.com/maixpy/api/index.html
+ 2024-04-29weekly1.0
- https://wiki.sipeed.com/maixpy/api/maix/network.html
- 2024-04-24
+ https://wiki.sipeed.com/maixpy/api/maix/tensor.html
+ 2024-04-29weekly1.0
- https://wiki.sipeed.com/maixpy/api/maix/nn.html
- 2024-04-24
+ https://wiki.sipeed.com/maixpy/api/maix/network/wifi.html
+ 2024-04-29weekly1.0
- https://wiki.sipeed.com/maixpy/api/maix/app.html
- 2024-04-24
+ https://wiki.sipeed.com/maixpy/api/maix/nn/F.html
+ 2024-04-29weekly1.0
- https://wiki.sipeed.com/maixpy/api/maix/i18n.html
- 2024-04-24
+ https://wiki.sipeed.com/maixpy/api/maix/comm.html
+ 2024-04-29weekly1.0
- https://wiki.sipeed.com/maixpy/api/maix/protocol.html
- 2024-04-24
+ https://wiki.sipeed.com/maixpy/api/maix/rtsp.html
+ 2024-04-29weekly1.0
- https://wiki.sipeed.com/maixpy/api/maix/video.html
- 2024-04-24
+ https://wiki.sipeed.com/maixpy/api/maix/sys.html
+ 2024-04-29weekly1.0
- https://wiki.sipeed.com/maixpy/api/maix/touchscreen.html
- 2024-04-24
+ https://wiki.sipeed.com/maixpy/api/maix/peripheral/i2c.html
+ 2024-04-29weekly1.0
- https://wiki.sipeed.com/maixpy/api/maix/peripheral/wdt.html
- 2024-04-24
+ https://wiki.sipeed.com/maixpy/api/maix/peripheral/gpio.html
+ 2024-04-29weekly1.0
- https://wiki.sipeed.com/maixpy/api/maix/peripheral/adc.html
- 2024-04-24
+ https://wiki.sipeed.com/maixpy/api/maix/peripheral/uart.html
+ 2024-04-29weekly1.0
- https://wiki.sipeed.com/maixpy/api/maix/peripheral/pwm.html
- 2024-04-24
+ https://wiki.sipeed.com/maixpy/api/maix/peripheral/key.html
+ 2024-04-29weekly1.0
- https://wiki.sipeed.com/maixpy/api/maix/time.html
- 2024-04-24
+ https://wiki.sipeed.com/maixpy/api/maix/peripheral/adc.html
+ 2024-04-29weekly1.0
- https://wiki.sipeed.com/maixpy/api/maix/peripheral/spi.html
- 2024-04-24
+ https://wiki.sipeed.com/maixpy/api/maix/peripheral/pwm.html
+ 2024-04-29weekly1.0
- https://wiki.sipeed.com/maixpy/api/maix/peripheral/timer.html
- 2024-04-24
+ https://wiki.sipeed.com/maixpy/api/maix/display.html
+ 2024-04-29weekly1.0
- https://wiki.sipeed.com/maixpy/api/maix/peripheral/i2c.html
- 2024-04-24
+ https://wiki.sipeed.com/maixpy/api/maix/video.html
+ 2024-04-29weekly1.0
- https://wiki.sipeed.com/maixpy/api/maix/tensor.html
- 2024-04-24
+ https://wiki.sipeed.com/maixpy/api/maix/touchscreen.html
+ 2024-04-29weekly1.0
- https://wiki.sipeed.com/maixpy/api/maix/nn/F.html
- 2024-04-24
+ https://wiki.sipeed.com/maixpy/api/maix/camera.html
+ 2024-04-29weekly1.0
- https://wiki.sipeed.com/maixpy/api/maix/comm.html
- 2024-04-24
+ https://wiki.sipeed.com/maixpy/api/maix/network.html
+ 2024-04-29weekly1.0
- https://wiki.sipeed.com/maixpy/api/maix/fs.html
- 2024-04-24
+ https://wiki.sipeed.com/maixpy/api/maix/nn.html
+ 2024-04-29weekly1.0
- https://wiki.sipeed.com/maixpy/api/index.html
- 2024-04-24
+ https://wiki.sipeed.com/maixpy/api/maix/time.html
+ 2024-04-29weekly1.0
- https://wiki.sipeed.com/maixpy/api/maix/peripheral/gpio.html
- 2024-04-24
+ https://wiki.sipeed.com/maixpy/api/maix/fs.html
+ 2024-04-29weekly1.0
- https://wiki.sipeed.com/maixpy/api/maix/peripheral/uart.html
- 2024-04-24
+ https://wiki.sipeed.com/maixpy/api/maix/app.html
+ 2024-04-29weekly1.0
- https://wiki.sipeed.com/maixpy/api/maix/peripheral/key.html
- 2024-04-24
+ https://wiki.sipeed.com/maixpy/api/maix/i18n.html
+ 2024-04-29
+ weekly
+ 1.0
+
+
+ https://wiki.sipeed.com/maixpy/api/maix/protocol.html
+ 2024-04-29weekly1.0https://wiki.sipeed.com/maixpy/api/maix/image.html
- 2024-04-24
+ 2024-04-29weekly1.0https://wiki.sipeed.com/maixpy/api/maix/example.html
- 2024-04-24
+ 2024-04-29weekly1.0https://wiki.sipeed.com/maixpy/api/maix/thread.html
- 2024-04-24
+ 2024-04-29weekly1.0
- https://wiki.sipeed.com/maixpy/doc/zh/faq.html
- 2024-04-22
+ https://wiki.sipeed.com/maixpy/doc/zh/basic/os.html
+ 2024-04-24weekly1.0
- https://wiki.sipeed.com/maixpy/doc/zh/basic/python.html
+ https://wiki.sipeed.com/maixpy/doc/zh/basic/python_pkgs.html2024-03-31weekly1.0
- https://wiki.sipeed.com/maixpy/doc/zh/basic/linux_basic.html
- 2024-03-12
+ https://wiki.sipeed.com/maixpy/doc/zh/basic/app_usage.html
+ 2024-03-31weekly1.0
- https://wiki.sipeed.com/maixpy/doc/zh/basic/maixvision.html
+ https://wiki.sipeed.com/maixpy/doc/zh/basic/maixpy_upgrade.html2024-03-31weekly1.0
- https://wiki.sipeed.com/maixpy/doc/zh/basic/app.html
- 2024-04-08
+ https://wiki.sipeed.com/maixpy/doc/zh/pro/compile_os.html
+ 2024-03-07weekly1.0
@@ -235,44 +241,74 @@
1.0
- https://wiki.sipeed.com/maixpy/doc/zh/vision/apriltag.html
+ https://wiki.sipeed.com/maixpy/doc/zh/faq.html
+ 2024-04-22
+ weekly
+ 1.0
+
+
+ https://wiki.sipeed.com/maixpy/doc/zh/basic/python.html
+ 2024-03-31
+ weekly
+ 1.0
+
+
+ https://wiki.sipeed.com/maixpy/doc/zh/basic/linux_basic.html
+ 2024-03-12
+ weekly
+ 1.0
+
+
+ https://wiki.sipeed.com/maixpy/doc/zh/basic/maixvision.html
+ 2024-03-31
+ weekly
+ 1.0
+
+
+ https://wiki.sipeed.com/maixpy/doc/zh/basic/app.html
+ 2024-04-08
+ weekly
+ 1.0
+
+
+ https://wiki.sipeed.com/maixpy/doc/zh/vision/qrcode.html2024-04-03weekly1.0
- https://wiki.sipeed.com/maixpy/doc/zh/vision/custmize_model.html
- 2024-04-24
+ https://wiki.sipeed.com/maixpy/doc/zh/source_code/add_c_module.html
+ 2024-04-08weekly1.0
- https://wiki.sipeed.com/maixpy/doc/zh/modules/thermal_cam.html
+ https://wiki.sipeed.com/maixpy/doc/zh/source_code/contribute.html2024-03-07weekly1.0
- https://wiki.sipeed.com/maixpy/doc/zh/modules/tof.html
+ https://wiki.sipeed.com/maixpy/doc/zh/peripheral/wdt.html2024-03-07weekly1.0
- https://wiki.sipeed.com/maixpy/doc/zh/modules/acc.html
+ https://wiki.sipeed.com/maixpy/doc/zh/peripheral/spi.html2024-03-07weekly1.0
- https://wiki.sipeed.com/maixpy/doc/zh/audio/recognize.html
- 2024-03-07
+ https://wiki.sipeed.com/maixpy/doc/zh/peripheral/i2c.html
+ 2024-03-30weekly1.0https://wiki.sipeed.com/maixpy/doc/zh/index.html
- 2024-04-24
+ 2024-04-29weekly1.0
@@ -284,13 +320,13 @@
https://wiki.sipeed.com/maixpy/doc/zh/source_code/faq.html
- 2024-03-07
+ 2024-04-26weekly1.0https://wiki.sipeed.com/maixpy/doc/zh/source_code/build.html
- 2024-04-01
+ 2024-04-29weekly1.0
@@ -301,92 +337,92 @@
1.0
- https://wiki.sipeed.com/maixpy/doc/zh/basic/os.html
- 2024-04-24
+ https://wiki.sipeed.com/maixpy/doc/zh/peripheral/gpio.html
+ 2024-03-07weekly1.0
- https://wiki.sipeed.com/maixpy/doc/zh/basic/python_pkgs.html
- 2024-03-31
+ https://wiki.sipeed.com/maixpy/doc/zh/peripheral/uart.html
+ 2024-03-07weekly1.0
- https://wiki.sipeed.com/maixpy/doc/zh/basic/app_usage.html
- 2024-03-31
+ https://wiki.sipeed.com/maixpy/doc/zh/peripheral/pwm.html
+ 2024-03-07weekly1.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-04-03weekly1.0
- https://wiki.sipeed.com/maixpy/doc/zh/pro/compile_os.html
+ https://wiki.sipeed.com/maixpy/doc/zh/modules/thermal_cam.html2024-03-07weekly1.0
- https://wiki.sipeed.com/maixpy/doc/zh/source_code/add_c_module.html
- 2024-04-08
+ https://wiki.sipeed.com/maixpy/doc/zh/modules/tof.html
+ 2024-03-07weekly1.0
- https://wiki.sipeed.com/maixpy/doc/zh/source_code/contribute.html
+ https://wiki.sipeed.com/maixpy/doc/zh/modules/acc.html2024-03-07weekly1.0
- https://wiki.sipeed.com/maixpy/doc/zh/peripheral/wdt.html
+ https://wiki.sipeed.com/maixpy/doc/zh/audio/recognize.html2024-03-07weekly1.0
- https://wiki.sipeed.com/maixpy/doc/zh/peripheral/spi.html
- 2024-03-07
+ https://wiki.sipeed.com/maixpy/doc/zh/vision/apriltag.html
+ 2024-04-03weekly1.0
- https://wiki.sipeed.com/maixpy/doc/zh/peripheral/i2c.html
- 2024-03-30
+ https://wiki.sipeed.com/maixpy/doc/zh/vision/custmize_model.html
+ 2024-04-24weekly1.0
- https://wiki.sipeed.com/maixpy/doc/zh/peripheral/gpio.html
- 2024-03-07
+ https://wiki.sipeed.com/maixpy/doc/zh/vision/self_learn_classifier.html
+ 2024-04-08weekly1.0
- https://wiki.sipeed.com/maixpy/doc/zh/peripheral/uart.html
- 2024-03-07
+ https://wiki.sipeed.com/maixpy/doc/zh/vision/face_recognition.html
+ 2024-04-08weekly1.0
- https://wiki.sipeed.com/maixpy/doc/zh/peripheral/pwm.html
+ https://wiki.sipeed.com/maixpy/doc/zh/vision/object_track.html2024-03-07weekly1.0
- https://wiki.sipeed.com/maixpy/doc/zh/vision/yolov5.html
- 2024-04-03
+ https://wiki.sipeed.com/maixpy/doc/zh/vision/display.html
+ 2024-03-31weekly1.0
- https://wiki.sipeed.com/maixpy/doc/zh/vision/qrcode.html
- 2024-04-03
+ https://wiki.sipeed.com/maixpy/doc/zh/vision/body_key_points.html
+ 2024-04-08weekly1.0
@@ -421,44 +457,266 @@
1.0
- https://wiki.sipeed.com/maixpy/doc/zh/vision/self_learn_classifier.html
- 2024-04-08
+ https://wiki.sipeed.com/maixpy/doc/en/modules/thermal_cam.html
+ 2024-04-26weekly1.0
- https://wiki.sipeed.com/maixpy/doc/zh/vision/face_recognition.html
- 2024-04-08
+ https://wiki.sipeed.com/maixpy/doc/en/modules/tof.html
+ 2024-04-26weekly1.0
- https://wiki.sipeed.com/maixpy/doc/zh/vision/object_track.html
- 2024-03-07
+ https://wiki.sipeed.com/maixpy/doc/en/modules/acc.html
+ 2024-04-26weekly1.0
- https://wiki.sipeed.com/maixpy/doc/zh/vision/display.html
- 2024-03-31
+ https://wiki.sipeed.com/maixpy/doc/en/audio/recognize.html
+ 2024-04-26weekly1.0
- https://wiki.sipeed.com/maixpy/doc/zh/vision/body_key_points.html
- 2024-04-08
+ https://wiki.sipeed.com/maixpy/doc/en/basic/os.html
+ 2024-04-29
+ weekly
+ 1.0
+
+
+ https://wiki.sipeed.com/maixpy/doc/en/basic/python_pkgs.html
+ 2024-04-29
+ weekly
+ 1.0
+
+
+ https://wiki.sipeed.com/maixpy/doc/en/basic/app_usage.html
+ 2024-04-29
+ weekly
+ 1.0
+
+
+ https://wiki.sipeed.com/maixpy/doc/en/basic/maixpy_upgrade.html
+ 2024-04-29
+ weekly
+ 1.0
+
+
+ https://wiki.sipeed.com/maixpy/doc/en/pro/compile_os.html
+ 2024-04-26
+ weekly
+ 1.0
+
+
+ https://wiki.sipeed.com/maixpy/doc/en/peripheral/gpio.html
+ 2024-04-26
+ weekly
+ 1.0
+
+
+ https://wiki.sipeed.com/maixpy/doc/en/peripheral/uart.html
+ 2024-04-26
+ weekly
+ 1.0
+
+
+ https://wiki.sipeed.com/maixpy/doc/en/peripheral/pwm.html
+ 2024-04-26
+ weekly
+ 1.0
+
+
+ https://wiki.sipeed.com/maixpy/doc/en/vision/yolov5.html
+ 2024-04-29
+ weekly
+ 1.0
+
+
+ https://wiki.sipeed.com/maixpy/doc/en/faq.html
+ 2024-04-29
+ weekly
+ 1.0
+
+
+ https://wiki.sipeed.com/maixpy/doc/en/basic/python.html
+ 2024-04-29
+ weekly
+ 1.0
+
+
+ https://wiki.sipeed.com/maixpy/doc/en/basic/linux_basic.html
+ 2024-04-29
+ weekly
+ 1.0
+
+
+ https://wiki.sipeed.com/maixpy/doc/en/basic/maixvision.html
+ 2024-04-29
+ weekly
+ 1.0
+
+
+ https://wiki.sipeed.com/maixpy/doc/en/basic/app.html
+ 2024-04-29
+ weekly
+ 1.0
+
+
+ https://wiki.sipeed.com/maixpy/doc/en/source_code/add_c_module.html
+ 2024-04-29
+ weekly
+ 1.0
+
+
+ https://wiki.sipeed.com/maixpy/doc/en/source_code/contribute.html
+ 2024-04-29
+ weekly
+ 1.0
+
+
+ https://wiki.sipeed.com/maixpy/doc/en/peripheral/wdt.html
+ 2024-04-26
+ weekly
+ 1.0
+
+
+ https://wiki.sipeed.com/maixpy/doc/en/peripheral/spi.html
+ 2024-04-26
+ weekly
+ 1.0
+
+
+ https://wiki.sipeed.com/maixpy/doc/en/peripheral/i2c.html
+ 2024-04-26
+ weekly
+ 1.0
+
+
+ https://wiki.sipeed.com/maixpy/doc/en/vision/qrcode.html
+ 2024-04-03
+ weekly
+ 1.0
+
+
+ https://wiki.sipeed.com/maixpy/doc/en/vision/ai.html
+ 2024-04-03
+ weekly
+ 1.0
+
+
+ https://wiki.sipeed.com/maixpy/doc/en/vision/self_learn_detector.html
+ 2024-04-29weekly1.0https://wiki.sipeed.com/maixpy/doc/en/index.html
- 2024-03-07
+ 2024-04-29
+ weekly
+ 1.0
+
+
+ https://wiki.sipeed.com/maixpy/doc/en/video/jpeg_streaming.html
+ 2024-04-03
+ weekly
+ 1.0
+
+
+ https://wiki.sipeed.com/maixpy/doc/en/source_code/faq.html
+ 2024-04-26
+ weekly
+ 1.0
+
+
+ https://wiki.sipeed.com/maixpy/doc/en/source_code/build.html
+ 2024-04-29
+ weekly
+ 1.0
+
+
+ https://wiki.sipeed.com/maixpy/doc/en/source_code/maixcdk.html
+ 2024-04-29
+ weekly
+ 1.0
+
+
+ https://wiki.sipeed.com/maixpy/doc/en/vision/apriltag.html
+ 2024-04-03
+ weekly
+ 1.0
+
+
+ https://wiki.sipeed.com/maixpy/doc/en/vision/custmize_model.html
+ 2024-04-29
+ weekly
+ 1.0
+
+
+ https://wiki.sipeed.com/maixpy/doc/en/vision/self_learn_classifier.html
+ 2024-04-29
+ weekly
+ 1.0
+
+
+ https://wiki.sipeed.com/maixpy/doc/en/vision/face_recognition.html
+ 2024-04-29
+ weekly
+ 1.0
+
+
+ https://wiki.sipeed.com/maixpy/doc/en/vision/object_track.html
+ 2024-04-26
+ weekly
+ 1.0
+
+
+ https://wiki.sipeed.com/maixpy/doc/en/vision/display.html
+ 2024-03-31
+ weekly
+ 1.0
+
+
+ https://wiki.sipeed.com/maixpy/doc/en/vision/body_key_points.html
+ 2024-04-29
+ weekly
+ 1.0
+
+
+ https://wiki.sipeed.com/maixpy/doc/en/vision/camera.html
+ 2024-04-03
+ weekly
+ 1.0
+
+
+ https://wiki.sipeed.com/maixpy/doc/en/vision/find_blobs.html
+ 2024-04-03
+ weekly
+ 1.0
+
+
+ https://wiki.sipeed.com/maixpy/doc/en/vision/classify.html
+ 2024-04-29
+ weekly
+ 1.0
+
+
+ https://wiki.sipeed.com/maixpy/doc/en/vision/image_ops.html
+ 2024-04-03
+ weekly
+ 1.0
+
+
+ https://wiki.sipeed.com/maixpy/doc/en/vision/maixhub_train.html
+ 2024-04-03weekly1.0https://wiki.sipeed.com/maixpy/doc/en/no_translate.html
- 2024-04-24
+ 2024-04-29weekly1.0
diff --git a/maixpy/static/search_index/index_0.json b/maixpy/static/search_index/index_0.json
index a876fa64..a891d092 100644
--- a/maixpy/static/search_index/index_0.json
+++ b/maixpy/static/search_index/index_0.json
@@ -1 +1 @@
-{"/maixpy/api/maix/err.html":{"title":"maix.err","content":" title: maix.err maix.err module > You can use `maix.err` to access this module with MaixPy > This module is generated from [MaixCDK](https://github.com/sipeed/MaixCDK) ## 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/util.html":{"title":"maix.util","content":" title: maix.util maix.util module > You can use `maix.util` to access this module with MaixPy > This module is generated from [MaixCDK](https://github.com/sipeed/MaixCDK) ## Module No module ## Enum ## Variable ## Function ### disable\\_kernel\\_debug item doc **brief** disable the kernel debug **C++ defination code**: ```cpp void disable_kernel_debug() ``` ### enable\\_kernel\\_debug item doc **brief** disable the kernel debug **C++ defination code**: ```cpp void enable_kernel_debug() ``` ## Class"},"/maixpy/api/maix/peripheral.html":{"title":"maix.peripheral","content":" title: maix.peripheral Chip's peripheral driver > You can use `maix.peripheral` to access this module with MaixPy > This module is generated from [MaixCDK](https://github.com/sipeed/MaixCDK) ## 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/rtsp.html":{"title":"maix.rtsp","content":" title: maix.rtsp maix.rtsp module > You can use `maix.rtsp` to access this module with MaixPy > This module is generated from [MaixCDK](https://github.com/sipeed/MaixCDK) ## Module No module ## Enum ### RtspStreamType item doc **brief** The stream type of rtsp **values** **RTSP_STREAM_NONE**: format invalid **RTSP_STREAM_H265**: **C++ defination code**: ```cpp enum RtspStreamType { RTSP_STREAM_NONE 0, // format invalid RTSP_STREAM_H265, } ``` ## Variable ## Function ## Class ### Rtsp item doc **brief** Rtsp class **C++ defination code**: ```cpp class Rtsp ``` #### \\_\\_init\\_\\_ ```python def __init__(self, ip: str '', port: int 8554, fps: int 30, stream_type: RtspStreamType ...) > None ``` item doc **type** func **brief** Construct a new Video object **param** **ip**: rtsp ip **port**: rtsp port **fps**: rtsp fps **stream_type**: rtsp stream type **static** False **C++ defination code**: ```cpp Rtsp(std::string ip std::string(), int port 8554, int fps 30, rtsp::RtspStreamType stream_type rtsp::RtspStreamType::RTSP_STREAM_H265) ``` #### start ```python def start(self) > maix.err.Err ``` item doc **type** func **brief** start rtsp **return** error code, err::ERR_NONE means success, others means failed **static** False **C++ defination code**: ```cpp err::Err start() ``` #### start (overload 1) item doc **type** func **brief** stop rtsp **return** error code, err::ERR_NONE means success, others means failed **static** False **C++ defination code**: ```cpp err::Err stop() ``` #### bind\\_camera ```python def bind_camera(self, camera: maix.camera.Camera) > maix.err.Err ``` item doc **type** func **brief** Bind camera **param** **camera**: camera object **return** error code, err::ERR_NONE means success, others means failed **static** False **C++ defination code**: ```cpp err::Err bind_camera(camera::Camera *camera) ``` #### write ```python def write(self, stream: ...) > maix.err.Err ``` item doc **type** func **brief** Write data to rtsp **param** **type**: rtsp stream type **data**: rtsp stream data **fps**: rtsp stream data size **return** error code, err::ERR_NONE means success, others means failed **static** False **C++ defination code**: ```cpp err::Err write(video::VideoStream &stream) ``` #### get\\_url ```python def get_url(self) > str ``` item doc **type** func **brief** Get url of rtsp **return** url of rtsp **static** False **C++ defination code**: ```cpp std::string get_url() ``` #### to\\_camera ```python def to_camera(self) > maix.camera.Camera ``` item doc **type** func **brief** Get camera object from rtsp **return** camera object **static** False **C++ defination code**: ```cpp camera::Camera *to_camera() ``` #### rtsp\\_is\\_start ```python def rtsp_is_start(self) > bool ``` item doc **type** func **brief** return rtsp start status **return** true means rtsp is start, false means rtsp is stop. **static** False **C++ defination code**: ```cpp bool rtsp_is_start() ```"},"/maixpy/api/maix/sys.html":{"title":"maix.sys","content":" title: maix.sys maix.sys module > You can use `maix.sys` to access this module with MaixPy > This module is generated from [MaixCDK](https://github.com/sipeed/MaixCDK) ## 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 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) ``` ### poweroff item doc **brief** Power off device **C++ defination code**: ```cpp void poweroff() ``` ### reboot item doc **brief** Power off device and power on **C++ defination code**: ```cpp void reboot() ``` ## Class"},"/maixpy/api/maix/display.html":{"title":"maix.display","content":" title: maix.display maix.display module, control display device and show image on it > You can use `maix.display` to access this module with MaixPy > This module is generated from [MaixCDK](https://github.com/sipeed/MaixCDK) ## 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\\_\\_ ```python def __init__(self, width: int 1, height: int 1, format: maix.image.Format ..., device: str None, open: bool True) > None ``` 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 ```python def width(self) > int ``` item doc **type** func **brief** Get display width **return** width **static** False **C++ defination code**: ```cpp int width() ``` #### height ```python def height(self) > int ``` 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 ```python def size(self) > list[int] ``` 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 ```python def format(self) > maix.image.Format ``` item doc **type** func **brief** Get display format **return** format **static** False **C++ defination code**: ```cpp image::Format format() ``` #### open ```python def open(self, width: int 1, height: int 1, format: maix.image.Format ...) > maix.err.Err ``` 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 ```python def close(self) > maix.err.Err ``` item doc **type** func **brief** close display device **return** error code **static** False **C++ defination code**: ```cpp err::Err close() ``` #### add\\_channel ```python def add_channel(self, width: int 1, height: int 1, format: maix.image.Format ..., open: bool True) > Display ``` 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 ```python def is_opened(self) > bool ``` 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 ```python def is_closed(self) > bool ``` 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 ```python def show(self, img: maix.image.Image, fit: maix.image.Fit ...) > maix.err.Err ``` 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 ```python def device(self) > str ``` item doc **type** func **brief** Get display device path **return** display device path **static** False **C++ defination code**: ```cpp std::string device() ``` #### set\\_backlight ```python def set_backlight(self, value: float) > None ``` item doc **type** func **brief** Set display backlight **param** **value**: backlight value, float type, range is [0, 100] **static** False **C++ defination code**: ```cpp void set_backlight(float value) ``` #### set\\_hmirror ```python def set_hmirror(self, en: bool) > maix.err.Err ``` item doc **type** func **brief** Set display mirror **param** **en**: enable/disable mirror **static** False **C++ defination code**: ```cpp err::Err set_hmirror(bool en) ``` #### set\\_vflip ```python def set_vflip(self, en: bool) > maix.err.Err ``` item doc **type** func **brief** Set display flip **param** **en**: enable/disable flip **static** False **C++ defination code**: ```cpp err::Err set_vflip(bool en) ```"},"/maixpy/api/maix/camera.html":{"title":"maix.camera","content":" title: maix.camera maix.camera module, access camera device and get image from it > You can use `maix.camera` to access this module with MaixPy > This module is generated from [MaixCDK](https://github.com/sipeed/MaixCDK) ## 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\\_\\_ ```python def __init__(self, width: int 1, height: int 1, format: maix.image.Format ..., device: str None, fps: int 1, buff_num: int 3, open: bool True) > None ``` 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 ```python def get_ch_nums(self) > int ``` 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 ```python def open(self, width: int 1, height: int 1, format: maix.image.Format ..., fps: int 1, buff_num: int 1) > maix.err.Err ``` 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 ```python def read(self, buff: capsule None, buff_size: int 0, block: bool True) > maix.image.Image ``` 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 ```python def clear_buff(self) > None ``` 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 ```python def skip_frames(self, num: int) > None ``` 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 ```python def close(self) > None ``` item doc **type** func **brief** Close camera **static** False **C++ defination code**: ```cpp void close() ``` #### add\\_channel ```python def add_channel(self, width: int 1, height: int 1, format: maix.image.Format ..., fps: int 1, buff_num: int 3, open: bool True) > Camera ``` 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 ```python def is_opened(self) > bool ``` 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 ```python def is_closed(self) > bool ``` 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 ```python def width(self) > int ``` item doc **type** func **brief** Get camera width **return** camera width **static** False **C++ defination code**: ```cpp int width() ``` #### height ```python def height(self) > int ``` item doc **type** func **brief** Get camera height **return** camera height **static** False **C++ defination code**: ```cpp int height() ``` #### fps ```python def fps(self) > int ``` item doc **type** func **brief** Get camera fps **return** camera fps **static** False **C++ defination code**: ```cpp int fps() ``` #### format ```python def format(self) > maix.image.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 ```python def buff_num(self) > int ``` item doc **type** func **brief** Get camera buffer number **return** camera buffer number **static** False **C++ defination code**: ```cpp int buff_num() ``` #### hmirror ```python def hmirror(self, value: int 1) > int ``` 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 ```python def vflip(self, value: int 1) > int ``` 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 ```python def exposure(self, value: int 1) > float ``` item doc **type** func **brief** Get camera exposure **return** camera exposure **static** False **C++ defination code**: ```cpp float exposure(int value 1) ``` #### gain ```python def gain(self, value: int 1) > float ``` item doc **type** func **brief** Get camera gain **return** camera gain **static** False **C++ defination code**: ```cpp float gain(int value 1) ``` #### device ```python def device(self) > str ``` item doc **type** func **brief** Get camera device path **return** camera device path **static** False **C++ defination code**: ```cpp std::string device() ``` #### write\\_reg ```python def write_reg(self, addr: int, data: int, bit_width: int 8) > maix.err.Err ``` 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 ```python def read_reg(self, addr: int, bit_width: int 8) > int ``` 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 ```python def show_colorbar(self, enable: bool) > maix.err.Err ``` 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) ``` #### set\\_resolution ```python def set_resolution(self, width: int, height: int) > maix.err.Err ``` item doc **type** func **brief** Set camera resolution **param** **width**: new width **height**: new height **static** False **C++ defination code**: ```cpp err::Err set_resolution(int width, int height) ``` #### set\\_hmirror ```python def set_hmirror(self, en: bool) > maix.err.Err ``` item doc **type** func **brief** Set camera mirror **param** **en**: enable/disable mirror **static** False **C++ defination code**: ```cpp err::Err set_hmirror(bool en) ``` #### set\\_vflip ```python def set_vflip(self, en: bool) > maix.err.Err ``` item doc **type** func **brief** Set camera flip **param** **en**: enable/disable flip **static** False **C++ defination code**: ```cpp err::Err set_vflip(bool en) ``` #### set\\_luma ```python def set_luma(self, value: int) > maix.err.Err ``` item doc **type** func **brief** Set camera constrast **param** **int**: constrast value **static** False **C++ defination code**: ```cpp err::Err set_luma(int value) ``` #### set\\_constrast ```python def set_constrast(self, value: int) > maix.err.Err ``` item doc **type** func **brief** Set camera constrast **param** **int**: constrast value **static** False **C++ defination code**: ```cpp err::Err set_constrast(int value) ``` #### set\\_saturation ```python def set_saturation(self, value: int) > maix.err.Err ``` item doc **type** func **brief** Set camera saturation **param** **int**: saturation value **static** False **C++ defination code**: ```cpp err::Err set_saturation(int value) ```"},"/maixpy/api/maix/network.html":{"title":"maix.network","content":" title: maix.network maix.network module > You can use `maix.network` to access this module with MaixPy > This module is generated from [MaixCDK](https://github.com/sipeed/MaixCDK) ## Module No module ## Enum ## Variable ## Function ### have\\_network item doc **brief** Return if device have network(WiFi/Eth etc.) **return** True if have network, else False. **C++ defination code**: ```cpp bool have_network() ``` ## Class"},"/maixpy/api/maix/nn.html":{"title":"maix.nn","content":" title: maix.nn maix.nn module > You can use `maix.nn` to access this module with MaixPy > This module is generated from [MaixCDK](https://github.com/sipeed/MaixCDK) ## 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/app.html":{"title":"maix.app","content":" title: maix.app maix.app module > You can use `maix.app` to access this module with MaixPy > This module is generated from [MaixCDK](https://github.com/sipeed/MaixCDK) ## 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 > You can use `maix.i18n` to access this module with MaixPy > This module is generated from [MaixCDK](https://github.com/sipeed/MaixCDK) ## 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\\_\\_ ```python def __init__(self, locales_dict: dict[str, dict[str, str]]) > None ``` 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 ```python def tr(self, key: str, locale: str '') > str ``` 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 ```python def set_locale(self, locale: str) > None ``` 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 ```python def get_locale(self) > str ``` 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/protocol.html":{"title":"maix.protocol","content":" title: maix.protocol maix.protocol module > You can use `maix.protocol` to access this module with MaixPy > This module is generated from [MaixCDK](https://github.com/sipeed/MaixCDK) ## 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 ```python def encode_resp_ok(*args, **kwargs) ``` 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 ```python def encode_report(*args, **kwargs) ``` 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 ```python def encode_resp_err(*args, **kwargs) ``` 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 ```python def set_body(self, body_new: maix.Bytes(bytes)) > None ``` 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 ```python def get_body(*args, **kwargs) ``` 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/video.html":{"title":"maix.video","content":" title: maix.video maix.video module > You can use `maix.video` to access this module with MaixPy > This module is generated from [MaixCDK](https://github.com/sipeed/MaixCDK) ## Module No module ## Enum ### VideoType item doc **brief** Video type **values** **VIDEO_NONE**: format invalid **VIDEO_ENC_H265_CBR**: **VIDEO_ENC_MP4_CBR**: **VIDEO_DEC_H265_CBR**: **VIDEO_DEC_MP4_CBR**: **C++ defination code**: ```cpp enum VideoType { VIDEO_NONE 0, // format invalid VIDEO_ENC_H265_CBR, VIDEO_ENC_MP4_CBR, VIDEO_DEC_H265_CBR, VIDEO_DEC_MP4_CBR, } ``` ## Variable ## Function ## Class ### VideoStream item doc **brief** VideoStream class **C++ defination code**: ```cpp class VideoStream ``` ### Encode item doc **brief** Encode class **C++ defination code**: ```cpp class Encode ``` ### Decode item doc **brief** Decode class **C++ defination code**: ```cpp class Decode ``` ### Video item doc **brief** Video class **C++ defination code**: ```cpp class Video ``` #### \\_\\_init\\_\\_ ```python def __init__(self, width: int 1, height: int 1, type: VideoType ...) > None ``` item doc **type** func **brief** Construct a new Video object **param** **path**: video path. if record is true, xxx.h265 means video format is H265, xxx.mp4 means video format is MP4 **record**: If record is true, means record vide. if record is false means play video, default is false. **interval**: record interval. unit: us **width**: video width, default is 1, means auto, mostly means max width of video support **height**: video height, default is 1, means auto, mostly means max height of video support **audio**: If audio is true, means record with audio. default is false. **sample_rate**: audio sample rate, default is 44100. **channel**: audio channel, default is 1. **open**: If true, vido will automatically call open() after creation. default is true. **static** False **C++ defination code**: ```cpp Video(std::string path std::string(), bool record false, int interval 33333, int width 1, int height 1, bool audio false, int sample_rate 44100, int channel 1, bool open true) ``` #### open ```python def open(self, width: int 1, height: int 1, type: VideoType ...) > maix.err.Err ``` item doc **type** func **brief** Open video and run **param** **path**: video path. if record is true, xxx.h265 means video format is H265, xxx.mp4 means video format is MP4 **record**: If record is true, means record vide. if record is false means play video, default is false. **interval**: record interval. unit: us **width**: video width, default is 1, means auto, mostly means max width of video support **height**: video height, default is 1, means auto, mostly means max height of video support **audio**: If audio is true, means record with audio. default is false. **sample_rate**: audio sample rate, default is 44100. **channel**: audio channel, default is 1. **return** error code, err::ERR_NONE means success, others means failed **static** False **C++ defination code**: ```cpp err::Err open(std::string path std::string(), bool record false, int interval 33333, int width 1, int height 1, bool audio false, int sample_rate 44100, int channel 1) ``` #### close ```python def close(self) > None ``` item doc **type** func **brief** Close video **static** False **C++ defination code**: ```cpp void close() ``` #### bind\\_camera item doc **type** func **brief** Bind camera **param** **camera**: camera object **return** error code, err::ERR_NONE means success, others means failed **static** False **C++ defination code**: ```cpp err::Err bind_camera(camera::Camera *camera) ``` #### record\\_start item doc **type** func **brief** start record video **param** **record_time**: record video time, unit: ms. If record_time 1, mean record will not auto stop until record_finish() is called. **return** error code, err::ERR_NONE means success, others means failed **static** False **C++ defination code**: ```cpp err::Err record_start(uint64_t record_time 1) ``` #### record\\_finish item doc **type** func **brief** stop record video **return** error code, err::ERR_NONE means success, others means failed **static** False **C++ defination code**: ```cpp err::Err record_finish() ``` #### capture item doc **type** func **brief** stop record video **return** error code, err::ERR_NONE means success, others means failed **static** False **C++ defination code**: ```cpp image::Image *capture() ``` #### encode ```python def encode(self, img: maix.image.Image) > VideoStream ``` item doc **type** func **brief** Encode image **param** **img**: the image will be encode **return** encode result **static** False **C++ defination code**: ```cpp video::VideoStream encode(image::Image &img) ``` #### decode ```python def decode(self, stream: VideoStream) > maix.image.Image ``` item doc **type** func **brief** Decode image **param** **img**: the image will be decode **return** decode result **static** False **C++ defination code**: ```cpp image::Image *decode(video::VideoStream &stream) ``` #### is\\_recording item doc **type** func **brief** Check if video is recording **return** true if video is recording, false if not **static** False **C++ defination code**: ```cpp bool is_recording() ``` #### is\\_opened ```python def is_opened(self) > bool ``` item doc **type** func **brief** Check if video is opened **return** true if video is opened, false if not **static** False **C++ defination code**: ```cpp bool is_opened() ``` #### is\\_closed ```python def is_closed(self) > bool ``` item doc **type** func **brief** check video device is closed or not **return** closed or not, bool type **static** False **C++ defination code**: ```cpp bool is_closed() ``` #### width ```python def width(self) > int ``` item doc **type** func **brief** Get video width **return** video width **static** False **C++ defination code**: ```cpp int width() ``` #### height ```python def height(self) > int ``` item doc **type** func **brief** Get video height **return** video height **static** False **C++ defination code**: ```cpp int height() ```"},"/maixpy/api/maix/touchscreen.html":{"title":"maix.touchscreen","content":" title: maix.touchscreen maix.touchscreen module > You can use `maix.touchscreen` to access this module with MaixPy > This module is generated from [MaixCDK](https://github.com/sipeed/MaixCDK) ## 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 > You can use `maix.peripheral.wdt` to access this module with MaixPy > This module is generated from [MaixCDK](https://github.com/sipeed/MaixCDK) ## 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, after construct, the wdt will auto start. **param** **id**: direction [in], id of wdt, int type **feed_ms**: direction [in], feed interval, int type, unit is ms, you must feed wdt in this interval, or system will restart. **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, stop and start watchdog timer. **static** False **C++ defination code**: ```cpp int restart() ```"},"/maixpy/api/maix/peripheral/adc.html":{"title":"maix.peripheral.adc","content":" title: maix.peripheral.adc maix.peripheral.adc module > You can use `maix.peripheral.adc` to access this module with MaixPy > This module is generated from [MaixCDK](https://github.com/sipeed/MaixCDK) ## Module No module ## Enum ## Variable ### RES\\_BIT\\_8 item doc **brief** 8 bit resolution, supported by the actual hardware **value** **8** **readonly** True **C++ defination code**: ```cpp const int RES_BIT_8 8 ``` ### RES\\_BIT\\_10 item doc **brief** 10 bit resolution, supported by the actual hardware **value** **10** **readonly** True **C++ defination code**: ```cpp const int RES_BIT_10 10 ``` ### RES\\_BIT\\_12 item doc **brief** 12 bit resolution, supported by the actual hardware **value** **12** **readonly** True **C++ defination code**: ```cpp const int RES_BIT_12 12 ``` ### RES\\_BIT\\_16 item doc **brief** 16 bit resolution, supported by the actual hardware **value** **16** **readonly** True **C++ defination code**: ```cpp const int RES_BIT_16 16 ``` ## Function ## Class ### ADC item doc **brief** Peripheral adc class **C++ defination code**: ```cpp class ADC ``` #### \\_\\_init\\_\\_ ```python def __init__(self, pin: int, resolution: int, vref: float 1) > None ``` 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, float vref 1) ``` #### read ```python def read(self) > int ``` 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 ```python def read_vol(self) > float ``` 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/pwm.html":{"title":"maix.peripheral.pwm","content":" title: maix.peripheral.pwm maix.peripheral.pwm module > You can use `maix.peripheral.pwm` to access this module with MaixPy > This module is generated from [MaixCDK](https://github.com/sipeed/MaixCDK) ## 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 id, int type, like 0, 1, 2 etc. **freq**: direction [in], pwm frequency, unit: Hz. int type. default is 1000 **duty**: direction [in], pwm duty. double type. range is [0, 100], default is 0. **enable**: direction [in], enable pwm output right now. bool type. default is true, if false, you need to call enable() to enable pwm output. **duty_val**: direction [in], pwm duty value, int type. default 1 means not set and auto calculate by freq and duty. This arg directly set pwm duty value, if set, will ignore duty arg. duty_val duty / 100 * T_ns, T_ns 1 / freq * 1000000000. **throw** If args error or init pwm failed, will throw err::Exception **static** False **C++ defination code**: ```cpp PWM(int id, int freq 1000, double duty 0, bool enable true, int duty_val 1) ``` #### duty item doc **type** func **brief** get or set pwm duty **param** **duty**: direction [in], pwm duty, double type, value in [0, 100], default 1 means only read. **return** current duty, float type, if set and set failed will return err::Err **static** False **C++ defination code**: ```cpp double duty(double 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 means set duty_val duty_val 1 or not set, return current duty_val **return** int type when get duty_val, return current duty_val, else return err::Err code. **static** False **C++ defination code**: ```cpp int duty_val(int duty_val 1) ``` #### freq item doc **type** func **brief** get or 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, current freq, if set and set failed will return err::Err **static** False **C++ defination code**: ```cpp int freq(int freq 1) ``` #### enable item doc **type** func **brief** set pwm enable **return** err::Err type, err.Err.ERR_NONE means success **static** False **C++ defination code**: ```cpp err::Err enable() ``` #### disable item doc **type** func **brief** set pwm disable **return** err::Err type, err.Err.ERR_NONE means success **static** False **C++ defination code**: ```cpp err::Err disable() ``` #### is\\_enabled item doc **type** func **brief** get pwm enable status **return** bool type, true means enable, false means disable **static** False **C++ defination code**: ```cpp bool is_enabled() ```"},"/maixpy/api/maix/time.html":{"title":"maix.time","content":" title: maix.time maix.time module > You can use `maix.time` to access this module with MaixPy > This module is generated from [MaixCDK](https://github.com/sipeed/MaixCDK) ## 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\\_\\_ ```python def __init__(self, year: int 0, month: int 0, day: int 0, hour: int 0, minute: int 0, second: int 0, microsecond: int 0, yearday: int 0, weekday: int 0, zone: int 0) > None ``` 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 ```python def strftime(self, format: str) > str ``` 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 ```python def timestamp(self) > float ``` item doc **type** func **brief** Convert to float timestamp **return** float timestamp **static** False **C++ defination code**: ```cpp double timestamp() ```"},"/maixpy/api/maix/peripheral/spi.html":{"title":"maix.peripheral.spi","content":" title: maix.peripheral.spi maix.peripheral.spi module > You can use `maix.peripheral.spi` to access this module with MaixPy > This module is generated from [MaixCDK](https://github.com/sipeed/MaixCDK) ## Module No module ## Enum ### Mode item doc **brief** SPI mode enum **values** **MASTER**: spi master mode **SLAVE**: spi slave mode **C++ defination code**: ```cpp enum Mode { MASTER 0x0, // spi master mode SLAVE 0x1, // spi slave mode } ``` ## Variable ## 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], spi bus id, int type **freq**: direction [in], freq of spi, int type **soft_cs**: direction [in], not use hardware cs, bool type, if set true, you can operate cs pin use gpio manually. **mode**: direction [in], mode of spi, spi.Mode type, spi.Mode.MASTER or spi.Mode.SLAVE. **polarity**: direction [in], polarity of spi, 0 means idle level of clock is low, 1 means high, int type, default is 0. **phase**: direction [in], phase of spi, 0 means data is captured on the first edge of the SPI clock cycle, 1 means second, int type, default is 0. **bits**: direction [in], bits of spi, int type, default is 8. **cs**: direction [in], cs pin number, int type, default is 0, if SPI support multi hardware cs, you can set it to other value. **static** False **C++ defination code**: ```cpp SPI(int id, spi::Mode mode, int freq, bool soft_cs false, int polarity 0, int phase 0, int bits 8, int cs 0) ``` #### read item doc **type** func **brief** read data from spi **param** **length**: direction [in], read length, int type **return** bytes data, Bytes type in C++, bytes type in MaixPy. You need to delete it manually after use in C++. **static** False **C++ defination code**: ```cpp Bytes *read(int length) ``` #### write\\_read item doc **type** func **brief** write data to spi and read data from spi at the same time. **param** **data**: direction [in], data to write, Bytes type in C++, bytes type in MaixPy **read_len**: direction [in], read length, int type, should > 0. **return** read data, Bytes type in C++, bytes type in MaixPy. You need to delete it manually after use in C++. **static** False **C++ defination code**: ```cpp Bytes *write_read(Bytes *data, int read_len) ``` #### 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/timer.html":{"title":"maix.peripheral.timer","content":" title: maix.peripheral.timer maix.peripheral.timer module > You can use `maix.peripheral.timer` to access this module with MaixPy > This module is generated from [MaixCDK](https://github.com/sipeed/MaixCDK) ## 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 > You can use `maix.peripheral.i2c` to access this module with MaixPy > This module is generated from [MaixCDK](https://github.com/sipeed/MaixCDK) ## Module No module ## Enum ### AddrSize item doc **brief** Address size enum **values** **SEVEN_BIT**: 7 bit address mode **TEN_BIT**: 10 bit address mode **C++ defination code**: ```cpp enum AddrSize { SEVEN_BIT 7, // 7 bit address mode TEN_BIT 10 // 10 bit address mode } ``` ### Mode item doc **brief** I2C mode enum **values** **MASTER**: master mode **SLAVE**: slave mode **C++ defination code**: ```cpp enum Mode { MASTER 0x00, // master mode SLAVE 0x01 // slave mode } ``` ## Variable ## Function ### list\\_devices item doc **brief** Get supported i2c bus devices. **return** i2c bus devices list, int type, is the i2c bus id. **C++ defination code**: ```cpp std::vector list_devices() ``` ## 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 bus id, int type, e.g. 0, 1, 2 **freq**: direction [in], i2c clock, int type, default is 100000(100kbit/s), will auto set fast mode if freq > 100000. **mode**: direction [in], mode of i2c, i2c.Mode.SLAVE or i2c.Mode.MASTER. **addr_size**: direction [in], address length of i2c, i2c.AddrSize.SEVEN_BIT or i2c.AddrSize.TEN_BIT. **throw** err::Exception if open i2c device failed. **static** False **C++ defination code**: ```cpp I2C(int id, i2c::Mode mode, int freq 100000, i2c::AddrSize addr_size i2c::AddrSize::SEVEN_BIT) ``` #### scan item doc **type** func **brief** scan all i2c salve address on the bus **return** the list of i2c slave address, int list type. **static** False **C++ defination code**: ```cpp std::vector scan() ``` #### 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, bytes type. Note: The range of value should be in [0,255]. **return** if success, return the length of written data, error occurred will return err::Err. **static** False **C++ defination code**: ```cpp int writeto(int addr, const Bytes &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, bytes type, you should delete it after use in C++. If read failed, return nullptr in C++, None in MaixPy. **static** False **C++ defination code**: ```cpp Bytes* readfrom(int addr, int len) ``` #### writeto\\_mem item doc **type** func **brief** write data to i2c slave's memory address **param** **addr**: direction [in], i2c slave address, int type **mem_addr**: direction [in], memory address want to write, int type. **data**: direction [in], data to write, bytes type. **mem_addr_size**: direction [in], memory address size, default is 8. **mem_addr_le**: direction [in], memory address little endian, default is false, that is send high byte first. **return** data length written if success, error occurred will return err::Err. **static** False **C++ defination code**: ```cpp int writeto_mem(int addr, int mem_addr, const Bytes &data, int mem_addr_size 8, bool mem_addr_le false) ``` #### readfrom\\_mem item doc **type** func **brief** read data from i2c slave **param** **addr**: direction [in], i2c slave address, int type **mem_addr**: direction [in], memory address want to read, int type. **len**: direction [in], data length to read, int type **mem_addr_size**: direction [in], memory address size, default is 8. **mem_addr_le**: direction [in], memory address little endian, default is false, that is send high byte first. **return** the list of data read from i2c slave, bytes type, you should delete it after use in C++. If read failed, return nullptr in C++, None in MaixPy. **static** False **C++ defination code**: ```cpp Bytes* readfrom_mem(int addr, int mem_addr, int len, int mem_addr_size 8, bool mem_addr_le false) ```"},"/maixpy/api/maix/tensor.html":{"title":"maix.tensor","content":" title: maix.tensor maix.tensor module > You can use `maix.tensor` to access this module with MaixPy > This module is generated from [MaixCDK](https://github.com/sipeed/MaixCDK) ## 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\\_\\_ ```python def __init__(self) > None ``` item doc **type** func **brief** Constructor of Tensors **static** False **C++ defination code**: ```cpp Tensors() ``` #### add\\_tensor ```python def add_tensor(self, key: str, tensor: Tensor, copy: bool, auto_delete: bool) > None ``` 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 ```python def rm_tensor(self, key: str) > None ``` item doc **type** func **brief** Remove tensor **static** False **C++ defination code**: ```cpp void rm_tensor(const std::string &key) ``` #### get\\_tensor ```python def get_tensor(self, key: str) > 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\\_\\_ ```python def __getitem__(self, key: str) > Tensor ``` item doc **type** func **brief** Operator [] **static** False **C++ defination code**: ```cpp tensor::Tensor *operator[](const std::string &key) ``` #### \\_\\_len\\_\\_ ```python def __len__(self) > int ``` item doc **type** func **brief** Size **static** False **C++ defination code**: ```cpp size_t size() ``` #### get\\_names ```python def get_names(self) > list[str] ``` 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 > You can use `maix.nn.F` to access this module with MaixPy > This module is generated from [MaixCDK](https://github.com/sipeed/MaixCDK) ## 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 > You can use `maix.comm` to access this module with MaixPy > This module is generated from [MaixCDK](https://github.com/sipeed/MaixCDK) ## 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/fs.html":{"title":"maix.fs","content":" title: maix.fs maix.fs module > You can use `maix.fs` to access this module with MaixPy > This module is generated from [MaixCDK](https://github.com/sipeed/MaixCDK) ## 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) ``` ### symlink item doc **brief** Create soft link **param** **src**: real file path **link**: link file path **force**: force link, if already have link file, will delet it first then create. **C++ defination code**: ```cpp err::Err symlink(const std::string &src, const std::string &link, bool force false) ``` ### 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) ``` ### sync item doc **brief** Sync files, ensure they're wrriten to disk from RAM **C++ defination code**: ```cpp void sync() ``` ### 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, you should manually delete it in C++. **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 ``` #### \\_\\_init\\_\\_ ```python def __init__(self) > None ``` item doc **type** func **brief** Construct File object **static** False **C++ defination code**: ```cpp File() ``` #### open ```python def open(self, path: str, mode: str) > maix.err.Err ``` 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 ```python def close(self) > None ``` item doc **type** func **brief** Close a file **static** False **C++ defination code**: ```cpp void close() ``` #### read ```python def read(self, size: int) > list[int] ``` 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 ```python def readline(self) > str ``` 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 ```python def write(self, buf: list[int]) > int ``` 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 ```python def seek(self, offset: int, whence: int) > int ``` 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 ```python def tell(self) > int ``` 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 ```python def flush(self) > maix.err.Err ``` 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/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.util](./maix/util.html) maix.util module [maix.network](./maix/network.html) maix.network module [maix.nn](./maix/nn.html) maix.nn module [maix.peripheral](./maix/peripheral.html) Chip's peripheral driver [maix.rtsp](./maix/rtsp.html) maix.rtsp module [maix.video](./maix/video.html) maix.video module [maix.touchscreen](./maix/touchscreen.html) maix.touchscreen module "},"/maixpy/api/maix/peripheral/gpio.html":{"title":"maix.peripheral.gpio","content":" title: maix.peripheral.gpio maix.peripheral.gpio module > You can use `maix.peripheral.gpio` to access this module with MaixPy > This module is generated from [MaixCDK](https://github.com/sipeed/MaixCDK) ## Module No module ## Enum ### Mode item doc **brief** GPIO mode **values** **IN**: input mode **OUT**: output mode **OUT_OD**: output open drain mode **MODE_MAX**: **C++ defination code**: ```cpp enum Mode { IN 0x01, // input mode OUT 0x02, // output mode OUT_OD 0x03, // output open drain mode MODE_MAX } ``` ### Pull item doc **brief** GPIO pull mode **values** **PULL_NONE**: pull none mode **PULL_UP**: pull up mode **PULL_DOWN**: pull down mode **PULL_MAX**: **C++ defination code**: ```cpp enum Pull { PULL_NONE 0x00, // pull none mode PULL_UP 0x01, // pull up mode PULL_DOWN 0x02, // pull down mode PULL_MAX } ``` ## Variable ## Function ## Class ### GPIO item doc **brief** Peripheral gpio class **C++ defination code**: ```cpp class GPIO ``` #### \\_\\_init\\_\\_ ```python def __init__(self, pin: str, mode: Mode ..., pull: Pull ...) > None ``` item doc **type** func **brief** GPIO constructor **param** **pin**: direction [in], gpio pin name, string type the same as board's pin name, e.g. \"B14\" or \"GPIOB14\", or number string like \"10\" if board no gpiochipe name. **mode**: direction [in], gpio mode. gpio.Mode type, default is gpio.Mode.IN (input) mode. **pull**: direction [in], gpio pull. gpio.Pull type, default is gpio.Pull.PULL_NONE (pull none) mode. For input mode, this will set gpio default status(value), if set to gpio.Pull.PULL_NONE, gpio value will be floating. For output mode, this will set gpio default status(value), if set to gpio.Pull.PULL_UP, gpio value will be 1, else 0. **throw** err::Exception if open gpio device failed. **static** False **C++ defination code**: ```cpp GPIO(std::string pin, gpio::Mode mode gpio::Mode::IN, gpio::Pull pull gpio::Pull::PULL_NONE) ``` #### value ```python def value(self, value: int 1) > int ``` item doc **type** func **brief** set and get gpio value **param** **value**: direction [in], gpio value. int type. 0, means write gpio to low level 1, means write gpio to high level 1, means read gpio value, not set **return** int type, return gpio value, can be 0 or 1 **static** False **C++ defination code**: ```cpp int value(int value 1) ``` #### high ```python def high(self) > None ``` item doc **type** func **brief** set gpio high (value to 1) **static** False **C++ defination code**: ```cpp void high() ``` #### low ```python def low(self) > None ``` item doc **type** func **brief** set gpio low (value to 0) **static** False **C++ defination code**: ```cpp void low() ``` #### toggle ```python def toggle(self) > None ``` item doc **type** func **brief** gpio toggle **static** False **C++ defination code**: ```cpp void toggle() ```"},"/maixpy/api/maix/peripheral/uart.html":{"title":"maix.peripheral.uart","content":" title: maix.peripheral.uart maix uart peripheral driver > You can use `maix.peripheral.uart` to access this module with MaixPy > This module is generated from [MaixCDK](https://github.com/sipeed/MaixCDK) ## 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\\_devices item doc **brief** Get supported uart ports. **return** uart ports list, string type. **C++ defination code**: ```cpp std::vector list_devices() ``` ## Class ### UART item doc **brief** maix uart peripheral driver **C++ defination code**: ```cpp class UART : public comm::CommBase ``` #### \\_\\_init\\_\\_ ```python def __init__(self, port: str '', baudrate: int 115200, databits: BITS ..., parity: PARITY ..., stopbits: STOP ..., flow_ctrl: FLOW_CTRL ...) > None ``` 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_devices(). 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 ```python def set_port(self, port: str) > maix.err.Err ``` item doc **type** func **brief** Set port **param** **port**: uart port. string type, can get it by uart.list_devices(). **return** set port error code, err.Err type. **static** False **C++ defination code**: ```cpp err::Err set_port(const std::string &port) ``` #### get\\_port ```python def get_port(self) > str ``` item doc **type** func **brief** Get port **return** uart port, string type. **static** False **C++ defination code**: ```cpp std::string get_port() ``` #### set\\_baudrate ```python def set_baudrate(self, baudrate: int) > maix.err.Err ``` 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 ```python def get_baudrate(self) > int ``` item doc **type** func **brief** Get baud rate **return** baud rate, int type. **static** False **C++ defination code**: ```cpp int get_baudrate() ``` #### open ```python def open(self) > maix.err.Err ``` 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 ```python def is_open(self) > bool ``` 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 ```python def close(self) > maix.err.Err ``` 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 ```python def write_str(self, str: str) > int ``` 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 ```python def write(self, data: maix.Bytes(bytes)) > int ``` 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 ```python def available(self, timeout: int 0) > int ``` 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 ```python def read(*args, **kwargs) ``` 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 ```python def readline(*args, **kwargs) ``` 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 > You can use `maix.peripheral.key` to access this module with MaixPy > This module is generated from [MaixCDK](https://github.com/sipeed/MaixCDK) ## 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\\_\\_ ```python def __init__(self, callback: typing.Callable[[int, int], None] None, open: bool True) > None ``` 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 ```python def open(self) > maix.err.Err ``` 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 ```python def close(self) > maix.err.Err ``` 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 ```python def is_opened(self) > bool ``` 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 ```python def read(self) > tuple[int, int] ``` 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/image.html":{"title":"maix.image","content":" title: maix.image maix.image module, image related definition and functions > You can use `maix.image` to access this module with MaixPy > This module is generated from [MaixCDK](https://github.com/sipeed/MaixCDK) ## 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) ``` ### from\\_bytes item doc **brief** Create image from bytes **param** **width**: image width **height**: image height **format**: image format **data**: image data, if data is None, will malloc memory for image data If the image is in jpeg format, data must be filled in. **copy**: if true and data is not None, will copy data to new buffer, else will use data directly. default is true to avoid memory leak. Use it carefully!!! **return** Image object **C++ defination code**: ```cpp image::Image *from_bytes(int width, int height, image::Format format, Bytes *data, bool copy true) ``` ### 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() ``` ### string\\_size item doc **brief** Get text rendered width and height **param** **string**: 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 string_size(std::string string, 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\\_\\_ ```python def __init__(self, width: int 0, height: int 0) > None ``` 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 ```python def width(self, width: int 1) > int ``` item doc **type** func **brief** width of size **param** **width**: set new width, if not set, only return current width **static** False **C++ defination code**: ```cpp int width(int width 1) ``` #### height ```python def height(self, height: int 1) > int ``` item doc **type** func **brief** height of size **param** **height**: set new height, if not set, only return current height **static** False **C++ defination code**: ```cpp int height(int height 1) ``` #### \\_\\_getitem\\_\\_ ```python def __getitem__(self, index: int) > int ``` 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 &operator[](int index) ``` #### \\_\\_str\\_\\_ ```python def __str__(self) > 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) ``` #### \\_\\_getitem\\_\\_ item doc **type** func **brief** Subscript operator **param** **index [0]**: get x1 of line [1] get y1 of line [2] get x2 of line [3] get y2 of line [4] get length of line [5] get magnitude of the straight line after Hough transformation [6] get angle of the straight line after Hough transformation (0 179 degrees) [7] get p value of the straight line after Hough transformation **return** int& **static** False **C++ defination code**: ```cpp int &__getitem__(int index) ``` #### 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\\_\\_ ```python def __init__(self, corners: list[list[int]], x: int, y: int, w: int, h: int, magnitude: int 0) > None ``` 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) ``` #### \\_\\_getitem\\_\\_ ```python def __getitem__(self, index: int) > int ``` item doc **type** func **brief** Subscript operator **param** **index [0]**: get x of rect [1] get y of rect [2] get w of rect [3] get h of rect [4] get magnitude of the straight line after Hough transformation **return** int& **static** False **C++ defination code**: ```cpp int &__getitem__(int index) ``` #### corners ```python def corners(self) > list[list[int]] ``` 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 ```python def rect(self) > list[int] ``` 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 ```python def x(self) > int ``` 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 ```python def y(self) > int ``` 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 ```python def w(self) > int ``` 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 ```python def h(self) > int ``` 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 ```python def magnitude(self) > int ``` 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\\_\\_ ```python def __init__(self, x: int, y: int, r: int, magnitude: int) > None ``` 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) ``` #### \\_\\_getitem\\_\\_ ```python def __getitem__(self, index: int) > int ``` item doc **type** func **brief** Subscript operator **param** **index [0]**: get x of circle [1] get y of circle [2] get r of circle [3] get magnitude of the circle after Hough transformation **return** int& **static** False **C++ defination code**: ```cpp int &__getitem__(int index) ``` #### x ```python def x(self) > int ``` 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 ```python def y(self) > int ``` 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 ```python def r(self) > int ``` 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 ```python def magnitude(self) > int ``` 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) ``` #### \\_\\_getitem\\_\\_ item doc **type** func **brief** Subscript operator **param** **index [0]**: Returns the blob’s bounding box x coordinate [1] Returns the blob’s bounding box y coordinate [2] Returns the blob’s bounding box w coordinate [3] Returns the blob’s bounding box h coordinate [4] Returns the number of pixels that are part of this blob [5] Returns the centroid x position of the blob [6] Returns the centroid y position of the blob **return** int& width or height **static** False **C++ defination code**: ```cpp int &__getitem__(int index) ``` #### 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) ``` #### \\_\\_getitem\\_\\_ item doc **type** func **brief** Subscript operator **param** **index [0]**: Returns the qrcode’s bounding box x coordinate [1] Returns the qrcode’s bounding box y coordinate [2] Returns the qrcode’s bounding box w coordinate [3] Returns the qrcode’s bounding box h coordinate [4] Not support this index, try to use payload() method [5] Returns the version of qrcode [6] Returns the error correction level of qrcode [7] Returns the mask of qrcode [8] Returns the datatype of qrcode [9] Returns the eci of qrcode **return** int& **static** False **C++ defination code**: ```cpp int &__getitem__(int index) ``` #### 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\\_\\_ ```python def __init__(self, rect: list[int], corners: list[list[int]], id: int, famliy: int, centroid_x: float, centroid_y: float, rotation: float, decision_margin: float, hamming: int, goodness: float, x_translation: float, y_translation: float, z_translation: float, x_rotation: float, y_rotation: float, z_rotation: float) > None ``` 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) ``` #### \\_\\_getitem\\_\\_ ```python def __getitem__(self, index: int) > int ``` item doc **type** func **brief** Subscript operator **param** **index [0]**: Returns the apriltag’s bounding box x coordinate [1] Returns the apriltag’s bounding box y coordinate [2] Returns the apriltag’s bounding box w coordinate [3] Returns the apriltag’s bounding box h coordinate [4] Returns the apriltag’s id [5] Returns the apriltag’s family [6] Not support [7] Not support [8] Not support [9] Not support [10] Returns the apriltag’s hamming [11] Not support [12] Not support [13] Not support [14] Not support [15] Not support [16] Not support [17] Not support **return** int& **static** False **C++ defination code**: ```cpp int &__getitem__(int index) ``` #### corners ```python def corners(self) > list[list[int]] ``` 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 ```python def rect(self) > list[int] ``` 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 ```python def x(self) > int ``` 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 ```python def y(self) > int ``` 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 ```python def w(self) > int ``` 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 ```python def h(self) > int ``` 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 ```python def id(self) > int ``` 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 ```python def family(self) > int ``` 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 ```python def cx(self) > int ``` 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 ```python def cxf(self) > float ``` 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 ```python def cy(self) > int ``` 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 ```python def cyf(self) > float ``` 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 ```python def rotation(self) > float ``` 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 ```python def decision_margin(self) > float ``` 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 ```python def hamming(self) > int ``` 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 ```python def goodness(self) > float ``` 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 ```python def x_translation(self) > float ``` 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 ```python def y_translation(self) > float ``` 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 ```python def z_translation(self) > float ``` 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 ```python def x_rotation(self) > float ``` 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 ```python def y_rotation(self) > float ``` 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 ```python def z_rotation(self) > float ``` 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) ``` #### \\_\\_getitem\\_\\_ item doc **type** func **brief** Subscript operator **param** **index [0]**: get x of DataMatrix [1] get y of DataMatrix [2] get w of DataMatrix [3] get h of DataMatrix [4] Not support this index, try to use payload() method [5] Not support this index, try to use rotation() method [6] get rows of DataMatrix [7] get columns of DataMatrix [8] get capacity of DataMatrix [9] get padding of DataMatrix **return** int& **static** False **C++ defination code**: ```cpp int &__getitem__(int index) ``` #### 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** get 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\\_\\_ ```python def __init__(self, rect: list[int], corners: list[list[int]], payload: str, type: int, rotation: float, quality: int) > None ``` 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) ``` #### \\_\\_getitem\\_\\_ ```python def __getitem__(self, index: int) > int ``` item doc **type** func **brief** Subscript operator **param** **index [0]**: get x of BarCode [1] get y of BarCode [2] get w of BarCode [3] get h of BarCode [4] Not support this index, try to use payload() method [5] get type of BarCode [6] Not support this index, try to use rotation() method [7] get quality of BarCode **return** int& **static** False **C++ defination code**: ```cpp int &__getitem__(int index) ``` #### corners ```python def corners(self) > list[list[int]] ``` 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 ```python def rect(self) > list[int] ``` 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 ```python def x(self) > int ``` 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 ```python def y(self) > int ``` 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 ```python def w(self) > int ``` 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 ```python def h(self) > int ``` 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 ```python def payload(self) > str ``` 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 ```python def type(self) > int ``` 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 ```python def rotation(self) > float ``` 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 ```python def quality(self) > int ``` 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) ``` #### \\_\\_getitem\\_\\_ item doc **type** func **brief** Subscript operator **param** **index**: array index **return** int& **static** False **C++ defination code**: ```cpp int &__getitem__(int index) ``` #### 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\\_\\_ ```python def __init__(self, x_translation: float, y_translation: float, rotation: float, scale: float, response: float) > None ``` 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) ``` #### \\_\\_getitem\\_\\_ ```python def __getitem__(self, index: int) > int ``` item doc **type** func **brief** Subscript operator **param** **index**: array index **return** int& **static** False **C++ defination code**: ```cpp int &__getitem__(int index) ``` #### x\\_translation ```python def x_translation(self) > float ``` 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 ```python def y_translation(self) > float ``` 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 ```python def rotation(self) > float ``` 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 ```python def scale(self) > float ``` 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 ```python def response(self) > float ``` 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\\_\\_ ```python def __init__(self, data: list[int]) > None ``` 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\\_\\_ ```python def __init__(self, cx: int, cy: int, x: int, y: int, w: int, h: int, score: int, theta: int, match: int) > None ``` 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\\_\\_ ```python def __init__(self, data: list[KeyPoint], threshold: int, normalized: bool) > None ``` 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 ```python def get_data(self) > list[KeyPoint] ``` 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\\_\\_ ```python def __init__(self) > None ``` 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 **static** False **C++ defination code**: ```cpp Image(int width, int height, image::Format format image::Format::FMT_RGB888) ``` #### 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\\_string 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 **string**: 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_string(int x, int y, const std::string &textstring, 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\\_cross item doc **type** func **brief** Draw cross on image **param** **x**: cross center point's coordinate x **y**: cross center point's coordinate y **color**: cross color @see image::Color **size**: how long the lines of the cross extend, by default(value is 5). So the line length is `2 * size + thickness` **thickness**: cross thickness(line width), by default(value is 1) **static** False **C++ defination code**: ```cpp image::Image *draw_cross(int x, int y, const image::Color &color, int size 5, int thickness 1) ``` #### 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) ```"},"/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 > You can use `maix.example` to access this module with MaixPy > This module is generated from [MaixCDK](https://github.com/sipeed/MaixCDK) ## Module No module ## Enum ### Kind item doc **brief** Example enum **values** **KIND_NONE**: Kind none, value always 0, other enum value will auto increase **KIND_DOG**: Kind dog **KIND_CAT**: Kind cat, value is auto generated according to KING_DOG **KIND_BIRD**: **KIND_MAX**: Max Kind quantity You can get max Kind value by KIND_MAX 1 **C++ defination code**: ```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\\_\\_ ```python def __init__(self) > None ``` 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\\_\\_ ```python def __init__(self, name: str, age: int 18, pet: Kind ...) > None ``` item doc **type** func **brief** Example constructor\\nthis constructor will be export to MaixPy as maix.example.Example.__init__ **param** **name**: direction [in], name of Example, string type **age**: direction [in], age of Example, int type, default is 18, value range is [0, 100] **attention** to make auto generate code work, param Kind should with full namespace name `example::Kind` instead of `Kind`, namespace `maix` can be ignored. **static** False **C++ defination code**: ```cpp Example(std::string &name, int age 18, example::Kind pet example::KIND_NONE) ``` #### get\\_name ```python def get_name(self) > str ``` item doc **type** func **brief** get name of Example\\nyou can also get name by property `name`. **return** name of Example, string type **static** False **C++ defination code**: ```cpp std::string get_name() ``` #### get\\_age ```python def get_age(self) > int ``` item doc **type** func **brief** get age of Example **return** age of Example, int type, value range is [0, 100] **static** False **C++ defination code**: ```cpp int get_age() ``` #### set\\_name ```python def set_name(self, name: str) > None ``` item doc **type** func **brief** set name of Example **param** **name**: name of Example, string type **static** False **C++ defination code**: ```cpp void set_name(std::string name) ``` #### set\\_age ```python def set_age(self, age: int) > None ``` item doc **type** func **brief** set age of Example **param** **age**: age of Example, int type, value range is [0, 100] **static** False **C++ defination code**: ```cpp void set_age(int age) ``` #### set\\_pet ```python def set_pet(self, pet: Kind) > None ``` item doc **type** func **brief** Example enum member **attention** **static** False **C++ defination code**: ```cpp void set_pet(example::Kind pet) ``` #### get\\_pet ```python def get_pet(self) > Kind ``` item doc **type** func **brief** Example enum member **static** False **C++ defination code**: ```cpp example::Kind get_pet() ``` #### get\\_list ```python def get_list(self, in: list[int]) > list[int] ``` item doc **type** func **brief** get list example **param** **in**: direction [in], input list, items are int type. In MaixPy, you can pass list or tuple to this API **return** list, items are int type, content is [1, 2, 3] + in. Alloc item, del in MaixPy will auto free memory. **static** False **C++ defination code**: ```cpp std::vector *get_list(std::vector in) ``` #### get\\_dict ```python def get_dict(self, in: dict[str, int]) > dict[str, int] ``` item doc **type** func **brief** Example dict API **param** **in**: direction [in], input dict, key is string type, value is int type. In MaixPy, you can pass `dict` to this API **return** dict, key is string type, value is int type, content is {\"a\": 1} + in In MaixPy, return type is `dict` object **static** False **C++ defination code**: ```cpp std::map get_dict(std::map &in) ``` #### hello ```python def hello(name: str) > str ``` item doc **type** func **brief** say hello to someone **param** **name**: name of someone, string type **return** string type, content is Example::hello_str + name **static** True **C++ defination code**: ```cpp static std::string hello(std::string name) ``` #### hello\\_bytes ```python def hello_bytes(*args, **kwargs) ``` item doc **type** func **brief** param is bytes example **param** **bytes**: bytes type param **return** bytes type, return value is bytes changed value **static** True **C++ defination code**: ```cpp static Bytes *hello_bytes(Bytes &bytes) ``` #### callback ```python def callback(cb: typing.Callable[[int, int], int]) > int ``` item doc **type** func **brief** Callback example **param** **cb**: callback function, param is two int type, return is int type **return** int type, return value is cb(1, 2) **static** True **C++ defination code**: ```cpp static int callback(std::function cb) ``` #### hello\\_dict ```python def hello_dict(dict: dict[str, int]) > dict[str, int] ``` item doc **type** func **brief** Dict param example **param** **dict**: dict type param, key is string type, value is int type **static** True **C++ defination code**: ```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 ```python def dict_test() > dict[str, Test] ``` item doc **type** func **brief** dict_test, return dict type, and element is pointer type(alloc in C++).\\nHere when the returned Tensor object will auto delete by Python GC. **static** True **C++ defination code**: ```cpp static std::map *dict_test() ```"},"/maixpy/api/maix/thread.html":{"title":"maix.thread","content":" title: maix.thread maix.thread module > You can use `maix.thread` to access this module with MaixPy > This module is generated from [MaixCDK](https://github.com/sipeed/MaixCDK) ## 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() ```"}}
\ No newline at end of file
+{"/maixpy/api/maix/err.html":{"title":"maix.err","content":" title: maix.err maix.err module > You can use `maix.err` to access this module with MaixPy > This module is generated from [MaixCDK](https://github.com/sipeed/MaixCDK) ## 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/util.html":{"title":"maix.util","content":" title: maix.util maix.util module > You can use `maix.util` to access this module with MaixPy > This module is generated from [MaixCDK](https://github.com/sipeed/MaixCDK) ## Module No module ## Enum ## Variable ## Function ### disable\\_kernel\\_debug item doc **brief** disable the kernel debug **C++ defination code**: ```cpp void disable_kernel_debug() ``` ### enable\\_kernel\\_debug item doc **brief** disable the kernel debug **C++ defination code**: ```cpp void enable_kernel_debug() ``` ## Class"},"/maixpy/api/maix/peripheral.html":{"title":"maix.peripheral","content":" title: maix.peripheral Chip's peripheral driver > You can use `maix.peripheral` to access this module with MaixPy > This module is generated from [MaixCDK](https://github.com/sipeed/MaixCDK) ## 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/peripheral/wdt.html":{"title":"maix.peripheral.wdt","content":" title: maix.peripheral.wdt maix.peripheral.wdt module > You can use `maix.peripheral.wdt` to access this module with MaixPy > This module is generated from [MaixCDK](https://github.com/sipeed/MaixCDK) ## 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, after construct, the wdt will auto start. **param** **id**: direction [in], id of wdt, int type **feed_ms**: direction [in], feed interval, int type, unit is ms, you must feed wdt in this interval, or system will restart. **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, stop and start watchdog timer. **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 > You can use `maix.peripheral.spi` to access this module with MaixPy > This module is generated from [MaixCDK](https://github.com/sipeed/MaixCDK) ## Module No module ## Enum ### Mode item doc **brief** SPI mode enum **values** **MASTER**: spi master mode **SLAVE**: spi slave mode **C++ defination code**: ```cpp enum Mode { MASTER 0x0, // spi master mode SLAVE 0x1, // spi slave mode } ``` ## Variable ## 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], spi bus id, int type **freq**: direction [in], freq of spi, int type **soft_cs**: direction [in], not use hardware cs, bool type, if set true, you can operate cs pin use gpio manually. **mode**: direction [in], mode of spi, spi.Mode type, spi.Mode.MASTER or spi.Mode.SLAVE. **polarity**: direction [in], polarity of spi, 0 means idle level of clock is low, 1 means high, int type, default is 0. **phase**: direction [in], phase of spi, 0 means data is captured on the first edge of the SPI clock cycle, 1 means second, int type, default is 0. **bits**: direction [in], bits of spi, int type, default is 8. **cs**: direction [in], cs pin number, int type, default is 0, if SPI support multi hardware cs, you can set it to other value. **static** False **C++ defination code**: ```cpp SPI(int id, spi::Mode mode, int freq, bool soft_cs false, int polarity 0, int phase 0, int bits 8, int cs 0) ``` #### read item doc **type** func **brief** read data from spi **param** **length**: direction [in], read length, int type **return** bytes data, Bytes type in C++, bytes type in MaixPy. You need to delete it manually after use in C++. **static** False **C++ defination code**: ```cpp Bytes *read(int length) ``` #### write\\_read item doc **type** func **brief** write data to spi and read data from spi at the same time. **param** **data**: direction [in], data to write, Bytes type in C++, bytes type in MaixPy **read_len**: direction [in], read length, int type, should > 0. **return** read data, Bytes type in C++, bytes type in MaixPy. You need to delete it manually after use in C++. **static** False **C++ defination code**: ```cpp Bytes *write_read(Bytes *data, int read_len) ``` #### 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/timer.html":{"title":"maix.peripheral.timer","content":" title: maix.peripheral.timer maix.peripheral.timer module > You can use `maix.peripheral.timer` to access this module with MaixPy > This module is generated from [MaixCDK](https://github.com/sipeed/MaixCDK) ## 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/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.util](./maix/util.html) maix.util module [maix.network](./maix/network.html) maix.network module [maix.nn](./maix/nn.html) maix.nn module [maix.peripheral](./maix/peripheral.html) Chip's peripheral driver [maix.rtsp](./maix/rtsp.html) maix.rtsp module [maix.video](./maix/video.html) maix.video module [maix.touchscreen](./maix/touchscreen.html) maix.touchscreen module "},"/maixpy/api/maix/tensor.html":{"title":"maix.tensor","content":" title: maix.tensor maix.tensor module > You can use `maix.tensor` to access this module with MaixPy > This module is generated from [MaixCDK](https://github.com/sipeed/MaixCDK) ## 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\\_\\_ ```python def __init__(self) > None ``` item doc **type** func **brief** Constructor of Tensors **static** False **C++ defination code**: ```cpp Tensors() ``` #### add\\_tensor ```python def add_tensor(self, key: str, tensor: Tensor, copy: bool, auto_delete: bool) > None ``` 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 ```python def rm_tensor(self, key: str) > None ``` item doc **type** func **brief** Remove tensor **static** False **C++ defination code**: ```cpp void rm_tensor(const std::string &key) ``` #### get\\_tensor ```python def get_tensor(self, key: str) > 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\\_\\_ ```python def __getitem__(self, key: str) > Tensor ``` item doc **type** func **brief** Operator [] **static** False **C++ defination code**: ```cpp tensor::Tensor *operator[](const std::string &key) ``` #### \\_\\_len\\_\\_ ```python def __len__(self) > int ``` item doc **type** func **brief** Size **static** False **C++ defination code**: ```cpp size_t size() ``` #### get\\_names ```python def get_names(self) > list[str] ``` 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/network/wifi.html":{"title":"maix.network.wifi","content":" title: maix.network.wifi maix.network.wifi module > You can use `maix.network.wifi` to access this module with MaixPy > This module is generated from [MaixCDK](https://github.com/sipeed/MaixCDK) ## Module No module ## Enum ## Variable ## Function ### list\\_devices item doc **brief** List WiFi interfaces **return** WiFi interface list, string type **C++ defination code**: ```cpp std::vector list_devices() ``` ## Class ### AP\\_Info item doc **brief** WiFi AP info **C++ defination code**: ```cpp class AP_Info ``` #### ssid item doc **type** var **brief** WiFi AP info SSID **static** False **readonly** False **C++ defination code**: ```cpp std::vector