diff --git a/maixpy/api/api.json b/maixpy/api/api.json index bd09efe7..c661a434 100644 --- a/maixpy/api/api.json +++ b/maixpy/api/api.json @@ -552,6 +552,20 @@ "static": false, "def": "tensor::DType dtype()" }, + "to_float_list": { + "type": "func", + "name": "to_float_list", + "doc": { + "brief": "get tensor data and return a list", + "return": "list type data", + "maixpy": "maix.tensor.Tensor.to_float_list", + "py_doc": "get tensor data and return a list\n\nReturns: list type data\n" + }, + "args": [], + "ret_type": "std::valarray*", + "static": false, + "def": "std::valarray* to_float_list()" + }, "argmax": { "type": "func", "name": "argmax", @@ -5288,6 +5302,30 @@ "static": false, "def": "image::Image *to_format(const image::Format &format)" }, + "to_jpeg": { + "type": "func", + "name": "to_jpeg", + "doc": { + "brief": "Convert image to jpeg", + "param": { + "quality": "the quality of jpg, default is 95. range is (50, 100]." + }, + "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", + "maixpy": "maix.image.Image.to_jpeg", + "py_doc": "Convert image to jpeg\n\nArgs:\n - quality: the quality of jpg, default is 95. range is (50, 100].\n\n\nReturns: new image object. Need be delete by caller in C++.\n" + }, + "args": [ + [ + "int", + "quality", + "95" + ] + ], + "ret_type": "image::Image*", + "static": false, + "def": "image::Image *to_jpeg(int quality = 95)" + }, "draw_image": { "type": "func", "name": "draw_image", @@ -5768,15 +5806,14 @@ "doc": { "brief": "Draw keypoints on image", "param": { - "keypoints": "keypoints, [x, y, rotation_andle_in_degrees], TODO: rotation_andle_in_degrees support in the feature", + "keypoints": "keypoints, [x1, y1, x2, y2...] or [x, y, rotation_andle_in_degrees, x2, y2, rotation_andle_in_degrees2](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)" + "thickness": "keypoints thickness(line width), by default(value is -1 means fill circle)" }, "return": "this image object self", "maixpy": "maix.image.Image.draw_keypoints", - "py_doc": "Draw keypoints on image\n\nArgs:\n - keypoints: keypoints, [x, y, rotation_andle_in_degrees], TODO: rotation_andle_in_degrees support in the feature\n - color: keypoints color @see image::Color\n - size: size of keypoints\n - thickness: keypoints thickness(line width), by default(value is 1)\n - fill: if true, will fill keypoints, by default(value is false)\n\n\nReturns: this image object self\n" + "py_doc": "Draw keypoints on image\n\nArgs:\n - keypoints: keypoints, [x1, y1, x2, y2...] or [x, y, rotation_andle_in_degrees, x2, y2, rotation_andle_in_degrees2](TODO: rotation_andle_in_degrees support in the feature)\n - color: keypoints color @see image::Color\n - size: size of keypoints\n - thickness: keypoints thickness(line width), by default(value is -1 means fill circle)\n\n\nReturns: this image object self\n" }, "args": [ [ @@ -5797,17 +5834,12 @@ [ "int", "thickness", - "1" - ], - [ - "bool", - "fill", - "false" + "-1" ] ], "ret_type": "image::Image*", "static": false, - "def": "image::Image *draw_keypoints(std::vector keypoints, const image::Color &color, int size = 10, int thickness = 1, bool fill = false)" + "def": "image::Image *draw_keypoints(std::vector keypoints, const image::Color &color, int size = 10, int thickness = -1)" }, "resize": { "type": "func", @@ -6073,13 +6105,13 @@ "type": "func", "name": "compress", "doc": { - "brief": "JPEG compresses the image in place.", + "brief": "JPEG compresses the image in place, the same as to_jpeg functioin, it's recommend to use to_jpeg instead.", "param": { "quality": "The quality of the compressed image. default is 95." }, "return": "Returns the compressed JPEG image", "maixpy": "maix.image.Image.compress", - "py_doc": "JPEG compresses the image in place.\n\nArgs:\n - quality: The quality of the compressed image. default is 95.\n\n\nReturns: Returns the compressed JPEG image\n" + "py_doc": "JPEG compresses the image in place, the same as to_jpeg functioin, it's recommend to use to_jpeg instead.\n\nArgs:\n - quality: The quality of the compressed image. default is 95.\n\n\nReturns: Returns the compressed JPEG image\n" }, "args": [ [ @@ -9852,6 +9884,56 @@ "static": false, "def": "uint32_t saturation(uint32_t value = -1)", "py_def": "def saturation(self, value: int = -1) -> int" + }, + "awb_mode": { + "type": "func", + "name": "awb_mode", + "doc": { + "brief": "Set/Get white balance mode", + "attention": "This method will affect the isp and thus the image, so please be careful with it.", + "param": { + "value": "value = 0, means set white balance to auto mode, value = 1, means set white balance to manual mode, default is auto mode." + }, + "return": "returns awb mode", + "maixpy": "maix.camera.Camera.awb_mode", + "py_doc": "Set/Get white balance mode\n\nArgs:\n - value: value = 0, means set white balance to auto mode, value = 1, means set white balance to manual mode, default is auto mode.\n\n\nReturns: returns awb mode\n" + }, + "args": [ + [ + "uint32_t", + "value", + "-1" + ] + ], + "ret_type": "uint32_t", + "static": false, + "def": "uint32_t awb_mode(uint32_t value = -1)", + "py_def": "def awb_mode(self, value: int = -1) -> int" + }, + "exp_mode": { + "type": "func", + "name": "exp_mode", + "doc": { + "brief": "Set/Get exposure mode", + "attention": "This method will affect the isp and thus the image, so please be careful with it.", + "param": { + "value": "value = 0, means set exposure to auto mode, value = 1, means set exposure to manual mode, default is auto mode." + }, + "return": "returns exposure mode", + "maixpy": "maix.camera.Camera.exp_mode", + "py_doc": "Set/Get exposure mode\n\nArgs:\n - value: value = 0, means set exposure to auto mode, value = 1, means set exposure to manual mode, default is auto mode.\n\n\nReturns: returns exposure mode\n" + }, + "args": [ + [ + "uint32_t", + "value", + "-1" + ] + ], + "ret_type": "uint32_t", + "static": false, + "def": "uint32_t exp_mode(uint32_t value = -1)", + "py_def": "def exp_mode(self, value: int = -1) -> int" } }, "def": "class Camera" @@ -14571,7 +14653,8 @@ ], "ret_type": "std::vector*", "static": false, - "def": "std::vector *detect(image::Image &img, float conf_th = 0.5, float iou_th = 0.45, maix::image::Fit fit = maix::image::FIT_CONTAIN)" + "def": "std::vector *detect(image::Image &img, float conf_th = 0.5, float iou_th = 0.45, maix::image::Fit fit = maix::image::FIT_CONTAIN)", + "py_def": "def detect(self, img: maix.image.Image, conf_th: float = 0.5, iou_th: float = 0.45, fit: maix.image.Fit = ...) -> list[...]" }, "input_size": { "type": "func", @@ -14980,8 +15063,7 @@ ], "ret_type": null, "static": false, - "def": "MUD(const char *model_path = nullptr)", - "py_def": "def __init__(self, model_path: str = None) -> None" + "def": "MUD(const char *model_path = nullptr)" }, "load": { "type": "func", @@ -15078,7 +15160,8 @@ ], "ret_type": null, "static": false, - "def": "LayerInfo(const std::string &name = \"\", tensor::DType dtype = tensor::DType::FLOAT32, std::vector shape = std::vector())" + "def": "LayerInfo(const std::string &name = \"\", tensor::DType dtype = tensor::DType::FLOAT32, std::vector shape = std::vector())", + "py_def": "def __init__(self, name: str = '', dtype: maix.tensor.DType = ..., shape: list[int] = []) -> None" }, "name": { "type": "var", @@ -15131,7 +15214,8 @@ "args": [], "ret_type": "std::string", "static": false, - "def": "std::string to_str()" + "def": "std::string to_str()", + "py_def": "def to_str(self) -> str" }, "__str__": { "type": "func", @@ -15179,7 +15263,8 @@ ], "ret_type": null, "static": false, - "def": "NN(const std::string &model = \"\")" + "def": "NN(const std::string &model = \"\")", + "py_def": "def __init__(self, model: str = '') -> None" }, "load": { "type": "func", @@ -15217,7 +15302,8 @@ "args": [], "ret_type": "bool", "static": false, - "def": "bool loaded()" + "def": "bool loaded()", + "py_def": "def loaded(self) -> bool" }, "inputs_info": { "type": "func", @@ -15231,7 +15317,8 @@ "args": [], "ret_type": "std::vector", "static": false, - "def": "std::vector inputs_info()" + "def": "std::vector inputs_info()", + "py_def": "def inputs_info(self) -> list[LayerInfo]" }, "outputs_info": { "type": "func", @@ -15245,7 +15332,8 @@ "args": [], "ret_type": "std::vector", "static": false, - "def": "std::vector outputs_info()" + "def": "std::vector outputs_info()", + "py_def": "def outputs_info(self) -> list[LayerInfo]" }, "extra_info": { "type": "func", @@ -15259,7 +15347,8 @@ "args": [], "ret_type": "std::map", "static": false, - "def": "std::map extra_info()" + "def": "std::map extra_info()", + "py_def": "def extra_info(self) -> dict[str, str]" }, "forward": { "type": "func", @@ -15282,7 +15371,8 @@ ], "ret_type": "tensor::Tensors*", "static": false, - "def": "tensor::Tensors *forward(tensor::Tensors &inputs)" + "def": "tensor::Tensors *forward(tensor::Tensors &inputs)", + "py_def": "def forward(self, inputs: maix.tensor.Tensors) -> maix.tensor.Tensors" }, "forward_image": { "type": "func", @@ -15329,7 +15419,8 @@ ], "ret_type": "tensor::Tensors*", "static": false, - "def": "tensor::Tensors *forward_image(image::Image &img, std::vector mean = std::vector(), std::vector scale = std::vector(), image::Fit fit = image::Fit::FIT_FILL, bool copy_result = true)" + "def": "tensor::Tensors *forward_image(image::Image &img, std::vector mean = std::vector(), std::vector scale = std::vector(), image::Fit fit = image::Fit::FIT_FILL, bool copy_result = true)", + "py_def": "def forward_image(self, img: maix.image.Image, mean: list[float] = [], scale: list[float] = [], fit: maix.image.Fit = ..., copy_result: bool = True) -> maix.tensor.Tensors" } }, "def": "class NN" @@ -15374,166 +15465,1117 @@ }, "auto_add": true }, - "Object": { + "FaceDetector": { "type": "class", - "name": "Object", + "name": "FaceDetector", "doc": { - "brief": "Object for detect result", - "maixpy": "maix.nn.Object", - "py_doc": "Object for detect result" + "brief": "FaceDetector class", + "maixpy": "maix.nn.FaceDetector", + "py_doc": "FaceDetector class" }, "members": { "__init__": { "type": "func", - "name": "Object", + "name": "FaceDetector", "doc": { - "brief": "Constructor of Object for detect result", + "brief": "Constructor of FaceDetector class", "param": { - "x": "left top x", - "y": "left top y", - "w": "width", - "h": "height", - "class_id": "class id", - "score": "score" + "model": "model path, default empty, you can load model later by load function." }, - "maixpy": "maix.nn.Object.__init__", - "maixcdk": "maix.nn.Object.Object", - "py_doc": "Constructor of Object for detect result\n\nArgs:\n - x: left top x\n - y: left top y\n - w: width\n - h: height\n - class_id: class id\n - score: score\n" + "throw": "If model arg is not empty and load failed, will throw err::Exception.", + "maixpy": "maix.nn.FaceDetector.__init__", + "maixcdk": "maix.nn.FaceDetector.FaceDetector", + "py_doc": "Constructor of FaceDetector class\n\nArgs:\n - model: model path, default empty, you can load model later by load function.\n" }, "args": [ [ - "int", - "x", - "0" - ], + "const string &", + "model", + "\"\"" + ] + ], + "ret_type": null, + "static": false, + "def": "FaceDetector(const string &model = \"\")" + }, + "load": { + "type": "func", + "name": "load", + "doc": { + "brief": "Load model from file", + "param": { + "model": "Model path want to load" + }, + "return": "err::Err", + "maixpy": "maix.nn.FaceDetector.load", + "py_doc": "Load model from file\n\nArgs:\n - model: Model path want to load\n\n\nReturns: err::Err\n" + }, + "args": [ [ - "int", - "y", - "0" - ], + "const string &", + "model", + null + ] + ], + "ret_type": "err::Err", + "static": false, + "def": "err::Err load(const string &model)", + "py_def": "def load(self, model: str) -> maix.err.Err" + }, + "detect": { + "type": "func", + "name": "detect", + "doc": { + "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.", + "maixpy": "maix.nn.FaceDetector.detect", + "py_doc": "Detect objects from image\n\nArgs:\n - img: Image want to detect, if image's size not match model input's, will auto resize with fit method.\n - conf_th: Confidence threshold, default 0.5.\n - iou_th: IoU threshold, default 0.45.\n - fit: Resize method, default image.Fit.FIT_CONTAIN.\n\n\nReturns: Object list. In C++, you should delete it after use.\n" + }, + "args": [ [ - "int", - "w", - "0" + "image::Image &", + "img", + null ], [ - "int", - "h", - "0" + "float", + "conf_th", + "0.5" ], [ - "int", - "class_id", - "0" + "float", + "iou_th", + "0.45" ], [ - "float", - "score", - "0" + "maix::image::Fit", + "fit", + "maix::image::FIT_CONTAIN" ] ], - "ret_type": null, + "ret_type": "std::vector*", "static": false, - "def": "Object(int x = 0, int y = 0, int w = 0, int h = 0, int class_id = 0, float score = 0)" + "def": "std::vector *detect(image::Image &img, float conf_th = 0.5, float iou_th = 0.45, maix::image::Fit fit = maix::image::FIT_CONTAIN)", + "py_def": "def detect(self, img: maix.image.Image, conf_th: float = 0.5, iou_th: float = 0.45, fit: maix.image.Fit = ...) -> list[...]" }, - "__str__": { + "input_size": { "type": "func", - "name": "to_str", + "name": "input_size", "doc": { - "brief": "Object info to string", - "return": "Object info string", - "maixpy": "maix.nn.Object.__str__", - "maixcdk": "maix.nn.Object.to_str", - "py_doc": "Object info to string\n\nReturns: Object info string\n" + "brief": "Get model input size", + "return": "model input size", + "maixpy": "maix.nn.FaceDetector.input_size", + "py_doc": "Get model input size\n\nReturns: model input size\n" }, "args": [], - "ret_type": "std::string", + "ret_type": "image::Size", "static": false, - "def": "std::string to_str()" + "def": "image::Size input_size()", + "py_def": "def input_size(self) -> maix.image.Size" }, - "x": { - "type": "var", - "name": "x", + "input_width": { + "type": "func", + "name": "input_width", "doc": { - "brief": "Object left top coordinate x", - "maixpy": "maix.nn.Object.x", - "py_doc": "Object left top coordinate x" + "brief": "Get model input width", + "return": "model input size of width", + "maixpy": "maix.nn.FaceDetector.input_width", + "py_doc": "Get model input width\n\nReturns: model input size of width\n" }, - "value": null, + "args": [], + "ret_type": "int", "static": false, - "readonly": false, - "def": "int x" + "def": "int input_width()", + "py_def": "def input_width(self) -> int" }, - "y": { - "type": "var", - "name": "y", + "input_height": { + "type": "func", + "name": "input_height", "doc": { - "brief": "Object left top coordinate y", - "maixpy": "maix.nn.Object.y", - "py_doc": "Object left top coordinate y" + "brief": "Get model input height", + "return": "model input size of height", + "maixpy": "maix.nn.FaceDetector.input_height", + "py_doc": "Get model input height\n\nReturns: model input size of height\n" }, - "value": null, + "args": [], + "ret_type": "int", "static": false, - "readonly": false, - "def": "int y" + "def": "int input_height()", + "py_def": "def input_height(self) -> int" }, - "w": { - "type": "var", - "name": "w", + "input_format": { + "type": "func", + "name": "input_format", "doc": { - "brief": "Object width", - "maixpy": "maix.nn.Object.w", - "py_doc": "Object width" + "brief": "Get input image format", + "return": "input image format, image::Format type.", + "maixpy": "maix.nn.FaceDetector.input_format", + "py_doc": "Get input image format\n\nReturns: input image format, image::Format type.\n" }, - "value": null, + "args": [], + "ret_type": "image::Format", "static": false, - "readonly": false, - "def": "int w" + "def": "image::Format input_format()", + "py_def": "def input_format(self) -> maix.image.Format" }, - "h": { + "mean": { "type": "var", - "name": "h", + "name": "mean", "doc": { - "brief": "Object height", - "maixpy": "maix.nn.Object.h", - "py_doc": "Object height" + "brief": "Get mean value, list type", + "maixpy": "maix.nn.FaceDetector.mean", + "py_doc": "Get mean value, list type" }, "value": null, "static": false, "readonly": false, - "def": "int h" + "def": "std::vector mean" }, - "class_id": { + "scale": { "type": "var", - "name": "class_id", + "name": "scale", "doc": { - "brief": "Object class id", - "maixpy": "maix.nn.Object.class_id", - "py_doc": "Object class id" + "brief": "Get scale value, list type", + "maixpy": "maix.nn.FaceDetector.scale", + "py_doc": "Get scale value, list type" + }, + "value": null, + "static": false, + "readonly": false, + "def": "std::vector scale" + } + }, + "def": "class FaceDetector" + }, + "Retinaface": { + "type": "class", + "name": "Retinaface", + "doc": { + "brief": "Retinaface class", + "maixpy": "maix.nn.Retinaface", + "py_doc": "Retinaface class" + }, + "members": { + "__init__": { + "type": "func", + "name": "Retinaface", + "doc": { + "brief": "Constructor of Retinaface 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.", + "maixpy": "maix.nn.Retinaface.__init__", + "maixcdk": "maix.nn.Retinaface.Retinaface", + "py_doc": "Constructor of Retinaface class\n\nArgs:\n - model: model path, default empty, you can load model later by load function.\n" + }, + "args": [ + [ + "const string &", + "model", + "\"\"" + ] + ], + "ret_type": null, + "static": false, + "def": "Retinaface(const string &model = \"\")" + }, + "load": { + "type": "func", + "name": "load", + "doc": { + "brief": "Load model from file", + "param": { + "model": "Model path want to load" + }, + "return": "err::Err", + "maixpy": "maix.nn.Retinaface.load", + "py_doc": "Load model from file\n\nArgs:\n - model: Model path want to load\n\n\nReturns: err::Err\n" + }, + "args": [ + [ + "const string &", + "model", + null + ] + ], + "ret_type": "err::Err", + "static": false, + "def": "err::Err load(const string &model)", + "py_def": "def load(self, model: str) -> maix.err.Err" + }, + "detect": { + "type": "func", + "name": "detect", + "doc": { + "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.4.", + "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.", + "maixpy": "maix.nn.Retinaface.detect", + "py_doc": "Detect objects from image\n\nArgs:\n - img: Image want to detect, if image's size not match model input's, will auto resize with fit method.\n - conf_th: Confidence threshold, default 0.4.\n - iou_th: IoU threshold, default 0.45.\n - fit: Resize method, default image.Fit.FIT_CONTAIN.\n\n\nReturns: Object list. In C++, you should delete it after use.\n" + }, + "args": [ + [ + "image::Image &", + "img", + null + ], + [ + "float", + "conf_th", + "0.4" + ], + [ + "float", + "iou_th", + "0.45" + ], + [ + "maix::image::Fit", + "fit", + "maix::image::FIT_CONTAIN" + ] + ], + "ret_type": "std::vector*", + "static": false, + "def": "std::vector *detect(image::Image &img, float conf_th = 0.4, float iou_th = 0.45, maix::image::Fit fit = maix::image::FIT_CONTAIN)", + "py_def": "def detect(self, img: maix.image.Image, conf_th: float = 0.5, iou_th: float = 0.45, fit: maix.image.Fit = ...) -> list[...]" + }, + "input_size": { + "type": "func", + "name": "input_size", + "doc": { + "brief": "Get model input size", + "return": "model input size", + "maixpy": "maix.nn.Retinaface.input_size", + "py_doc": "Get model input size\n\nReturns: model input size\n" + }, + "args": [], + "ret_type": "image::Size", + "static": false, + "def": "image::Size input_size()", + "py_def": "def input_size(self) -> maix.image.Size" + }, + "input_width": { + "type": "func", + "name": "input_width", + "doc": { + "brief": "Get model input width", + "return": "model input size of width", + "maixpy": "maix.nn.Retinaface.input_width", + "py_doc": "Get model input width\n\nReturns: model input size of width\n" + }, + "args": [], + "ret_type": "int", + "static": false, + "def": "int input_width()", + "py_def": "def input_width(self) -> int" + }, + "input_height": { + "type": "func", + "name": "input_height", + "doc": { + "brief": "Get model input height", + "return": "model input size of height", + "maixpy": "maix.nn.Retinaface.input_height", + "py_doc": "Get model input height\n\nReturns: model input size of height\n" + }, + "args": [], + "ret_type": "int", + "static": false, + "def": "int input_height()", + "py_def": "def input_height(self) -> int" + }, + "input_format": { + "type": "func", + "name": "input_format", + "doc": { + "brief": "Get input image format", + "return": "input image format, image::Format type.", + "maixpy": "maix.nn.Retinaface.input_format", + "py_doc": "Get input image format\n\nReturns: input image format, image::Format type.\n" + }, + "args": [], + "ret_type": "image::Format", + "static": false, + "def": "image::Format input_format()", + "py_def": "def input_format(self) -> maix.image.Format" + }, + "mean": { + "type": "var", + "name": "mean", + "doc": { + "brief": "Get mean value, list type", + "maixpy": "maix.nn.Retinaface.mean", + "py_doc": "Get mean value, list type" + }, + "value": null, + "static": false, + "readonly": false, + "def": "std::vector mean" + }, + "scale": { + "type": "var", + "name": "scale", + "doc": { + "brief": "Get scale value, list type", + "maixpy": "maix.nn.Retinaface.scale", + "py_doc": "Get scale value, list type" + }, + "value": null, + "static": false, + "readonly": false, + "def": "std::vector scale" + } + }, + "def": "class Retinaface" + }, + "Object": { + "type": "class", + "name": "Object", + "doc": { + "brief": "Object for detect result", + "maixpy": "maix.nn.Object", + "py_doc": "Object for detect result" + }, + "members": { + "__init__": { + "type": "func", + "name": "Object", + "doc": { + "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" + }, + "maixpy": "maix.nn.Object.__init__", + "maixcdk": "maix.nn.Object.Object", + "py_doc": "Constructor of Object for detect result\n\nArgs:\n - x: left top x\n - y: left top y\n - w: width\n - h: height\n - class_id: class id\n - score: score\n" + }, + "args": [ + [ + "int", + "x", + "0" + ], + [ + "int", + "y", + "0" + ], + [ + "int", + "w", + "0" + ], + [ + "int", + "h", + "0" + ], + [ + "int", + "class_id", + "0" + ], + [ + "float", + "score", + "0" + ], + [ + "std::vector", + "points", + "std::vector()" + ] + ], + "ret_type": null, + "static": false, + "def": "Object(int x = 0, int y = 0, int w = 0, int h = 0, int class_id = 0, float score = 0, std::vector points = std::vector())" + }, + "__str__": { + "type": "func", + "name": "to_str", + "doc": { + "brief": "Object info to string", + "return": "Object info string", + "maixpy": "maix.nn.Object.__str__", + "maixcdk": "maix.nn.Object.to_str", + "py_doc": "Object info to string\n\nReturns: Object info string\n" + }, + "args": [], + "ret_type": "std::string", + "static": false, + "def": "std::string to_str()", + "py_def": "def to_str(self) -> str" + }, + "x": { + "type": "var", + "name": "x", + "doc": { + "brief": "Object left top coordinate x", + "maixpy": "maix.nn.Object.x", + "py_doc": "Object left top coordinate x" + }, + "value": null, + "static": false, + "readonly": false, + "def": "int x" + }, + "y": { + "type": "var", + "name": "y", + "doc": { + "brief": "Object left top coordinate y", + "maixpy": "maix.nn.Object.y", + "py_doc": "Object left top coordinate y" + }, + "value": null, + "static": false, + "readonly": false, + "def": "int y" + }, + "w": { + "type": "var", + "name": "w", + "doc": { + "brief": "Object width", + "maixpy": "maix.nn.Object.w", + "py_doc": "Object width" + }, + "value": null, + "static": false, + "readonly": false, + "def": "int w" + }, + "h": { + "type": "var", + "name": "h", + "doc": { + "brief": "Object height", + "maixpy": "maix.nn.Object.h", + "py_doc": "Object height" + }, + "value": null, + "static": false, + "readonly": false, + "def": "int h" + }, + "class_id": { + "type": "var", + "name": "class_id", + "doc": { + "brief": "Object class id", + "maixpy": "maix.nn.Object.class_id", + "py_doc": "Object class id" }, "value": null, "static": false, "readonly": false, "def": "int class_id" }, - "score": { - "type": "var", - "name": "score", + "score": { + "type": "var", + "name": "score", + "doc": { + "brief": "Object score", + "maixpy": "maix.nn.Object.score", + "py_doc": "Object score" + }, + "value": null, + "static": false, + "readonly": false, + "def": "float score" + }, + "points": { + "type": "var", + "name": "points", + "doc": { + "brief": "keypoints", + "maixpy": "maix.nn.Object.points", + "py_doc": "keypoints" + }, + "value": null, + "static": false, + "readonly": false, + "def": "std::vector points" + } + }, + "def": "class Object" + }, + "ObjectFloat": { + "type": "class", + "name": "ObjectFloat", + "doc": { + "brief": "Object for detect result", + "maixpy": "maix.nn.ObjectFloat", + "py_doc": "Object for detect result" + }, + "members": { + "__init__": { + "type": "func", + "name": "ObjectFloat", + "doc": { + "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" + }, + "maixpy": "maix.nn.ObjectFloat.__init__", + "maixcdk": "maix.nn.ObjectFloat.ObjectFloat", + "py_doc": "Constructor of Object for detect result\n\nArgs:\n - x: left top x\n - y: left top y\n - w: width\n - h: height\n - class_id: class id\n - score: score\n" + }, + "args": [ + [ + "float", + "x", + "0" + ], + [ + "float", + "y", + "0" + ], + [ + "float", + "w", + "0" + ], + [ + "float", + "h", + "0" + ], + [ + "float", + "class_id", + "0" + ], + [ + "float", + "score", + "0" + ], + [ + "std::vector", + "points", + "std::vector()" + ] + ], + "ret_type": null, + "static": false, + "def": "ObjectFloat(float x = 0, float y = 0, float w = 0, float h = 0, float class_id = 0, float score = 0, std::vector points = std::vector())" + }, + "__str__": { + "type": "func", + "name": "to_str", + "doc": { + "brief": "Object info to string", + "return": "Object info string", + "maixpy": "maix.nn.ObjectFloat.__str__", + "maixcdk": "maix.nn.ObjectFloat.to_str", + "py_doc": "Object info to string\n\nReturns: Object info string\n" + }, + "args": [], + "ret_type": "std::string", + "static": false, + "def": "std::string to_str()", + "py_def": "def to_str(self) -> str" + }, + "x": { + "type": "var", + "name": "x", + "doc": { + "brief": "Object left top coordinate x", + "maixpy": "maix.nn.ObjectFloat.x", + "py_doc": "Object left top coordinate x" + }, + "value": null, + "static": false, + "readonly": false, + "def": "float x" + }, + "y": { + "type": "var", + "name": "y", + "doc": { + "brief": "Object left top coordinate y", + "maixpy": "maix.nn.ObjectFloat.y", + "py_doc": "Object left top coordinate y" + }, + "value": null, + "static": false, + "readonly": false, + "def": "float y" + }, + "w": { + "type": "var", + "name": "w", + "doc": { + "brief": "Object width", + "maixpy": "maix.nn.ObjectFloat.w", + "py_doc": "Object width" + }, + "value": null, + "static": false, + "readonly": false, + "def": "float w" + }, + "h": { + "type": "var", + "name": "h", + "doc": { + "brief": "Object height", + "maixpy": "maix.nn.ObjectFloat.h", + "py_doc": "Object height" + }, + "value": null, + "static": false, + "readonly": false, + "def": "float h" + }, + "class_id": { + "type": "var", + "name": "class_id", + "doc": { + "brief": "Object class id", + "maixpy": "maix.nn.ObjectFloat.class_id", + "py_doc": "Object class id" + }, + "value": null, + "static": false, + "readonly": false, + "def": "float class_id" + }, + "score": { + "type": "var", + "name": "score", + "doc": { + "brief": "Object score", + "maixpy": "maix.nn.ObjectFloat.score", + "py_doc": "Object score" + }, + "value": null, + "static": false, + "readonly": false, + "def": "float score" + }, + "points": { + "type": "var", + "name": "points", + "doc": { + "brief": "keypoints", + "maixpy": "maix.nn.ObjectFloat.points", + "py_doc": "keypoints" + }, + "value": null, + "static": false, + "readonly": false, + "def": "std::vector points" + } + }, + "def": "class ObjectFloat" + } + }, + "auto_add": true + }, + "audio": { + "type": "module", + "doc": { + "brief": "maix.audio module", + "maixpy": "maix.audio", + "py_doc": "maix.audio module" + }, + "members": { + "Format": { + "type": "enum", + "name": "Format", + "doc": { + "brief": "Audio type", + "maixpy": "maix.audio.Format", + "py_doc": "Audio type" + }, + "values": [ + [ + "FMT_NONE", + "0", + "format invalid" + ], + [ + "FMT_S8", + "", + "unsigned 8 bits" + ], + [ + "FMT_S16_LE", + "", + "signed 16 bits, little endian" + ], + [ + "FMT_S32_LE", + "", + "signed 32 bits, little endian" + ], + [ + "FMT_S16_BE", + "", + "signed 16 bits, big endian" + ], + [ + "FMT_S32_BE", + "", + "signed 32 bits, big endian" + ], + [ + "FMT_U8", + "", + "unsigned 8 bits" + ], + [ + "FMT_U16_LE", + "", + "unsigned 16 bits, little endian" + ], + [ + "FMT_U32_LE", + "", + "unsigned 32 bits, little endian" + ], + [ + "FMT_U16_BE", + "", + "unsigned 16 bits, big endian" + ], + [ + "FMT_U32_BE", + "", + "unsigned 32 bits, big endian" + ] + ], + "def": "enum Format\n {\n FMT_NONE = 0, // format invalid\n FMT_S8, // unsigned 8 bits\n FMT_S16_LE, // signed 16 bits, little endian\n FMT_S32_LE, // signed 32 bits, little endian\n FMT_S16_BE, // signed 16 bits, big endian\n FMT_S32_BE, // signed 32 bits, big endian\n FMT_U8, // unsigned 8 bits\n FMT_U16_LE, // unsigned 16 bits, little endian\n FMT_U32_LE, // unsigned 32 bits, little endian\n FMT_U16_BE, // unsigned 16 bits, big endian\n FMT_U32_BE, // unsigned 32 bits, big endian\n }" + }, + "Recorder": { + "type": "class", + "name": "Recorder", + "doc": { + "brief": "Recorder class", + "maixpy": "maix.audio.Recorder", + "py_doc": "Recorder class" + }, + "members": { + "__init__": { + "type": "func", + "name": "Recorder", + "doc": { + "brief": "Construct a new Recorder object", + "param": { + "path": "record path. the path determines the location where you save the file, if path is none, the audio module will not save file.", + "sample_rate": "record sample rate, default is 48000(48KHz), means 48000 samples per second.", + "format": "record sample format, default is audio::Format::FMT_S16_LE, means sampling 16 bits at a time and save as signed 16 bits, little endian. see @audio::Format", + "channel": "record sample channel, default is 1, means 1 channel sampling at the same time" + }, + "maixpy": "maix.audio.Recorder.__init__", + "maixcdk": "maix.audio.Recorder.Recorder", + "py_doc": "Construct a new Recorder object\n\nArgs:\n - path: record path. the path determines the location where you save the file, if path is none, the audio module will not save file.\n - sample_rate: record sample rate, default is 48000(48KHz), means 48000 samples per second.\n - format: record sample format, default is audio::Format::FMT_S16_LE, means sampling 16 bits at a time and save as signed 16 bits, little endian. see @audio::Format\n - channel: record sample channel, default is 1, means 1 channel sampling at the same time\n" + }, + "args": [ + [ + "std::string", + "path", + "std::string()" + ], + [ + "int", + "sample_rate", + "48000" + ], + [ + "audio::Format", + "format", + "audio::Format::FMT_S16_LE" + ], + [ + "int", + "channel", + "1" + ] + ], + "ret_type": null, + "static": false, + "def": "Recorder(std::string path = std::string(), int sample_rate = 48000, audio::Format format = audio::Format::FMT_S16_LE, int channel = 1)" + }, + "volume": { + "type": "func", + "name": "volume", + "doc": { + "brief": "Set/Get record volume", + "param": { + "value": "volume value, If you use this parameter, audio will set the value to volume,\nif you don't, it will return the current volume." + }, + "return": "the current volume", + "maixpy": "maix.audio.Recorder.volume", + "py_doc": "Set/Get record volume\n\nArgs:\n - value: volume value, If you use this parameter, audio will set the value to volume,\nif you don't, it will return the current volume.\n\n\nReturns: the current volume\n" + }, + "args": [ + [ + "int", + "value", + "-1" + ] + ], + "ret_type": "int", + "static": false, + "def": "int volume(int value = -1)" + }, + "record": { + "type": "func", + "name": "record", + "doc": { + "brief": "Record, Read all cached data in buffer and return.", + "param": { + "record_ms": "record time. unit: ms", + "sample_rate": "audio sample rate", + "format": "audio sample format", + "channel": "audio sample channel" + }, + "return": "pcm data. datatype @see Bytes. If you pass in record_ms parameter, the return value is an empty Bytes object.", + "maixpy": "maix.audio.Recorder.record", + "py_doc": "Record, Read all cached data in buffer and return.\n\nArgs:\n - record_ms: record time. unit: ms\n - sample_rate: audio sample rate\n - format: audio sample format\n - channel: audio sample channel\n\n\nReturns: pcm data. datatype @see Bytes. If you pass in record_ms parameter, the return value is an empty Bytes object.\n" + }, + "args": [ + [ + "int", + "record_ms", + "-1" + ] + ], + "ret_type": "maix::Bytes*", + "static": false, + "def": "maix::Bytes *record(int record_ms = -1)" + }, + "finish": { + "type": "func", + "name": "finish", + "doc": { + "brief": "Finish the record, if you have passed in the path, this api will save the audio data to file.", + "return": "error code, err::ERR_NONE means success, others means failed", + "maixpy": "maix.audio.Recorder.finish", + "py_doc": "Finish the record, if you have passed in the path, this api will save the audio data to file.\n\nReturns: error code, err::ERR_NONE means success, others means failed\n" + }, + "args": [], + "ret_type": "err::Err", + "static": false, + "def": "err::Err finish()" + }, + "sample_rate": { + "type": "func", + "name": "sample_rate", + "doc": { + "brief": "Get sample rate", + "return": "returns sample rate", + "maixpy": "maix.audio.Recorder.sample_rate", + "py_doc": "Get sample rate\n\nReturns: returns sample rate\n" + }, + "args": [], + "ret_type": "int", + "static": false, + "def": "int sample_rate()" + }, + "format": { + "type": "func", + "name": "format", + "doc": { + "brief": "Get sample format", + "return": "returns sample format", + "maixpy": "maix.audio.Recorder.format", + "py_doc": "Get sample format\n\nReturns: returns sample format\n" + }, + "args": [], + "ret_type": "audio::Format", + "static": false, + "def": "audio::Format format()" + }, + "channel": { + "type": "func", + "name": "channel", + "doc": { + "brief": "Get sample channel", + "return": "returns sample channel", + "maixpy": "maix.audio.Recorder.channel", + "py_doc": "Get sample channel\n\nReturns: returns sample channel\n" + }, + "args": [], + "ret_type": "int", + "static": false, + "def": "int channel()" + } + }, + "def": "class Recorder" + }, + "Player": { + "type": "class", + "name": "Player", + "doc": { + "brief": "Player class", + "maixpy": "maix.audio.Player", + "py_doc": "Player class" + }, + "members": { + "__init__": { + "type": "func", + "name": "Player", + "doc": { + "brief": "Construct a new Player object", + "param": { + "path": "player path. the path determines the location where you save the file, if path is none, the audio module will not save file.", + "sample_rate": "player sample rate, default is 48000(48KHz), means 48000 samples per second.", + "format": "player sample format, default is audio::Format::FMT_S16_LE, means sampling 16 bits at a time and save as signed 16 bits, little endian. see @audio::Format", + "channel": "player sample channel, default is 1, means 1 channel sampling at the same time" + }, + "maixpy": "maix.audio.Player.__init__", + "maixcdk": "maix.audio.Player.Player", + "py_doc": "Construct a new Player object\n\nArgs:\n - path: player path. the path determines the location where you save the file, if path is none, the audio module will not save file.\n - sample_rate: player sample rate, default is 48000(48KHz), means 48000 samples per second.\n - format: player sample format, default is audio::Format::FMT_S16_LE, means sampling 16 bits at a time and save as signed 16 bits, little endian. see @audio::Format\n - channel: player sample channel, default is 1, means 1 channel sampling at the same time\n" + }, + "args": [ + [ + "std::string", + "path", + "std::string()" + ], + [ + "int", + "sample_rate", + "48000" + ], + [ + "audio::Format", + "format", + "audio::Format::FMT_S16_LE" + ], + [ + "int", + "channel", + "1" + ] + ], + "ret_type": null, + "static": false, + "def": "Player(std::string path = std::string(), int sample_rate = 48000, audio::Format format = audio::Format::FMT_S16_LE, int channel = 1)" + }, + "volume": { + "type": "func", + "name": "volume", "doc": { - "brief": "Object score", - "maixpy": "maix.nn.Object.score", - "py_doc": "Object score" + "brief": "Set/Get player volume(Not support now)", + "param": { + "value": "volume value, If you use this parameter, audio will set the value to volume,\nif you don't, it will return the current volume." + }, + "return": "the current volume", + "maixpy": "maix.audio.Player.volume", + "py_doc": "Set/Get player volume(Not support now)\n\nArgs:\n - value: volume value, If you use this parameter, audio will set the value to volume,\nif you don't, it will return the current volume.\n\n\nReturns: the current volume\n" }, - "value": null, + "args": [ + [ + "int", + "value", + "-1" + ] + ], + "ret_type": "int", "static": false, - "readonly": false, - "def": "float score" + "def": "int volume(int value = -1)" + }, + "play": { + "type": "func", + "name": "play", + "doc": { + "brief": "Play", + "param": { + "data": "audio data, must be raw data" + }, + "return": "error code, err::ERR_NONE means success, others means failed", + "maixpy": "maix.audio.Player.play", + "py_doc": "Play\n\nArgs:\n - data: audio data, must be raw data\n\n\nReturns: error code, err::ERR_NONE means success, others means failed\n" + }, + "args": [ + [ + "maix::Bytes *", + "data", + "maix::audio::Player::NoneBytes" + ] + ], + "ret_type": "err::Err", + "static": false, + "def": "err::Err play(maix::Bytes *data = maix::audio::Player::NoneBytes)" + }, + "sample_rate": { + "type": "func", + "name": "sample_rate", + "doc": { + "brief": "Get sample rate", + "return": "returns sample rate", + "maixpy": "maix.audio.Player.sample_rate", + "py_doc": "Get sample rate\n\nReturns: returns sample rate\n" + }, + "args": [], + "ret_type": "int", + "static": false, + "def": "int sample_rate()" + }, + "format": { + "type": "func", + "name": "format", + "doc": { + "brief": "Get sample format", + "return": "returns sample format", + "maixpy": "maix.audio.Player.format", + "py_doc": "Get sample format\n\nReturns: returns sample format\n" + }, + "args": [], + "ret_type": "audio::Format", + "static": false, + "def": "audio::Format format()" + }, + "channel": { + "type": "func", + "name": "channel", + "doc": { + "brief": "Get sample channel", + "return": "returns sample channel", + "maixpy": "maix.audio.Player.channel", + "py_doc": "Get sample channel\n\nReturns: returns sample channel\n" + }, + "args": [], + "ret_type": "int", + "static": false, + "def": "int channel()" } }, - "def": "class Object" + "def": "class Player" } }, - "auto_add": true + "auto_add": false }, "peripheral": { "type": "module", @@ -15666,6 +16708,85 @@ }, "auto_add": true }, + "pinmap": { + "type": "module", + "doc": { + "brief": "maix.peripheral.pinmap module" + }, + "members": { + "get_pins": { + "type": "func", + "name": "get_pins", + "doc": { + "brief": "Get all pins of devices", + "return": "pin name list, string type.", + "maixpy": "maix.peripheral.pinmap.get_pins", + "py_doc": "Get all pins of devices\n\nReturns: pin name list, string type.\n" + }, + "args": [], + "ret_type": "std::vector", + "static": false, + "def": "std::vector get_pins()", + "py_def": "def get_pins() -> list[str]" + }, + "get_pin_functions": { + "type": "func", + "name": "get_pin_functions", + "doc": { + "brief": "Get all function of a pin", + "param": { + "pin": "pin name, string type." + }, + "return": "function list, function name is string type.", + "throw": "If pin name error will throwout err.Err.ERR_ARGS error.", + "maixpy": "maix.peripheral.pinmap.get_pin_functions", + "py_doc": "Get all function of a pin\n\nArgs:\n - pin: pin name, string type.\n\n\nReturns: function list, function name is string type.\n" + }, + "args": [ + [ + "const std::string &", + "pin", + null + ] + ], + "ret_type": "std::vector", + "static": false, + "def": "std::vector get_pin_functions(const std::string &pin)", + "py_def": "def get_pin_functions(pin: str) -> list[str]" + }, + "set_pin_function": { + "type": "func", + "name": "set_pin_function", + "doc": { + "brief": "Set function of a pin", + "param": { + "pin": "pin name, string type.", + "func": "which function should this pin use." + }, + "return": "if set ok, will return err.Err.ERR_NONE, else error occurs.", + "maixpy": "maix.peripheral.pinmap.set_pin_function", + "py_doc": "Set function of a pin\n\nArgs:\n - pin: pin name, string type.\n - func: which function should this pin use.\n\n\nReturns: if set ok, will return err.Err.ERR_NONE, else error occurs.\n" + }, + "args": [ + [ + "const std::string &", + "pin", + null + ], + [ + "const std::string &", + "func", + null + ] + ], + "ret_type": "err::Err", + "static": false, + "def": "err::Err set_pin_function(const std::string &pin, const std::string &func)", + "py_def": "def set_pin_function(pin: str, func: str) -> maix.err.Err" + } + }, + "auto_add": true + }, "pwm": { "type": "module", "doc": { @@ -17302,6 +18423,161 @@ }, "auto_add": true }, + "rtmp": { + "type": "module", + "doc": { + "brief": "maix.rtmp module" + }, + "members": { + "Rtmp": { + "type": "class", + "name": "Rtmp", + "doc": { + "brief": "Rtmp class", + "maixpy": "maix.rtmp.Rtmp", + "py_doc": "Rtmp class" + }, + "members": { + "__init__": { + "type": "func", + "name": "Rtmp", + "doc": { + "brief": "Construct a new Video object", + "note": "Rtmp url : rtmp://host:prot/app/stream\nexample:\nr = Rtmp(\"localhost\", 1935, \"live\", \"stream\")\nmeans rtmp url is rtmp://localhost:1935/live/stream", + "param": { + "host": "rtmp ip", + "port": "rtmp port, default is 1935.", + "app": "rtmp app name", + "stream": "rtmp stream name" + }, + "maixpy": "maix.rtmp.Rtmp.__init__", + "maixcdk": "maix.rtmp.Rtmp.Rtmp", + "py_doc": "Construct a new Video object\n\nArgs:\n - host: rtmp ip\n - port: rtmp port, default is 1935.\n - app: rtmp app name\n - stream: rtmp stream name\n" + }, + "args": [ + [ + "std::string", + "host", + null + ], + [ + "int", + "port", + "1935" + ], + [ + "std::string", + "app", + "std::string()" + ], + [ + "std::string", + "stream", + "std::string()" + ] + ], + "ret_type": null, + "static": false, + "def": "Rtmp(std::string host, int port = 1935, std::string app = std::string(), std::string stream = std::string())" + }, + "bind_camera": { + "type": "func", + "name": "bind_camera", + "doc": { + "brief": "Bind camera", + "note": "If the cam object is bound, the cam object cannot be used elsewhere.", + "param": { + "cam": "camera object" + }, + "return": "error code, err::ERR_NONE means success, others means failed", + "maixpy": "maix.rtmp.Rtmp.bind_camera", + "py_doc": "Bind camera\n\nArgs:\n - cam: camera object\n\n\nReturns: error code, err::ERR_NONE means success, others means failed\n" + }, + "args": [ + [ + "camera::Camera *", + "cam", + null + ] + ], + "ret_type": "err::Err", + "static": false, + "def": "err::Err bind_camera(camera::Camera *cam)" + }, + "start": { + "type": "func", + "name": "start", + "doc": { + "brief": "Start push stream", + "note": "only support flv file now", + "param": { + "path": "File path, if you passed file path, cyclic push the file, else if you bound camera, push the camera image." + }, + "return": "error code, err::ERR_NONE means success, others means failed", + "maixpy": "maix.rtmp.Rtmp.start", + "py_doc": "Start push stream\n\nArgs:\n - path: File path, if you passed file path, cyclic push the file, else if you bound camera, push the camera image.\n\n\nReturns: error code, err::ERR_NONE means success, others means failed\n" + }, + "args": [ + [ + "std::string", + "path", + "std::string()" + ] + ], + "ret_type": "err::Err", + "static": false, + "def": "err::Err start(std::string path = std::string())" + }, + "stop": { + "type": "func", + "name": "stop", + "doc": { + "brief": "Stop push", + "return": "error code, err::ERR_NONE means success, others means failed", + "maixpy": "maix.rtmp.Rtmp.stop", + "py_doc": "Stop push\n\nReturns: error code, err::ERR_NONE means success, others means failed\n" + }, + "args": [], + "ret_type": "err::Err", + "static": false, + "def": "err::Err stop()" + }, + "get_path": { + "type": "func", + "name": "get_path", + "doc": { + "brief": "Get the file path of the push stream", + "return": "file path", + "maixpy": "maix.rtmp.Rtmp.get_path", + "py_doc": "Get the file path of the push stream\n\nReturns: file path\n" + }, + "args": [], + "ret_type": "std::string", + "static": false, + "def": "std::string get_path()", + "overload": [ + { + "type": "func", + "name": "is_started", + "doc": { + "brief": "Check whether push streaming has started", + "return": "If rtmp thread is running, returns true", + "maixpy": "maix.rtmp.Rtmp.get_path", + "py_doc": "Check whether push streaming has started\n\nReturns: If rtmp thread is running, returns true\n" + }, + "args": [], + "ret_type": "bool", + "static": false, + "def": "bool is_started()" + } + ] + } + }, + "def": "class Rtmp" + } + }, + "auto_add": true + }, "rtsp": { "type": "module", "doc": { @@ -17930,11 +19206,12 @@ "format": "picture pixel format. this value may be set automatically. default is FMT_YVU420SP.", "time_base": "frame time base. time_base default is 30, means 1/30 ms", "framerate": "frame rate. framerate default is 30, means 30 frames per second\nfor video. 1/time_base is not the average frame rate if the frame rate is not constant.", - "open": "If true, vido will automatically call open() after creation. default is true." + "capture": "enable capture, if true, you can use capture() function to get an image object", + "open": "If true, video will automatically call open() after creation. default is true." }, "maixpy": "maix.video.Video.__init__", "maixcdk": "maix.video.Video.Video", - "py_doc": "Construct a new Video object\n\nArgs:\n - path: video path. the path determines the location where you load or save the file, if path is none, the video module will not save or load file.\nxxx.h265 means video format is H265, xxx.mp4 means video format is MP4\n - width: picture width. this value may be set automatically. default is 2560.\n - height: picture height. this value may be set automatically. default is 1440.\n - format: picture pixel format. this value may be set automatically. default is FMT_YVU420SP.\n - time_base: frame time base. time_base default is 30, means 1/30 ms\n - framerate: frame rate. framerate default is 30, means 30 frames per second\nfor video. 1/time_base is not the average frame rate if the frame rate is not constant.\n - open: If true, vido will automatically call open() after creation. default is true.\n" + "py_doc": "Construct a new Video object\n\nArgs:\n - path: video path. the path determines the location where you load or save the file, if path is none, the video module will not save or load file.\nxxx.h265 means video format is H265, xxx.mp4 means video format is MP4\n - width: picture width. this value may be set automatically. default is 2560.\n - height: picture height. this value may be set automatically. default is 1440.\n - format: picture pixel format. this value may be set automatically. default is FMT_YVU420SP.\n - time_base: frame time base. time_base default is 30, means 1/30 ms\n - framerate: frame rate. framerate default is 30, means 30 frames per second\nfor video. 1/time_base is not the average frame rate if the frame rate is not constant.\n - capture: enable capture, if true, you can use capture() function to get an image object\n - open: If true, video will automatically call open() after creation. default is true.\n" }, "args": [ [ @@ -17967,6 +19244,11 @@ "framerate", "30" ], + [ + "bool", + "capture", + "false" + ], [ "bool", "open", @@ -17975,8 +19257,8 @@ ], "ret_type": null, "static": false, - "def": "Video(std::string path = std::string(), int width = 2560, int height = 1440, image::Format format = image::Format::FMT_YVU420SP, int time_base = 30, int framerate = 30, bool open = true)", - "py_def": "def __init__(self, path: str = '', width: int = 2560, height: int = 1440, format: maix.image.Format = ..., time_base: int = 30, framerate: int = 30, open: bool = True) -> None" + "def": "Video(std::string path = std::string(), int width = 2560, int height = 1440, image::Format format = image::Format::FMT_YVU420SP, int time_base = 30, int framerate = 30, bool capture = false, bool open = true)", + "py_def": "def __init__(self, path: str = '', width: int = 2560, height: int = 1440, format: maix.image.Format = ..., time_base: int = 30, framerate: int = 30, capture: bool = False, open: bool = True) -> None" }, "open": { "type": "func", @@ -18052,23 +19334,23 @@ "doc": { "brief": "Encode image.", "param": { - "img": "the image will be encode.\nif the img is NULL, this function will try to get image from camera, you must use bind_camera to bind camera." + "img": "the image will be encode.\nif the img is NULL, this function will try to get image from camera, you must use bind_camera() function to bind the camera." }, "return": "encode result", "maixpy": "maix.video.Video.encode", - "py_doc": "Encode image.\n\nArgs:\n - img: the image will be encode.\nif the img is NULL, this function will try to get image from camera, you must use bind_camera to bind camera.\n\n\nReturns: encode result\n" + "py_doc": "Encode image.\n\nArgs:\n - img: the image will be encode.\nif the img is NULL, this function will try to get image from camera, you must use bind_camera() function to bind the camera.\n\n\nReturns: encode result\n" }, "args": [ [ "image::Image *", "img", - "NULL" + "maix::video::Video::NoneImage" ] ], - "ret_type": "video::Packet", + "ret_type": "video::Packet*", "static": false, - "def": "video::Packet encode(image::Image *img = NULL)", - "py_def": "def encode(self, img: maix.image.Image = 0) -> Packet" + "def": "video::Packet *encode(image::Image *img = maix::video::Video::NoneImage)", + "py_def": "def encode(self, img: maix.image.Image = ...) -> Packet" }, "decode": { "type": "func", @@ -18086,13 +19368,13 @@ [ "video::Frame *", "frame", - "NULL" + "nullptr" ] ], "ret_type": "image::Image*", "static": false, - "def": "image::Image *decode(video::Frame *frame = NULL)", - "py_def": "def decode(self, frame: Frame = 0) -> maix.image.Image" + "def": "image::Image *decode(video::Frame *frame = nullptr)", + "py_def": "def decode(self, frame: Frame = None) -> maix.image.Image" }, "finish": { "type": "func", @@ -18109,6 +19391,22 @@ "def": "err::Err finish()", "py_def": "def finish(self) -> maix.err.Err" }, + "capture": { + "type": "func", + "name": "capture", + "doc": { + "brief": "Capture image", + "attention": "Each time encode is called, the last captured image will be released.", + "return": "error code", + "maixpy": "maix.video.Video.capture", + "py_doc": "Capture image\n\nReturns: error code\n" + }, + "args": [], + "ret_type": "image::Image*", + "static": false, + "def": "image::Image *capture()", + "py_def": "def capture(self) -> maix.image.Image" + }, "is_recording": { "type": "func", "name": "is_recording", diff --git a/maixpy/api/index.html b/maixpy/api/index.html index a9b507d4..66db8eeb 100644 --- a/maixpy/api/index.html +++ b/maixpy/api/index.html @@ -122,9 +122,11 @@

MaixPy

+ + @@ -270,10 +273,18 @@

MaixPy API -- Maix AI machine vision platform Python API

maix.nn maix.nn module + + maix.audio + maix.audio module + maix.peripheral Chip's peripheral driver + + maix.rtmp + maix.rtmp module + maix.rtsp maix.rtsp module diff --git a/maixpy/api/maix/app.html b/maixpy/api/maix/app.html index 6d762b8d..c492c8c1 100644 --- a/maixpy/api/maix/app.html +++ b/maixpy/api/maix/app.html @@ -122,9 +122,11 @@

MaixPy

+ + diff --git a/maixpy/api/maix/audio.html b/maixpy/api/maix/audio.html new file mode 100644 index 00000000..0cccbd50 --- /dev/null +++ b/maixpy/api/maix/audio.html @@ -0,0 +1,797 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + maix.audio - MaixPy + + + + + + + + + + +
+ +
+ +
+
+
+
+ +

maix.audio

+ +
+
+
    + +
+
+
+
+ + +
+
+ + + +
+
+
+
+ + +
+
+ +
+
+ +

maix.audio module

+
+

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

+
+

Module

+

No module

+

Enum

+

Format

+ + + + + + + + + + + + + + + + + +
itemdoc
briefAudio type
valuesFMT_NONE: format invalid
FMT_S8: unsigned 8 bits
FMT_S16_LE: signed 16 bits, little endian
FMT_S32_LE: signed 32 bits, little endian
FMT_S16_BE: signed 16 bits, big endian
FMT_S32_BE: signed 32 bits, big endian
FMT_U8: unsigned 8 bits
FMT_U16_LE: unsigned 16 bits, little endian
FMT_U32_LE: unsigned 32 bits, little endian
FMT_U16_BE: unsigned 16 bits, big endian
FMT_U32_BE: unsigned 32 bits, big endian
+

C++ defination code:

+ +
enum Format
+    {
+        FMT_NONE = 0,       // format invalid
+        FMT_S8,             // unsigned 8 bits
+        FMT_S16_LE,         // signed 16 bits, little endian
+        FMT_S32_LE,         // signed 32 bits, little endian
+        FMT_S16_BE,         // signed 16 bits, big endian
+        FMT_S32_BE,         // signed 32 bits, big endian
+        FMT_U8,             // unsigned 8 bits
+        FMT_U16_LE,         // unsigned 16 bits, little endian
+        FMT_U32_LE,         // unsigned 32 bits, little endian
+        FMT_U16_BE,         // unsigned 16 bits, big endian
+        FMT_U32_BE,         // unsigned 32 bits, big endian
+    }
+
+

Variable

+

Function

+

Class

+

Recorder

+ + + + + + + + + + + + + +
itemdoc
briefRecorder class
+

C++ defination code:

+ +
class Recorder
+
+

__init__

+ + + + + + + + + + + + + + + + + + + + + + + + + +
itemdoc
typefunc
briefConstruct a new Recorder object
parampath: record path. the path determines the location where you save the file, if path is none, the audio module will not save file.
sample_rate: record sample rate, default is 48000(48KHz), means 48000 samples per second.
format: record sample format, default is audio::Format::FMT_S16_LE, means sampling 16 bits at a time and save as signed 16 bits, little endian. see @audio::Format
channel: record sample channel, default is 1, means 1 channel sampling at the same time
staticFalse
+

C++ defination code:

+ +
Recorder(std::string path = std::string(), int sample_rate = 48000, audio::Format format = audio::Format::FMT_S16_LE, int channel = 1)
+
+

volume

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
itemdoc
typefunc
briefSet/Get record volume
paramvalue: volume value, If you use this parameter, audio will set the value to volume,
if you don't, it will return the current volume.
returnthe current volume
staticFalse
+

C++ defination code:

+ +
int volume(int value = -1)
+
+

record

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
itemdoc
typefunc
briefRecord, Read all cached data in buffer and return.
paramrecord_ms: record time. unit: ms
sample_rate: audio sample rate
format: audio sample format
channel: audio sample channel
returnpcm data. datatype @see Bytes. If you pass in record_ms parameter, the return value is an empty Bytes object.
staticFalse
+

C++ defination code:

+ +
maix::Bytes *record(int record_ms = -1)
+
+

finish

+ + + + + + + + + + + + + + + + + + + + + + + + + +
itemdoc
typefunc
briefFinish the record, if you have passed in the path, this api will save the audio data to file.
returnerror code, err::ERR_NONE means success, others means failed
staticFalse
+

C++ defination code:

+ +
err::Err finish()
+
+

sample_rate

+ + + + + + + + + + + + + + + + + + + + + + + + + +
itemdoc
typefunc
briefGet sample rate
returnreturns sample rate
staticFalse
+

C++ defination code:

+ +
int sample_rate()
+
+

format

+ + + + + + + + + + + + + + + + + + + + + + + + + +
itemdoc
typefunc
briefGet sample format
returnreturns sample format
staticFalse
+

C++ defination code:

+ +
audio::Format format()
+
+

channel

+ + + + + + + + + + + + + + + + + + + + + + + + + +
itemdoc
typefunc
briefGet sample channel
returnreturns sample channel
staticFalse
+

C++ defination code:

+ +
int channel()
+
+

Player

+ + + + + + + + + + + + + +
itemdoc
briefPlayer class
+

C++ defination code:

+ +
class Player
+
+

__init__

+ + + + + + + + + + + + + + + + + + + + + + + + + +
itemdoc
typefunc
briefConstruct a new Player object
parampath: player path. the path determines the location where you save the file, if path is none, the audio module will not save file.
sample_rate: player sample rate, default is 48000(48KHz), means 48000 samples per second.
format: player sample format, default is audio::Format::FMT_S16_LE, means sampling 16 bits at a time and save as signed 16 bits, little endian. see @audio::Format
channel: player sample channel, default is 1, means 1 channel sampling at the same time
staticFalse
+

C++ defination code:

+ +
Player(std::string path = std::string(), int sample_rate = 48000, audio::Format format = audio::Format::FMT_S16_LE, int channel = 1)
+
+

volume

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
itemdoc
typefunc
briefSet/Get player volume(Not support now)
paramvalue: volume value, If you use this parameter, audio will set the value to volume,
if you don't, it will return the current volume.
returnthe current volume
staticFalse
+

C++ defination code:

+ +
int volume(int value = -1)
+
+

play

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
itemdoc
typefunc
briefPlay
paramdata: audio data, must be raw data
returnerror code, err::ERR_NONE means success, others means failed
staticFalse
+

C++ defination code:

+ +
err::Err play(maix::Bytes *data = maix::audio::Player::NoneBytes)
+
+

sample_rate

+ + + + + + + + + + + + + + + + + + + + + + + + + +
itemdoc
typefunc
briefGet sample rate
returnreturns sample rate
staticFalse
+

C++ defination code:

+ +
int sample_rate()
+
+

format

+ + + + + + + + + + + + + + + + + + + + + + + + + +
itemdoc
typefunc
briefGet sample format
returnreturns sample format
staticFalse
+

C++ defination code:

+ +
audio::Format format()
+
+

channel

+ + + + + + + + + + + + + + + + + + + + + + + + + +
itemdoc
typefunc
briefGet sample channel
returnreturns sample channel
staticFalse
+

C++ defination code:

+ +
int channel()
+
+ + +
+
+
+ + +
+
+
+
+
+
+ +
+
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/maixpy/api/maix/camera.html b/maixpy/api/maix/camera.html index 3e06fdb9..c34e00a0 100644 --- a/maixpy/api/maix/camera.html +++ b/maixpy/api/maix/camera.html @@ -122,9 +122,11 @@

MaixPy

+ + @@ -1278,6 +1281,90 @@

saturation

C++ defination code:

uint32_t saturation(uint32_t value = -1)
+
+

awb_mode

+ +
def awb_mode(self, value: int = -1) -> int
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
itemdoc
typefunc
briefSet/Get white balance mode
attentionThis method will affect the isp and thus the image, so please be careful with it.
paramvalue: value = 0, means set white balance to auto mode, value = 1, means set white balance to manual mode, default is auto mode.
returnreturns awb mode
staticFalse
+

C++ defination code:

+ +
uint32_t awb_mode(uint32_t value = -1)
+
+

exp_mode

+ +
def exp_mode(self, value: int = -1) -> int
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
itemdoc
typefunc
briefSet/Get exposure mode
attentionThis method will affect the isp and thus the image, so please be careful with it.
paramvalue: value = 0, means set exposure to auto mode, value = 1, means set exposure to manual mode, default is auto mode.
returnreturns exposure mode
staticFalse
+

C++ defination code:

+ +
uint32_t exp_mode(uint32_t value = -1)
 
diff --git a/maixpy/api/maix/comm.html b/maixpy/api/maix/comm.html index a2138c6b..bd5616bf 100644 --- a/maixpy/api/maix/comm.html +++ b/maixpy/api/maix/comm.html @@ -122,9 +122,11 @@

MaixPy

+ + diff --git a/maixpy/api/maix/display.html b/maixpy/api/maix/display.html index 649a7386..f31519b9 100644 --- a/maixpy/api/maix/display.html +++ b/maixpy/api/maix/display.html @@ -122,9 +122,11 @@

MaixPy

+ + diff --git a/maixpy/api/maix/err.html b/maixpy/api/maix/err.html index 89a73f3b..18a19659 100644 --- a/maixpy/api/maix/err.html +++ b/maixpy/api/maix/err.html @@ -122,9 +122,11 @@

MaixPy

+ + diff --git a/maixpy/api/maix/example.html b/maixpy/api/maix/example.html index 7cbbdd55..b24a83a5 100644 --- a/maixpy/api/maix/example.html +++ b/maixpy/api/maix/example.html @@ -122,9 +122,11 @@

MaixPy

+ + diff --git a/maixpy/api/maix/fs.html b/maixpy/api/maix/fs.html index b51ba236..6bc69f22 100644 --- a/maixpy/api/maix/fs.html +++ b/maixpy/api/maix/fs.html @@ -122,9 +122,11 @@

MaixPy

+ + diff --git a/maixpy/api/maix/i18n.html b/maixpy/api/maix/i18n.html index 9238d2e6..8a7e534c 100644 --- a/maixpy/api/maix/i18n.html +++ b/maixpy/api/maix/i18n.html @@ -122,9 +122,11 @@

MaixPy

+ + diff --git a/maixpy/api/maix/image.html b/maixpy/api/maix/image.html index ae77f1e0..59f602de 100644 --- a/maixpy/api/maix/image.html +++ b/maixpy/api/maix/image.html @@ -122,9 +122,11 @@

MaixPy

+ + @@ -7804,6 +7807,45 @@

to_format

image::Image *to_format(const image::Format &format)
 
+

to_jpeg

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
itemdoc
typefunc
briefConvert image to jpeg
paramquality: the quality of jpg, default is 95. range is (50, 100].
returnnew image object. Need be delete by caller in C++.
throwerr.Exception, if two images' format not support, or already the format, will raise exception
staticFalse
+

C++ defination code:

+ +
image::Image *to_jpeg(int quality = 95)
+

draw_image

@@ -8135,7 +8177,7 @@

draw_keypoints

- + @@ -8149,7 +8191,7 @@

draw_keypoints

paramkeypoints: 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)
keypoints: keypoints, [x1, y1, x2, y2...] or [x, y, rotation_andle_in_degrees, x2, y2, rotation_andle_in_degrees2](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 means fill circle)
return

C++ defination code:

-
image::Image *draw_keypoints(std::vector<int> keypoints, const image::Color &color, int size = 10, int thickness = 1, bool fill = false)
+
image::Image *draw_keypoints(std::vector<int> keypoints, const image::Color &color, int size = 10, int thickness = -1)
 

resize

@@ -8409,7 +8451,7 @@

compress

- + diff --git a/maixpy/api/maix/network.html b/maixpy/api/maix/network.html index b53b32dc..70364db8 100644 --- a/maixpy/api/maix/network.html +++ b/maixpy/api/maix/network.html @@ -122,9 +122,11 @@

MaixPy

+ + diff --git a/maixpy/api/maix/network/wifi.html b/maixpy/api/maix/network/wifi.html index 693bd5d6..0008015d 100644 --- a/maixpy/api/maix/network/wifi.html +++ b/maixpy/api/maix/network/wifi.html @@ -122,9 +122,11 @@

MaixPy

+ + diff --git a/maixpy/api/maix/nn.html b/maixpy/api/maix/nn.html index 023785c0..2400c343 100644 --- a/maixpy/api/maix/nn.html +++ b/maixpy/api/maix/nn.html @@ -122,9 +122,11 @@

MaixPy

+ + @@ -305,6 +308,9 @@

load

err::Err load(const string &model)
 

detect

+ +
def detect(self, img: maix.image.Image, conf_th: float = 0.5, iou_th: float = 0.45, fit: maix.image.Fit = ...) -> list[...]
+
briefJPEG compresses the image in place.JPEG compresses the image in place, the same as to_jpeg functioin, it's recommend to use to_jpeg instead.
param
@@ -1123,9 +1129,6 @@

MUD

class MUD
 

__init__

- -
def __init__(self, model_path: str = None) -> None
-
@@ -1276,6 +1279,9 @@

LayerInfo

class LayerInfo
 

__init__

+ +
def __init__(self, name: str = '', dtype: maix.tensor.DType = ..., shape: list[int] = []) -> None
+
@@ -1404,6 +1410,9 @@

shape

std::vector<int> shape
 

to_str

+ +
def to_str(self) -> str
+
@@ -1480,6 +1489,9 @@

NN

class NN
 

__init__

+ +
def __init__(self, model: str = '') -> None
+
@@ -1549,6 +1561,9 @@

load

err::Err load(const std::string &model)
 

loaded

+ +
def loaded(self) -> bool
+
@@ -1580,6 +1595,9 @@

loaded

bool loaded()
 

inputs_info

+ +
def inputs_info(self) -> list[LayerInfo]
+
@@ -1611,6 +1629,9 @@

inputs_info

std::vector<nn::LayerInfo> inputs_info()
 

outputs_info

+ +
def outputs_info(self) -> list[LayerInfo]
+
@@ -1642,6 +1663,9 @@

outputs_info

std::vector<nn::LayerInfo> outputs_info()
 

extra_info

+ +
def extra_info(self) -> dict[str, str]
+
@@ -1673,6 +1697,9 @@

extra_info

std::map<std::string, std::string> extra_info()
 

forward

+ +
def forward(self, inputs: maix.tensor.Tensors) -> maix.tensor.Tensors
+
@@ -1708,6 +1735,9 @@

forward

tensor::Tensors *forward(tensor::Tensors &inputs)
 

forward_image

+ +
def forward_image(self, img: maix.image.Image, mean: list[float] = [], scale: list[float] = [], fit: maix.image.Fit = ..., copy_result: bool = True) -> maix.tensor.Tensors
+
@@ -1742,7 +1772,7 @@

forward_image

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)
 
-

Object

+

FaceDetector

@@ -1753,13 +1783,13 @@

Object

- +
briefObject for detect resultFaceDetector class

C++ defination code:

-
class Object
+
class FaceDetector
 

__init__

@@ -1776,11 +1806,15 @@

__init__

- + - + + + + + @@ -1790,9 +1824,12 @@

__init__

briefConstructor of Object for detect resultConstructor of FaceDetector class
paramx: left top x
y: left top y
w: width
h: height
class_id: class id
score: score
model: model path, default empty, you can load model later by load function.
throwIf model arg is not empty and load failed, will throw err::Exception.
static

C++ defination code:

-
Object(int x = 0, int y = 0, int w = 0, int h = 0, int class_id = 0, float score = 0)
+
FaceDetector(const string &model = "")
+
+

load

+ +
def load(self, model: str) -> maix.err.Err
 
-

__str__

@@ -1807,11 +1844,15 @@

__str__

- + + + + + - + @@ -1821,9 +1862,12 @@

__str__

briefObject info to stringLoad model from file
parammodel: Model path want to load
returnObject info stringerr::Err
static

C++ defination code:

-
std::string to_str()
+
err::Err load(const string &model)
+
+

detect

+ +
def detect(self, img: maix.image.Image, conf_th: float = 0.5, iou_th: float = 0.45, fit: maix.image.Fit = ...) -> list[...]
 
-

x

@@ -1834,27 +1878,38 @@

x

- + - + - - + + - + + + + + + + + +
typevarfunc
briefObject left top coordinate xDetect objects from image
staticFalseparamimg: 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.
readonlythrowIf image format not match model input format, will throw err::Exception.
returnObject list. In C++, you should delete it after use.
static False

C++ defination code:

-
int x
+
std::vector<nn::Object> *detect(image::Image &img, float conf_th = 0.5, float iou_th = 0.45, maix::image::Fit fit = maix::image::FIT_CONTAIN)
+
+

input_size

+ +
def input_size(self) -> maix.image.Size
 
-

y

@@ -1865,27 +1920,64 @@

y

- + - + + + + + + +
typevarfunc
briefObject left top coordinate yGet model input size
returnmodel input size
static False
+

C++ defination code:

+ +
image::Size input_size()
+
+

input_width

+ +
def input_width(self) -> int
+
+ + + + + + + + - + + + + + + + + + + + + +
itemdoc
readonlytypefunc
briefGet model input width
returnmodel input size of width
static False

C++ defination code:

-
int y
+
int input_width()
+
+

input_height

+ +
def input_height(self) -> int
 
-

w

@@ -1896,27 +1988,61 @@

w

- + - + + + + + + +
typevarfunc
briefObject widthGet model input height
returnmodel input size of height
static False
+

C++ defination code:

+ +
int input_height()
+
+

input_format

+ +
def input_format(self) -> maix.image.Format
+
+ + + + + + + + - + + + + + + + + + + + + +
itemdoc
readonlytypefunc
briefGet input image format
returninput image format, image::Format type.
static False

C++ defination code:

-
int w
+
image::Format input_format()
 
-

h

+

mean

@@ -1931,7 +2057,7 @@

h

- + @@ -1945,9 +2071,9 @@

h

briefObject heightGet mean value, list type
static

C++ defination code:

-
int h
+
std::vector<float> mean
 
-

class_id

+

scale

@@ -1962,7 +2088,7 @@

class_id

- + @@ -1976,9 +2102,28 @@

class_id

briefObject class idGet scale value, list type
static

C++ defination code:

-
int class_id
+
std::vector<float> scale
 
-

score

+

Retinaface

+ + + + + + + + + + + + + +
itemdoc
briefRetinaface class
+

C++ defination code:

+ +
class Retinaface
+
+

__init__

@@ -1989,25 +2134,909 @@

score

- + - + + + + + + + + + + +
typevarfunc
briefObject scoreConstructor of Retinaface class
parammodel: model path, default empty, you can load model later by load function.
throwIf model arg is not empty and load failed, will throw err::Exception.
static False
+

C++ defination code:

+ +
Retinaface(const string &model = "")
+
+

load

+ +
def load(self, model: str) -> maix.err.Err
+
+ + - + + + + + + + + + + + + + + + + + + + + + + +
readonlyitemdoc
typefunc
briefLoad model from file
parammodel: Model path want to load
returnerr::Err
static False

C++ defination code:

-
float score
+
err::Err load(const string &model)
+
+

detect

+ +
def detect(self, img: maix.image.Image, conf_th: float = 0.5, iou_th: float = 0.45, fit: maix.image.Fit = ...) -> list[...]
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
itemdoc
typefunc
briefDetect objects from image
paramimg: 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.4.
iou_th: IoU threshold, default 0.45.
fit: Resize method, default image.Fit.FIT_CONTAIN.
throwIf image format not match model input format, will throw err::Exception.
returnObject list. In C++, you should delete it after use.
staticFalse
+

C++ defination code:

+ +
std::vector<nn::Object> *detect(image::Image &img, float conf_th = 0.4, float iou_th = 0.45, maix::image::Fit fit = maix::image::FIT_CONTAIN)
+
+

input_size

+ +
def input_size(self) -> maix.image.Size
+
+ + + + + + + + + + + + + + + + + + + + + + + + + +
itemdoc
typefunc
briefGet model input size
returnmodel input size
staticFalse
+

C++ defination code:

+ +
image::Size input_size()
+
+

input_width

+ +
def input_width(self) -> int
+
+ + + + + + + + + + + + + + + + + + + + + + + + + +
itemdoc
typefunc
briefGet model input width
returnmodel input size of width
staticFalse
+

C++ defination code:

+ +
int input_width()
+
+

input_height

+ +
def input_height(self) -> int
+
+ + + + + + + + + + + + + + + + + + + + + + + + + +
itemdoc
typefunc
briefGet model input height
returnmodel input size of height
staticFalse
+

C++ defination code:

+ +
int input_height()
+
+

input_format

+ +
def input_format(self) -> maix.image.Format
+
+ + + + + + + + + + + + + + + + + + + + + + + + + +
itemdoc
typefunc
briefGet input image format
returninput image format, image::Format type.
staticFalse
+

C++ defination code:

+ +
image::Format input_format()
+
+

mean

+ + + + + + + + + + + + + + + + + + + + + + + + + +
itemdoc
typevar
briefGet mean value, list type
staticFalse
readonlyFalse
+

C++ defination code:

+ +
std::vector<float> mean
+
+

scale

+ + + + + + + + + + + + + + + + + + + + + + + + + +
itemdoc
typevar
briefGet scale value, list type
staticFalse
readonlyFalse
+

C++ defination code:

+ +
std::vector<float> scale
+
+

Object

+ + + + + + + + + + + + + +
itemdoc
briefObject for detect result
+

C++ defination code:

+ +
class Object
+
+

__init__

+ + + + + + + + + + + + + + + + + + + + + + + + + +
itemdoc
typefunc
briefConstructor of Object for detect result
paramx: left top x
y: left top y
w: width
h: height
class_id: class id
score: score
staticFalse
+

C++ defination code:

+ +
Object(int x = 0, int y = 0, int w = 0, int h = 0, int class_id = 0, float score = 0, std::vector<int> points = std::vector<int>())
+
+

__str__

+ +
def to_str(self) -> str
+
+ + + + + + + + + + + + + + + + + + + + + + + + + +
itemdoc
typefunc
briefObject info to string
returnObject info string
staticFalse
+

C++ defination code:

+ +
std::string to_str()
+
+

x

+ + + + + + + + + + + + + + + + + + + + + + + + + +
itemdoc
typevar
briefObject left top coordinate x
staticFalse
readonlyFalse
+

C++ defination code:

+ +
int x
+
+

y

+ + + + + + + + + + + + + + + + + + + + + + + + + +
itemdoc
typevar
briefObject left top coordinate y
staticFalse
readonlyFalse
+

C++ defination code:

+ +
int y
+
+

w

+ + + + + + + + + + + + + + + + + + + + + + + + + +
itemdoc
typevar
briefObject width
staticFalse
readonlyFalse
+

C++ defination code:

+ +
int w
+
+

h

+ + + + + + + + + + + + + + + + + + + + + + + + + +
itemdoc
typevar
briefObject height
staticFalse
readonlyFalse
+

C++ defination code:

+ +
int h
+
+

class_id

+ + + + + + + + + + + + + + + + + + + + + + + + + +
itemdoc
typevar
briefObject class id
staticFalse
readonlyFalse
+

C++ defination code:

+ +
int class_id
+
+

score

+ + + + + + + + + + + + + + + + + + + + + + + + + +
itemdoc
typevar
briefObject score
staticFalse
readonlyFalse
+

C++ defination code:

+ +
float score
+
+

points

+ + + + + + + + + + + + + + + + + + + + + + + + + +
itemdoc
typevar
briefkeypoints
staticFalse
readonlyFalse
+

C++ defination code:

+ +
std::vector<int> points
+
+

ObjectFloat

+ + + + + + + + + + + + + +
itemdoc
briefObject for detect result
+

C++ defination code:

+ +
class ObjectFloat
+
+

__init__

+ + + + + + + + + + + + + + + + + + + + + + + + + +
itemdoc
typefunc
briefConstructor of Object for detect result
paramx: left top x
y: left top y
w: width
h: height
class_id: class id
score: score
staticFalse
+

C++ defination code:

+ +
ObjectFloat(float x = 0, float y = 0, float w = 0, float h = 0, float class_id = 0, float score = 0, std::vector<float> points = std::vector<float>())
+
+

__str__

+ +
def to_str(self) -> str
+
+ + + + + + + + + + + + + + + + + + + + + + + + + +
itemdoc
typefunc
briefObject info to string
returnObject info string
staticFalse
+

C++ defination code:

+ +
std::string to_str()
+
+

x

+ + + + + + + + + + + + + + + + + + + + + + + + + +
itemdoc
typevar
briefObject left top coordinate x
staticFalse
readonlyFalse
+

C++ defination code:

+ +
float x
+
+

y

+ + + + + + + + + + + + + + + + + + + + + + + + + +
itemdoc
typevar
briefObject left top coordinate y
staticFalse
readonlyFalse
+

C++ defination code:

+ +
float y
+
+

w

+ + + + + + + + + + + + + + + + + + + + + + + + + +
itemdoc
typevar
briefObject width
staticFalse
readonlyFalse
+

C++ defination code:

+ +
float w
+
+

h

+ + + + + + + + + + + + + + + + + + + + + + + + + +
itemdoc
typevar
briefObject height
staticFalse
readonlyFalse
+

C++ defination code:

+ +
float h
+
+

class_id

+ + + + + + + + + + + + + + + + + + + + + + + + + +
itemdoc
typevar
briefObject class id
staticFalse
readonlyFalse
+

C++ defination code:

+ +
float class_id
+
+

score

+ + + + + + + + + + + + + + + + + + + + + + + + + +
itemdoc
typevar
briefObject score
staticFalse
readonlyFalse
+

C++ defination code:

+ +
float score
+
+

points

+ + + + + + + + + + + + + + + + + + + + + + + + + +
itemdoc
typevar
briefkeypoints
staticFalse
readonlyFalse
+

C++ defination code:

+ +
std::vector<float> points
 
diff --git a/maixpy/api/maix/nn/F.html b/maixpy/api/maix/nn/F.html index c28691f5..56b9c29b 100644 --- a/maixpy/api/maix/nn/F.html +++ b/maixpy/api/maix/nn/F.html @@ -122,9 +122,11 @@

MaixPy

+ + @@ -248,8 +251,8 @@

Class

diff --git a/maixpy/doc/en/basic/maixpy_upgrade.html b/maixpy/doc/en/basic/maixpy_upgrade.html index 5020d936..7cf2073e 100644 --- a/maixpy/doc/en/basic/maixpy_upgrade.html +++ b/maixpy/doc/en/basic/maixpy_upgrade.html @@ -102,7 +102,7 @@

MaixPy

diff --git a/maixpy/doc/en/basic/maixvision.html b/maixpy/doc/en/basic/maixvision.html index e51e16e9..5c8abf2f 100644 --- a/maixpy/doc/en/basic/maixvision.html +++ b/maixpy/doc/en/basic/maixvision.html @@ -44,7 +44,7 @@ - MaixVision - MaixPy Programming + Graphical Block Programming - MaixPy + MaixVision -- MaixPy Programming IDE + Graphical Block Programming - MaixPy @@ -102,7 +102,7 @@

MaixPy

@@ -175,7 +198,7 @@

MaixPy

-

MaixVision - MaixPy Programming + Graphical Block Programming

+

MaixVision -- MaixPy Programming IDE + Graphical Block Programming

@@ -211,13 +234,15 @@

MaixVision - MaixPy Programming + Graphical Block Programming

Introduction

-

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.

+

MaixVision is a development tool specifically designed for the Maix ecosystem, supporting MaixPy programming and graphical block programming. It allows for online operation and debugging, real-time image preview, and synchronizing images from device displays, which is convenient for debugging and development.

+

It also supports packaging and installing applications on devices, allowing users to easily generate and install applications with one click.

+

In addition, it integrates several handy tools for development, such as file management, threshold editor, QR code generator, and more.

+

Download

+

Visit the MaixVision homepage to download.

Using MaixPy Programming and Online Running

-

By following the steps in the Quick Start, we can easily use MaixPy programming and run programs online.

+

Follow the steps in Quick Start to connect your device, and you can easily use MaixPy programming and run it 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:

+

MaixPy provides a display module that can show images on the screen. Also, when the show method of the display module is called, it sends the image to be displayed on MaixVision, for example:

from maix import display, camera
 
@@ -226,42 +251,71 @@ 

Real-time Image Preview

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.

+

Here we use the camera to capture an image, then display it on the screen using the disp.show() method, and also send it to MaixVision for display.

+

When we click the 'pause' button in the top right corner, it will stop sending images to MaixVision.

+

Code Auto Completion

+

Code suggestions depend on local Python packages installed on your computer. To enable code suggestions, you need to install Python on your computer and the required Python packages.

+
    +
  • To install Python, visit the Python official website.
  • +
  • To install the required packages, for MaixPy, for instance, you need to install the MaixPy package on your computer using pip install MaixPy. If MaixPy gets updated, you should update it on both your computer and device. On your computer, manually execute pip install MaixPy -U in the terminal. For device updates, update directly in the Settings application.
  • +
+
+

Users in China can use a local mirror pip install -i https://pypi.tuna.tsinghua.edu.cn/simple MaixPy.

+
+
    +
  • Restart MaixVision to see the code suggestions.
  • +
+
+

If suggestions still do not appear, you can manually set the path to the Python executable in settings and restart.

+
+
+

Note that installing Python packages on your computer is just for code suggestions. The actual code runs on the device (development board), and the device must also have the corresponding packages to run properly.

+
+
+

Additionally, while you have the MaixPy package installed on your computer, due to our limited resources, we cannot guarantee that you can directly use the Maix package in your computer's Python. Please run it on supported devices.

+
+

Calculating the Image Histogram

+

In the previous step, we could see the image in real-time in MaixVision. By selecting an area with the mouse, we can view the histogram for that area at the bottom of the screen, displaying different color channels.

+

This feature is helpful when finding suitable parameters for some image processing algorithms.

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:

+

Here we have an important concept to grasp: distinguish between the Device File System and the Computer 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.
  • +
  • Computer File System: Operates on the computer. Opening a file or project in MaixVision accesses files on the computer, and saving is automatically done to the computer's file system.
  • +
  • Device File System: The program sends the code to the device for execution, so the files used in 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.

+

A common issue is when students save a file on the computer, such as D:\data\a.jpg, and then use this file on the device with img = image.load("D:\data\a.jpg"). Naturally, the file cannot be found because the device does not have D:\data\a.jpg.

+

For specifics on how to send files from the computer to the device, 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:

+

First, connect to the device, then click the button to browse the device file system, as shown below. Then you can upload files to the device or download files to the computer.

+

maixvision_browser2

+

maixvision_browser

+
+Alternatively, other tools can be used, click to expand +

First, know the device's IP address or name, which MaixVision can find, or see in the device's Settings->System Information, such as maixcam-xxxx.local or 192.168.0.123.
+ The username and password are root, using the SFTP protocol for file transfer, and the port number is 22.

+

There are many useful tools available for different systems:

+

Windows

+

Use WinSCP or FileZilla to connect to the device and transfer files, choosing the SFTP protocol and entering the device and account information to connect.

+

Specific instructions can be searched online.

+

Linux

+

In the terminal, use the scp command to transfer files to the device, such as:

scp /path/to/your/file.py root@maixcam-xxxx.local:/root
 
-

For Mac

+

Mac

    -
  • Method 1: Use the scp command in the terminal to transfer files to the device, for example:
  • +
  • Method 1: In the terminal, use the scp command to transfer files to the device, such as:
scp /path/to/your/file.py root@maixcam-xxxx.local:/root
 
    -
  • 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.
  • +
  • Method 2: Use FileZilla or other tools to connect to the device and transfer files, choosing the SFTP protocol and entering the device and account information to connect.
+
+
+

Using Graphical Block Programming

+

Under development, please stay tuned.

diff --git a/maixpy/doc/en/basic/os.html b/maixpy/doc/en/basic/os.html index d022990f..24e88013 100644 --- a/maixpy/doc/en/basic/os.html +++ b/maixpy/doc/en/basic/os.html @@ -102,7 +102,7 @@

MaixPy

diff --git a/maixpy/doc/en/basic/python.html b/maixpy/doc/en/basic/python.html index 917c011a..db219d04 100644 --- a/maixpy/doc/en/basic/python.html +++ b/maixpy/doc/en/basic/python.html @@ -102,7 +102,7 @@

MaixPy

diff --git a/maixpy/doc/en/basic/python_pkgs.html b/maixpy/doc/en/basic/python_pkgs.html index 145fb63a..cdfbec93 100644 --- a/maixpy/doc/en/basic/python_pkgs.html +++ b/maixpy/doc/en/basic/python_pkgs.html @@ -102,7 +102,7 @@

MaixPy

diff --git a/maixpy/doc/en/faq.html b/maixpy/doc/en/faq.html index c9b45e20..b756927f 100644 --- a/maixpy/doc/en/faq.html +++ b/maixpy/doc/en/faq.html @@ -102,7 +102,7 @@

MaixPy

diff --git a/maixpy/doc/en/index.html b/maixpy/doc/en/index.html index 34b199e7..8fb09a2e 100644 --- a/maixpy/doc/en/index.html +++ b/maixpy/doc/en/index.html @@ -102,7 +102,7 @@

MaixPy

diff --git a/maixpy/doc/en/modules/acc.html b/maixpy/doc/en/modules/acc.html index d6a75d24..ac1308c4 100644 --- a/maixpy/doc/en/modules/acc.html +++ b/maixpy/doc/en/modules/acc.html @@ -102,7 +102,7 @@

MaixPy

diff --git a/maixpy/doc/en/modules/thermal_cam.html b/maixpy/doc/en/modules/thermal_cam.html index 3145ee4d..2c076aa6 100644 --- a/maixpy/doc/en/modules/thermal_cam.html +++ b/maixpy/doc/en/modules/thermal_cam.html @@ -102,7 +102,7 @@

MaixPy

@@ -229,8 +252,8 @@

diff --git a/maixpy/doc/en/no_translate.html b/maixpy/doc/en/no_translate.html index 7820a3fd..9d41eaf6 100644 --- a/maixpy/doc/en/no_translate.html +++ b/maixpy/doc/en/no_translate.html @@ -102,7 +102,7 @@

MaixPy

diff --git a/maixpy/doc/en/peripheral/gpio.html b/maixpy/doc/en/peripheral/gpio.html index 52e81607..b39bb669 100644 --- a/maixpy/doc/en/peripheral/gpio.html +++ b/maixpy/doc/en/peripheral/gpio.html @@ -44,7 +44,7 @@ - MaixPy + MaixPy Using GPIO - MaixPy @@ -102,7 +102,7 @@

MaixPy

@@ -175,7 +198,7 @@

MaixPy

-

+

MaixPy Using GPIO

@@ -189,8 +212,8 @@

-
@@ -214,7 +237,41 @@

- +

Introduction

+

Using GPIO allows you to control pins for input or output high and low levels, which is commonly used to read signals or output control signals.

+

Using GPIO in MaixPy

+
+

MaixPy Firmware should > 4.1.2(not include)

+
+

First, we need to know which pins and GPIOs the device has. For MaixCAM, each pin corresponds to a GPIO controller, as shown in the figure:

+

+

It is important to note that pins can be used not only as GPIOs but also for other functions like PWM. Before using them, we need to set the pin function to GPIO.

+

For example, on MaixCAM, some pins are already occupied by other functions by default, such as UART0 and WiFi (SDIO1 + A26), so it is not recommended to use them. Other pins can be used, and the A14 pin is connected to the onboard LED, which is used as a system load indicator by default. If initialized, it will automatically disable the system indicator function and can be used as a regular GPIO (note that A14 can only be used as an output). This way, you can control the LED's on and off state.

+ +
from maix import gpio, pinmap, time
+
+pinmap.set_pin_function("A14", "GPIOA14")
+led = gpio.GPIO("A14", gpio.Mode.OUT)
+led.value(0)
+
+while 1:
+    led.toggle()
+    time.sleep_ms(500)
+
+

Here, we first use pinmap to set the function of the A14 pin to GPIO. Of course, for A14, since it only has the GPIO function, it can be omitted. For the sake of generality, other pins may need to be set, so it is set in this example.

+

For more APIs, please refer to the GPIO API Documentation

+

GPIO in Input Mode

+ +
from maix import gpio, pinmap, time
+
+pinmap.set_pin_function("A19", "GPIOA19")
+led = gpio.GPIO("A19", gpio.Mode.IN)
+
+while 1:
+    print(led.value())
+    time.sleep_ms(1) # sleep to make cpu free
+
+
diff --git a/maixpy/doc/en/peripheral/i2c.html b/maixpy/doc/en/peripheral/i2c.html index 5717f293..eb2b10fd 100644 --- a/maixpy/doc/en/peripheral/i2c.html +++ b/maixpy/doc/en/peripheral/i2c.html @@ -44,10 +44,10 @@ - MaixPy + MaixPy Using I2C - MaixPy - + @@ -102,7 +102,7 @@

MaixPy

@@ -175,7 +198,7 @@

MaixPy

-

+

MaixPy Using I2C

@@ -189,10 +212,6 @@

- -
@@ -214,7 +233,42 @@

- +

For MaixCAM, due to the tight pin resource constraints, the I2C pins overlap with the WiFi module (SDIO1), so you can only use either WiFi or hardware I2C, but not both.

+

Therefore, it is recommended to use IO emulation for I2C.

+
+

Note: Requires MaixPy image and firmware > 4.1.2 (not included)

+
+

IO Emulation I2C

+

To emulate I2C, you only need to use the GPIO functionality for the pins. On MaixCAM, the emulated I2C is fixed to pins A15 (SCL) and A27 (SDA), with the i2c number being 5. To use it, simply:

+ +
from maix import i2c, pinmap
+
+# pinmap.set_pin_function("A15", "GPIOA23")
+# pinmap.set_pin_function("A27", "GPIOA24")
+
+bus1 = i2c.I2C(5, i2c.Mode.MASTER)
+slaves = bus1.scan()
+print("find slaves:", slaves)
+
+

More API visit i2c API doc

+

Hardware I2C

+

As mentioned above, for MaixCAM, hardware I2C and WiFi are mutually exclusive. If you must use hardware I2C, you need to disable WiFi and use the pinmap module to set the pin functions to I2C, then use the maix.i2c module to operate.

+
+

TODO: Provide a method to disable WiFi (requires disabling the WiFi driver in the system, which is relatively complex)

+
+

Hardware I2C and its correspond pin see:

+

+ +
from maix import i2c, pinmap
+
+pinmap.set_pin_function("P18", "I2C1_SCL")
+pinmap.set_pin_function("P21", "I2C1_SDA")
+
+bus1 = i2c.I2C(1, i2c.Mode.MASTER)
+slaves = bus1.scan()
+print("find slaves:", slaves)
+
+
diff --git a/maixpy/doc/en/peripheral/pwm.html b/maixpy/doc/en/peripheral/pwm.html index 86ef178c..8ad748af 100644 --- a/maixpy/doc/en/peripheral/pwm.html +++ b/maixpy/doc/en/peripheral/pwm.html @@ -44,7 +44,7 @@ - MaixPy + Using PWM in MaixPy - MaixPy @@ -102,7 +102,7 @@

MaixPy

@@ -175,7 +198,7 @@

MaixPy

-

+

Using PWM in MaixPy

@@ -189,8 +212,8 @@

-
@@ -214,7 +237,44 @@

- +

Introduction

+

To use PWM in MaixPy (v4), first set the pin function to PWM using pinmap.

+

Each PWM corresponds to a specific pin, as shown in the pin diagram of MaixCAM:

+

+

We recommend using PWM6 and PWM7.

+

For MaixCAM, since WiFi uses all pins of SDIO1, PWM4~9 can only be used alternatively with WiFi.

+
+

TODO: Provide a method to disable WiFi (requires disabling the WiFi driver in the system, which is quite complex)

+
+

Using PWM to Control a Servo in MaixPy

+

Here we take controlling a servo as an example, using PWM7 and the A19 pin of MaixCAM:

+ +
from maix import pwm, time, pinmap
+
+SERVO_PERIOD = 50     # 50Hz 20ms
+SERVO_MIN_DUTY = 2.5  # 2.5% -> 0.5ms
+SERVO_MAX_DUTY = 12.5  # 12.5% -> 2.5ms
+
+# Use PWM7
+pwm_id = 7
+# !! set pinmap to use PWM7
+pinmap.set_pin_function("A19", "PWM7")
+
+def angle_to_duty(percent):
+    return (SERVO_MAX_DUTY - SERVO_MIN_DUTY) * percent / 100.0 + SERVO_MIN_DUTY
+
+out = pwm.PWM(pwm_id, freq=SERVO_PERIOD, duty=angle_to_duty(0), enable=True)
+
+for i in range(100):
+    out.duty(angle_to_duty(i))
+    time.sleep_ms(100)
+
+for i in range(100):
+    out.duty(angle_to_duty(100 - i))
+    time.sleep_ms(100)
+
+

This code controls the servo to rotate from the minimum angle to the maximum angle and then back to the minimum angle.

+
diff --git a/maixpy/doc/en/peripheral/spi.html b/maixpy/doc/en/peripheral/spi.html index baf5bb5e..22ced05a 100644 --- a/maixpy/doc/en/peripheral/spi.html +++ b/maixpy/doc/en/peripheral/spi.html @@ -44,10 +44,10 @@ - MaixPy + MaixPy ues SPI - MaixPy - + @@ -102,7 +102,7 @@

MaixPy

@@ -175,7 +198,7 @@

MaixPy

-

+

MaixPy ues SPI

@@ -189,10 +212,6 @@

- -
@@ -214,7 +233,8 @@

- +

TODO:

+
diff --git a/maixpy/doc/en/peripheral/uart.html b/maixpy/doc/en/peripheral/uart.html index 1ef8e5ba..61a8a065 100644 --- a/maixpy/doc/en/peripheral/uart.html +++ b/maixpy/doc/en/peripheral/uart.html @@ -44,7 +44,7 @@ - MaixPy + Introduction to Using UART in MaixPy - MaixPy @@ -102,7 +102,7 @@

MaixPy

@@ -175,7 +198,7 @@

MaixPy

-

+

Introduction to Using UART in MaixPy

@@ -189,8 +212,8 @@

-
@@ -214,7 +237,60 @@

- +

Introduction to UART

+

UART (Universal Asynchronous Receiver/Transmitter) is a communication method that includes definitions for both hardware and communication protocols.

+
    +
  • Hardware includes:

    +
      +
    • 3 pins: GND, RX, TX. The communication parties connect RX and TX in a cross configuration, i.e., the TX of one side is connected to the RX of the other side, and both GND pins are connected together.
    • +
    • Controller: Usually inside the chip, also known as a UART peripheral. A chip generally has one or more UART controllers, each with corresponding pins.
    • +
    +
  • +
  • Communication protocol: To ensure smooth communication between both parties, a set of protocols is defined. You can learn the specifics on your own. Common parameters include baud rate and parity bit, with baud rate being the most frequently used parameter.

    +
  • +
+

Using the board's UART, you can communicate with other microcontrollers or SoCs. For instance, you can implement a human detection function on MaixCAM and send the detected coordinates to an STM32 microcontroller via UART.

+

Using UART in MaixPy

+

For MaixCAM, a UART is by default exposed through the USB port. By connecting a Type-C adapter board, you can directly use the UART pins on it. Alternatively, you can use the A16 (TX) and A17 (RX) pins on the board directly, which are equivalent to the ones exposed through the USB port.

+

When using the UART exposed through the USB port on MaixCAM, note that the RX and TX pins on the Type-C adapter board will switch when you flip the Type-C connector. So, if communication fails, it might be due to reversed RX and TX. Try flipping the Type-C connector and check if the communication works properly. This is a design flaw, but it’s manageable with minimal adjustments.

+

After connecting the communicating boards (connecting RX to TX in a cross configuration and both GND pins together), you can use the software.

+

Using UART in MaixPy is simple:

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

Here, we list all UART devices in the system and use the first one, which is the one exposed through the Type-C port.

+

For more UART APIs, please refer to the UART API Documentation

+

Other Usage and Using Additional UARTs

+ +
from maix import app, uart, pinmap, time
+import sys
+
+# pinmap.set_pin_function("A16", "UART0_TX")
+# pinmap.set_pin_function("A17", "UART0_RX")
+device = "/dev/ttyS0"
+
+serial0 = uart.UART(device, 115200)
+
+serial0.write("hello 1\r\n".encode())
+serial0.write_str("hello 2\r\n")
+
+while not app.need_exit():
+    data = serial0.read()
+    if data:
+        print("Received, type: {}, len: {}, data: {}".format(type(data), len(data), data))
+        serial0.write(data)
+    time.sleep_ms(1) # sleep 1ms to make CPU free
+
+

Here, we set up pin mapping, especially if you want to use UARTs other than UART0. Use pinmap.set_pin_function based on the pin numbers and UART in the diagram:

+

+

Additionally, a sleep_ms function is added in the loop to briefly release the CPU, ensuring that the program does not occupy the CPU fully. There are other methods to achieve this, but this is the simplest and most straightforward approach.

+
diff --git a/maixpy/doc/en/peripheral/wdt.html b/maixpy/doc/en/peripheral/wdt.html index c628f269..6a8fa7be 100644 --- a/maixpy/doc/en/peripheral/wdt.html +++ b/maixpy/doc/en/peripheral/wdt.html @@ -44,7 +44,7 @@ - MaixPy + Using Watchdog Timer in MaixPy - MaixPy @@ -102,7 +102,7 @@

MaixPy

@@ -175,7 +198,7 @@

MaixPy

-

+

Using Watchdog Timer in MaixPy

@@ -189,8 +212,8 @@

-
@@ -214,7 +237,23 @@

- +

Introduction

+

To prevent program issues, a watchdog timer (WDT) is often used to automatically restart the system when the program encounters a problem.

+

The principle is that there is a countdown timer that we need to periodically reset within the program logic (also called "feeding the dog"). If our program gets stuck and fails to reset the countdown timer, the hardware will trigger a system reboot when the timer reaches 0.

+

Using WDT in MaixPy

+ +
from maix import wdt, app, time
+
+w = wdt.WDT(0, 1000)
+
+while not app.need_exit():
+    w.feed()
+    # Here, sleep operation is our task
+    # 200 ms is normal; if it exceeds 1000 ms, it will cause a system reset
+    time.sleep_ms(200)
+
+

This code sets up a watchdog timer that requires feeding every 1000 ms. If the program fails to feed the watchdog within this period, the system will reset.

+
diff --git a/maixpy/doc/en/pro/compile_os.html b/maixpy/doc/en/pro/compile_os.html index 61be8f61..d0f38ac8 100644 --- a/maixpy/doc/en/pro/compile_os.html +++ b/maixpy/doc/en/pro/compile_os.html @@ -102,7 +102,7 @@

MaixPy

diff --git a/maixpy/doc/en/projects/index.html b/maixpy/doc/en/projects/index.html new file mode 100644 index 00000000..72101ee4 --- /dev/null +++ b/maixpy/doc/en/projects/index.html @@ -0,0 +1,357 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Practical Projects with MaixPy, Introduction and Collection - MaixPy + + + + + + + + + + +
+ +
+ +
+
+
+
+ +

Practical Projects with MaixPy, Introduction and Collection

+ +
+
+
    + +
+
+
+
+ + +
+
+ + + +
+
+
+
+ + +
+
+ +
+
+ +

Introduction

+

Here we provide some common practical project examples for community members to refer to and replicate for use. This also helps to inspire everyone to create more and better applications and projects.

+

There are several ways to find projects implemented with MaixPy:

+

MaixPy Official Documentation

+

You can find practical projects in the documentation on the left, such as "Line Following Car."

+

If you have a good project or a recommended project, you can also contribute by adding it to the documentation.

+

MaixHub Project Sharing Square

+

Projects can be found in the MaixHub Project Sharing section.

+

High-quality shares will also be linked to the MaixPy official documentation.

+

You can also share your project-making methods, which will receive official rewards (guaranteed) and cash tips from community members (usually, high-quality projects that meet urgent needs are more likely to be tipped).

+

Recommend Projects:

+ +

MaixHub App Sharing

+

In addition to project sharing, you can also find directly runnable applications at the MaixHub App Store, some of which might be written in MaixPy. If the author has provided the source code or written detailed tutorials, these can also be referred to.

+

Recommend Projects:

+ + + +
+
+ +
+
+
+
+
+ +
+
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/maixpy/doc/en/projects/line_tracking_robot.html b/maixpy/doc/en/projects/line_tracking_robot.html new file mode 100644 index 00000000..24cb277e --- /dev/null +++ b/maixpy/doc/en/projects/line_tracking_robot.html @@ -0,0 +1,420 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + MaixPy Line Tracking Robot (/Car) - MaixPy + + + + + + + + + + +
+ +
+ +
+
+
+
+ +

MaixPy Line Tracking Robot (/Car)

+ +
+
+
    + +
+
+
+
+ + + + +
+
+ + + +
+
+
+
+ + +
+
+ + +
+ + Update history +
+ + + + + + + + + + + + + + + + + + + +
DateVersionAuthorUpdate content
2024-05-091.0.0lxowalle + + Initial documentation + +
+
+
+ +
+
+ +

Before reading this article, make sure you know how to develop with MaixCAM. For details, please read Quick Start.

+

Introduction

+

This article describes how to implement a line tracking robot using MaixPy.

+

How to implement line tracking robot using MaixPy

+
    +
  1. Preparation of MaixCAM and trolley
  2. +
  3. Implementing the line tracking function
  4. +
  5. Implement the trolley control function
  6. +
+

Preparation of MaixCAM and trolley

+

TODO

+

Implementing the line tracking function

+

You can quickly find straight lines using the get_regression of the image module, see [Line tracking](. /line_tracking.html).

+

Code:

+ +
from maix import camera, display, image
+
+cam = camera.Camera(320, 240)
+disp = display.Display()
+
+# 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()
+
+    lines = img.get_regression(thresholds, area_threshold = 100)
+    for a in lines:
+        img.draw_line(a.x1(), a.y1(), a.x2(), a.y2(), image.COLOR_GREEN, 2)
+        theta = a.theta()
+        rho = a.rho()
+        if theta > 90:
+            theta = 270 - theta
+        else:
+            theta = 90 - theta
+        img.draw_string(0, 0, "theta: " + str(theta) + ", rho: " + str(rho), image.COLOR_BLUE)
+
+    disp.show(img)
+
+
+

The above code implements the function of finding a straight line, note:

+
    +
  • Use a.theta() to get the angle of the line.
  • +
  • Use a.rho() to get the distance between the line and the origin (the origin is in the upper left corner).
  • +
+

After find the straight line with reference to the above code, you can use a.theta() and a.rho() to control the direction of the cart.

+

Implement the trolley control function

+

TODO

+ + +
+
+ +
+
+
+
+
+ +
+
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/maixpy/doc/en/sidebar.yaml b/maixpy/doc/en/sidebar.yaml index dabc8295..5751da37 100644 --- a/maixpy/doc/en/sidebar.yaml +++ b/maixpy/doc/en/sidebar.yaml @@ -2,126 +2,146 @@ items: - file: README.md label: Quick Start - file: faq.md - label: FAQ + label: FAQ - label: Base -- file: basic/os.md - label: Burning system -- file: basic/app_usage.md - label: App uses -- file: basic/maixpy_upgrade.md - label: Update MaixPy -- file: basic/maixvision.md - label: MaixVision uses -- file: basic/python.md - label: Python syntax -- file: basic/linux_basic.md - label: Linux fundamentals -- file: basic/python_pkgs.md - label: Add python packages -- file: basic/app.md - label: Apps development + collapsed: false + items: + - file: basic/os.md + label: Burning system + - file: basic/app_usage.md + label: App uses + - file: basic/maixpy_upgrade.md + label: Update MaixPy + - file: basic/maixvision.md + label: MaixVision uses + - file: basic/python.md + label: Python syntax + - file: basic/linux_basic.md + label: Linux fundamentals + - file: basic/python_pkgs.md + label: Add python packages + - file: basic/app.md + label: Apps development - label: Basic images and algorithms -- file: vision/display.md - label: Screen uses -- file: vision/camera.md - label: Camera uses -- file: vision/image_ops.md - label: Image control -- file: vision/find_blobs.md - label: Finding color blocks -- file: vision/qrcode.md - label: QRcode identity -- file: vision/apriltag.md - label: AprilTag identity + items: + - file: vision/display.md + label: Screen uses + - file: vision/camera.md + label: Camera uses + - file: vision/image_ops.md + label: Image control + - file: vision/find_blobs.md + label: Finding color blocks + - file: vision/line_tracking.md + label: Line tracking + - file: vision/qrcode.md + label: QRcode identity + - file: vision/apriltag.md + label: AprilTag identity - label: AI Vision -- file: vision/ai.md - label: AI vision knowledge -- file: vision/classify.md - label: AI object classify -- file: vision/yolov5.md - label: YOLOv5 object detect -- file: vision/face_recognition.md - label: Face detect -- file: vision/body_key_points.md - label: Human critical point detection -- file: vision/self_learn_classifier.md - label: Self-learning classifier -- file: vision/self_learn_detector.md - label: Self-learning detector -- file: vision/object_track.md - label: Object tracking and counting -- file: vision/ocr.md - label: OCR -- file: vision/maixhub_train.md - label: MaixHub online AI training -- file: vision/custmize_model.md - label: Custom model + items: + - file: vision/ai.md + label: AI vision knowledge + - file: vision/classify.md + label: AI object classify + - file: vision/yolov5.md + label: YOLOv5 object detect + - file: vision/face_detection.md + label: Face detect and keypoints + - file: vision/face_recognition.md + label: Face recognition + - file: vision/body_key_points.md + label: Human critical point detection + - file: vision/self_learn_classifier.md + label: Self-learning classifier + - file: vision/self_learn_detector.md + label: Self-learning detector + - file: vision/object_track.md + label: Object tracking and counting + - file: vision/ocr.md + label: OCR + - file: vision/maixhub_train.md + label: MaixHub online AI training + - file: vision/custmize_model.md + label: Custom model - label: AI audio -- file: audio/record.md - label: Audio record -- file: audio/play.md - label: Play audio -- file: audio/classifier.md - label: AI voice classifier -- file: audio/keyword.md - label: Keyword recognize -- file: audio/recognize.md - label: Real-time voice recognize -- file: audio/synthesis.md - label: Speech synthesis + items: + - file: audio/record.md + label: Audio record + - file: audio/play.md + label: Play audio + - file: audio/classifier.md + label: AI voice classifier + - file: audio/keyword.md + label: Keyword recognize + - file: audio/recognize.md + label: Real-time voice recognize + - file: audio/synthesis.md + label: Speech synthesis - label: Video -- file: video/record.md - label: Video record -- file: video/play.md - label: Play video -- file: video/jpeg_streaming.md - label: JPEG stream -- file: video/rtsp.md - label: RTSP stream + items: + - file: video/record.md + label: Video record + - file: video/play.md + label: Play video + - file: video/jpeg_streaming.md + label: JPEG stream + - file: video/rtsp.md + label: RTSP stream - label: On-chip peripherals -- file: peripheral/gpio.md - label: GPIO -- file: peripheral/uart.md - label: UART -- file: peripheral/i2c.md - label: I2C -- file: peripheral/pwm.md - label: PWM -- file: peripheral/spi.md - label: SPI -- file: peripheral/wdt.md - label: WDT watchdog + items: + - file: peripheral/gpio.md + label: GPIO + - file: peripheral/uart.md + label: UART + - file: peripheral/i2c.md + label: I2C + - file: peripheral/pwm.md + label: PWM + - file: peripheral/spi.md + label: SPI + - file: peripheral/wdt.md + label: WDT watchdog - label: Off-chip modules -- file: modules/acc.md - label: Accelerometer -- file: modules/temp_hum.md - label: Temperature and humidity -- file: modules/tof.md - label: TOF -- file: modules/thermal_cam.md - label: Thermal imaging + items: + - file: modules/acc.md + label: Accelerometer + - file: modules/temp_hum.md + label: Temperature and humidity + - file: modules/tof.md + label: TOF + - file: modules/thermal_cam.md + label: Thermal imaging + +- label: Porjects + items: + - file: projects/README.md + label: Intro & Collection + - file: projects/line_tracking_robot.md + label: Line tracking robot - label: Advanced -- file: source_code/contribute.md - label: Contribute -- file: source_code/build.md - label: Build source code -- file: source_code/faq.md - label: MaixPy Source FAQ -- file: source_code/add_c_module.md - label: Write in C/C++ -- file: source_code/maixcdk.md - label: MaixCDK develop -- file: pro/compile_os.md - label: Build firmware + items: + - file: source_code/contribute.md + label: Contribute + - file: source_code/build.md + label: Build source code + - file: source_code/faq.md + label: MaixPy Source FAQ + - file: source_code/add_c_module.md + label: Write in C/C++ + - file: source_code/maixcdk.md + label: MaixCDK develop + - file: pro/compile_os.md + label: Build firmware diff --git a/maixpy/doc/en/source_code/add_c_module.html b/maixpy/doc/en/source_code/add_c_module.html index bb2411df..ede25ae9 100644 --- a/maixpy/doc/en/source_code/add_c_module.html +++ b/maixpy/doc/en/source_code/add_c_module.html @@ -102,7 +102,7 @@

MaixPy

diff --git a/maixpy/doc/en/source_code/build.html b/maixpy/doc/en/source_code/build.html index 93290e3e..0e5858cf 100644 --- a/maixpy/doc/en/source_code/build.html +++ b/maixpy/doc/en/source_code/build.html @@ -102,7 +102,7 @@

MaixPy

@@ -212,18 +235,34 @@

MaixPy develop source code guide

Get source code

-
git clone https://github.com/sipeed/MaixPy
-cd MaixPy
+
mkdir -p ~/maix
+cd ~/maix
+git clone https://github.com/sipeed/MaixPy
 
+

Getting MaixCDK Source Code

+

The MaixPy project depends on MaixCDK. You need to clone it first and place it in a directory on your computer (do not place it under the MaixPy directory).

+ +
cd ~/maix
+git clone https://github.com/sipeed/MaixCDK
+
+

Then, you need to set the environment variable MAIXCAK_PATH to specify the path to MaixCDK, which can be added in ~/.bashrc or ~/.zshrc (depending on your shell):

+ +
export MAIXCAK_PATH=~/maix/MaixCDK
+
+

Only after successfully setting the environment variable can MaixPy locate the MaixCDK source code.

Build and pack to wheel

-
python setup.py bdist_wheel maixcam
+
cd ~/maix/MaixPy
+python setup.py bdist_wheel maixcam
 

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.

+
+

Additionally, if you are debugging APIs and need to install frequently, using pip can be slow. You can compile and then copy the maix directory directly to the /usr/lib/python3.11/site-packages directory on your device to overwrite the old files.

+

Build manually

maixcdk build
diff --git a/maixpy/doc/en/source_code/contribute.html b/maixpy/doc/en/source_code/contribute.html
index 545110f2..e4e3741c 100644
--- a/maixpy/doc/en/source_code/contribute.html
+++ b/maixpy/doc/en/source_code/contribute.html
@@ -102,7 +102,7 @@ 

MaixPy

@@ -252,9 +275,9 @@

Contributing to MaixPy Code Co @@ -189,8 +212,8 @@

MaixPy Source Code FAQ

-
+

/usr/bin/ld: /lib/libgdal.so.30: undefined reference to `std::condition_variable::wait(std::unique_lockstd::mutex&)@GLIBCXX_3.4.30' collect2: error: ld returned 1 exit status

+

This issue commonly arises when building for Linux and using a conda environment, due to some libraries in the conda environment having compilation parameter problems. The solution is to not use conda, or to individually locate the problematic library within conda and replace it with the system's version or simply delete it (the system will then locate the necessary library).

diff --git a/maixpy/doc/en/source_code/maixcdk.html b/maixpy/doc/en/source_code/maixcdk.html index 1c944884..0f35a5e6 100644 --- a/maixpy/doc/en/source_code/maixcdk.html +++ b/maixpy/doc/en/source_code/maixcdk.html @@ -102,7 +102,7 @@

MaixPy

diff --git a/maixpy/doc/en/video/jpeg_streaming.html b/maixpy/doc/en/video/jpeg_streaming.html index 0424d3b8..a9ea7b09 100644 --- a/maixpy/doc/en/video/jpeg_streaming.html +++ b/maixpy/doc/en/video/jpeg_streaming.html @@ -102,7 +102,7 @@

MaixPy

diff --git a/maixpy/doc/en/vision/ai.html b/maixpy/doc/en/vision/ai.html index 89916de7..e1e8b8e5 100644 --- a/maixpy/doc/en/vision/ai.html +++ b/maixpy/doc/en/vision/ai.html @@ -102,7 +102,7 @@

MaixPy

diff --git a/maixpy/doc/en/vision/apriltag.html b/maixpy/doc/en/vision/apriltag.html index 152dc611..d80277fd 100644 --- a/maixpy/doc/en/vision/apriltag.html +++ b/maixpy/doc/en/vision/apriltag.html @@ -102,7 +102,7 @@

MaixPy

@@ -246,7 +269,7 @@

MaixPy Apriltag Recognition

-

Before reading this article, make sure you are familiar with how to develop with MaixPy. For more details, please read MaixVision -- MaixPy Programming + Graphical Block Programming.

+

Before reading this article, make sure you are familiar with how to develop with MaixCAM. For more details, please read Quick Start.

Introduction

This article introduces how to use MaixPy to recognize Apriltag labels.

Using MaixPy to Recognize Apriltag Labels

diff --git a/maixpy/doc/en/vision/body_key_points.html b/maixpy/doc/en/vision/body_key_points.html index 83b7742f..be04477e 100644 --- a/maixpy/doc/en/vision/body_key_points.html +++ b/maixpy/doc/en/vision/body_key_points.html @@ -102,7 +102,7 @@

MaixPy

@@ -237,7 +260,7 @@

Usage

- Face detect + Face recognition diff --git a/maixpy/doc/en/vision/camera.html b/maixpy/doc/en/vision/camera.html index 400d1505..1cdc8373 100644 --- a/maixpy/doc/en/vision/camera.html +++ b/maixpy/doc/en/vision/camera.html @@ -102,7 +102,7 @@

MaixPy

diff --git a/maixpy/doc/en/vision/classify.html b/maixpy/doc/en/vision/classify.html index 2daed247..63843dd3 100644 --- a/maixpy/doc/en/vision/classify.html +++ b/maixpy/doc/en/vision/classify.html @@ -102,7 +102,7 @@

MaixPy

diff --git a/maixpy/doc/en/vision/custmize_model.html b/maixpy/doc/en/vision/custmize_model.html index 8a93376b..92b116ae 100644 --- a/maixpy/doc/en/vision/custmize_model.html +++ b/maixpy/doc/en/vision/custmize_model.html @@ -102,7 +102,7 @@

MaixPy

diff --git a/maixpy/doc/en/vision/display.html b/maixpy/doc/en/vision/display.html index 44015e52..a0cc80ce 100644 --- a/maixpy/doc/en/vision/display.html +++ b/maixpy/doc/en/vision/display.html @@ -102,7 +102,7 @@

MaixPy

diff --git a/maixpy/doc/en/vision/face_detection.html b/maixpy/doc/en/vision/face_detection.html new file mode 100644 index 00000000..d8a946c5 --- /dev/null +++ b/maixpy/doc/en/vision/face_detection.html @@ -0,0 +1,374 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + MaixPy Face Detection and Key Points Detection - MaixPy + + + + + + + + + + +
+ +
+ +
+
+
+
+ +

MaixPy Face Detection and Key Points Detection

+ +
+
+
    + +
+
+
+
+ + +
+
+ + + +
+
+
+
+ + +
+
+ +
+
+ +

Introduction

+

Face detection can be used in many places, such as providing the step of face detection for face recognition, or applications related to face tracking, and more.

+

The face detection provided here can not only detect faces but also detect 5 key points, including two eyes, one nose, and the two corners of a mouth.

+

face detection

+

Using Face Detection in MaixPy

+

MaixPy officially provides two face detection models, sourced from the open projects face detector 1MB with landmark and Retinaface.

+

To use them, first download a model, either one as there's not much difference between them:

+ +

Then copy the model file to your device, see Using MaixVision for how to copy.

+
+

The default image contains a file that can be used directly; if not available, you must download it yourself. The downloaded zip package contains multiple resolutions to choose from; the higher the resolution, the more precise but also more time-consuming.

+
+

Next, run the code. The following line of commented code is for loading the Retinaface model, choose which line of code to use based on the model you downloaded.

+
+

To use this function, MaixPy must >= 4.1.4.

+
+ +
from maix import camera, display, image, nn, app
+import math
+
+detector = nn.FaceDetector(model="/root/models/face_detector.mud")
+# detector = nn.Retinaface(model="/root/models/retinaface.mud")
+
+cam = camera.Camera(detector.input_width(), detector.input_height(), detector.input_format())
+dis = display.Display()
+
+while not app.need_exit():
+    img = cam.read()
+    objs = detector.detect(img, conf_th = 0.4, iou_th = 0.45)
+    for obj in objs:
+        img.draw_rect(obj.x, obj.y, obj.w, obj.h, color = image.COLOR_RED)
+        radius = math.ceil(obj.w / 10)
+        img.draw_keypoints(obj.points, image.COLOR_RED, size = radius if radius < 5 else 4)
+    dis.show(img)
+
+
+ + +
+
+ +
+
+
+
+
+ +
+
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/maixpy/doc/en/vision/face_recognition.html b/maixpy/doc/en/vision/face_recognition.html index 943253ff..d1d238ec 100644 --- a/maixpy/doc/en/vision/face_recognition.html +++ b/maixpy/doc/en/vision/face_recognition.html @@ -102,7 +102,7 @@

MaixPy

@@ -259,9 +282,9 @@

Using MaixPy

@@ -257,7 +280,7 @@

MaixPy Find Blobs

-

Before reading this article, make sure you know how to develop with MaixPy. For details, please read MaixVision -- MaixPy Programming + Graphical Block Programming.

+

Before reading this article, make sure you know how to develop with MaixCAM. For details, please read Quick Start.

Introduction

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.

@@ -423,8 +446,8 @@

About the LAB Color Space

diff --git a/maixpy/doc/en/vision/line_tracking.html b/maixpy/doc/en/vision/line_tracking.html new file mode 100644 index 00000000..bbe8c5be --- /dev/null +++ b/maixpy/doc/en/vision/line_tracking.html @@ -0,0 +1,536 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + MaixPy Line Tracking - MaixPy + + + + + + + + + + +
+ +
+ +
+
+
+
+ +

MaixPy Line Tracking

+ +
+
+
    + +
+
+
+
+ + + + +
+
+ + + +
+
+
+
+ + +
+
+ + +
+ + Update history +
+ + + + + + + + + + + + + + + + + + + +
DateVersionAuthorUpdate content
2024-05-091.0.0lxowalle + + Initial document + +
+
+
+ +
+
+ +

Before reading this article, make sure you already know how to develop MaixCAM. For details, please read Quick Start.

+

Introduction

+

In vision applications, the function of tracking line is often required in applications such as line-following robot. In this article, we will describe:

+
    +
  • How to use MaixPy to tracking line.

    +
  • +
  • How to tracking line using MaixCam's default application

    +
  • +
+

How to use MaixPy to tracking line

+

The maix.image.Image module in MaixPy provides the get_regression method, which can conveniently tracking line.

+

Code example

+

A simple example of finding and drawing a line.

+ +
from maix import camera, display, image
+
+cam = camera.Camera(320, 240)
+disp = display.Display()
+
+# 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()
+
+    lines = img.get_regression(thresholds, area_threshold = 100)
+    for a in lines:
+        img.draw_line(a.x1(), a.y1(), a.x2(), a.y2(), image.COLOR_GREEN, 2)
+        theta = a.theta()
+        rho = a.rho()
+        if theta > 90:
+            theta = 270 - theta
+        else:
+            theta = 90 - theta
+        img.draw_string(0, 0, "theta: " + str(theta) + ", rho: " + str(rho), image.COLOR_BLUE)
+
+    disp.show(img)
+
+

Steps:

+
    +
  1. import image, camera, display modules

    + +
    from maix import image, camera, display
    +
    +
  2. +
  3. Initialize camera and display

    + +
    cam = camera.Camera(320, 240) # Initialise camera, output resolution 320x240 in RGB format.
    +disp = display.Display()
    +
    +
  4. +
  5. Get the image from the camera and display it

    + +
    while 1:
    +    img = cam.read()
    +    disp.show(img)
    +
    +
  6. +
  7. Call the get_regression method to find the straight line in the camera image and draw it to the screen

    + +
    lines = img.get_regression(thresholds, area_threshold = 100)
    +for a in lines:
    +   img.draw_line(a.x1(), a.y1(), a.x2(), a.y2(), image.COLOR_GREEN, 2)
    +   theta = a.theta()
    +   rho = a.rho()
    +   if theta > 90:
    +      theta = 270 - theta
    +   else:
    +      theta = 90 - theta
    +   img.draw_string(0, 0, "theta: " + str(theta) + ", rho: " + str(rho), image.COLOR_BLUE)
    +
    +
      +
    • img is the camera image read via cam.read(), when initialised as cam = camera.Camera(320, 240), the img object is an RGB image with a resolution of 320x240.
    • +
    • img.get_regression is used to find straight lines, thresholds is a list of colour thresholds, each element is a colour threshold, multiple thresholds are passed in if multiple thresholds are found at the same time, and each colour threshold has the format [L_MIN, L_MAX, A_MIN, A_MAX, B_MIN, B_MAX], where L, A, B are the three channels of LAB colour space, L channel is the luminance, A channel is the red-green channel, B channel is the blue-yellow channel. pixels_threshold is a pixel area threshold used to filter some unwanted straight lines.
    • +
    • for a in lines is used to iterate through the returned Line objects, where a is the current Line object. Normally the get_regression function will only return one Line object, but if you need to find more than one line, try the find_line method.
    • +
    • Use img.draw_line to draw the found line, a.x1(), a.y1(), a.x2(), a.y2() represent the coordinates of the ends of the line.
    • +
    • Use img.draw_string to show the angle between the line and the x-axis in the upper left corner, and a.theta() is the angle between the line and the y-axis, which is converted to theta for easier understanding, a.rho() is the length of the vertical line from the origin to the line.
    • +
    +
  8. +
  9. Run the code through the maixvision, you can find the line, look at the effect!

    +

    image-20240509110204007

    +
  10. +
+

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.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
ParameterDescriptionExample
thresholdsThresholds 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]
invertEnable threshold inversion, when enabled, the passed thresholds are inverted. Default is False.Enable threshold inversion
img.find_blobs(invert=True)
roiSet 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_thresholdFilter 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_thresholdFilter 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.

+

How to tracking line using MaixCam's default application

+

To quickly verify the line tracking functionality, you can use the line_tracking application provided by MaixCam to experience the line finding effect.

+

How to use it

+
    +
  1. Select and open the Line tracking application.
  2. +
  3. Click on the line in the screen that needs to be identified and the colour of the line will be displayed on the left hand side
  4. +
  5. Click on the colour to be detected on the left (the colour below L A B in the screen)
  6. +
  7. The line will be identified and the coordinates and angle of the line will be output from the serial port.
  8. +
+

Demo

+

+

Advanced operations

+

Manual adjustment of LAB threshold to tracking line

+

The application provides manual setting of LAB threshold to tracking line accurately.

+

Steps:

+
    +
  1. Click the options icon in the bottom-left corner to enter configuration mode.
  2. +
  3. 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.
  4. +
  5. 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.
  6. +
  7. 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.
  8. +
+

Getting Detection Data via Serial Protocol

+

The line tracking application supports reporting detected straight line information 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:

+ +
AA CA AC BB 0E 00 00 00 00 E1 09 FC 01 01 00 E9 01 6F 01 57 00 C1 C6
+
+
    +
  • AA CA AC BB: Protocol header, fixed content

    +
  • +
  • 0E 00 00 00: Data length, the total length excluding the protocol header and data length, here means the length is 14.

    +
  • +
  • E1: Flag bit, used to identify the serial message flag

    +
  • +
  • 09: Command type, for the line tracking application, this value is fixed at 0x09.

    +
  • +
  • FC 01 01 00 E9 01 6F 01 57 00: The coordinates and angle information for both ends of line, with each value represented as a 2-byte value in little-end format. FC 01 and 01 00 indicate that the coordinates of the first endpoint are (508, 1), E9 01 and 6F 01 indicate that the coordinates of the second endpoint are (489, 367), and 57 00 indicates that the angle of the line to the x-axis is 87 degrees

    +
  • +
  • C1 C6: CRC checksum value, used to verify if the frame data has errors during transmission.

    +
  • +
+ + +
+
+ +
+
+
+
+
+ +
+
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/maixpy/doc/en/vision/maixhub_train.html b/maixpy/doc/en/vision/maixhub_train.html index 0334a01f..5233dea3 100644 --- a/maixpy/doc/en/vision/maixhub_train.html +++ b/maixpy/doc/en/vision/maixhub_train.html @@ -102,7 +102,7 @@

MaixPy

diff --git a/maixpy/doc/en/vision/object_track.html b/maixpy/doc/en/vision/object_track.html index feafd5a2..8eedf2cb 100644 --- a/maixpy/doc/en/vision/object_track.html +++ b/maixpy/doc/en/vision/object_track.html @@ -102,7 +102,7 @@

MaixPy

diff --git a/maixpy/doc/en/vision/qrcode.html b/maixpy/doc/en/vision/qrcode.html index f773fdbc..282678e5 100644 --- a/maixpy/doc/en/vision/qrcode.html +++ b/maixpy/doc/en/vision/qrcode.html @@ -102,7 +102,7 @@

MaixPy

@@ -246,7 +269,7 @@

MaixPy QR Code Recognition

-

Before reading this article, make sure you are familiar with how to develop with MaixPy. For details, please read MaixVision -- MaixPy Programming + Graphical Block Programming

+

Before reading this article, make sure you are familiar with how to develop with MaixCAM. For details, please read Quick Start.

Introduction

This article explains how to use MaixPy for QR code recognition.

Using MaixPy to Recognize QR Codes

@@ -339,9 +362,9 @@

Common Parameter Explanation

diff --git a/maixpy/doc/en/vision/self_learn_detector.html b/maixpy/doc/en/vision/self_learn_detector.html index dda43445..6cb1a257 100644 --- a/maixpy/doc/en/vision/self_learn_detector.html +++ b/maixpy/doc/en/vision/self_learn_detector.html @@ -102,7 +102,7 @@

MaixPy

diff --git a/maixpy/doc/en/vision/yolov5.html b/maixpy/doc/en/vision/yolov5.html index 24181af3..88c5d44a 100644 --- a/maixpy/doc/en/vision/yolov5.html +++ b/maixpy/doc/en/vision/yolov5.html @@ -102,7 +102,7 @@

MaixPy

@@ -253,8 +276,8 @@

Training Your Own Object Detec diff --git a/maixpy/doc/zh/basic/app.html b/maixpy/doc/zh/basic/app.html index 5b440849..85f503a0 100644 --- a/maixpy/doc/zh/basic/app.html +++ b/maixpy/doc/zh/basic/app.html @@ -102,7 +102,7 @@

MaixPy

diff --git a/maixpy/doc/zh/basic/app_usage.html b/maixpy/doc/zh/basic/app_usage.html index 446e1cfd..5d7b2a83 100644 --- a/maixpy/doc/zh/basic/app_usage.html +++ b/maixpy/doc/zh/basic/app_usage.html @@ -102,7 +102,7 @@

MaixPy

diff --git a/maixpy/doc/zh/basic/linux_basic.html b/maixpy/doc/zh/basic/linux_basic.html index 7dba26f9..c49c03e6 100644 --- a/maixpy/doc/zh/basic/linux_basic.html +++ b/maixpy/doc/zh/basic/linux_basic.html @@ -102,7 +102,7 @@

MaixPy

diff --git a/maixpy/doc/zh/basic/maixpy_upgrade.html b/maixpy/doc/zh/basic/maixpy_upgrade.html index 87a1773f..78871064 100644 --- a/maixpy/doc/zh/basic/maixpy_upgrade.html +++ b/maixpy/doc/zh/basic/maixpy_upgrade.html @@ -102,7 +102,7 @@

MaixPy

diff --git a/maixpy/doc/zh/basic/maixvision.html b/maixpy/doc/zh/basic/maixvision.html index 8eb77a7e..3a8402e9 100644 --- a/maixpy/doc/zh/basic/maixvision.html +++ b/maixpy/doc/zh/basic/maixvision.html @@ -44,7 +44,7 @@ - MaixVision -- MaixPy 编程 + 图形化积木编程 - MaixPy + MaixVision -- MaixPy 编程 IDE + 图形化积木编程 - MaixPy @@ -102,7 +102,7 @@

MaixPy

@@ -175,7 +198,7 @@

MaixPy

-

MaixVision -- MaixPy 编程 + 图形化积木编程

+

MaixVision -- MaixPy 编程 IDE + 图形化积木编程

@@ -211,9 +234,11 @@

MaixVision -- MaixPy 编程 + 图形化积木编程

简介

-

MaixVision 是专为 Maix 生态打造的一款开发者编程工具,支持 MaixPy 编程和图形化积木编程,同时支持在线运行和调试,以及实时预览图像,可以同步设备显示屏的图像,方便调试和开发。

+

MaixVision 是专为 Maix 生态打造的一款开发者编程工具,支持 MaixPy 编程和图形化积木编程,同时支持在线运行和调试,以及实时预览图像,可以同步设备显示屏的图像,方便调试和开发。

以及支持打包应用和安装应用到设备,方便用户一键生成、安装应用。

同时还集成一些方便开发的小工具,比如文件管理,阈值编辑器,二维码生成等等。

+

下载

+

访问 MaixVision 主页 下载。

使用 MaixPy 编程和在线运行

按照快速开始的步骤连接设备,我们可以很方便地使用 MaixPy 编程和在线运行。

实时预览图像

@@ -228,11 +253,30 @@

实时预览图

这里我们用摄像头读取了图像,然后通过disp.show()方法将图像显示到屏幕上,同时也会发送到 MaixVision 显示。

当我们点击了右上角的暂停按钮,就会停止发送图像到 MaixVision 显示。

+

代码自动补全

+

代码提示依赖电脑本地的 Python 包,为了实现代码提示,我们需要在电脑中安装 Python,并且安装需要提示的 Python 包。

+
    +
  • 安装 Python 请访问 Python 官网安装。
  • +
  • 安装需要提示的包,比如对于 MaixPy, 你需要在电脑也安装一份 MaixPy 包,在电脑使用pip install MaixPy即可安装好,如果MaixPy更新了,你也需要在电脑和设备更新到MaixPy,电脑手动在终端执行pip install MaixPy -U即可,设备更新直接在设置应用中更新即可。
  • +
+
+

中国国内用户可以使用国内镜像pip install -i https://pypi.tuna.tsinghua.edu.cn/simple MaixPy

+
+
    +
  • 重启 MaixVision 就能够看到代码提示了。
  • +
+
+

如果仍然不能提示,可以手动在设置中设置 python 可执行文件的路径后重启。

+
+
+

注意在电脑安装 Python 包这里只是为了用作代码提示,实际代码运行还是在设备(开发板)上,设备上也要有对应的包才能正常运行。

+
+
+

另外,虽然你在电脑上安装了 MaixPy 包,但是由于我们精力有限,我们不确保你能直接在电脑的 Python 导入 maix 包进行使用,请在支持的设备上运行。

+

计算图像的直方图

在上一步中我们可以在 MaixVision 中实时看到图像,我们用鼠标框选一个区域,图像下方就能看到这个区域的直方图了,选择不同的颜色表示方法,可以看到不同的颜色通道的直方图。

这个功能方便我们在做某些图像处理算法时找到一些合适的参数。

-

使用图形化积木编程

-

开发中,敬请期待。

区分设备文件系统电脑文件系统

这里我们有一个比较重要的概念需要掌握:分清楚设备文件系统电脑文件系统

    @@ -242,10 +286,13 @@

    传输文件到设备

    -

    开发中,敬请期待。

    -

    目前可以用其它工具代替:

    -

    先知道设备的 ip 地址或者设备名称,MaixVision 就可以搜索到, 或者在设备设置->系统信息中看到,比如类似 maixcam-xxxx.local 或者 192.168.0.123
    -用户名和密码都是 root, 使用 SFTP 协议传输文件,端口号是 22

    +

    先连接设备,然后点击浏览设备文件系统的按钮,有两个入口,如下图,然后就能上传文件到设备,或者从设备下载文件到电脑了。

    +

    maixvision_browser2

    +

    maixvision_browser

    +
    +也可以用其它工具代替,点击展开 +

    先知道设备的 ip 地址或者设备名称,MaixVision 就可以搜索到, 或者在设备设置->系统信息中看到,比如类似 maixcam-xxxx.local 或者 192.168.0.123
    + 用户名和密码都是 root, 使用 SFTP 协议传输文件,端口号是 22

    然后不同系统下都有很多好用的软件:

    Windows 下

    使用 WinSCP 或者 FileZilla 等工具连接设备,将文件传输到设备上,选择 SFTP 协议填写设备和账号信息连接即可。

    @@ -265,6 +312,10 @@

    Mac 下

    • 方法二:使用 FileZilla 等工具连接设备,将文件传输到设备上,选择 SFTP 协议填写设备和账号信息连接即可。
    +
    +
    +

    使用图形化积木编程

    +

    开发中,敬请期待。

    diff --git a/maixpy/doc/zh/basic/os.html b/maixpy/doc/zh/basic/os.html index 6fb91233..9a085a1d 100644 --- a/maixpy/doc/zh/basic/os.html +++ b/maixpy/doc/zh/basic/os.html @@ -102,7 +102,7 @@

    MaixPy

    diff --git a/maixpy/doc/zh/basic/python.html b/maixpy/doc/zh/basic/python.html index 3e9bea9d..fb9ec593 100644 --- a/maixpy/doc/zh/basic/python.html +++ b/maixpy/doc/zh/basic/python.html @@ -102,7 +102,7 @@

    MaixPy

    diff --git a/maixpy/doc/zh/basic/python_pkgs.html b/maixpy/doc/zh/basic/python_pkgs.html index 11a4c214..0287ed66 100644 --- a/maixpy/doc/zh/basic/python_pkgs.html +++ b/maixpy/doc/zh/basic/python_pkgs.html @@ -102,7 +102,7 @@

    MaixPy

    diff --git a/maixpy/doc/zh/faq.html b/maixpy/doc/zh/faq.html index 7900326c..9f44faa1 100644 --- a/maixpy/doc/zh/faq.html +++ b/maixpy/doc/zh/faq.html @@ -102,7 +102,7 @@

    MaixPy

    diff --git a/maixpy/doc/zh/index.html b/maixpy/doc/zh/index.html index 45b8e794..a7806653 100644 --- a/maixpy/doc/zh/index.html +++ b/maixpy/doc/zh/index.html @@ -102,7 +102,7 @@

    MaixPy

    diff --git a/maixpy/doc/zh/modules/acc.html b/maixpy/doc/zh/modules/acc.html index b0f7ea88..465a0f0d 100644 --- a/maixpy/doc/zh/modules/acc.html +++ b/maixpy/doc/zh/modules/acc.html @@ -102,7 +102,7 @@

    MaixPy

    diff --git a/maixpy/doc/zh/modules/thermal_cam.html b/maixpy/doc/zh/modules/thermal_cam.html index 778c54ef..b4329804 100644 --- a/maixpy/doc/zh/modules/thermal_cam.html +++ b/maixpy/doc/zh/modules/thermal_cam.html @@ -102,7 +102,7 @@

    MaixPy

    @@ -229,8 +252,8 @@

    diff --git a/maixpy/doc/zh/peripheral/gpio.html b/maixpy/doc/zh/peripheral/gpio.html index df80ecf0..44ff9ea9 100644 --- a/maixpy/doc/zh/peripheral/gpio.html +++ b/maixpy/doc/zh/peripheral/gpio.html @@ -44,10 +44,10 @@ - MaixPy + MaixPy 使用 GPIO - MaixPy - + @@ -102,7 +102,7 @@

    MaixPy

    @@ -175,7 +198,7 @@

    MaixPy

    -

    +

    MaixPy 使用 GPIO

    @@ -189,10 +212,6 @@

    - -
    @@ -214,7 +233,41 @@

    - +

    简介

    +

    使用 GPIO 可以控制引脚输入或者输出高低电平,用来读取信号或者输出控制信号,十分常用。

    +

    MaixPy 中使用 GPIO

    +
    +

    MaixPy 固件版本应该 > 4.1.2(不包含)

    +
    +

    首先我们需要知道设备有哪些引脚和 GPIO,对于 MaixCAM 每个引脚都对应了一个 GPIO 控制器,如图:

    +

    +

    需要注意的是,引脚除了作为 GPIO 使用,还能用作其它功能比如 PWM 使用,使用前我们需要设置一下引脚的功能为 GPIO。

    +

    比如在 MaixCAM 上有些引脚默认已经被其它功能占用,比如 UART0, WiFi(SDIO1 + A26), 不建议使用它们,其它的可以使用,另外 A14 引脚连接到了板载的 LED,默认是作为系统的负载提示灯,如果初始化它会自动取消系统提示灯功能作为普通 GPIO 被使用(注意A14只能作为输出),这样你就能控制这颗 LED 的亮灭了。

    + +
    from maix import gpio, pinmap, time
    +
    +pinmap.set_pin_function("A14", "GPIOA14")
    +led = gpio.GPIO("A14", gpio.Mode.OUT)
    +led.value(0)
    +
    +while 1:
    +    led.toggle()
    +    time.sleep_ms(500)
    +
    +

    这里先使用pinmap设置了A14引脚的功能为GPIO,当然,对于A14因为只有GPIO功能,可以不设置,为了程序通用起见,其它引脚可能需要设置,所以这里例程设置了。

    +

    更多 API 请看 GPIO API 文档

    +

    GPIO 作为输入模式

    + +
    from maix import gpio, pinmap, time
    +
    +pinmap.set_pin_function("A19", "GPIOA19")
    +led = gpio.GPIO("A19", gpio.Mode.IN)
    +
    +while 1:
    +    print(led.value())
    +    time.sleep_ms(1) # sleep to make cpu free
    +
    +
    diff --git a/maixpy/doc/zh/peripheral/i2c.html b/maixpy/doc/zh/peripheral/i2c.html index ad64524c..656b51b7 100644 --- a/maixpy/doc/zh/peripheral/i2c.html +++ b/maixpy/doc/zh/peripheral/i2c.html @@ -44,10 +44,10 @@ - MaixPy + MaixPy 使用 I2C - MaixPy - + @@ -102,7 +102,7 @@

    MaixPy

    @@ -175,7 +198,7 @@

    MaixPy

    -

    +

    MaixPy 使用 I2C

    @@ -189,10 +212,6 @@

    - -
    @@ -214,7 +233,44 @@

    - +

    对于 MaixCAM,由于引脚资源比较紧张,引出的 I2C 引脚和 WiFi 模块(SDIO1)重合了,所以 WiFi 和硬件 I2C 只能二选一使用。

    +

    所以推荐使用 IO 模拟 I2C。

    +
    +

    注意需要 MaixPy 镜像和固件 > 4.1.2(不包含)

    +
    +

    IO 模拟 I2C

    +

    模拟 I2C 只需要引脚使用 GPIO 功能即可,在 MaixCAM 上,模拟 I2C 被固定在引脚A15(SCL),A27(SDA),并且i2c编号为5, 要使用,只需要:

    + +
    from maix import i2c, pinmap
    +
    +# pinmap.set_pin_function("A15", "GPIOA23")
    +# pinmap.set_pin_function("A27", "GPIOA24")
    +
    +bus1 = i2c.I2C(5, i2c.Mode.MASTER)
    +slaves = bus1.scan()
    +print("find slaves:", slaves)
    +
    +
    +

    更多 API 看 i2c API 文档

    +

    硬件 I2C

    +

    如上面所说, 对于 MaixCAM 硬件 I2CWiFi 只能二选一,如果一定要用,需要禁用WiFi,使用pinmap模块设置引脚功能为 I2C,在使用maix.i2c模块操作。

    +
    +

    TODO: 提供禁用 WiFi 的方法(需要系统里面禁用掉 WiFi 驱动,比较复杂)

    +
    +

    硬件I2C及对应的引脚看图:

    +

    + +
    from maix import i2c, pinmap
    +
    +pinmap.set_pin_function("P18", "I2C1_SCL")
    +pinmap.set_pin_function("P21", "I2C1_SDA")
    +
    +bus1 = i2c.I2C(1, i2c.Mode.MASTER)
    +slaves = bus1.scan()
    +print("find slaves:", slaves)
    +
    +
    +
    diff --git a/maixpy/doc/zh/peripheral/pwm.html b/maixpy/doc/zh/peripheral/pwm.html index 91bdb2aa..84b8ef83 100644 --- a/maixpy/doc/zh/peripheral/pwm.html +++ b/maixpy/doc/zh/peripheral/pwm.html @@ -44,10 +44,10 @@ - MaixPy + MaixPy 使用 PWM - MaixPy - + @@ -102,7 +102,7 @@

    MaixPy

    @@ -175,7 +198,7 @@

    MaixPy

    -

    +

    MaixPy 使用 PWM

    @@ -189,10 +212,6 @@

    - -
    @@ -214,7 +233,47 @@

    - +

    简介

    +

    在 MaixPy (v4) 中使用 PWM,先使用pinmap设置引脚的功能为 PWM,在使用。

    +

    以及每个 PWM 有对应的引脚,根据 MaixCAM 的引脚图可以看到:

    +

    +

    这里我们推荐使用PWM6PWM7

    +

    对于 MaixCAM 因为WiFi 使用了SDIO1的所有引脚,所以PWM4~9只能和WiFi二选一使用。

    +
    +

    TODO: 提供禁用 WiFi 的方法(需要系统里面禁用掉 WiFi 驱动,比较复杂)

    +
    +

    MaixPy 使用 PWM 控制舵机

    +

    这里我们以控制舵机为例, 使用MaixCAMPWM7A19引脚:

    + +
    from maix import pwm, time, pinmap
    +
    +SERVO_PERIOD = 50     # 50Hz 20ms
    +SERVO_MIN_DUTY = 2.5  # 2.5% -> 0.5ms
    +SERVO_MAX_DUTY = 12.5  # 12.5% -> 2.5ms
    +
    +# Use PWM7
    +pwm_id = 7
    +# !! set pinmap to use PWM7
    +pinmap.set_pin_function("A19", "PWM7")
    +
    +
    +
    +def angle_to_duty(percent):
    +    return (SERVO_MAX_DUTY - SERVO_MIN_DUTY) * percent / 100.0 + SERVO_MIN_DUTY
    +
    +
    +out = pwm.PWM(pwm_id, freq=SERVO_PERIOD, duty=angle_to_duty(0), enable=True)
    +
    +for i in range(100):
    +    out.duty(angle_to_duty(i))
    +    time.sleep_ms(100)
    +
    +for i in range(100):
    +    out.duty(angle_to_duty(100 - i))
    +    time.sleep_ms(100)
    +
    +

    这里的功能是控制舵机从最小角度旋转到最大角度再旋转回最小角度。

    +
    diff --git a/maixpy/doc/zh/peripheral/spi.html b/maixpy/doc/zh/peripheral/spi.html index ad2d74ea..d543a267 100644 --- a/maixpy/doc/zh/peripheral/spi.html +++ b/maixpy/doc/zh/peripheral/spi.html @@ -44,10 +44,10 @@ - MaixPy + MaixPy 使用 SPI - MaixPy - + @@ -102,7 +102,7 @@

    MaixPy

    @@ -175,7 +198,7 @@

    MaixPy

    -

    +

    MaixPy 使用 SPI

    @@ -189,10 +212,6 @@

    - -
    @@ -214,7 +233,8 @@

    - +

    TODO:

    +
    diff --git a/maixpy/doc/zh/peripheral/uart.html b/maixpy/doc/zh/peripheral/uart.html index 5cc99367..6b97a43e 100644 --- a/maixpy/doc/zh/peripheral/uart.html +++ b/maixpy/doc/zh/peripheral/uart.html @@ -44,10 +44,10 @@ - MaixPy + MaixPy UART 串口使用介绍 - MaixPy - + @@ -102,7 +102,7 @@

    MaixPy

    @@ -175,7 +198,7 @@

    MaixPy

    -

    +

    MaixPy UART 串口使用介绍

    @@ -189,10 +212,6 @@

    - -
    @@ -214,7 +233,60 @@

    - +

    串口简介

    +

    串口是一种通信方式,包含了硬件和通信协议的定义。

    +
      +
    • 硬件包括:
        +
      • 3 个引脚: GNDRXTX,通信双发交叉连接 RX TX, 即一方 TX 发送到另一方的 RX, 双方 GND 连接到一起。
      • +
      • 控制器,一般在芯片内部,也叫 UART 外设,一般一个芯片有一个或者多个 UART 控制器,每个控制器有相对应的引脚。
      • +
      +
    • +
    • 通信协议: 为了让双方能顺利通信,规定了一套协议,具体可以自行学习,常见的参数有 波特率 校验位等,波特率是我们用得最多的参数。
    • +
    +

    通过板子的串口,可以和其它单片机或者 SOC 进行数据通信,比如可以在 MaixCAM 上实现人体检测功能,检测到坐标后通过串口发送给 STM32 单片机。

    +

    MaixPy 中使用串口

    +

    对于 MaixCAM 默认从 USB 口引出了一个串口,可以插上配套的 Type-C 转接小板,就能直接使用上面的串口引脚,
    +也可以不用转接板,直接使用板子上的 A16(TX)A17(RX)引脚, 和 USB 口引出的是同样的引脚,是等效的。

    +

    对于 MaixCAM 使用 USB 引出的串口时需要注意,Typc-C 正插和反插,转接小板上的 RXTX会交换,所以当你发现无法通信时,有可能就是 RX TX 反了,可以尝试将 Type-C 翻转一面插再看看通信是否正常。这个算是设计缺陷,不过一般也不会经常拔插所以适应一下也能接受。

    +

    将两个通信的板子双方连接好后(通信双发交叉连接 RX TX, 即一方 TX 发送到另一方的 RX, 双方 GND 连接到一起),就可以使用软件了。

    +

    通过 MaixPy 使用串口很简单:

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

    先列出了系统的所有串口设备,然后这里使用了第一个,也就是上面说的 Type-C 出 引出的串口。

    +

    更多串口的 API 请看 UART API 文档

    +

    其它写法,以及使用其它串口

    + +
    
    +from maix import app, uart, pinmap, time
    +import sys
    +
    +# pinmap.set_pin_function("A16", "UART0_TX")
    +# pinmap.set_pin_function("A17", "UART0_RX")
    +device = "/dev/ttyS0"
    +
    +serial0 = uart.UART(device, 115200)
    +
    +serial0.write("hello 1\r\n".encode())
    +serial0.write_str("hello 2\r\n")
    +
    +while not app.need_exit():
    +    data = serial0.read()
    +    if data:
    +        print("Received, type: {}, len: {}, data: {}".format(type(data), len(data), data))
    +        serial0.write(data)
    +    time.sleep_ms(1) # sleep 1ms to make CPU free
    +
    +

    这里先设置了引脚映射,特别是如果你要使用除了 UART0 以外的串口,根据图中的引脚号和 UART 使用pinmap.set_pin_function来设置

    +

    +

    另外,这里循环里面加了一个 sleep_ms 是简单地释放一下 CPU,以达到程序不会占满 CPU 的效果,当然也有其它方式,这种方式最简单粗暴。

    +
    diff --git a/maixpy/doc/zh/peripheral/wdt.html b/maixpy/doc/zh/peripheral/wdt.html index d62d6710..e458290a 100644 --- a/maixpy/doc/zh/peripheral/wdt.html +++ b/maixpy/doc/zh/peripheral/wdt.html @@ -44,10 +44,10 @@ - MaixPy + MaixPy 使用看门狗定时器 - MaixPy - + @@ -102,7 +102,7 @@

    MaixPy

    @@ -175,7 +198,7 @@

    MaixPy

    -

    +

    MaixPy 使用看门狗定时器

    @@ -189,10 +212,6 @@

    - -
    @@ -214,7 +233,23 @@

    - +

    简介

    +

    为了防止程序出现问题,常常会用到看门狗定时器(WDT), 在程序出问题时自动重启系统。

    +

    原理就是有一个倒计时计数器,我们需要在程序的逻辑中定期地去设置这个倒计时时间(也叫喂狗),如果我们的程序在哪儿卡住了导致没有定期去设置倒计时,倒计时到 0 后硬件就会出发系统重启。

    +

    MaixPy 中使用 WDT

    + +
    from maix import wdt, app, time
    +
    +w = wdt.WDT(0, 1000)
    +
    +while not app.need_exit():
    +    w.feed()
    +    # here sleep op is our operation
    +    # 200 ms is normal, if > 1000ms will cause system reset
    +    time.sleep_ms(200)
    +
    +
    +
    diff --git a/maixpy/doc/zh/pro/compile_os.html b/maixpy/doc/zh/pro/compile_os.html index 219cb05d..0caa5682 100644 --- a/maixpy/doc/zh/pro/compile_os.html +++ b/maixpy/doc/zh/pro/compile_os.html @@ -102,7 +102,7 @@

    MaixPy

    diff --git a/maixpy/doc/zh/projects/index.html b/maixpy/doc/zh/projects/index.html new file mode 100644 index 00000000..0b2239f9 --- /dev/null +++ b/maixpy/doc/zh/projects/index.html @@ -0,0 +1,357 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + MaixPy 项目实战 介绍和汇总 - MaixPy + + + + + + + + + + +
    + +
    + +
    +
    +
    +
    + +

    MaixPy 项目实战 介绍和汇总

    + +
    +
    +
      + +
    +
    +
    +
    + + +
    +
    + + + +
    +
    +
    +
    + + +
    +
    + +
    +
    + +

    简介

    +

    这里提供一些常见的项目实战示例,方便社区成员可以参考复现使用,也方便激发大家的灵感做出更多更好的应用和项目出来。

    +

    要找到用 MaixPy 实现的相关的项目,有几种方式:

    +

    MaixPy 官方文档

    +

    也就是本文档左边目录可以找到的项目实战,比如小车巡线

    +

    如果你有好的项目,或者好的项目推荐,也可以贡献文档添加进来。

    +

    MaixHub 项目分享广场

    +

    MaixHub 项目分享 栏目可以找到项目分享。

    +

    有高质量的分享也会被链接到 MaixPy 官方文档。

    +

    你也可以分享你的项目制作方法,会获得官方(必获得)以及社区成员的现金打赏(通常高质量能解决急需需求的更容易被打赏)。

    +

    推荐项目:

    + +

    MaixHub 应用分享

    +

    除了项目分享以外,还可以在MaixHub 应用商店 找到可以直接运行的应用,有部分应用可能是用 MaixPy 编写的,如果作者提供了源码或者写了详细的教程也都可以参考。

    +

    推荐项目:

    + + + +
    +
    + +
    +
    +
    +
    +
    + +
    +
    +
    +
    +
    + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/maixpy/doc/zh/projects/line_tracking_robot.html b/maixpy/doc/zh/projects/line_tracking_robot.html new file mode 100644 index 00000000..1fc4f39e --- /dev/null +++ b/maixpy/doc/zh/projects/line_tracking_robot.html @@ -0,0 +1,422 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + MaixPy 小车巡线 - MaixPy + + + + + + + + + + +
    + +
    + +
    +
    +
    +
    + +

    MaixPy 小车巡线

    + +
    +
    +
      + +
    +
    +
    +
    + + + + +
    +
    + + + +
    +
    +
    +
    + + +
    +
    + + +
    + + 更新历史 +
    + + + + + + + + + + + + + + + + + + + +
    日期版本作者更新内容
    2024-05-091.0.0lxowalle + + 初版文档 + +
    +
    +
    + +
    +
    + +

    阅读本文前,确保已经知晓如何开发MaixCAM,详情请阅读快速开始

    +

    简介

    +

    本文将介绍如何使用MaixPy实现寻线小车

    +

    如何使用MaixPy实现寻线小车

    +
      +
    1. 准备MaixCAM与小车
    2. +
    3. 实现寻线功能
    4. +
    5. 实现小车控制功能
    6. +
    +

    准备MaixCAM与小车

    +

    TODO

    +

    实现寻线功能

    +

    使用image模块的get_regression可以快速寻找到直线,详情见寻找直线

    +

    代码实现:

    + +
    from maix import camera, display, image
    +
    +cam = camera.Camera(320, 240)
    +disp = display.Display()
    +
    +# 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()
    +
    +    lines = img.get_regression(thresholds, area_threshold = 100)
    +    for a in lines:
    +        img.draw_line(a.x1(), a.y1(), a.x2(), a.y2(), image.COLOR_GREEN, 2)
    +        theta = a.theta()
    +        rho = a.rho()
    +        if theta > 90:
    +            theta = 270 - theta
    +        else:
    +            theta = 90 - theta
    +        img.draw_string(0, 0, "theta: " + str(theta) + ", rho: " + str(rho), image.COLOR_BLUE)
    +
    +    disp.show(img)
    +
    +
    +

    上述代码实现了寻线功能, 上述参数中需注意:

    +
      +
    • 设置合适的thresholds值来寻找到对应的直线
    • +
    • 设置合适的area_threshold值来过滤环境干扰,可以过滤一些面积小的直线
    • +
    • 使用a.theta()获取直线的角度
    • +
    • 使用a.rho()获取直线与原点(原点在左上角)的距离
    • +
    +

    根据实际环境调试好寻线参数后, 就可以利用a.theta()a.rho()控制小车方向了。

    +

    实现小车控制功能

    +

    TODO

    + + +
    +
    + +
    +
    +
    +
    +
    + +
    +
    +
    +
    +
    + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/maixpy/doc/zh/sidebar.yaml b/maixpy/doc/zh/sidebar.yaml index 3c0a1185..0fa76b58 100644 --- a/maixpy/doc/zh/sidebar.yaml +++ b/maixpy/doc/zh/sidebar.yaml @@ -5,123 +5,143 @@ items: label: FAQ 常见问题 - label: 基础 -- file: basic/os.md - label: 升级和烧录系统 -- file: basic/app_usage.md - label: 应用使用说明 -- file: basic/maixpy_upgrade.md - label: 更新 MaixPy -- file: basic/maixvision.md - label: MaixVision 使用 -- file: basic/python.md - label: Python 语法 -- file: basic/linux_basic.md - label: Linux 基础知识 -- file: basic/python_pkgs.md - label: 添加额外的 Python 包 -- file: basic/app.md - label: 应用开发和商店 + collapsed: false + items: + - file: basic/os.md + label: 升级和烧录系统 + - file: basic/app_usage.md + label: 应用使用说明 + - file: basic/maixpy_upgrade.md + label: 更新 MaixPy + - file: basic/maixvision.md + label: MaixVision 使用 + - file: basic/python.md + label: Python 语法 + - file: basic/linux_basic.md + label: Linux 基础知识 + - file: basic/python_pkgs.md + label: 添加额外的 Python 包 + - file: basic/app.md + label: 应用开发和商店 - label: 基础图像和算法 -- file: vision/display.md - label: 屏幕使用 -- file: vision/camera.md - label: 摄像头使用 -- file: vision/image_ops.md - label: 基本图像操作 -- file: vision/find_blobs.md - label: 寻找色块 -- file: vision/qrcode.md - label: 二维码识别 -- file: vision/apriltag.md - label: AprilTag 识别 + items: + - file: vision/display.md + label: 屏幕使用 + - file: vision/camera.md + label: 摄像头使用 + - file: vision/image_ops.md + label: 基本图像操作 + - file: vision/find_blobs.md + label: 寻找色块 + - file: vision/line_tracking.md + label: 寻找直线 + - file: vision/qrcode.md + label: 二维码识别 + - file: vision/apriltag.md + label: AprilTag 识别 - label: AI 视觉 -- file: vision/ai.md - label: AI 视觉基本知识 -- file: vision/classify.md - label: AI 物体分类 -- file: vision/yolov5.md - label: YOLOv5 物体检测 -- file: vision/face_recognition.md - label: 人脸识别 -- file: vision/body_key_points.md - label: 人体关键点检测 -- file: vision/self_learn_classifier.md - label: 自学习分类器 -- file: vision/self_learn_detector.md - label: 自学习检测器 -- file: vision/object_track.md - label: 物体轨迹跟踪和计数 -- file: vision/ocr.md - label: OCR 文字识别 -- file: vision/maixhub_train.md - label: MaixHub 在线 AI 模型训练 -- file: vision/custmize_model.md - label: 自定义(离线训练转换)模型 + items: + - file: vision/ai.md + label: AI 视觉基本知识 + - file: vision/classify.md + label: AI 物体分类 + - file: vision/yolov5.md + label: YOLOv5 物体检测 + - file: vision/face_detection.md + label: 人脸及关键点检测 + - file: vision/face_recognition.md + label: 人脸识别 + - file: vision/body_key_points.md + label: 人体关键点检测 + - file: vision/self_learn_classifier.md + label: 自学习分类器 + - file: vision/self_learn_detector.md + label: 自学习检测器 + - file: vision/object_track.md + label: 物体轨迹跟踪和计数 + - file: vision/ocr.md + label: OCR 文字识别 + - file: vision/maixhub_train.md + label: MaixHub 在线 AI 模型训练 + - file: vision/custmize_model.md + label: 自定义(离线训练转换)模型 - label: AI 听觉 -- file: audio/record.md - label: 录音 -- file: audio/play.md - label: 播放音频 -- file: audio/classifier.md - label: AI 声音分类器 -- file: audio/keyword.md - label: 关键词识别 -- file: audio/recognize.md - label: 语音实时识别 -- file: audio/synthesis.md - label: 语音合成 + items: + - file: audio/record.md + label: 录音 + - file: audio/play.md + label: 播放音频 + - file: audio/classifier.md + label: AI 声音分类器 + - file: audio/keyword.md + label: 关键词识别 + - file: audio/recognize.md + label: 语音实时识别 + - file: audio/synthesis.md + label: 语音合成 - label: 视频 -- file: video/record.md - label: 录像 -- file: video/play.md - label: 播放视频 -- file: video/jpeg_streaming.md - label: JPEG 串流 -- file: video/rtsp.md - label: RTSP 串流 + items: + - file: video/record.md + label: 录像 + - file: video/play.md + label: 播放视频 + - file: video/jpeg_streaming.md + label: JPEG 串流 + - file: video/rtsp.md + label: RTSP 串流 - label: 片上外设 -- file: peripheral/gpio.md - label: GPIO 和 点灯 -- file: peripheral/uart.md - label: UART 串口使用 -- file: peripheral/i2c.md - label: I2C 使用 -- file: peripheral/pwm.md - label: PWM 使用 -- file: peripheral/spi.md - label: SPI 使用 -- file: peripheral/wdt.md - label: WDT 看门狗使用 + items: + - file: peripheral/gpio.md + label: GPIO 和 点灯 + - file: peripheral/uart.md + label: UART 串口使用 + - file: peripheral/i2c.md + label: I2C 使用 + - file: peripheral/pwm.md + label: PWM 使用 + - file: peripheral/spi.md + label: SPI 使用 + - file: peripheral/wdt.md + label: WDT 看门狗使用 - label: 片外模块 -- file: modules/acc.md - label: 加速度计使用 -- file: modules/temp_hum.md - label: 温湿度传感器 -- file: modules/tof.md - label: TOF 测距 -- file: modules/thermal_cam.md - label: 热成像摄像头 + items: + - file: modules/acc.md + label: 加速度计使用 + - file: modules/temp_hum.md + label: 温湿度传感器 + - file: modules/tof.md + label: TOF 测距 + - file: modules/thermal_cam.md + label: 热成像摄像头 + +- label: 项目实战 + items: + - file: projects/README.md + label: 介绍和汇总 + - file: projects/line_tracking_robot.md + label: 小车巡线 - label: 进阶 -- file: source_code/contribute.md - label: 贡献文档和代码 -- file: source_code/build.md - label: 构建 MaixPy 源码 -- file: source_code/faq.md - label: MaixPy 源码 FAQ -- file: source_code/add_c_module.md - label: 使用 C/C++ 写一个模块 -- file: source_code/maixcdk.md - label: 使用 MaixCDK 开发 -- file: pro/compile_os.md - label: 编译系统 + items: + - file: source_code/contribute.md + label: 贡献文档和代码 + - file: source_code/build.md + label: 构建 MaixPy 源码 + - file: source_code/faq.md + label: MaixPy 源码 FAQ + - file: source_code/add_c_module.md + label: 使用 C/C++ 写一个模块 + - file: source_code/maixcdk.md + label: 使用 MaixCDK 开发 + - file: pro/compile_os.md + label: 编译系统 diff --git a/maixpy/doc/zh/source_code/add_c_module.html b/maixpy/doc/zh/source_code/add_c_module.html index adfad721..91c3338b 100644 --- a/maixpy/doc/zh/source_code/add_c_module.html +++ b/maixpy/doc/zh/source_code/add_c_module.html @@ -102,7 +102,7 @@

    MaixPy

    diff --git a/maixpy/doc/zh/source_code/build.html b/maixpy/doc/zh/source_code/build.html index bb403d5f..73790c04 100644 --- a/maixpy/doc/zh/source_code/build.html +++ b/maixpy/doc/zh/source_code/build.html @@ -102,7 +102,7 @@

    MaixPy

    @@ -212,18 +235,34 @@

    MaixPy 开发源代码指南

    获取源代码

    -
    git clone https://github.com/sipeed/MaixPy
    -cd MaixPy
    +
    mkdir -p ~/maix
    +cd ~/maix
    +git clone https://github.com/sipeed/MaixPy
     
    +

    获取 MaixCDK 源码

    +

    MaixPy 项目依赖于 MaixCDK,需要先克隆它,放到电脑的某个目录(勿放在 MaixPy 目录下)

    + +
    cd ~/maix
    +git clone https://github.com/sipeed/MaixCDK
    +
    +

    然后需要设置环境变量 MAIXCAK_PATH 指定 MaixCDK 的路径,可以在 ~/.bashrc 或者~/.zshrc(根据你使用的shell决定)添加:

    + +
    export MAIXCAK_PATH=~/maix/MaixCDK
    +
    +

    只有在成功设置环境变量后, MaixPy 才能找到 MaixCDK 源码。

    构建并打包成 wheel 文件

    -
    python setup.py bdist_wheel maixcam
    +
    cd ~/maix/MaixPy
    +python setup.py bdist_wheel maixcam
     
    -

    maixcam 可以被替换为其他板卡配置, 请查看 setup.py 中的 platform_names 变量。

    -

    构建成功后, 你会在 dist 目录中找到 wheel 文件, 使用 pip install -U MaixPy****.wheel 在你的设备上安装或升级。

    +

    maixcam 可以被替换为其他板卡配置, 请查看 MaixPy/platforms 目录。

    +

    构建成功后, 你会在 dist 目录中找到 wheel 文件, 传输到设备(开发板),在设备终端中使用 pip install -U MaixPy****.wheel 在你的设备上安装或升级。

    python setup.py bdist_wheel maixcam --skip-build 不会执行构建命令, 只会打包 wheel 文件, 因此你可以先使用 maixcdk menuconfigmaixcdk build 来自定义构建。

    +
    +

    另外如果你是在调试 API,需要频繁安装,使用 pip 安装会比较慢,可以直接编译后拷贝 maix 目录到设备的 /usr/lib/python3.11/site-packages目录下覆盖旧的文件即可。

    +

    手动构建

    maixcdk build
    diff --git a/maixpy/doc/zh/source_code/contribute.html b/maixpy/doc/zh/source_code/contribute.html
    index 9acb65c7..dadb86de 100644
    --- a/maixpy/doc/zh/source_code/contribute.html
    +++ b/maixpy/doc/zh/source_code/contribute.html
    @@ -102,7 +102,7 @@ 

    MaixPy

    @@ -252,9 +275,9 @@

    参与 M @@ -189,8 +212,8 @@

    MaixPy 源代码常见问题

    -
    +

    /usr/bin/ld: /lib/libgdal.so.30: undefined reference to `std::condition_variable::wait(std::unique_lockstd::mutex&)@GLIBCXX_3.4.30' collect2: error: ld returned 1 exit status

    +

    一般在为 Linux 构建时并且使用 conda 环境时容易出现,conda 环境中的一些库编译参数问题,解决方法就是不用 conda 即可, 或者单独找到 conda 中的那个库,替换成系统的或者直接删掉(会从系统找)

    diff --git a/maixpy/doc/zh/source_code/maixcdk.html b/maixpy/doc/zh/source_code/maixcdk.html index 4c95e517..fe36593b 100644 --- a/maixpy/doc/zh/source_code/maixcdk.html +++ b/maixpy/doc/zh/source_code/maixcdk.html @@ -102,7 +102,7 @@

    MaixPy

    diff --git a/maixpy/doc/zh/video/jpeg_streaming.html b/maixpy/doc/zh/video/jpeg_streaming.html index 6128f1e2..9e04a317 100644 --- a/maixpy/doc/zh/video/jpeg_streaming.html +++ b/maixpy/doc/zh/video/jpeg_streaming.html @@ -102,7 +102,7 @@

    MaixPy

    diff --git a/maixpy/doc/zh/vision/ai.html b/maixpy/doc/zh/vision/ai.html index c9711493..c3a63954 100644 --- a/maixpy/doc/zh/vision/ai.html +++ b/maixpy/doc/zh/vision/ai.html @@ -102,7 +102,7 @@

    MaixPy

    diff --git a/maixpy/doc/zh/vision/apriltag.html b/maixpy/doc/zh/vision/apriltag.html index 105bd483..0ea2ccba 100644 --- a/maixpy/doc/zh/vision/apriltag.html +++ b/maixpy/doc/zh/vision/apriltag.html @@ -102,7 +102,7 @@

    MaixPy

    @@ -246,7 +269,7 @@

    MaixPy 识别Apriltag标签

    -

    阅读本文前,确保已经知晓如何开发MaixPy,详情请阅读MaixVision -- MaixPy 编程 + 图形化积木编程

    +

    阅读本文前,确保已经知晓如何开发MaixCAM,详情请阅读快速开始

    简介

    本文介绍如何使用MaixPy来识别Apriltag标签

    使用 MaixPy 识别Apriltag标签

    diff --git a/maixpy/doc/zh/vision/body_key_points.html b/maixpy/doc/zh/vision/body_key_points.html index a249e3b4..332ce68e 100644 --- a/maixpy/doc/zh/vision/body_key_points.html +++ b/maixpy/doc/zh/vision/body_key_points.html @@ -102,7 +102,7 @@

    MaixPy

    diff --git a/maixpy/doc/zh/vision/camera.html b/maixpy/doc/zh/vision/camera.html index 280a3fb7..6194893a 100644 --- a/maixpy/doc/zh/vision/camera.html +++ b/maixpy/doc/zh/vision/camera.html @@ -102,7 +102,7 @@

    MaixPy

    diff --git a/maixpy/doc/zh/vision/classify.html b/maixpy/doc/zh/vision/classify.html index 1f9999f5..6fc4dedd 100644 --- a/maixpy/doc/zh/vision/classify.html +++ b/maixpy/doc/zh/vision/classify.html @@ -102,7 +102,7 @@

    MaixPy

    diff --git a/maixpy/doc/zh/vision/custmize_model.html b/maixpy/doc/zh/vision/custmize_model.html index 11d390be..29a2d238 100644 --- a/maixpy/doc/zh/vision/custmize_model.html +++ b/maixpy/doc/zh/vision/custmize_model.html @@ -102,7 +102,7 @@

    MaixPy

    diff --git a/maixpy/doc/zh/vision/display.html b/maixpy/doc/zh/vision/display.html index b4ca2751..77b1d36a 100644 --- a/maixpy/doc/zh/vision/display.html +++ b/maixpy/doc/zh/vision/display.html @@ -102,7 +102,7 @@

    MaixPy

    diff --git a/maixpy/doc/zh/vision/face_detection.html b/maixpy/doc/zh/vision/face_detection.html new file mode 100644 index 00000000..8448bcb5 --- /dev/null +++ b/maixpy/doc/zh/vision/face_detection.html @@ -0,0 +1,375 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + MaixPy 人脸检测和关键点检测 - MaixPy + + + + + + + + + + +
    + +
    + +
    +
    +
    +
    + +

    MaixPy 人脸检测和关键点检测

    + +
    +
    +
      + +
    +
    +
    +
    + + +
    +
    + + + +
    +
    +
    +
    + + +
    +
    + +
    +
    + +

    简介

    +

    人脸检测在很多地方都能用到,比如是为人脸识别提供人脸检测这一步骤,或者是人脸跟踪相关的应用等等。

    +

    这里提供的人脸检测不光可以检测到人脸,还能检测到 5 个关键点,包括两个眼睛,一个鼻子,一张嘴巴的两个嘴角。

    +

    face detection

    +

    MaixPy 中使用人脸检测

    +

    MaixPy 官方提供了两种人脸检测模型,分别来自开源项目 face detector 1MB with landmarkRetinafate

    +

    要使用需要先下载模型,选择一个即可,两者区别不大:

    + +

    然后拷贝模型文件到设备,拷贝方法见 MaixVision 使用

    +
    +

    默认镜像里面有一个文件,可以直接使用,如果没有则需要你自己下载,而且下载的压缩包里面有多个分辨率可以选择,分辨率越高越精准但耗时更长

    +
    +

    然后执行代码,这里有一行被注释了代码是加载Retinafae模型,根据你下载的模型选择使用哪一行代码

    +
    +

    本功能需要 MaixPy >= 4.1.4 才能使用

    +
    + +
    from maix import camera, display, image, nn, app
    +import math
    +
    +
    +detector = nn.FaceDetector(model="/root/models/face_detector.mud")
    +# detector = nn.Retinaface(model="/root/models/retinaface.mud")
    +
    +cam = camera.Camera(detector.input_width(), detector.input_height(), detector.input_format())
    +dis = display.Display()
    +
    +while not app.need_exit():
    +    img = cam.read()
    +    objs = detector.detect(img, conf_th = 0.4, iou_th = 0.45)
    +    for obj in objs:
    +        img.draw_rect(obj.x, obj.y, obj.w, obj.h, color = image.COLOR_RED)
    +        radius = math.ceil(obj.w / 10)
    +        img.draw_keypoints(obj.points, image.COLOR_RED, size = radius if radius < 5 else 4)
    +    dis.show(img)
    +
    +
    + + +
    +
    + +
    +
    +
    +
    +
    + +
    +
    +
    +
    +
    + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/maixpy/doc/zh/vision/face_recognition.html b/maixpy/doc/zh/vision/face_recognition.html index c499b6b0..26280790 100644 --- a/maixpy/doc/zh/vision/face_recognition.html +++ b/maixpy/doc/zh/vision/face_recognition.html @@ -102,7 +102,7 @@

    MaixPy

    @@ -259,9 +282,9 @@

    MaixPy 使用

    diff --git a/maixpy/doc/zh/vision/find_blobs.html b/maixpy/doc/zh/vision/find_blobs.html index d759a2c6..99ae3c34 100644 --- a/maixpy/doc/zh/vision/find_blobs.html +++ b/maixpy/doc/zh/vision/find_blobs.html @@ -102,7 +102,7 @@

    MaixPy

    @@ -257,7 +280,7 @@

    MaixPy 寻找色块

    -

    阅读本文前,确保已经知晓如何开发MaixPy,详情请阅读MaixVision -- MaixPy 编程 + 图形化积木编程

    +

    阅读本文前,确保已经知晓如何开发MaixCAM,详情请阅读快速开始

    简介

    本文将介绍如何使用MaixPy来寻找色块,以及如何使用MaixCam的默认应用程序寻找色块。

    在视觉应用中,寻找色块是一个非常常见的需求,比如机器人找色块,自动化生产线找色块等等,即需要识别画面中的特定的颜色区域,获取这个区域的位置和大小等信息。

    @@ -329,7 +352,7 @@

    常用参数说 thresholds - 基于lab颜色空间的阈值,threshold=[[l_min, l_max, a_min, a_max, b_min, b_max]],分别表示:
    亮度范围为[l_min, l_max]|
    绿色到红色的分量范围为[l_min, l_max]
    蓝色到黄色的分量范围为[b_min, b_max]
    可同时设置多个阈值 + 基于lab颜色空间的阈值,threshold=[[l_min, l_max, a_min, a_max, b_min, b_max]],分别表示:
    亮度范围为[l_min, l_max]|
    绿色到红色的分量范围为[a_min, a_max]
    蓝色到黄色的分量范围为[b_min, b_max]
    可同时设置多个阈值 设置两个阈值来检测红色和绿色
    img.find_blobs(threshold=[[0, 80, 40, 80, 10, 80], [0, 80, -120, -10, 0, 30]])
    红色阈值为[0, 80, 40, 80, 10, 80]
    绿色阈值为[0, 80, -120, -10, 0, 30] @@ -432,8 +455,8 @@

    关于LAB颜

    diff --git a/maixpy/doc/zh/vision/line_tracking.html b/maixpy/doc/zh/vision/line_tracking.html new file mode 100644 index 00000000..d531b82c --- /dev/null +++ b/maixpy/doc/zh/vision/line_tracking.html @@ -0,0 +1,541 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + MaixPy 寻找直线 - MaixPy + + + + + + + + + + +
    + +
    + +
    +
    +
    +
    + +

    MaixPy 寻找直线

    + +
    +
    +
      + +
    +
    +
    +
    + + + + +
    +
    + + + +
    +
    +
    +
    + + +
    +
    + + +
    + + 更新历史 +
    + + + + + + + + + + + + + + + + + + + +
    日期版本作者更新内容
    2024-05-091.0.0lxowalle + + 初版文档 + +
    +
    +
    + +
    +
    + +

    阅读本文前,确保已经知晓如何开发MaixCAM,详情请阅读快速开始

    +

    简介

    +

    在视觉应用中,在巡迹小车、巡线机器人等应用中经常需要寻找线条的功能。本文将介绍:

    +
      +
    • 如何使用MaixPy来实现巡线功能

      +
    • +
    • 如何使用MaixCam的默认应用程序巡线

      +
    • +
    +

    如何使用MaixPy来寻找直线

    +

    MaixPy的 maix.image.Image中提供了get_regression方法来寻找直线

    +

    代码示例

    +

    一个简单的示例,实现寻找并画出直线

    + +
    from maix import camera, display, image
    +
    +cam = camera.Camera(320, 240)
    +disp = display.Display()
    +
    +# 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()
    +
    +    lines = img.get_regression(thresholds, area_threshold = 100)
    +    for a in lines:
    +        img.draw_line(a.x1(), a.y1(), a.x2(), a.y2(), image.COLOR_GREEN, 2)
    +        theta = a.theta()
    +        rho = a.rho()
    +        if theta > 90:
    +            theta = 270 - theta
    +        else:
    +            theta = 90 - theta
    +        img.draw_string(0, 0, "theta: " + str(theta) + ", rho: " + str(rho), image.COLOR_BLUE)
    +
    +    disp.show(img)
    +
    +

    步骤:

    +
      +
    1. 导入image、camera、display模块

      + +
      from maix import image, camera, display
      +
      +
    2. +
    3. 初始化摄像头和显示

      + +
      cam = camera.Camera(320, 240)	# 初始化摄像头,输出分辨率320x240 RGB格式
      +disp = display.Display()
      +
      +
    4. +
    5. 从摄像头获取图片并显示

      + +
      while 1:
      +    img = cam.read()
      +    disp.show(img)
      +
      +
    6. +
    7. 调用get_regression方法寻找摄像头图片中的直线,并画到屏幕上

      + +
      lines = img.get_regression(thresholds, area_threshold = 100)
      +for a in lines:
      +   img.draw_line(a.x1(), a.y1(), a.x2(), a.y2(), image.COLOR_GREEN, 2)
      +   theta = a.theta()
      +   rho = a.rho()
      +   if theta > 90:
      +      theta = 270 - theta
      +   else:
      +      theta = 90 - theta
      +   img.draw_string(0, 0, "theta: " + str(theta) + ", rho: " + str(rho), image.COLOR_BLUE)
      +
      +
        +
      • img是通过cam.read()读取到的摄像头图像,当初始化的方式为cam = camera.Camera(320, 240)时,img对象是一张分辨率为320x240的RGB图。
      • +
      • img.get_regression用来寻找直线, thresholds 是一个颜色阈值列表,每个元素是一个颜色阈值,同时找到多个阈值就传入多个,每个颜色阈值的格式为 [L_MIN, L_MAX, A_MIN, A_MAX, B_MIN, B_MAX],这里的 LABLAB颜色空间的三个通道,L 通道是亮度,A 通道是红绿通道,B 通道是蓝黄通道。pixels_threshold是一个像素面积的阈值,用来过滤一些不需要直线。
      • +
      • for a in lines用来遍历返回的Line对象, 其中a就是当前的Line对象。通常get_regression函数只会返回一个Line对象,如果需要寻找多条直线,可以尝试使用find_line方法
      • +
      • 使用img.draw_line来画出找到的线条,a.x1(), a.y1(), a.x2(), a.y2()分别代表直线两端的坐标
      • +
      • 使用img.draw_string在左上角显示直线与x轴的夹角, a.theta()是直线与y轴的夹角, 这里为了方便理解转换成直线与x轴的夹角thetaa.rho()是原点与直线的垂线的长度.
      • +
      +
    8. +
    9. 通过maixvision运行代码,就可以寻线啦,看看效果吧

      +

      image-20240509110204007

      +
    10. +
    +

    常用参数说明

    +

    列举常用参数说明,如果没有找到可以实现应用的参数,则需要考虑是否使用其他算法实现,或者基于目前算法的结果扩展所需的功能

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    参数说明示例
    thresholds基于lab颜色空间的阈值,threshold=[[l_min, l_max, a_min, a_max, b_min, b_max]],分别表示:
    亮度范围为[l_min, l_max]|
    绿色到红色的分量范围为[a_min, a_max]
    蓝色到黄色的分量范围为[b_min, b_max]
    可同时设置多个阈值
    设置两个阈值来检测红色和绿色
    img.find_blobs(threshold=[[0, 80, 40, 80, 10, 80], [0, 80, -120, -10, 0, 30]])
    红色阈值为[0, 80, 40, 80, 10, 80]
    绿色阈值为[0, 80, -120, -10, 0, 30]
    invert使能阈值反转,使能后传入阈值与实际阈值相反,默认为False使能阈值反转
    img.find_blobs(invert=True)
    roi设置算法计算的矩形区域,roi=[x, y, w, h],x,y表示矩形区域左上角坐标,w,h表示矩形区域的宽度和高度,默认为整张图片计算坐标为(50,50),宽和高为100的区域
    img.find_blobs(roi=[50, 50, 100, 100])
    area_threshold过滤像素面积小于area_threshold的直线,单位为像素点,默认为10。该参数可用于过滤一些无用的小直线过滤面积小于1000的直线
    img.find_blobs(area_threshold=1000)
    pixels_threshold过滤有效像素点小于pixels_threshold的直线,默认为10。该参数可用于过滤一些无用的小直线过滤有效像素点小于1000的直线
    img.find_blobs(pixels_threshold=1000)
    +

    本文介绍常用方法,更多 API 请看 API 文档的 image 部分。

    +

    如何使用MaixCam的默认应用程序寻找直线

    +

    为了快速验证寻找直线的功能,可以先使用MaixCam提供的line_tracking应用程序来体验寻找直线的效果。

    +

    使用方法

    +
      +
    1. 选择并打开Line tracking应用
    2. +
    3. 点击屏幕中需要识别的直线,左侧会显示该直线的颜色
    4. +
    5. 点击左侧(界面中L A B下方的颜色)需要检测的颜色
    6. +
    7. 此时就可以识别到对应的直线了,同时串口也会输出直线的坐标和角度信息。
    8. +
    +

    演示

    +

    +

    进阶操作

    +

    手动设置LAB阈值寻找直线

    +

    APP提供手动设置LAB阈值来精确的寻找直线

    +

    操作方法:

    +
      +
    1. 点击左下角选项图标,进入配置模式

      +
    2. +
    3. 摄像头对准需要寻找的物体点击屏幕上的目标直线,此时界面中L A B下方会显示该物体对应颜色的矩形框,并显示该物体颜色的LAB值

      +
    4. +
    5. 点击下方选项L Min,L Max,A Min,A Max,B Min,B Max,点击后右侧会出现滑动条来设置该选项值。这些值分别对应LAB颜色格式的L通道、A通道和B通道的最小值和最大值

      +
    6. +
    7. 参考步骤2计算的物体颜色的LAB值,将L Min,L Max,A Min,A Max,B Min,B Max调整到合适的值,即可识别到对应的直线。

      +

      例如LAB=(20, 50, 80),由于L=20,为了适配一定范围让L Min=10L Max=30;同理,由于A=50,让A Min=40A Max=60; 由于B=80,让B Min=70B Max=90

      +
    8. +
    +

    通过串口协议获取检测数据

    +

    寻找直线应用支持通过串口(默认波特率为115200)上报检测到的直线信息。

    +

    由于上报信息只有一条,这里直接用示例来说明上报信息的内容。

    +

    例如上报信息为:

    + +
    AA CA AC BB 0E 00 00 00 E1 09 FC 01 01 00 E9 01 6F 01 57 00 C1 C6
    +
    +
      +
    • AA CA AC BB:协议头部,内容固定

      +
    • +
    • 0E 00 00 00:数据长度,除了协议头部和数据长度外的总长度,这里表示长度为14

      +
    • +
    • E1:标志位,用来标识串口消息标志

      +
    • +
    • 09:命令类型,对于寻找直线APP应用该值固定为0x09

      +
    • +
    • FC 01 01 00 E9 01 6F 01 57 00:直线的两端坐标和角度信息,每个值用小端格式的2字节表示。FC 0101 00表示第一个端点坐标为(508, 1),E9 016F 01表示第二个端点坐标为(489, 367),57 00表示直线与x轴的角度为87度

      +
    • +
    • C1 C6:CRC 校验值,用以校验帧数据在传输过程中是否出错

      +
    • +
    + + +
    +
    + +
    +
    +
    +
    +
    + +
    +
    +
    +
    +
    + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/maixpy/doc/zh/vision/maixhub_train.html b/maixpy/doc/zh/vision/maixhub_train.html index 0da49d8c..45eb2f61 100644 --- a/maixpy/doc/zh/vision/maixhub_train.html +++ b/maixpy/doc/zh/vision/maixhub_train.html @@ -102,7 +102,7 @@

    MaixPy

    diff --git a/maixpy/doc/zh/vision/object_track.html b/maixpy/doc/zh/vision/object_track.html index dd0aa02e..7a5694a7 100644 --- a/maixpy/doc/zh/vision/object_track.html +++ b/maixpy/doc/zh/vision/object_track.html @@ -102,7 +102,7 @@

    MaixPy

    diff --git a/maixpy/doc/zh/vision/qrcode.html b/maixpy/doc/zh/vision/qrcode.html index 5e05fe10..e458965b 100644 --- a/maixpy/doc/zh/vision/qrcode.html +++ b/maixpy/doc/zh/vision/qrcode.html @@ -102,7 +102,7 @@

    MaixPy

    @@ -246,7 +269,7 @@

    MaixPy 二维码识别

    -

    阅读本文前,确保已经知晓如何开发MaixPy,详情请阅读MaixVision -- MaixPy 编程 + 图形化积木编程

    +

    阅读本文前,确保已经知晓如何开发MaixCAM,详情请阅读快速开始

    简介

    本文介绍如何使用MaixPy来识别二维码

    使用 MaixPy 识别二维码

    @@ -339,9 +362,9 @@

    常用参数说
    diff --git a/maixpy/doc/zh/vision/self_learn_classifier.html b/maixpy/doc/zh/vision/self_learn_classifier.html index dbcf5b3b..8d94ce8f 100644 --- a/maixpy/doc/zh/vision/self_learn_classifier.html +++ b/maixpy/doc/zh/vision/self_learn_classifier.html @@ -102,7 +102,7 @@

    MaixPy

    diff --git a/maixpy/doc/zh/vision/self_learn_detector.html b/maixpy/doc/zh/vision/self_learn_detector.html index bef8aa86..4863a8f3 100644 --- a/maixpy/doc/zh/vision/self_learn_detector.html +++ b/maixpy/doc/zh/vision/self_learn_detector.html @@ -102,7 +102,7 @@

    MaixPy

    diff --git a/maixpy/doc/zh/vision/yolov5.html b/maixpy/doc/zh/vision/yolov5.html index 7e2f91c1..42915ff7 100644 --- a/maixpy/doc/zh/vision/yolov5.html +++ b/maixpy/doc/zh/vision/yolov5.html @@ -102,7 +102,7 @@

    MaixPy

    @@ -253,8 +276,8 @@

    - - 人脸识别 + + 人脸及关键点检测 diff --git a/maixpy/sitemap.xml b/maixpy/sitemap.xml index 081c8527..e46c820e 100644 --- a/maixpy/sitemap.xml +++ b/maixpy/sitemap.xml @@ -1,200 +1,230 @@ - https://wiki.sipeed.com/maixpy/api/maix/err.html - 2024-05-08 + https://wiki.sipeed.com/maixpy/api/maix/peripheral/spi.html + 2024-05-16 weekly 1.0 - https://wiki.sipeed.com/maixpy/api/maix/util.html - 2024-05-08 + https://wiki.sipeed.com/maixpy/api/maix/peripheral/timer.html + 2024-05-16 weekly 1.0 - https://wiki.sipeed.com/maixpy/api/maix/peripheral.html - 2024-05-08 + https://wiki.sipeed.com/maixpy/api/maix/peripheral/i2c.html + 2024-05-16 + weekly + 1.0 + + + https://wiki.sipeed.com/maixpy/api/maix/peripheral/gpio.html + 2024-05-16 + weekly + 1.0 + + + https://wiki.sipeed.com/maixpy/api/maix/video.html + 2024-05-16 + weekly + 1.0 + + + https://wiki.sipeed.com/maixpy/api/maix/touchscreen.html + 2024-05-16 weekly 1.0 https://wiki.sipeed.com/maixpy/api/maix/peripheral/wdt.html - 2024-05-08 + 2024-05-16 weekly 1.0 - https://wiki.sipeed.com/maixpy/api/maix/peripheral/spi.html - 2024-05-08 + https://wiki.sipeed.com/maixpy/api/maix/peripheral/pinmap.html + 2024-05-16 weekly 1.0 - https://wiki.sipeed.com/maixpy/api/maix/peripheral/timer.html - 2024-05-08 + https://wiki.sipeed.com/maixpy/api/maix/protocol.html + 2024-05-16 weekly 1.0 - https://wiki.sipeed.com/maixpy/api/index.html - 2024-05-08 + https://wiki.sipeed.com/maixpy/api/maix/tensor.html + 2024-05-16 + weekly + 1.0 + + + https://wiki.sipeed.com/maixpy/api/maix/network/wifi.html + 2024-05-16 + weekly + 1.0 + + + https://wiki.sipeed.com/maixpy/api/maix/nn/F.html + 2024-05-16 weekly 1.0 https://wiki.sipeed.com/maixpy/api/maix/comm.html - 2024-05-08 + 2024-05-16 weekly 1.0 https://wiki.sipeed.com/maixpy/api/maix/rtsp.html - 2024-05-08 + 2024-05-16 weekly 1.0 https://wiki.sipeed.com/maixpy/api/maix/sys.html - 2024-05-08 + 2024-05-16 weekly 1.0 - https://wiki.sipeed.com/maixpy/api/maix/app.html - 2024-05-08 + https://wiki.sipeed.com/maixpy/api/maix/display.html + 2024-05-16 weekly 1.0 - https://wiki.sipeed.com/maixpy/api/maix/i18n.html - 2024-05-08 + https://wiki.sipeed.com/maixpy/api/maix/util.html + 2024-05-16 weekly 1.0 - https://wiki.sipeed.com/maixpy/api/maix/protocol.html - 2024-05-08 + https://wiki.sipeed.com/maixpy/api/maix/peripheral.html + 2024-05-16 weekly 1.0 - https://wiki.sipeed.com/maixpy/api/maix/peripheral/key.html - 2024-05-08 + https://wiki.sipeed.com/maixpy/api/maix/app.html + 2024-05-16 weekly 1.0 - https://wiki.sipeed.com/maixpy/api/maix/peripheral/adc.html - 2024-05-08 + https://wiki.sipeed.com/maixpy/api/maix/i18n.html + 2024-05-16 weekly 1.0 - https://wiki.sipeed.com/maixpy/api/maix/peripheral/pwm.html - 2024-05-08 + https://wiki.sipeed.com/maixpy/api/maix/example.html + 2024-05-16 weekly 1.0 - https://wiki.sipeed.com/maixpy/api/maix/time.html - 2024-05-08 + https://wiki.sipeed.com/maixpy/api/maix/thread.html + 2024-05-16 weekly 1.0 - https://wiki.sipeed.com/maixpy/api/maix/fs.html - 2024-05-08 + https://wiki.sipeed.com/maixpy/api/maix/err.html + 2024-05-16 weekly 1.0 - https://wiki.sipeed.com/maixpy/api/maix/peripheral/i2c.html - 2024-05-08 + https://wiki.sipeed.com/maixpy/api/maix/rtmp.html + 2024-05-16 weekly 1.0 - https://wiki.sipeed.com/maixpy/api/maix/peripheral/gpio.html - 2024-05-08 + https://wiki.sipeed.com/maixpy/api/index.html + 2024-05-16 weekly 1.0 - https://wiki.sipeed.com/maixpy/api/maix/peripheral/uart.html - 2024-05-08 + https://wiki.sipeed.com/maixpy/api/maix/audio.html + 2024-05-16 weekly 1.0 - https://wiki.sipeed.com/maixpy/api/maix/display.html - 2024-05-08 + https://wiki.sipeed.com/maixpy/api/maix/time.html + 2024-05-16 weekly 1.0 - https://wiki.sipeed.com/maixpy/api/maix/video.html - 2024-05-08 + https://wiki.sipeed.com/maixpy/api/maix/fs.html + 2024-05-16 weekly 1.0 - https://wiki.sipeed.com/maixpy/api/maix/touchscreen.html - 2024-05-08 + https://wiki.sipeed.com/maixpy/api/maix/peripheral/uart.html + 2024-05-16 weekly 1.0 - https://wiki.sipeed.com/maixpy/api/maix/camera.html - 2024-05-08 + https://wiki.sipeed.com/maixpy/api/maix/peripheral/key.html + 2024-05-16 weekly 1.0 - https://wiki.sipeed.com/maixpy/api/maix/network.html - 2024-05-08 + https://wiki.sipeed.com/maixpy/api/maix/peripheral/adc.html + 2024-05-16 weekly 1.0 - https://wiki.sipeed.com/maixpy/api/maix/nn.html - 2024-05-08 + https://wiki.sipeed.com/maixpy/api/maix/peripheral/pwm.html + 2024-05-16 weekly 1.0 - https://wiki.sipeed.com/maixpy/api/maix/tensor.html - 2024-05-08 + https://wiki.sipeed.com/maixpy/api/maix/camera.html + 2024-05-16 weekly 1.0 - https://wiki.sipeed.com/maixpy/api/maix/network/wifi.html - 2024-05-08 + https://wiki.sipeed.com/maixpy/api/maix/network.html + 2024-05-16 weekly 1.0 - https://wiki.sipeed.com/maixpy/api/maix/nn/F.html - 2024-05-08 + https://wiki.sipeed.com/maixpy/api/maix/nn.html + 2024-05-16 weekly 1.0 https://wiki.sipeed.com/maixpy/api/maix/image.html - 2024-05-08 + 2024-05-16 weekly 1.0 - https://wiki.sipeed.com/maixpy/api/maix/example.html - 2024-05-08 + https://wiki.sipeed.com/maixpy/doc/zh/basic/maixvision.html + 2024-05-12 weekly 1.0 - https://wiki.sipeed.com/maixpy/api/maix/thread.html - 2024-05-08 + https://wiki.sipeed.com/maixpy/doc/zh/basic/app.html + 2024-04-08 weekly 1.0 @@ -217,26 +247,32 @@ 1.0 - https://wiki.sipeed.com/maixpy/doc/zh/basic/maixpy_upgrade.html - 2024-03-31 + https://wiki.sipeed.com/maixpy/doc/zh/peripheral/spi.html + 2024-05-14 weekly 1.0 - https://wiki.sipeed.com/maixpy/doc/zh/pro/compile_os.html - 2024-03-07 + https://wiki.sipeed.com/maixpy/doc/zh/peripheral/i2c.html + 2024-05-14 weekly 1.0 - https://wiki.sipeed.com/maixpy/doc/zh/vision/ai.html - 2024-04-03 + https://wiki.sipeed.com/maixpy/doc/zh/peripheral/gpio.html + 2024-05-14 weekly 1.0 - https://wiki.sipeed.com/maixpy/doc/zh/vision/self_learn_detector.html - 2024-04-08 + https://wiki.sipeed.com/maixpy/doc/zh/peripheral/uart.html + 2024-05-14 + weekly + 1.0 + + + https://wiki.sipeed.com/maixpy/doc/zh/peripheral/pwm.html + 2024-05-14 weekly 1.0 @@ -247,31 +283,31 @@ 1.0 - https://wiki.sipeed.com/maixpy/doc/zh/basic/python.html - 2024-03-31 + https://wiki.sipeed.com/maixpy/doc/zh/projects/line_tracking_robot.html + 2024-05-09 weekly 1.0 - https://wiki.sipeed.com/maixpy/doc/zh/basic/linux_basic.html - 2024-03-12 + https://wiki.sipeed.com/maixpy/doc/zh/projects/index.html + 2024-05-09 weekly 1.0 - https://wiki.sipeed.com/maixpy/doc/zh/basic/maixvision.html + https://wiki.sipeed.com/maixpy/doc/zh/basic/python.html 2024-03-31 weekly 1.0 - https://wiki.sipeed.com/maixpy/doc/zh/basic/app.html - 2024-04-08 + https://wiki.sipeed.com/maixpy/doc/zh/basic/linux_basic.html + 2024-03-12 weekly 1.0 - https://wiki.sipeed.com/maixpy/doc/zh/vision/qrcode.html + https://wiki.sipeed.com/maixpy/doc/zh/vision/yolov5.html 2024-04-03 weekly 1.0 @@ -295,98 +331,98 @@ 1.0 - https://wiki.sipeed.com/maixpy/doc/zh/vision/image_ops.html - 2024-04-03 + https://wiki.sipeed.com/maixpy/doc/zh/source_code/build.html + 2024-05-09 weekly 1.0 - https://wiki.sipeed.com/maixpy/doc/zh/vision/maixhub_train.html - 2024-04-03 + https://wiki.sipeed.com/maixpy/doc/zh/source_code/maixcdk.html + 2024-03-07 weekly 1.0 - https://wiki.sipeed.com/maixpy/doc/zh/index.html - 2024-04-29 + https://wiki.sipeed.com/maixpy/doc/zh/source_code/add_c_module.html + 2024-04-08 weekly 1.0 - https://wiki.sipeed.com/maixpy/doc/zh/video/jpeg_streaming.html - 2024-04-03 + https://wiki.sipeed.com/maixpy/doc/zh/source_code/contribute.html + 2024-03-07 weekly 1.0 - https://wiki.sipeed.com/maixpy/doc/zh/source_code/faq.html - 2024-04-26 + https://wiki.sipeed.com/maixpy/doc/zh/peripheral/wdt.html + 2024-05-14 weekly 1.0 - https://wiki.sipeed.com/maixpy/doc/zh/source_code/build.html - 2024-04-29 + https://wiki.sipeed.com/maixpy/doc/zh/vision/self_learn_detector.html + 2024-04-08 weekly 1.0 - https://wiki.sipeed.com/maixpy/doc/zh/source_code/maixcdk.html - 2024-03-07 + https://wiki.sipeed.com/maixpy/doc/zh/vision/image_ops.html + 2024-04-03 weekly 1.0 - https://wiki.sipeed.com/maixpy/doc/zh/peripheral/gpio.html - 2024-03-07 + https://wiki.sipeed.com/maixpy/doc/zh/vision/line_tracking.html + 2024-05-09 weekly 1.0 - https://wiki.sipeed.com/maixpy/doc/zh/peripheral/uart.html - 2024-03-07 + https://wiki.sipeed.com/maixpy/doc/zh/vision/face_detection.html + 2024-05-16 weekly 1.0 - https://wiki.sipeed.com/maixpy/doc/zh/peripheral/pwm.html - 2024-03-07 + https://wiki.sipeed.com/maixpy/doc/zh/vision/maixhub_train.html + 2024-04-03 weekly 1.0 - https://wiki.sipeed.com/maixpy/doc/zh/vision/yolov5.html + https://wiki.sipeed.com/maixpy/doc/zh/vision/ai.html 2024-04-03 weekly 1.0 - https://wiki.sipeed.com/maixpy/doc/zh/source_code/add_c_module.html - 2024-04-08 + https://wiki.sipeed.com/maixpy/doc/zh/basic/maixpy_upgrade.html + 2024-03-31 weekly 1.0 - https://wiki.sipeed.com/maixpy/doc/zh/source_code/contribute.html + https://wiki.sipeed.com/maixpy/doc/zh/pro/compile_os.html 2024-03-07 weekly 1.0 - https://wiki.sipeed.com/maixpy/doc/zh/peripheral/wdt.html + https://wiki.sipeed.com/maixpy/doc/zh/modules/thermal_cam.html 2024-03-07 weekly 1.0 - https://wiki.sipeed.com/maixpy/doc/zh/peripheral/spi.html + https://wiki.sipeed.com/maixpy/doc/zh/modules/tof.html 2024-03-07 weekly 1.0 - https://wiki.sipeed.com/maixpy/doc/zh/peripheral/i2c.html - 2024-03-30 + https://wiki.sipeed.com/maixpy/doc/zh/modules/acc.html + 2024-03-07 weekly 1.0 @@ -408,6 +444,30 @@ weekly 1.0 + + https://wiki.sipeed.com/maixpy/doc/zh/audio/recognize.html + 2024-03-07 + weekly + 1.0 + + + https://wiki.sipeed.com/maixpy/doc/zh/index.html + 2024-04-29 + weekly + 1.0 + + + https://wiki.sipeed.com/maixpy/doc/zh/video/jpeg_streaming.html + 2024-04-03 + weekly + 1.0 + + + https://wiki.sipeed.com/maixpy/doc/zh/source_code/faq.html + 2024-05-10 + weekly + 1.0 + https://wiki.sipeed.com/maixpy/doc/zh/vision/face_recognition.html 2024-04-08 @@ -433,26 +493,20 @@ 1.0 - https://wiki.sipeed.com/maixpy/doc/zh/modules/thermal_cam.html - 2024-03-07 - weekly - 1.0 - - - https://wiki.sipeed.com/maixpy/doc/zh/modules/tof.html - 2024-03-07 + https://wiki.sipeed.com/maixpy/doc/zh/vision/qrcode.html + 2024-04-03 weekly 1.0 - https://wiki.sipeed.com/maixpy/doc/zh/modules/acc.html - 2024-03-07 + https://wiki.sipeed.com/maixpy/doc/en/basic/maixvision.html + 2024-05-12 weekly 1.0 - https://wiki.sipeed.com/maixpy/doc/zh/audio/recognize.html - 2024-03-07 + https://wiki.sipeed.com/maixpy/doc/en/basic/app.html + 2024-04-29 weekly 1.0 @@ -475,188 +529,194 @@ 1.0 - https://wiki.sipeed.com/maixpy/doc/en/basic/maixpy_upgrade.html - 2024-04-29 + https://wiki.sipeed.com/maixpy/doc/en/source_code/build.html + 2024-05-09 weekly 1.0 - https://wiki.sipeed.com/maixpy/doc/en/pro/compile_os.html - 2024-04-26 + https://wiki.sipeed.com/maixpy/doc/en/source_code/maixcdk.html + 2024-04-29 weekly 1.0 - https://wiki.sipeed.com/maixpy/doc/en/modules/thermal_cam.html - 2024-04-26 + 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/modules/tof.html - 2024-04-26 + https://wiki.sipeed.com/maixpy/doc/en/source_code/contribute.html + 2024-04-29 weekly 1.0 - https://wiki.sipeed.com/maixpy/doc/en/modules/acc.html - 2024-04-26 + https://wiki.sipeed.com/maixpy/doc/en/peripheral/wdt.html + 2024-05-14 weekly 1.0 - https://wiki.sipeed.com/maixpy/doc/en/audio/recognize.html - 2024-04-26 + https://wiki.sipeed.com/maixpy/doc/en/faq.html + 2024-05-08 weekly 1.0 - https://wiki.sipeed.com/maixpy/doc/en/peripheral/gpio.html - 2024-04-26 + https://wiki.sipeed.com/maixpy/doc/en/projects/line_tracking_robot.html + 2024-05-09 weekly 1.0 - https://wiki.sipeed.com/maixpy/doc/en/peripheral/uart.html - 2024-04-26 + https://wiki.sipeed.com/maixpy/doc/en/projects/index.html + 2024-05-09 weekly 1.0 - https://wiki.sipeed.com/maixpy/doc/en/peripheral/pwm.html - 2024-04-26 + https://wiki.sipeed.com/maixpy/doc/en/basic/python.html + 2024-04-29 weekly 1.0 - https://wiki.sipeed.com/maixpy/doc/en/vision/yolov5.html + https://wiki.sipeed.com/maixpy/doc/en/basic/linux_basic.html 2024-04-29 weekly 1.0 - https://wiki.sipeed.com/maixpy/doc/en/vision/ai.html - 2024-04-03 + https://wiki.sipeed.com/maixpy/doc/en/vision/self_learn_detector.html + 2024-04-29 weekly 1.0 - https://wiki.sipeed.com/maixpy/doc/en/vision/self_learn_detector.html + https://wiki.sipeed.com/maixpy/doc/en/basic/maixpy_upgrade.html 2024-04-29 weekly 1.0 - https://wiki.sipeed.com/maixpy/doc/en/source_code/add_c_module.html - 2024-04-29 + https://wiki.sipeed.com/maixpy/doc/en/pro/compile_os.html + 2024-04-26 weekly 1.0 - https://wiki.sipeed.com/maixpy/doc/en/source_code/contribute.html - 2024-04-29 + https://wiki.sipeed.com/maixpy/doc/en/modules/thermal_cam.html + 2024-04-26 weekly 1.0 - https://wiki.sipeed.com/maixpy/doc/en/peripheral/wdt.html + https://wiki.sipeed.com/maixpy/doc/en/modules/tof.html 2024-04-26 weekly 1.0 - https://wiki.sipeed.com/maixpy/doc/en/peripheral/spi.html + https://wiki.sipeed.com/maixpy/doc/en/modules/acc.html 2024-04-26 weekly 1.0 - https://wiki.sipeed.com/maixpy/doc/en/peripheral/i2c.html - 2024-04-26 + https://wiki.sipeed.com/maixpy/doc/en/vision/yolov5.html + 2024-04-29 weekly 1.0 - https://wiki.sipeed.com/maixpy/doc/en/vision/qrcode.html + https://wiki.sipeed.com/maixpy/doc/en/vision/camera.html 2024-04-03 weekly 1.0 - https://wiki.sipeed.com/maixpy/doc/en/index.html - 2024-04-29 + https://wiki.sipeed.com/maixpy/doc/en/vision/find_blobs.html + 2024-04-03 weekly 1.0 - https://wiki.sipeed.com/maixpy/doc/en/video/jpeg_streaming.html - 2024-04-03 + https://wiki.sipeed.com/maixpy/doc/en/vision/classify.html + 2024-04-29 weekly 1.0 - https://wiki.sipeed.com/maixpy/doc/en/source_code/faq.html + https://wiki.sipeed.com/maixpy/doc/en/audio/recognize.html 2024-04-26 weekly 1.0 - https://wiki.sipeed.com/maixpy/doc/en/source_code/build.html + https://wiki.sipeed.com/maixpy/doc/en/index.html 2024-04-29 weekly 1.0 - https://wiki.sipeed.com/maixpy/doc/en/source_code/maixcdk.html - 2024-04-29 + https://wiki.sipeed.com/maixpy/doc/en/video/jpeg_streaming.html + 2024-04-03 weekly 1.0 - https://wiki.sipeed.com/maixpy/doc/en/faq.html - 2024-05-08 + https://wiki.sipeed.com/maixpy/doc/en/source_code/faq.html + 2024-05-10 weekly 1.0 - https://wiki.sipeed.com/maixpy/doc/en/basic/python.html - 2024-04-29 + https://wiki.sipeed.com/maixpy/doc/en/vision/apriltag.html + 2024-04-03 weekly 1.0 - https://wiki.sipeed.com/maixpy/doc/en/basic/linux_basic.html + https://wiki.sipeed.com/maixpy/doc/en/vision/custmize_model.html 2024-04-29 weekly 1.0 - https://wiki.sipeed.com/maixpy/doc/en/basic/maixvision.html + 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/basic/app.html - 2024-04-29 + https://wiki.sipeed.com/maixpy/doc/en/peripheral/spi.html + 2024-05-14 weekly 1.0 - https://wiki.sipeed.com/maixpy/doc/en/vision/apriltag.html - 2024-04-03 + https://wiki.sipeed.com/maixpy/doc/en/peripheral/i2c.html + 2024-05-14 weekly 1.0 - https://wiki.sipeed.com/maixpy/doc/en/vision/custmize_model.html - 2024-04-29 + https://wiki.sipeed.com/maixpy/doc/en/peripheral/gpio.html + 2024-05-14 weekly 1.0 - https://wiki.sipeed.com/maixpy/doc/en/vision/self_learn_classifier.html - 2024-04-29 + https://wiki.sipeed.com/maixpy/doc/en/peripheral/uart.html + 2024-05-14 + weekly + 1.0 + + + https://wiki.sipeed.com/maixpy/doc/en/peripheral/pwm.html + 2024-05-14 weekly 1.0 @@ -685,26 +745,26 @@ 1.0 - https://wiki.sipeed.com/maixpy/doc/en/vision/camera.html + https://wiki.sipeed.com/maixpy/doc/en/vision/qrcode.html 2024-04-03 weekly 1.0 - https://wiki.sipeed.com/maixpy/doc/en/vision/find_blobs.html + 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/classify.html - 2024-04-29 + https://wiki.sipeed.com/maixpy/doc/en/vision/line_tracking.html + 2024-05-09 weekly 1.0 - https://wiki.sipeed.com/maixpy/doc/en/vision/image_ops.html - 2024-04-03 + https://wiki.sipeed.com/maixpy/doc/en/vision/face_detection.html + 2024-05-16 weekly 1.0 @@ -714,9 +774,15 @@ 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/no_translate.html - 2024-05-08 + 2024-05-16 weekly 1.0 diff --git a/maixpy/static/image/line_tracking_demo.jpg b/maixpy/static/image/line_tracking_demo.jpg new file mode 100644 index 00000000..3bd95870 Binary files /dev/null and b/maixpy/static/image/line_tracking_demo.jpg differ diff --git a/maixpy/static/search_index/index_0.json b/maixpy/static/search_index/index_0.json index e6dcfba9..b0f3d066 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 ```python def to_str(e: Err) > 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 ```python def get_error() > str ``` item doc **brief** get last error string **return** error string **C++ defination code**: ```cpp std::string& get_error() ``` ### set\\_error ```python def set_error(str: str) > None ``` 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 ```python def check_raise(e: Err, msg: str '') > None ``` 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 ```python def check_bool_raise(ok: bool, msg: str '') > None ``` 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 ```python def check_null_raise(ptr: capsule, msg: str '') > None ``` 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 ```python def disable_kernel_debug() > None ``` item doc **brief** disable the kernel debug **C++ defination code**: ```cpp void disable_kernel_debug() ``` ### enable\\_kernel\\_debug ```python def enable_kernel_debug() > None ``` 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/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/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 ### Region item doc **brief** Region class **C++ defination code**: ```cpp class Region ``` #### \\_\\_init\\_\\_ ```python def __init__(self, x: int, y: int, width: int, height: int, format: maix.image.Format, camera: maix.camera.Camera) > None ``` item doc **type** func **brief** Construct a new Region object **param** **x**: region coordinate x
    **y**: region coordinate y
    **width**: region width
    **height**: region height
    **format**: region format
    **camera**: bind region to camera
    **static** False **C++ defination code**: ```cpp Region(int x, int y, int width, int height, image::Format format, camera::Camera *camera) ``` #### get\\_canvas ```python def get_canvas(self) > maix.image.Image ``` item doc **type** func **brief** Return an image object from region **return** image object **static** False **C++ defination code**: ```cpp image::Image *get_canvas() ``` #### update\\_canvas ```python def update_canvas(self) > maix.err.Err ``` item doc **type** func **brief** Update canvas **return** error code **static** False **C++ defination code**: ```cpp err::Err update_canvas() ``` ### Rtsp item doc **brief** Rtsp class **C++ defination code**: ```cpp class Rtsp ``` #### \\_\\_init\\_\\_ 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 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 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 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::Frame &stream) ``` #### get\\_url 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 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 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() ``` #### add\\_region item doc **type** func **brief** return a region object, you can draw image on the region. **param** **x**: region coordinate x
    **y**: region coordinate y
    **width**: region width
    **height**: region height
    **format**: region format, support Format::FMT_BGRA8888 only
    **return** the reigon object **static** False **C++ defination code**: ```cpp rtsp::Region *add_region(int x, int y, int width, int height, image::Format format image::Format::FMT_BGRA8888) ``` #### update\\_region item doc **type** func **brief** update and show region **return** error code **static** False **C++ defination code**: ```cpp err::Err update_region(rtsp::Region ®ion) ```"},"/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 ```python def os_version() > str ``` 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 ```python def device_name() > str ``` item doc **brief** Get device name **return** device name, e.g. \"MaixCAM\" **C++ defination code**: ```cpp std::string device_name() ``` ### host\\_name ```python def host_name() > str ``` item doc **brief** Get host name **return** host name, e.g. \"maixcam 2f9f\" **C++ defination code**: ```cpp std::string host_name() ``` ### host\\_domain ```python def host_domain() > str ``` item doc **brief** Get host domain **return** host domain, e.g. \"maixcam 2f9f.local\" **C++ defination code**: ```cpp std::string host_domain() ``` ### ip\\_address ```python def ip_address() > dict[str, str] ``` 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 ```python def mac_address() > dict[str, str] ``` 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 ```python def device_key() > str ``` 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 ```python def memory_info() > dict[str, int] ``` 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 ```python def bytes_to_human(bytes: int, precision: int 2, base: int 1024, unit: str 'B', sep: str ' ') > str ``` 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 ```python def cpu_freq() > dict[str, int] ``` 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 ```python def cpu_temp() > dict[str, float] ``` 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 ```python def cpu_usage() > dict[str, float] ``` 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 ```python def npu_freq() > dict[str, int] ``` 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 ```python def disk_usage(path: str '/') > dict[str, int] ``` 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 ```python def disk_partitions(only_disk: bool True) > list[dict[str, str]] ``` 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 ```python def poweroff() > None ``` item doc **brief** Power off device **C++ defination code**: ```cpp void poweroff() ``` ### reboot ```python def reboot() > None ``` item doc **brief** Power off device and power on **C++ defination code**: ```cpp void reboot() ``` ## Class"},"/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 ```python def app_id() > str ``` item doc **brief** Get current APP ID. **return** APP ID. **C++ defination code**: ```cpp string app_id() ``` ### set\\_app\\_id ```python def set_app_id(app_id: str) > str ``` 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 ```python def get_apps_info_path() > str ``` item doc **brief** Get APP info file path. **C++ defination code**: ```cpp string get_apps_info_path() ``` ### get\\_apps\\_info ```python def get_apps_info(ignore_launcher: bool False, ignore_app_store: bool False) > list[APP_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 ```python def get_app_data_path() > str ``` 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 ```python def get_app_path(app_id: str '') > str ``` 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 ```python def get_tmp_path() > str ``` 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 ```python def get_share_path() > str ``` 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 ```python def get_picture_path() > str ``` 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 ```python def get_video_path() > str ``` 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 ```python def get_font_path() > str ``` 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 ```python def get_icon_path() > str ``` 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 ```python def get_sys_config_kv(item: str, key: str, value: str '', from_cache: bool True) > str ``` 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 ```python def get_app_config_kv(item: str, key: str, value: str '', from_cache: bool True) > str ``` 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 ```python def set_app_config_kv(item: str, key: str, value: str, write_file: bool True) > maix.err.Err ``` 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 ```python def get_app_config_path() > str ``` 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 ```python def set_exit_msg(code: maix.err.Err, msg: str) > maix.err.Err ``` 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 ```python def get_exit_msg(cache: bool False) > tuple[str, maix.err.Err, str] ``` 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 ```python def have_exit_msg(cache: bool False) > bool ``` 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 ```python def switch_app(app_id: str, idx: int 1) > None ``` 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 ```python def need_exit() > bool ``` 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 ```python def running() > bool ``` 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 ```python def set_exit_flag(exit: bool) > None ``` 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 ```python def get_locale(self) > str ``` 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 ```python def crc16_IBM(data: maix.Bytes(bytes)) > int ``` 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/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/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 ```python def time() > float ``` item doc **brief** Get current time in s **return** current time in s, double type **C++ defination code**: ```cpp double time() ``` ### time\\_ms ```python def time_ms() > int ``` 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 ```python def time_s() > int ``` 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 ```python def time_us() > int ``` 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 ```python def time_diff(last: float, now: float 1) > float ``` 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 ```python def sleep(s: float) > None ``` item doc **brief** Sleep seconds **param** **s**: seconds, double type
    **C++ defination code**: ```cpp void sleep(double s) ``` ### sleep\\_ms ```python def sleep_ms(ms: int) > None ``` item doc **brief** Sleep milliseconds **param** **ms**: milliseconds, uint64_t type
    **C++ defination code**: ```cpp void sleep_ms(uint64_t ms) ``` ### sleep\\_us ```python def sleep_us(us: int) > None ``` item doc **brief** Sleep microseconds **param** **us**: microseconds, uint64_t type
    **C++ defination code**: ```cpp void sleep_us(uint64_t us) ``` ### now ```python def now() > DateTime ``` item doc **brief** Get current UTC date and time **return** current date and time, DateTime type **C++ defination code**: ```cpp time::DateTime *now() ``` ### localtime ```python def localtime() > DateTime ``` item doc **brief** Get local time **return** local time, DateTime type **C++ defination code**: ```cpp time::DateTime *localtime() ``` ### strptime ```python def strptime(str: str, format: str) > DateTime ``` 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/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 ```python def isabs(path: str) > bool ``` 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 ```python def isdir(path: str) > bool ``` 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 ```python def isfile(path: str) > bool ``` 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 ```python def islink(path: str) > bool ``` 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 ```python def symlink(src: str, link: str, force: bool False) > maix.err.Err ``` 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 ```python def exists(path: str) > bool ``` 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 ```python def mkdir(path: str, exist_ok: bool True, recursive: bool True) > maix.err.Err ``` 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 ```python def rmdir(path: str, recursive: bool False) > maix.err.Err ``` 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 ```python def remove(path: str) > maix.err.Err ``` 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 ```python def rename(src: str, dst: str) > maix.err.Err ``` 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 ```python def sync() > None ``` item doc **brief** Sync files, ensure they're wrriten to disk from RAM **C++ defination code**: ```cpp void sync() ``` ### getsize ```python def getsize(path: str) > int ``` 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 ```python def dirname(path: str) > str ``` 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 ```python def basename(path: str) > str ``` 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 ```python def abspath(path: str) > str ``` 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 ```python def getcwd() > str ``` item doc **brief** Get current working directory **return** current working directory absolute path **C++ defination code**: ```cpp std::string getcwd() ``` ### realpath ```python def realpath(path: str) > str ``` 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 ```python def splitext(path: str) > str ``` 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 ```python def listdir(path: str, recursive: bool False, full_path: bool False) > list[str] ``` 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 ```python def open(self, path: str, mode: str) > maix.err.Err ``` 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 ```python def tempdir() > str ``` 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/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/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/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) ``` #### get\\_backlight ```python def get_backlight(self) > float ``` item doc **type** func **brief** Get display backlight **return** value backlight value, float type, range is [0, 100] **static** False **C++ defination code**: ```cpp float get_backlight() ``` #### 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/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 ### Frame item doc **brief** Frame class **C++ defination code**: ```cpp class Frame ``` ### Packet item doc **brief** Packet class **C++ defination code**: ```cpp class Packet ``` #### \\_\\_init\\_\\_ item doc **type** func **brief** Packet number (pair of numerator and denominator). **param** **data**: src data pointer, use pointers directly without copying.
    Note: this object will try to free this memory
    **len**: data len
    **pts**: presentation time stamp. unit: time_base
    **dts**: decoding time stamp. unit: time_base
    **duration**: packet display time. unit: time_base
    **static** False **C++ defination code**: ```cpp Packet(uint8_t *data, int len, uint64_t pts 1, uint64_t dts 1, int64_t duration 0) ``` #### get item doc **type** func **brief** Get raw data of packet **return** raw data **static** False **C++ defination code**: ```cpp std::vector get() ``` #### data item doc **type** func **brief** Get raw data of packet **return** raw data **static** False **C++ defination code**: ```cpp uint8_t *data() ``` #### data\\_size item doc **type** func **brief** Get raw data size of packet **return** size of raw data **static** False **C++ defination code**: ```cpp size_t data_size() ``` #### is\\_valid item doc **type** func **brief** Check packet is valid **return** true, packet is valid; false, packet is invalid **static** False **C++ defination code**: ```cpp bool is_valid() ``` #### set\\_pts item doc **type** func **brief** Set pts **param** **pts**: presentation time stamp. unit: time_base
    **return** true, packet is valid; false, packet is invalid **static** False **C++ defination code**: ```cpp void set_pts(uint64_t pts) ``` #### set\\_dts item doc **type** func **brief** Set dts **param** **dts**: decoding time stamp. unit: time_base
    **return** true, packet is valid; false, packet is invalid **static** False **C++ defination code**: ```cpp void set_dts(uint64_t dts) ``` #### set\\_duration item doc **type** func **brief** Set duration **param** **duration**: packet display time. unit: time_base
    **return** true, packet is valid; false, packet is invalid **static** False **C++ defination code**: ```cpp void set_duration(uint64_t duration) ``` ### Video item doc **brief** Video class **C++ defination code**: ```cpp class Video ``` #### \\_\\_init\\_\\_ ```python def __init__(self, path: str '', width: int 2560, height: int 1440, format: maix.image.Format ..., time_base: int 30, framerate: int 30, open: bool True) > None ``` item doc **type** func **brief** Construct a new Video object **param** **path**: video path. the path determines the location where you load or save the file, if path is none, the video module will not save or load file.
    xxx.h265 means video format is H265, xxx.mp4 means video format is MP4
    **width**: picture width. this value may be set automatically. default is 2560.
    **height**: picture height. this value may be set automatically. default is 1440.
    **format**: picture pixel format. this value may be set automatically. default is FMT_YVU420SP.
    **time_base**: frame time base. time_base default is 30, means 1/30 ms
    **framerate**: frame rate. framerate default is 30, means 30 frames per second
    for video. 1/time_base is not the average frame rate if the frame rate is not constant.
    **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(), int width 2560, int height 1440, image::Format format image::Format::FMT_YVU420SP, int time_base 30, int framerate 30, bool open true) ``` #### open ```python def open(self, path: str '', fps: float 30.0) > maix.err.Err ``` item doc **type** func **brief** Open video and run **param** **path**: video path. the path determines the location where you load or save the file, if path is none, the video module will not save or load file.
    xxx.h265 means video format is H265, xxx.mp4 means video format is MP4
    **fps**: video fps
    **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(), double fps 30.0) ``` #### close ```python def close(self) > None ``` item doc **type** func **brief** Close video **static** False **C++ defination code**: ```cpp void close() ``` #### 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) ``` #### encode ```python def encode(self, img: maix.image.Image 0) > Packet ``` item doc **type** func **brief** Encode image. **param** **img**: the image will be encode.
    if the img is NULL, this function will try to get image from camera, you must use bind_camera to bind camera.
    **return** encode result **static** False **C++ defination code**: ```cpp video::Packet encode(image::Image *img NULL) ``` #### decode ```python def decode(self, frame: Frame 0) > maix.image.Image ``` item doc **type** func **brief** Decode frame **param** **frame**: the frame will be decode
    **return** decode result **static** False **C++ defination code**: ```cpp image::Image *decode(video::Frame *frame NULL) ``` #### finish ```python def finish(self) > maix.err.Err ``` item doc **type** func **brief** Encode or decode finish **return** error code **static** False **C++ defination code**: ```cpp err::Err finish() ``` #### is\\_recording ```python def is_recording(self) > bool ``` 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/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 ```python def set_regs_enable(enable: bool True) > None ``` 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** Set/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** Set/Get camera vertical flip **return** camera vertical flip **static** False **C++ defination code**: ```cpp int vflip(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) ``` #### get\\_channel ```python def get_channel(self) > int ``` item doc **type** func **brief** Get channel of camera **return** channel number **static** False **C++ defination code**: ```cpp int get_channel() ``` #### 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
    **return** error code, err::ERR_NONE means success, others means failed **static** False **C++ defination code**: ```cpp err::Err set_resolution(int width, int height) ``` #### exposure ```python def exposure(self, value: int 1) > int ``` item doc **type** func **brief** Set/Get camera exposure **attention** This method will affect the isp and thus the image, so please be careful with it. **param** **value**: exposure time. unit: us
    If value 1, return exposure time.
    If value ! 0, set and return exposure time.
    **return** camera exposure time **static** False **C++ defination code**: ```cpp uint64_t exposure(uint64_t value 1) ``` #### gain ```python def gain(self, value: int 1) > int ``` item doc **type** func **brief** Set/Get camera gain **attention** This method will affect the isp and thus the image, so please be careful with it. **param** **value**: camera gain.
    If value 1, returns camera gain.
    If value ! 0, set and return camera gain.
    **return** camera gain **static** False **C++ defination code**: ```cpp uint32_t gain(uint32_t value 1) ``` #### luma ```python def luma(self, value: int 1) > int ``` item doc **type** func **brief** Set/Get camera luma **attention** This method will affect the isp and thus the image, so please be careful with it. **param** **value**: luma value, range is [0, 100]
    If value 1, returns luma value.
    If value ! 0, set and return luma value.
    **return** returns luma value **static** False **C++ defination code**: ```cpp uint32_t luma(uint32_t value 1) ``` #### constrast ```python def constrast(self, value: int 1) > int ``` item doc **type** func **brief** Set/Get camera constrast **attention** This method will affect the isp and thus the image, so please be careful with it. **param** **value**: constrast value, range is [0, 100]
    If value 1, returns constrast value.
    If value ! 0, set and return constrast value.
    **return** returns constrast value **static** False **C++ defination code**: ```cpp uint32_t constrast(uint32_t value 1) ``` #### saturation ```python def saturation(self, value: int 1) > int ``` item doc **type** func **brief** Set/Get camera saturation **attention** This method will affect the isp and thus the image, so please be careful with it. **param** **value**: saturation value, range is [0, 100]
    If value 1, returns saturation value.
    If value ! 0, set and return saturation value.
    **return** returns saturation value **static** False **C++ defination code**: ```cpp uint32_t saturation(uint32_t value 1) ```"},"/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 module brief [wifi](./network/wifi.html) maix.network.wifi module ## Enum ## Variable ## Function ### have\\_network ```python def have_network() > bool ``` 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 ```python def load(self, model: str) > maix.err.Err ``` 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 ```python def input_size(self) > maix.image.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 ```python def input_width(self) > int ``` 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 ```python def input_height(self) > int ``` 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 ```python def input_format(self) > maix.image.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\\_\\_ ```python def __init__(self, model: str '') > None ``` 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 ```python def load(self, model: str) > maix.err.Err ``` 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 ```python def classify(self, img: maix.image.Image, softmax: bool True) > list[tuple[int, float]] ``` 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 ```python def classify_raw(self, data: maix.tensor.Tensor, softmax: bool True) > list[tuple[int, float]] ``` 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 ```python def input_size(self) > maix.image.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 ```python def input_width(self) > int ``` 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 ```python def input_height(self) > int ``` 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 ```python def input_format(self) > maix.image.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 ```python def input_shape(self) > list[int] ``` 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\\_\\_ ```python def __init__(self, model_path: str None) > None ``` 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 ```python def load(self, model: str) > maix.err.Err ``` 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\\_\\_ ```python def __str__(self) > 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 ```python def load(self, model: str) > maix.err.Err ``` 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.
    **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** 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, bool copy_result true) ``` ### 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/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 ```python def list_devices() > list[str] ``` 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 ssid ``` #### bssid item doc **type** var **brief** WiFi AP info BSSID **static** False **readonly** False **C++ defination code**: ```cpp std::string bssid ``` #### security item doc **type** var **brief** WiFi AP info security **static** False **readonly** False **C++ defination code**: ```cpp std::string security ``` #### channel item doc **type** var **brief** WiFi AP info channel **static** False **readonly** False **C++ defination code**: ```cpp int channel ``` #### frequency item doc **type** var **brief** WiFi AP info frequency **static** False **readonly** False **C++ defination code**: ```cpp int frequency ``` #### rssi item doc **type** var **brief** WiFi AP info rssi **static** False **readonly** False **C++ defination code**: ```cpp int rssi ``` #### ssid\\_str ```python def ssid_str(self) > str ``` item doc **type** func **brief** WiFi AP info ssid_str **static** False **C++ defination code**: ```cpp std::string ssid_str() ``` ### Wifi item doc **brief** Wifi class **C++ defination code**: ```cpp class Wifi ``` #### \\_\\_init\\_\\_ item doc **type** func **brief** Wifi class **param** **iface**: wifi interface name, default is wlan0
    **static** False **C++ defination code**: ```cpp Wifi(std::string iface \"wlan0\") ``` #### get\\_ip item doc **type** func **brief** Get current WiFi ip **return** ip, string type, if network not connected, will return empty string. **static** False **C++ defination code**: ```cpp std::string get_ip() ``` #### get\\_mac item doc **type** func **brief** Get current WiFi MAC address **return** ip, string type. **static** False **C++ defination code**: ```cpp std::string get_mac() ``` #### get\\_gateway item doc **type** func **brief** Get current WiFi ip **return** ip, string type, if network not connected, will return empty string. **static** False **C++ defination code**: ```cpp std::string get_gateway() ``` #### start\\_scan item doc **type** func **brief** WiFi start scan AP info around in background. **return** If success, return err.Err.ERR_NONE, else means failed. **static** False **C++ defination code**: ```cpp err::Err start_scan() ``` #### get\\_scan\\_result item doc **type** func **brief** Get WiFi scan AP info. **return** wifi.AP_Info list. **static** False **C++ defination code**: ```cpp std::vector get_scan_result() ``` #### stop\\_scan item doc **type** func **brief** Stop WiFi scan AP info. **static** False **C++ defination code**: ```cpp void stop_scan() ``` #### connect item doc **type** func **brief** Connect to WiFi AP. **param** **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. **static** False **C++ defination code**: ```cpp err::Err connect(const std::string &ssid, const std::string &password, bool wait true, int timeout 60) ``` #### disconnect item doc **type** func **brief** Disconnect from WiFi AP. **return** If success, return err.Err.ERR_NONE, else means failed. **static** False **C++ defination code**: ```cpp err::Err disconnect() ``` #### is\\_connected item doc **type** func **brief** See if WiFi is connected to AP. **return** If connected return true, else false. **static** False **C++ defination code**: ```cpp bool is_connected() ```"},"/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 ```python def softmax(tensor: maix.tensor.Tensor, replace: bool) > maix.tensor.Tensor ``` 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/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 ```python def load(path: str, format: Format ...) > Image ``` 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 ```python def from_bytes(width: int, height: int, format: Format, data: maix.Bytes(bytes), copy: bool True) > Image ``` 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 ```python def load_font(name: str, path: str, size: int 16) > maix.err.Err ``` 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 ```python def fonts() > list[str] ``` item doc **brief** Get all loaded fonts **return** all loaded fonts, string list type **C++ defination code**: ```cpp std::vector *fonts() ``` ### string\\_size ```python def string_size(string: str, scale: float 1, thickness: int 1, font: str '') > 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 ```python def image2cv(img: Image, bgr: bool True, copy: bool True) > numpy.ndarray[numpy.uint8] ``` 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 ```python def hello(name: str) > str ``` item doc **brief** say hello to someone **param** **name**: direction [in], name of someone, string type
    **return** string type, content is hello + name **C++ defination code**: ```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 ```python def change_arg_name2(e: Example) > None ``` 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/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/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/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 ### Frame item doc **brief** Frame class **C++ defination code**: ```cpp class Frame ``` ### Packet item doc **brief** Packet class **C++ defination code**: ```cpp class Packet ``` #### \\_\\_init\\_\\_ item doc **type** func **brief** Packet number (pair of numerator and denominator). **param** **data**: src data pointer, use pointers directly without copying.
    Note: this object will try to free this memory
    **len**: data len
    **pts**: presentation time stamp. unit: time_base
    **dts**: decoding time stamp. unit: time_base
    **duration**: packet display time. unit: time_base
    **static** False **C++ defination code**: ```cpp Packet(uint8_t *data, int len, uint64_t pts 1, uint64_t dts 1, int64_t duration 0) ``` #### get item doc **type** func **brief** Get raw data of packet **return** raw data **static** False **C++ defination code**: ```cpp std::vector get() ``` #### data item doc **type** func **brief** Get raw data of packet **return** raw data **static** False **C++ defination code**: ```cpp uint8_t *data() ``` #### data\\_size item doc **type** func **brief** Get raw data size of packet **return** size of raw data **static** False **C++ defination code**: ```cpp size_t data_size() ``` #### is\\_valid item doc **type** func **brief** Check packet is valid **return** true, packet is valid; false, packet is invalid **static** False **C++ defination code**: ```cpp bool is_valid() ``` #### set\\_pts item doc **type** func **brief** Set pts **param** **pts**: presentation time stamp. unit: time_base
    **return** true, packet is valid; false, packet is invalid **static** False **C++ defination code**: ```cpp void set_pts(uint64_t pts) ``` #### set\\_dts item doc **type** func **brief** Set dts **param** **dts**: decoding time stamp. unit: time_base
    **return** true, packet is valid; false, packet is invalid **static** False **C++ defination code**: ```cpp void set_dts(uint64_t dts) ``` #### set\\_duration item doc **type** func **brief** Set duration **param** **duration**: packet display time. unit: time_base
    **return** true, packet is valid; false, packet is invalid **static** False **C++ defination code**: ```cpp void set_duration(uint64_t duration) ``` ### Video item doc **brief** Video class **C++ defination code**: ```cpp class Video ``` #### \\_\\_init\\_\\_ ```python def __init__(self, path: str '', width: int 2560, height: int 1440, format: maix.image.Format ..., time_base: int 30, framerate: int 30, capture: bool False, open: bool True) > None ``` item doc **type** func **brief** Construct a new Video object **param** **path**: video path. the path determines the location where you load or save the file, if path is none, the video module will not save or load file.
    xxx.h265 means video format is H265, xxx.mp4 means video format is MP4
    **width**: picture width. this value may be set automatically. default is 2560.
    **height**: picture height. this value may be set automatically. default is 1440.
    **format**: picture pixel format. this value may be set automatically. default is FMT_YVU420SP.
    **time_base**: frame time base. time_base default is 30, means 1/30 ms
    **framerate**: frame rate. framerate default is 30, means 30 frames per second
    for video. 1/time_base is not the average frame rate if the frame rate is not constant.
    **capture**: enable capture, if true, you can use capture() function to get an image object
    **open**: If true, video will automatically call open() after creation. default is true.
    **static** False **C++ defination code**: ```cpp Video(std::string path std::string(), int width 2560, int height 1440, image::Format format image::Format::FMT_YVU420SP, int time_base 30, int framerate 30, bool capture false, bool open true) ``` #### open ```python def open(self, path: str '', fps: float 30.0) > maix.err.Err ``` item doc **type** func **brief** Open video and run **param** **path**: video path. the path determines the location where you load or save the file, if path is none, the video module will not save or load file.
    xxx.h265 means video format is H265, xxx.mp4 means video format is MP4
    **fps**: video fps
    **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(), double fps 30.0) ``` #### close ```python def close(self) > None ``` item doc **type** func **brief** Close video **static** False **C++ defination code**: ```cpp void close() ``` #### 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) ``` #### encode ```python def encode(self, img: maix.image.Image ...) > Packet ``` item doc **type** func **brief** Encode image. **param** **img**: the image will be encode.
    if the img is NULL, this function will try to get image from camera, you must use bind_camera() function to bind the camera.
    **return** encode result **static** False **C++ defination code**: ```cpp video::Packet *encode(image::Image *img maix::video::Video::NoneImage) ``` #### decode ```python def decode(self, frame: Frame None) > maix.image.Image ``` item doc **type** func **brief** Decode frame **param** **frame**: the frame will be decode
    **return** decode result **static** False **C++ defination code**: ```cpp image::Image *decode(video::Frame *frame nullptr) ``` #### finish ```python def finish(self) > maix.err.Err ``` item doc **type** func **brief** Encode or decode finish **return** error code **static** False **C++ defination code**: ```cpp err::Err finish() ``` #### capture ```python def capture(self) > maix.image.Image ``` item doc **type** func **brief** Capture image **attention** Each time encode is called, the last captured image will be released. **return** error code **static** False **C++ defination code**: ```cpp image::Image *capture() ``` #### is\\_recording ```python def is_recording(self) > bool ``` 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/pinmap.html":{"title":"maix.peripheral.pinmap","content":" title: maix.peripheral.pinmap maix.peripheral.pinmap module > You can use `maix.peripheral.pinmap` to access this module with MaixPy > This module is generated from [MaixCDK](https://github.com/sipeed/MaixCDK) ## Module No module ## Enum ## Variable ## Function ### get\\_pins ```python def get_pins() > list[str] ``` item doc **brief** Get all pins of devices **return** pin name list, string type. **C++ defination code**: ```cpp std::vector get_pins() ``` ### get\\_pin\\_functions ```python def get_pin_functions(pin: str) > list[str] ``` item doc **brief** Get all function of a pin **param** **pin**: pin name, string type.
    **return** function list, function name is string type. **throw** If pin name error will throwout err.Err.ERR_ARGS error. **C++ defination code**: ```cpp std::vector get_pin_functions(const std::string &pin) ``` ### set\\_pin\\_function ```python def set_pin_function(pin: str, func: str) > maix.err.Err ``` item doc **brief** Set function of a pin **param** **pin**: pin name, string type.
    **func**: which function should this pin use.
    **return** if set ok, will return err.Err.ERR_NONE, else error occurs. **C++ defination code**: ```cpp err::Err set_pin_function(const std::string &pin, const std::string &func) ``` ## Class"},"/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 ```python def crc16_IBM(data: maix.Bytes(bytes)) > int ``` 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/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() ``` #### to\\_float\\_list item doc **type** func **brief** get tensor data and return a list **return** list type data **static** False **C++ defination code**: ```cpp std::valarray* to_float_list() ``` #### 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 ```python def list_devices() > list[str] ``` 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 ssid ``` #### bssid item doc **type** var **brief** WiFi AP info BSSID **static** False **readonly** False **C++ defination code**: ```cpp std::string bssid ``` #### security item doc **type** var **brief** WiFi AP info security **static** False **readonly** False **C++ defination code**: ```cpp std::string security ``` #### channel item doc **type** var **brief** WiFi AP info channel **static** False **readonly** False **C++ defination code**: ```cpp int channel ``` #### frequency item doc **type** var **brief** WiFi AP info frequency **static** False **readonly** False **C++ defination code**: ```cpp int frequency ``` #### rssi item doc **type** var **brief** WiFi AP info rssi **static** False **readonly** False **C++ defination code**: ```cpp int rssi ``` #### ssid\\_str ```python def ssid_str(self) > str ``` item doc **type** func **brief** WiFi AP info ssid_str **static** False **C++ defination code**: ```cpp std::string ssid_str() ``` ### Wifi item doc **brief** Wifi class **C++ defination code**: ```cpp class Wifi ``` #### \\_\\_init\\_\\_ item doc **type** func **brief** Wifi class **param** **iface**: wifi interface name, default is wlan0
    **static** False **C++ defination code**: ```cpp Wifi(std::string iface \"wlan0\") ``` #### get\\_ip item doc **type** func **brief** Get current WiFi ip **return** ip, string type, if network not connected, will return empty string. **static** False **C++ defination code**: ```cpp std::string get_ip() ``` #### get\\_mac item doc **type** func **brief** Get current WiFi MAC address **return** ip, string type. **static** False **C++ defination code**: ```cpp std::string get_mac() ``` #### get\\_gateway item doc **type** func **brief** Get current WiFi ip **return** ip, string type, if network not connected, will return empty string. **static** False **C++ defination code**: ```cpp std::string get_gateway() ``` #### start\\_scan item doc **type** func **brief** WiFi start scan AP info around in background. **return** If success, return err.Err.ERR_NONE, else means failed. **static** False **C++ defination code**: ```cpp err::Err start_scan() ``` #### get\\_scan\\_result item doc **type** func **brief** Get WiFi scan AP info. **return** wifi.AP_Info list. **static** False **C++ defination code**: ```cpp std::vector get_scan_result() ``` #### stop\\_scan item doc **type** func **brief** Stop WiFi scan AP info. **static** False **C++ defination code**: ```cpp void stop_scan() ``` #### connect item doc **type** func **brief** Connect to WiFi AP. **param** **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. **static** False **C++ defination code**: ```cpp err::Err connect(const std::string &ssid, const std::string &password, bool wait true, int timeout 60) ``` #### disconnect item doc **type** func **brief** Disconnect from WiFi AP. **return** If success, return err.Err.ERR_NONE, else means failed. **static** False **C++ defination code**: ```cpp err::Err disconnect() ``` #### is\\_connected item doc **type** func **brief** See if WiFi is connected to AP. **return** If connected return true, else false. **static** False **C++ defination code**: ```cpp bool is_connected() ```"},"/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 ```python def softmax(tensor: maix.tensor.Tensor, replace: bool) > maix.tensor.Tensor ``` 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/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 ### Region item doc **brief** Region class **C++ defination code**: ```cpp class Region ``` #### \\_\\_init\\_\\_ ```python def __init__(self, x: int, y: int, width: int, height: int, format: maix.image.Format, camera: maix.camera.Camera) > None ``` item doc **type** func **brief** Construct a new Region object **param** **x**: region coordinate x
    **y**: region coordinate y
    **width**: region width
    **height**: region height
    **format**: region format
    **camera**: bind region to camera
    **static** False **C++ defination code**: ```cpp Region(int x, int y, int width, int height, image::Format format, camera::Camera *camera) ``` #### get\\_canvas ```python def get_canvas(self) > maix.image.Image ``` item doc **type** func **brief** Return an image object from region **return** image object **static** False **C++ defination code**: ```cpp image::Image *get_canvas() ``` #### update\\_canvas ```python def update_canvas(self) > maix.err.Err ``` item doc **type** func **brief** Update canvas **return** error code **static** False **C++ defination code**: ```cpp err::Err update_canvas() ``` ### Rtsp item doc **brief** Rtsp class **C++ defination code**: ```cpp class Rtsp ``` #### \\_\\_init\\_\\_ 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 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 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 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::Frame &stream) ``` #### get\\_url 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 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 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() ``` #### add\\_region item doc **type** func **brief** return a region object, you can draw image on the region. **param** **x**: region coordinate x
    **y**: region coordinate y
    **width**: region width
    **height**: region height
    **format**: region format, support Format::FMT_BGRA8888 only
    **return** the reigon object **static** False **C++ defination code**: ```cpp rtsp::Region *add_region(int x, int y, int width, int height, image::Format format image::Format::FMT_BGRA8888) ``` #### update\\_region item doc **type** func **brief** update and show region **return** error code **static** False **C++ defination code**: ```cpp err::Err update_region(rtsp::Region ®ion) ```"},"/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 ```python def os_version() > str ``` 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 ```python def device_name() > str ``` item doc **brief** Get device name **return** device name, e.g. \"MaixCAM\" **C++ defination code**: ```cpp std::string device_name() ``` ### host\\_name ```python def host_name() > str ``` item doc **brief** Get host name **return** host name, e.g. \"maixcam 2f9f\" **C++ defination code**: ```cpp std::string host_name() ``` ### host\\_domain ```python def host_domain() > str ``` item doc **brief** Get host domain **return** host domain, e.g. \"maixcam 2f9f.local\" **C++ defination code**: ```cpp std::string host_domain() ``` ### ip\\_address ```python def ip_address() > dict[str, str] ``` 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 ```python def mac_address() > dict[str, str] ``` 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 ```python def device_key() > str ``` 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 ```python def memory_info() > dict[str, int] ``` 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 ```python def bytes_to_human(bytes: int, precision: int 2, base: int 1024, unit: str 'B', sep: str ' ') > str ``` 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 ```python def cpu_freq() > dict[str, int] ``` 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 ```python def cpu_temp() > dict[str, float] ``` 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 ```python def cpu_usage() > dict[str, float] ``` 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 ```python def npu_freq() > dict[str, int] ``` 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 ```python def disk_usage(path: str '/') > dict[str, int] ``` 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 ```python def disk_partitions(only_disk: bool True) > list[dict[str, str]] ``` 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 ```python def poweroff() > None ``` item doc **brief** Power off device **C++ defination code**: ```cpp void poweroff() ``` ### reboot ```python def reboot() > None ``` 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) ``` #### get\\_backlight ```python def get_backlight(self) > float ``` item doc **type** func **brief** Get display backlight **return** value backlight value, float type, range is [0, 100] **static** False **C++ defination code**: ```cpp float get_backlight() ``` #### 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/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 ```python def disable_kernel_debug() > None ``` item doc **brief** disable the kernel debug **C++ defination code**: ```cpp void disable_kernel_debug() ``` ### enable\\_kernel\\_debug ```python def enable_kernel_debug() > None ``` 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 [pinmap](./peripheral/pinmap.html) maix.peripheral.pinmap module [pwm](./peripheral/pwm.html) maix.peripheral.pwm module [gpio](./peripheral/gpio.html) maix.peripheral.gpio module [spi](./peripheral/spi.html) maix.peripheral.spi module [uart](./peripheral/uart.html) maix uart peripheral driver [key](./peripheral/key.html) maix.peripheral.key module [i2c](./peripheral/i2c.html) maix.peripheral.i2c module [adc](./peripheral/adc.html) maix.peripheral.adc module ## Enum ## Variable ## Function ## Class"},"/maixpy/api/maix/app.html":{"title":"maix.app","content":" title: maix.app maix.app module > 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 ```python def app_id() > str ``` item doc **brief** Get current APP ID. **return** APP ID. **C++ defination code**: ```cpp string app_id() ``` ### set\\_app\\_id ```python def set_app_id(app_id: str) > str ``` 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 ```python def get_apps_info_path() > str ``` item doc **brief** Get APP info file path. **C++ defination code**: ```cpp string get_apps_info_path() ``` ### get\\_apps\\_info ```python def get_apps_info(ignore_launcher: bool False, ignore_app_store: bool False) > list[APP_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 ```python def get_app_data_path() > str ``` 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 ```python def get_app_path(app_id: str '') > str ``` 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 ```python def get_tmp_path() > str ``` 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 ```python def get_share_path() > str ``` 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 ```python def get_picture_path() > str ``` 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 ```python def get_video_path() > str ``` 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 ```python def get_font_path() > str ``` 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 ```python def get_icon_path() > str ``` 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 ```python def get_sys_config_kv(item: str, key: str, value: str '', from_cache: bool True) > str ``` 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 ```python def get_app_config_kv(item: str, key: str, value: str '', from_cache: bool True) > str ``` 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 ```python def set_app_config_kv(item: str, key: str, value: str, write_file: bool True) > maix.err.Err ``` 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 ```python def get_app_config_path() > str ``` 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 ```python def set_exit_msg(code: maix.err.Err, msg: str) > maix.err.Err ``` 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 ```python def get_exit_msg(cache: bool False) > tuple[str, maix.err.Err, str] ``` 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 ```python def have_exit_msg(cache: bool False) > bool ``` 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 ```python def switch_app(app_id: str, idx: int 1) > None ``` 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 ```python def need_exit() > bool ``` 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 ```python def running() > bool ``` 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 ```python def set_exit_flag(exit: bool) > None ``` 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 ```python def get_locale(self) > str ``` 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/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 ```python def hello(name: str) > str ``` item doc **brief** say hello to someone **param** **name**: direction [in], name of someone, string type
    **return** string type, content is hello + name **C++ defination code**: ```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 ```python def change_arg_name2(e: Example) > None ``` 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() ```"},"/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 ```python def to_str(e: Err) > 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 ```python def get_error() > str ``` item doc **brief** get last error string **return** error string **C++ defination code**: ```cpp std::string& get_error() ``` ### set\\_error ```python def set_error(str: str) > None ``` 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 ```python def check_raise(e: Err, msg: str '') > None ``` 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 ```python def check_bool_raise(ok: bool, msg: str '') > None ``` 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 ```python def check_null_raise(ptr: capsule, msg: str '') > None ``` 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/rtmp.html":{"title":"maix.rtmp","content":" title: maix.rtmp maix.rtmp module > You can use `maix.rtmp` to access this module with MaixPy > This module is generated from [MaixCDK](https://github.com/sipeed/MaixCDK) ## Module No module ## Enum ## Variable ## Function ## Class ### Rtmp item doc **brief** Rtmp class **C++ defination code**: ```cpp class Rtmp ``` #### \\_\\_init\\_\\_ item doc **type** func **brief** Construct a new Video object **note** Rtmp url : rtmp://host:prot/app/stream
    example:
    r Rtmp(\"localhost\", 1935, \"live\", \"stream\")
    means rtmp url is rtmp://localhost:1935/live/stream **param** **host**: rtmp ip
    **port**: rtmp port, default is 1935.
    **app**: rtmp app name
    **stream**: rtmp stream name
    **static** False **C++ defination code**: ```cpp Rtmp(std::string host, int port 1935, std::string app std::string(), std::string stream std::string()) ``` #### bind\\_camera item doc **type** func **brief** Bind camera **note** If the cam object is bound, the cam object cannot be used elsewhere. **param** **cam**: 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 *cam) ``` #### start item doc **type** func **brief** Start push stream **note** only support flv file now **param** **path**: File path, if you passed file path, cyclic push the file, else if you bound camera, push the camera image.
    **return** error code, err::ERR_NONE means success, others means failed **static** False **C++ defination code**: ```cpp err::Err start(std::string path std::string()) ``` #### stop item doc **type** func **brief** Stop push **return** error code, err::ERR_NONE means success, others means failed **static** False **C++ defination code**: ```cpp err::Err stop() ``` #### get\\_path item doc **type** func **brief** Get the file path of the push stream **return** file path **static** False **C++ defination code**: ```cpp std::string get_path() ``` #### get\\_path (overload 1) item doc **type** func **brief** Check whether push streaming has started **return** If rtmp thread is running, returns true **static** False **C++ defination code**: ```cpp bool is_started() ```"},"/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.audio](./maix/audio.html) maix.audio module [maix.peripheral](./maix/peripheral.html) Chip's peripheral driver [maix.rtmp](./maix/rtmp.html) maix.rtmp module [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/audio.html":{"title":"maix.audio","content":" title: maix.audio maix.audio module > You can use `maix.audio` 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** Audio type **values** **FMT_NONE**: format invalid
    **FMT_S8**: unsigned 8 bits
    **FMT_S16_LE**: signed 16 bits, little endian
    **FMT_S32_LE**: signed 32 bits, little endian
    **FMT_S16_BE**: signed 16 bits, big endian
    **FMT_S32_BE**: signed 32 bits, big endian
    **FMT_U8**: unsigned 8 bits
    **FMT_U16_LE**: unsigned 16 bits, little endian
    **FMT_U32_LE**: unsigned 32 bits, little endian
    **FMT_U16_BE**: unsigned 16 bits, big endian
    **FMT_U32_BE**: unsigned 32 bits, big endian
    **C++ defination code**: ```cpp enum Format { FMT_NONE 0, // format invalid FMT_S8, // unsigned 8 bits FMT_S16_LE, // signed 16 bits, little endian FMT_S32_LE, // signed 32 bits, little endian FMT_S16_BE, // signed 16 bits, big endian FMT_S32_BE, // signed 32 bits, big endian FMT_U8, // unsigned 8 bits FMT_U16_LE, // unsigned 16 bits, little endian FMT_U32_LE, // unsigned 32 bits, little endian FMT_U16_BE, // unsigned 16 bits, big endian FMT_U32_BE, // unsigned 32 bits, big endian } ``` ## Variable ## Function ## Class ### Recorder item doc **brief** Recorder class **C++ defination code**: ```cpp class Recorder ``` #### \\_\\_init\\_\\_ item doc **type** func **brief** Construct a new Recorder object **param** **path**: record path. the path determines the location where you save the file, if path is none, the audio module will not save file.
    **sample_rate**: record sample rate, default is 48000(48KHz), means 48000 samples per second.
    **format**: record sample format, default is audio::Format::FMT_S16_LE, means sampling 16 bits at a time and save as signed 16 bits, little endian. see @audio::Format
    **channel**: record sample channel, default is 1, means 1 channel sampling at the same time
    **static** False **C++ defination code**: ```cpp Recorder(std::string path std::string(), int sample_rate 48000, audio::Format format audio::Format::FMT_S16_LE, int channel 1) ``` #### volume item doc **type** func **brief** Set/Get record volume **param** **value**: volume value, If you use this parameter, audio will set the value to volume,
    if you don't, it will return the current volume.
    **return** the current volume **static** False **C++ defination code**: ```cpp int volume(int value 1) ``` #### record item doc **type** func **brief** Record, Read all cached data in buffer and return. **param** **record_ms**: record time. unit: ms
    **sample_rate**: audio sample rate
    **format**: audio sample format
    **channel**: audio sample channel
    **return** pcm data. datatype @see Bytes. If you pass in record_ms parameter, the return value is an empty Bytes object. **static** False **C++ defination code**: ```cpp maix::Bytes *record(int record_ms 1) ``` #### finish item doc **type** func **brief** Finish the record, if you have passed in the path, this api will save the audio data to file. **return** error code, err::ERR_NONE means success, others means failed **static** False **C++ defination code**: ```cpp err::Err finish() ``` #### sample\\_rate item doc **type** func **brief** Get sample rate **return** returns sample rate **static** False **C++ defination code**: ```cpp int sample_rate() ``` #### format item doc **type** func **brief** Get sample format **return** returns sample format **static** False **C++ defination code**: ```cpp audio::Format format() ``` #### channel item doc **type** func **brief** Get sample channel **return** returns sample channel **static** False **C++ defination code**: ```cpp int channel() ``` ### Player item doc **brief** Player class **C++ defination code**: ```cpp class Player ``` #### \\_\\_init\\_\\_ item doc **type** func **brief** Construct a new Player object **param** **path**: player path. the path determines the location where you save the file, if path is none, the audio module will not save file.
    **sample_rate**: player sample rate, default is 48000(48KHz), means 48000 samples per second.
    **format**: player sample format, default is audio::Format::FMT_S16_LE, means sampling 16 bits at a time and save as signed 16 bits, little endian. see @audio::Format
    **channel**: player sample channel, default is 1, means 1 channel sampling at the same time
    **static** False **C++ defination code**: ```cpp Player(std::string path std::string(), int sample_rate 48000, audio::Format format audio::Format::FMT_S16_LE, int channel 1) ``` #### volume item doc **type** func **brief** Set/Get player volume(Not support now) **param** **value**: volume value, If you use this parameter, audio will set the value to volume,
    if you don't, it will return the current volume.
    **return** the current volume **static** False **C++ defination code**: ```cpp int volume(int value 1) ``` #### play item doc **type** func **brief** Play **param** **data**: audio data, must be raw data
    **return** error code, err::ERR_NONE means success, others means failed **static** False **C++ defination code**: ```cpp err::Err play(maix::Bytes *data maix::audio::Player::NoneBytes) ``` #### sample\\_rate item doc **type** func **brief** Get sample rate **return** returns sample rate **static** False **C++ defination code**: ```cpp int sample_rate() ``` #### format item doc **type** func **brief** Get sample format **return** returns sample format **static** False **C++ defination code**: ```cpp audio::Format format() ``` #### channel item doc **type** func **brief** Get sample channel **return** returns sample channel **static** False **C++ defination code**: ```cpp int channel() ```"},"/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 ```python def time() > float ``` item doc **brief** Get current time in s **return** current time in s, double type **C++ defination code**: ```cpp double time() ``` ### time\\_ms ```python def time_ms() > int ``` 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 ```python def time_s() > int ``` 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 ```python def time_us() > int ``` 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 ```python def time_diff(last: float, now: float 1) > float ``` 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 ```python def sleep(s: float) > None ``` item doc **brief** Sleep seconds **param** **s**: seconds, double type
    **C++ defination code**: ```cpp void sleep(double s) ``` ### sleep\\_ms ```python def sleep_ms(ms: int) > None ``` item doc **brief** Sleep milliseconds **param** **ms**: milliseconds, uint64_t type
    **C++ defination code**: ```cpp void sleep_ms(uint64_t ms) ``` ### sleep\\_us ```python def sleep_us(us: int) > None ``` item doc **brief** Sleep microseconds **param** **us**: microseconds, uint64_t type
    **C++ defination code**: ```cpp void sleep_us(uint64_t us) ``` ### now ```python def now() > DateTime ``` item doc **brief** Get current UTC date and time **return** current date and time, DateTime type **C++ defination code**: ```cpp time::DateTime *now() ``` ### localtime ```python def localtime() > DateTime ``` item doc **brief** Get local time **return** local time, DateTime type **C++ defination code**: ```cpp time::DateTime *localtime() ``` ### strptime ```python def strptime(str: str, format: str) > DateTime ``` 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/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 ```python def isabs(path: str) > bool ``` 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 ```python def isdir(path: str) > bool ``` 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 ```python def isfile(path: str) > bool ``` 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 ```python def islink(path: str) > bool ``` 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 ```python def symlink(src: str, link: str, force: bool False) > maix.err.Err ``` 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 ```python def exists(path: str) > bool ``` 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 ```python def mkdir(path: str, exist_ok: bool True, recursive: bool True) > maix.err.Err ``` 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 ```python def rmdir(path: str, recursive: bool False) > maix.err.Err ``` 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 ```python def remove(path: str) > maix.err.Err ``` 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 ```python def rename(src: str, dst: str) > maix.err.Err ``` 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 ```python def sync() > None ``` item doc **brief** Sync files, ensure they're wrriten to disk from RAM **C++ defination code**: ```cpp void sync() ``` ### getsize ```python def getsize(path: str) > int ``` 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 ```python def dirname(path: str) > str ``` 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 ```python def basename(path: str) > str ``` 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 ```python def abspath(path: str) > str ``` 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 ```python def getcwd() > str ``` item doc **brief** Get current working directory **return** current working directory absolute path **C++ defination code**: ```cpp std::string getcwd() ``` ### realpath ```python def realpath(path: str) > str ``` 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 ```python def splitext(path: str) > str ``` 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 ```python def listdir(path: str, recursive: bool False, full_path: bool False) > list[str] ``` 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 ```python def open(self, path: str, mode: str) > maix.err.Err ``` 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 ```python def tempdir() > str ``` 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/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/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/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 ```python def set_regs_enable(enable: bool True) > None ``` 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** Set/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** Set/Get camera vertical flip **return** camera vertical flip **static** False **C++ defination code**: ```cpp int vflip(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) ``` #### get\\_channel ```python def get_channel(self) > int ``` item doc **type** func **brief** Get channel of camera **return** channel number **static** False **C++ defination code**: ```cpp int get_channel() ``` #### 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
    **return** error code, err::ERR_NONE means success, others means failed **static** False **C++ defination code**: ```cpp err::Err set_resolution(int width, int height) ``` #### exposure ```python def exposure(self, value: int 1) > int ``` item doc **type** func **brief** Set/Get camera exposure **attention** This method will affect the isp and thus the image, so please be careful with it. **param** **value**: exposure time. unit: us
    If value 1, return exposure time.
    If value ! 0, set and return exposure time.
    **return** camera exposure time **static** False **C++ defination code**: ```cpp uint64_t exposure(uint64_t value 1) ``` #### gain ```python def gain(self, value: int 1) > int ``` item doc **type** func **brief** Set/Get camera gain **attention** This method will affect the isp and thus the image, so please be careful with it. **param** **value**: camera gain.
    If value 1, returns camera gain.
    If value ! 0, set and return camera gain.
    **return** camera gain **static** False **C++ defination code**: ```cpp uint32_t gain(uint32_t value 1) ``` #### luma ```python def luma(self, value: int 1) > int ``` item doc **type** func **brief** Set/Get camera luma **attention** This method will affect the isp and thus the image, so please be careful with it. **param** **value**: luma value, range is [0, 100]
    If value 1, returns luma value.
    If value ! 0, set and return luma value.
    **return** returns luma value **static** False **C++ defination code**: ```cpp uint32_t luma(uint32_t value 1) ``` #### constrast ```python def constrast(self, value: int 1) > int ``` item doc **type** func **brief** Set/Get camera constrast **attention** This method will affect the isp and thus the image, so please be careful with it. **param** **value**: constrast value, range is [0, 100]
    If value 1, returns constrast value.
    If value ! 0, set and return constrast value.
    **return** returns constrast value **static** False **C++ defination code**: ```cpp uint32_t constrast(uint32_t value 1) ``` #### saturation ```python def saturation(self, value: int 1) > int ``` item doc **type** func **brief** Set/Get camera saturation **attention** This method will affect the isp and thus the image, so please be careful with it. **param** **value**: saturation value, range is [0, 100]
    If value 1, returns saturation value.
    If value ! 0, set and return saturation value.
    **return** returns saturation value **static** False **C++ defination code**: ```cpp uint32_t saturation(uint32_t value 1) ``` #### awb\\_mode ```python def awb_mode(self, value: int 1) > int ``` item doc **type** func **brief** Set/Get white balance mode **attention** This method will affect the isp and thus the image, so please be careful with it. **param** **value**: value 0, means set white balance to auto mode, value 1, means set white balance to manual mode, default is auto mode.
    **return** returns awb mode **static** False **C++ defination code**: ```cpp uint32_t awb_mode(uint32_t value 1) ``` #### exp\\_mode ```python def exp_mode(self, value: int 1) > int ``` item doc **type** func **brief** Set/Get exposure mode **attention** This method will affect the isp and thus the image, so please be careful with it. **param** **value**: value 0, means set exposure to auto mode, value 1, means set exposure to manual mode, default is auto mode.
    **return** returns exposure mode **static** False **C++ defination code**: ```cpp uint32_t exp_mode(uint32_t value 1) ```"},"/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 module brief [wifi](./network/wifi.html) maix.network.wifi module ## Enum ## Variable ## Function ### have\\_network ```python def have_network() > bool ``` 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 ```python def load(self, model: str) > maix.err.Err ``` 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 ```python def detect(self, img: maix.image.Image, conf_th: float 0.5, iou_th: float 0.45, fit: maix.image.Fit ...) > list[...] ``` 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 ```python def input_size(self) > maix.image.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 ```python def input_width(self) > int ``` 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 ```python def input_height(self) > int ``` 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 ```python def input_format(self) > maix.image.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\\_\\_ ```python def __init__(self, model: str '') > None ``` 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 ```python def load(self, model: str) > maix.err.Err ``` 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 ```python def classify(self, img: maix.image.Image, softmax: bool True) > list[tuple[int, float]] ``` 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 ```python def classify_raw(self, data: maix.tensor.Tensor, softmax: bool True) > list[tuple[int, float]] ``` 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 ```python def input_size(self) > maix.image.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 ```python def input_width(self) > int ``` 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 ```python def input_height(self) > int ``` 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 ```python def input_format(self) > maix.image.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 ```python def input_shape(self) > list[int] ``` 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 ```python def load(self, model: str) > maix.err.Err ``` 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\\_\\_ ```python def __init__(self, name: str '', dtype: maix.tensor.DType ..., shape: list[int] []) > None ``` 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 ```python def to_str(self) > str ``` item doc **type** func **brief** To string **static** False **C++ defination code**: ```cpp std::string to_str() ``` #### \\_\\_str\\_\\_ ```python def __str__(self) > 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\\_\\_ ```python def __init__(self, model: str '') > None ``` 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 ```python def load(self, model: str) > maix.err.Err ``` 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 ```python def loaded(self) > bool ``` 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 ```python def inputs_info(self) > list[LayerInfo] ``` 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 ```python def outputs_info(self) > list[LayerInfo] ``` 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 ```python def extra_info(self) > dict[str, str] ``` 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 ```python def forward(self, inputs: maix.tensor.Tensors) > maix.tensor.Tensors ``` 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 ```python def forward_image(self, img: maix.image.Image, mean: list[float] [], scale: list[float] [], fit: maix.image.Fit ..., copy_result: bool True) > maix.tensor.Tensors ``` 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.
    **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** 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, bool copy_result true) ``` ### FaceDetector item doc **brief** FaceDetector class **C++ defination code**: ```cpp class FaceDetector ``` #### \\_\\_init\\_\\_ item doc **type** func **brief** Constructor of FaceDetector 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 FaceDetector(const string &model \"\") ``` #### load ```python def load(self, model: str) > maix.err.Err ``` 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 ```python def detect(self, img: maix.image.Image, conf_th: float 0.5, iou_th: float 0.45, fit: maix.image.Fit ...) > list[...] ``` 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 ```python def input_size(self) > maix.image.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 ```python def input_width(self) > int ``` 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 ```python def input_height(self) > int ``` 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 ```python def input_format(self) > maix.image.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() ``` #### 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 ``` ### Retinaface item doc **brief** Retinaface class **C++ defination code**: ```cpp class Retinaface ``` #### \\_\\_init\\_\\_ item doc **type** func **brief** Constructor of Retinaface 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 Retinaface(const string &model \"\") ``` #### load ```python def load(self, model: str) > maix.err.Err ``` 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 ```python def detect(self, img: maix.image.Image, conf_th: float 0.5, iou_th: float 0.45, fit: maix.image.Fit ...) > list[...] ``` 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.4.
    **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.4, float iou_th 0.45, maix::image::Fit fit maix::image::FIT_CONTAIN) ``` #### input\\_size ```python def input_size(self) > maix.image.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 ```python def input_width(self) > int ``` 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 ```python def input_height(self) > int ``` 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 ```python def input_format(self) > maix.image.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() ``` #### 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 ``` ### 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, std::vector points std::vector()) ``` #### \\_\\_str\\_\\_ ```python def to_str(self) > 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 ``` #### points item doc **type** var **brief** keypoints **static** False **readonly** False **C++ defination code**: ```cpp std::vector points ``` ### ObjectFloat item doc **brief** Object for detect result **C++ defination code**: ```cpp class ObjectFloat ``` #### \\_\\_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 ObjectFloat(float x 0, float y 0, float w 0, float h 0, float class_id 0, float score 0, std::vector points std::vector()) ``` #### \\_\\_str\\_\\_ ```python def to_str(self) > 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 float x ``` #### y item doc **type** var **brief** Object left top coordinate y **static** False **readonly** False **C++ defination code**: ```cpp float y ``` #### w item doc **type** var **brief** Object width **static** False **readonly** False **C++ defination code**: ```cpp float w ``` #### h item doc **type** var **brief** Object height **static** False **readonly** False **C++ defination code**: ```cpp float h ``` #### class\\_id item doc **type** var **brief** Object class id **static** False **readonly** False **C++ defination code**: ```cpp float class_id ``` #### score item doc **type** var **brief** Object score **static** False **readonly** False **C++ defination code**: ```cpp float score ``` #### points item doc **type** var **brief** keypoints **static** False **readonly** False **C++ defination code**: ```cpp std::vector points ```"},"/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 ```python def load(path: str, format: Format ...) > Image ``` 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 ```python def from_bytes(width: int, height: int, format: Format, data: maix.Bytes(bytes), copy: bool True) > Image ``` 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 ```python def load_font(name: str, path: str, size: int 16) > maix.err.Err ``` 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 ```python def fonts() > list[str] ``` item doc **brief** Get all loaded fonts **return** all loaded fonts, string list type **C++ defination code**: ```cpp std::vector *fonts() ``` ### string\\_size ```python def string_size(string: str, scale: float 1, thickness: int 1, font: str '') > 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 ```python def image2cv(img: Image, bgr: bool True, copy: bool True) > numpy.ndarray[numpy.uint8] ``` 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) ``` #### to\\_jpeg item doc **type** func **brief** Convert image to jpeg **param** **quality**: the quality of jpg, default is 95. range is (50, 100].
    **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_jpeg(int quality 95) ``` #### 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, [x1, y1, x2, y2...] or [x, y, rotation_andle_in_degrees, x2, y2, rotation_andle_in_degrees2](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 means fill circle)
    **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) ``` #### 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, the same as to_jpeg functioin, it's recommend to use to_jpeg instead. **param** **quality**: The quality of the compressed image. default is 95.
    **return** Returns the compressed JPEG image **static** False **C++ defination code**: ```cpp image::Image *compress(int quality 95) ``` #### clear item doc **type** func **brief** Sets all pixels in the image to zero **param** **mask**: Mask is another image to use as a pixel level mask for the operation. The mask should be an image with just black or white pixels and should be the same size as the image being operated on.
    Only pixels set in the mask are modified. default is None.
    **return** Returns the image after the operation is completed. **static** False **C++ defination code**: ```cpp image::Image *clear(image::Image *mask nullptr) ``` #### mask\\_rectange item doc **type** func **brief** Zeros a rectangular part of the image. If no arguments are supplied this method zeros the center of the image. **param** **x**: The x coordinate of the top left corner of the rectangle.
    **y**: The y coordinate of the top left corner of the rectangle.
    **w**: The width of the rectangle.
    **h**: The height of the rectangle.
    **return** Returns the image after the operation is completed. **static** False **C++ defination code**: ```cpp image::Image *mask_rectange(int x 1, int y 1, int w 1, int h 1) ``` #### mask\\_circle item doc **type** func **brief** Zeros a circular part of the image. If no arguments are supplied this method zeros the center of the image. **param** **x**: The x coordinate of the center of the circle.
    **y**: The y coordinate of the center of the circle.
    **radius**: The radius of the circle.
    **return** Returns the image after the operation is completed. **static** False **C++ defination code**: ```cpp image::Image *mask_circle(int x 1, int y 1, int radius 1) ``` #### mask\\_ellipse item doc **type** func **brief** Zeros a ellipse part of the image. If no arguments are supplied this method zeros the center of the image. **param** **x**: The x coordinate of the center of the ellipse.
    **y**: The y coordinate of the center of the ellipse.
    **radius_x**: The radius of the ellipse in the x direction.
    **radius_y**: The radius of the ellipse in the y direction.
    **rotation_angle_in_degrees**: The rotation angle of the ellipse in degrees.
    **return** Returns the image after the operation is completed. **static** False **C++ defination code**: ```cpp image::Image *mask_ellipse(int x 1, int y 1, int radius_x 1, int radius_y 1, float rotation_angle_in_degrees 0) ``` #### binary item doc **type** func **brief** Sets all pixels in the image to black or white depending on if the pixel is inside of a threshold in the threshold list thresholds or not. **param** **thresholds**: You can define multiple thresholds.
    For GRAYSCALE format, you can use {{Lmin, Lmax}, ...} to define one or more thresholds.
    For RGB888 format, you can use {{Lmin, Lmax, Amin, Amax, Bmin, Bmax}, ...} to define one or more thresholds.
    Where the upper case L,A,B represent the L,A,B channels of the LAB image format, and min, max represent the minimum and maximum values of the corresponding channels.
    **invert**: If true, the thresholds will be inverted before the operation. default is false.
    **zero**: If zero is true, the image will be set the pixels within the threshold to 0, other pixels remain unchanged. If zero is false, the image will be set to black or white. default is false.
    **mask**: Mask is another image to use as a pixel level mask for the operation. The mask should be an image with just black or white pixels and should be the same size as the image being operated on.
    Only pixels set in the mask are modified. default is None.
    **to_bitmap**: If true, the image will be converted to a bitmap image before thresholding. default is false. TODO: support in the feature
    **copy**: Select whether to return a new image or modify the original image. default is false.
    **return** Returns the image after the operation is completed. **static** False **C++ defination code**: ```cpp image::Image *binary(std::vector> thresholds std::vector>(), bool invert false, bool zero false, image::Image *mask nullptr, bool to_bitmap false, bool copy false) ``` #### invert item doc **type** func **brief** Inverts the image in place. **return** Returns the image after the operation is completed **static** False **C++ defination code**: ```cpp image::Image *invert() ``` #### b\\_and item doc **type** func **brief** Performs a bitwise and operation between the image and the other image. **param** **other**: The other image should be an image and should be the same size as the image being operated on. TODO: support path?
    **mask**: Mask is another image to use as a pixel level mask for the operation. The mask should be an image with just black or white pixels and should be the same size as the image being operated on.
    Only pixels set in the mask are modified. default is None.
    **return** Returns the image after the operation is completed. **static** False **C++ defination code**: ```cpp image::Image *b_and(image::Image *other, image::Image *mask nullptr) ``` #### b\\_nand item doc **type** func **brief** Performs a bitwise nand operation between the image and the other image. **param** **other**: The other image should be an image and should be the same size as the image being operated on. TODO: support path?
    **mask**: Mask is another image to use as a pixel level mask for the operation. The mask should be an image with just black or white pixels and should be the same size as the image being operated on.
    Only pixels set in the mask are modified. default is None.
    **return** Returns the image after the operation is completed. **static** False **C++ defination code**: ```cpp image::Image *b_nand(image::Image *other, image::Image *mask nullptr) ``` #### b\\_or item doc **type** func **brief** Performs a bitwise or operation between the image and the other image. **param** **other**: The other image should be an image and should be the same size as the image being operated on. TODO: support path?
    **mask**: Mask is another image to use as a pixel level mask for the operation. The mask should be an image with just black or white pixels and should be the same size as the image being operated on.
    Only pixels set in the mask are modified. default is None.
    **return** Returns the image after the operation is completed. **static** False **C++ defination code**: ```cpp image::Image *b_or(image::Image *other, image::Image *mask nullptr) ``` #### b\\_nor item doc **type** func **brief** Performs a bitwise nor operation between the image and the other image. **param** **other**: The other image should be an image and should be the same size as the image being operated on. TODO: support path?
    **mask**: Mask is another image to use as a pixel level mask for the operation. The mask should be an image with just black or white pixels and should be the same size as the image being operated on.
    Only pixels set in the mask are modified. default is None.
    **return** Returns the image after the operation is completed. **static** False **C++ defination code**: ```cpp image::Image *b_nor(image::Image *other, image::Image *mask nullptr) ``` #### b\\_xor item doc **type** func **brief** Performs a bitwise xor operation between the image and the other image. **param** **other**: The other image should be an image and should be the same size as the image being operated on. TODO: support path?
    **mask**: Mask is another image to use as a pixel level mask for the operation. The mask should be an image with just black or white pixels and should be the same size as the image being operated on.
    Only pixels set in the mask are modified. default is None.
    **return** Returns the image after the operation is completed. **static** False **C++ defination code**: ```cpp image::Image *b_xor(image::Image *other, image::Image *mask nullptr) ``` #### b\\_xnor item doc **type** func **brief** Performs a bitwise xnor operation between the image and the other image. **param** **other**: The other image should be an image and should be the same size as the image being operated on. TODO: support path?
    **mask**: Mask is another image to use as a pixel level mask for the operation. The mask should be an image with just black or white pixels and should be the same size as the image being operated on.
    Only pixels set in the mask are modified. default is None.
    **return** Returns the image after the operation is completed. **static** False **C++ defination code**: ```cpp image::Image *b_xnor(image::Image *other, image::Image *mask nullptr) ``` #### awb item doc **type** func **brief** Performs an auto white balance operation on the image. TODO: support in the feature **param** **max**: if True uses the white patch algorithm instead. default is false.
    **return** Returns the image after the operation is completed. **static** False **C++ defination code**: ```cpp image::Image *awb(bool max false) ``` #### ccm item doc **type** func **brief** Multiples the passed (3x3) or (4x3) floating point color correction matrix with the image.\\nnote: Grayscale format is not support. **param** **matrix**: The color correction matrix to use. 3x3 or 4x3 matrix.
    Weights may either be positive or negative, and the sum of each column in the 3x3 matrix should generally be 1.
    example:
    {
    1, 0, 0,
    0, 1, 0,
    0, 0, 1,
    }
    Where the last row of the 4x3 matrix is an offset per color channel. If you add an offset you may wish to make the
    weights sum to less than 1 to account for the offset.
    example:
    {
    1, 0, 0,
    0, 1, 0,
    0, 0, 1,
    0, 0, 0,
    }
    **return** Returns the image after the operation is completed. **static** False **C++ defination code**: ```cpp image::Image *ccm(std::vector &matrix) ``` #### gamma item doc **type** func **brief** Quickly changes the image gamma, contrast, and brightness. Create a array whose size is usually 255,\\nand use the parameters gamma, contrast, and brightness to calculate the value of the array, and then map the\\nimage pixel value through the value of the array.\\nThe calculation method for array is: array[array_idx] (powf((array_idx / 255.0), (1 / gamma)) * contrast + brightness) * scale,\\n`powf` is a function used to calculate floating point power.\\n`array` is the array used for mapping.\\n`array_idx` is the index of the array, the maximum value is determined according to the image format, usually 255.\\n`scale` is a constant, the value is determined by the image format, usually 255.\\nMapping method:\\nAssume that a pixel value in the image is 128, then map the pixel value to the value of array[128]\\nUsers can adjust the value of the array through the gamma, contrast, and brightness parameters. **param** **gamma**: The contrast gamma greater than 1.0 makes the image darker in a non linear manner while less than 1.0 makes the image brighter. default is 1.0.
    **contrast**: The contrast value greater than 1.0 makes the image brighter in a linear manner while less than 1.0 makes the image darker. default is 1.0.
    **brightness**: The brightness value greater than 0.0 makes the image brighter in a constant manner while less than 0.0 makes the image darker. default is 0.0.
    **return** Returns the image after the operation is completed. **static** False **C++ defination code**: ```cpp image::Image *gamma(double gamma 1.0, double contrast 1.0, double brightness 0.0) ``` #### gamma\\_corr item doc **type** func **brief** Alias for Image.gamma. **param** **gamma**: The contrast gamma greater than 1.0 makes the image darker in a non linear manner while less than 1.0 makes the image brighter. default is 1.0.
    **contrast**: The contrast value greater than 1.0 makes the image brighter in a linear manner while less than 1.0 makes the image darker. default is 1.0.
    **brightness**: The brightness value greater than 0.0 makes the image brighter in a constant manner while less than 0.0 makes the image darker. default is 0.0.
    **return** Returns the image after the operation is completed. **static** False **C++ defination code**: ```cpp image::Image *gamma_corr(double gamma, double contrast 1.0, double brightness 0.0) ``` #### negate item doc **type** func **brief** Flips (numerically inverts) all pixels values in an image **return** Returns the image after the operation is completed. **static** False **C++ defination code**: ```cpp image::Image *negate() ``` #### replace item doc **type** func **brief** Replaces all pixels in the image with the corresponding pixels in the other image. **param** **other**: The other image should be an image and should be the same size as the image being operated on.
    **hmirror**: If true, the image will be horizontally mirrored before the operation. default is false.
    **vflip**: If true, the image will be vertically flipped before the operation. default is false.
    **transpose**: If true, the image can be used to rotate 90 degrees or 270 degrees.
    hmirror false, vflip false, transpose false, the image will not be rotated.
    hmirror false, vflip true, transpose true, the image will be rotated 90 degrees.
    hmirror true, vflip true, transpose false, the image will be rotated 180 degrees.
    hmirror true, vflip false, transpose true, the image will be rotated 270 degrees.
    **mask**: Mask is another image to use as a pixel level mask for the operation. The mask should be an image with just black or white pixels and should be the same size as the image being operated on.
    Only pixels set in the mask are modified. default is None.
    **return** Returns the image after the operation is completed. **static** False **C++ defination code**: ```cpp image::Image *replace(image::Image *other nullptr, bool hmirror false, bool vflip false, bool transpose false, image::Image *mask nullptr) ``` #### set item doc **type** func **brief** Alias for Image::replace. **param** **other**: The other image should be an image and should be the same size as the image being operated on.
    **hmirror**: If true, the image will be horizontally mirrored before the operation. default is false.
    **vflip**: If true, the image will be vertically flipped before the operation. default is false.
    **mask**: Mask is another image to use as a pixel level mask for the operation. The mask should be an image with just black or white pixels and should be the same size as the image being operated on.
    Only pixels set in the mask are modified. default is None.
    **return** Returns the image after the operation is completed. **static** False **C++ defination code**: ```cpp image::Image *set(image::Image *other, bool hmirror false, bool vflip false, bool transpose false, image::Image *mask nullptr) ``` #### add item doc **type** func **brief** Adds the other image to the image. **param** **other**: The other image should be an image and should be the same size as the image being operated on. TODO: support path?
    **mask**: Mask is another image to use as a pixel level mask for the operation. The mask should be an image with just black or white pixels and should be the same size as the image being operated on.
    Only pixels set in the mask are modified. default is None.
    **return** Returns the image after the operation is completed. **static** False **C++ defination code**: ```cpp image::Image *add(image::Image *other, image::Image *mask nullptr) ``` #### sub item doc **type** func **brief** Subtracts the other image from the image. **param** **other**: The other image should be an image and should be the same size as the image being operated on. TODO: support path?
    **reverse**: If true, the image will be reversed before the operation. default is false.
    **mask**: Mask is another image to use as a pixel level mask for the operation. The mask should be an image with just black or white pixels and should be the same size as the image being operated on.
    Only pixels set in the mask are modified. default is None.
    **return** Returns the image after the operation is completed. **static** False **C++ defination code**: ```cpp image::Image *sub(image::Image *other, bool reverse false, image::Image *mask nullptr) ``` #### mul item doc **type** func **brief** Multiplies the image by the other image.\\nNote: This method is meant for image blending and cannot multiply the pixels in the image by a scalar like 2. **param** **other**: The other image should be an image and should be the same size as the image being operated on. TODO: support path?
    **invert**: If true, the image will be change the multiplication operation from a*b to 1/((1/a)*(1/b)).
    In particular, this lightens the image instead of darkening it (e.g. multiply versus burn operations). default is false.
    **mask**: Mask is another image to use as a pixel level mask for the operation. The mask should be an image with just black or white pixels and should be the same size as the image being operated on.
    Only pixels set in the mask are modified. default is None.
    **return** Returns the image after the operation is completed. **static** False **C++ defination code**: ```cpp image::Image *mul(image::Image *other, bool invert false, image::Image *mask nullptr) ``` #### div item doc **type** func **brief** Divides the image by the other image.\\nThis method is meant for image blending and cannot divide the pixels in the image by a scalar like 2. **param** **other**: The other image should be an image and should be the same size as the image being operated on. TODO: support path?
    **invert**: If true, the image will be change the division direction from a/b to b/a. default is false.
    **mod**: If true, the image will be change the division operation to the modulus operation. default is false.
    **mask**: Mask is another image to use as a pixel level mask for the operation. The mask should be an image with just black or white pixels and should be the same size as the image being operated on.
    Only pixels set in the mask are modified. default is None.
    **return** Returns the image after the operation is completed. **static** False **C++ defination code**: ```cpp image::Image *div(image::Image *other, bool invert false, bool mod false, image::Image *mask nullptr) ``` #### min item doc **type** func **brief** Caculate the minimum of each pixel in the image and the other image. **param** **other**: The other image should be an image and should be the same size as the image being operated on.
    **mask**: Mask is another image to use as a pixel level mask for the operation. The mask should be an image with just black or white pixels and should be the same size as the image being operated on.
    Only pixels set in the mask are modified. default is None.
    **return** Returns the image after the operation is completed. **static** False **C++ defination code**: ```cpp image::Image *min(image::Image *other, image::Image *mask nullptr) ``` #### max item doc **type** func **brief** Caculate the maximum of each pixel in the image and the other image. **param** **other**: The other image should be an image and should be the same size as the image being operated on.
    **mask**: Mask is another image to use as a pixel level mask for the operation. The mask should be an image with just black or white pixels and should be the same size as the image being operated on.
    Only pixels set in the mask are modified. default is None.
    **return** Returns the image after the operation is completed. **static** False **C++ defination code**: ```cpp image::Image *max(image::Image *other, image::Image *mask nullptr) ``` #### difference item doc **type** func **brief** Caculate the absolute value of the difference between each pixel in the image and the other image. **param** **other**: The other image should be an image and should be the same size as the image being operated on.
    **mask**: Mask is another image to use as a pixel level mask for the operation. The mask should be an image with just black or white pixels and should be the same size as the image being operated on.
    Only pixels set in the mask are modified. default is None.
    **return** Returns the image after the operation is completed. **static** False **C++ defination code**: ```cpp image::Image *difference(image::Image *other, image::Image *mask nullptr) ``` #### blend item doc **type** func **brief** Blends the image with the other image.\\nres alpha * this_img / 256 + (256 alpha) * other_img / 256 **param** **other**: The other image should be an image and should be the same size as the image being operated on.
    **alpha**: The alpha value of the blend, the value range is [0, 256],default is 128.
    **mask**: Mask is another image to use as a pixel level mask for the operation. The mask should be an image with just black or white pixels and should be the same size as the image being operated on.
    Only pixels set in the mask are modified. default is None.
    **return** Returns the image after the operation is completed. **static** False **C++ defination code**: ```cpp image::Image *blend(image::Image *other, int alpha 128, image::Image *mask nullptr) ``` #### histeq item doc **type** func **brief** Runs the histogram equalization algorithm on the image. **param** **adaptive**: If true, an adaptive histogram equalization method will be run on the image instead which as generally better results than non adaptive histogram qualization but a longer run time. default is false.
    **clip_limit**: Provides a way to limit the contrast of the adaptive histogram qualization. Use a small value for this, like 10, to produce good histogram equalized contrast limited images. default is 1.
    **mask**: Mask is another image to use as a pixel level mask for the operation. The mask should be an image with just black or white pixels and should be the same size as the image being operated on.
    Only pixels set in the mask are modified. default is None.
    **return** Returns the image after the operation is completed. **static** False **C++ defination code**: ```cpp image::Image *histeq(bool adaptive false, int clip_limit 1, image::Image *mask nullptr) ``` #### mean item doc **type** func **brief** Standard mean blurring filter using a box filter.\\nThe parameters offset and invert are valid when threshold is True. **param** **size**: Kernel size. The actual kernel size is ((size * 2) + 1) * ((size * 2) + 1). Use 1(3x3 kernel), 2(5x5 kernel).
    **threshold**: If true, which will enable adaptive thresholding of the image which sets pixels to white or black based on a pixel’s brightness in relation to the brightness of the kernel of pixels around them.
    default is false.
    **offset**: The larger the offset value, the lower brightness pixels on the original image will be set to white. default is 0.
    **invert**: If true, the image will be inverted before the operation. default is false.
    **mask**: Mask is another image to use as a pixel level mask for the operation. The mask should be an image with just black or white pixels and should be the same size as the image being operated on.
    Only pixels set in the mask are modified. default is None.
    **return** Returns the image after the operation is completed. **static** False **C++ defination code**: ```cpp image::Image *mean(int size, bool threshold false, int offset 0, bool invert false, image::Image *mask nullptr) ``` #### median item doc **type** func **brief** Runs the median filter on the image. The median filter is the best filter for smoothing surfaces while preserving edges but it is very slow. **param** **size**: Kernel size. The actual kernel size is ((size * 2) + 1) * ((size * 2) + 1). Use 1(3x3 kernel), 2(5x5 kernel).
    **percentile**: This parameter controls the percentile of the value used in the kernel. You can set this to 0 for a min filter, 0.25 for a lower quartile filter, 0.75 for an upper quartile filter, and 1.0 for a max filter. default is 0.5.
    **threshold**: If true, which will enable adaptive thresholding of the image which sets pixels to white or black based on a pixel’s brightness in relation to the brightness of the kernel of pixels around them.
    default is false.
    **offset**: The larger the offset value, the lower brightness pixels on the original image will be set to white. default is 0.
    **invert**: If true, the image will be inverted before the operation. default is false.
    **mask**: Mask is another image to use as a pixel level mask for the operation. The mask should be an image with just black or white pixels and should be the same size as the image being operated on.
    Only pixels set in the mask are modified. default is None.
    **return** Returns the image after the operation is completed. **static** False **C++ defination code**: ```cpp image::Image *median(int size, double percentile 0.5, bool threshold false, int offset 0, bool invert false, image::Image *mask nullptr) ``` #### mode item doc **type** func **brief** Runs the mode filter on the image by replacing each pixel with the mode of their neighbors. **param** **size**: Kernel size. The actual kernel size is ((size * 2) + 1) * ((size * 2) + 1). Use 1(3x3 kernel), 2(5x5 kernel).
    **threshold**: If true, which will enable adaptive thresholding of the image which sets pixels to white or black based on a pixel’s brightness in relation to the brightness of the kernel of pixels around them.
    default is false.
    **offset**: The larger the offset value, the lower brightness pixels on the original image will be set to white. default is 0.
    **invert**: If true, the image will be inverted before the operation. default is false.
    **mask**: Mask is another image to use as a pixel level mask for the operation. The mask should be an image with just black or white pixels and should be the same size as the image being operated on.
    Only pixels set in the mask are modified. default is None.
    **return** Returns the image after the operation is completed. **static** False **C++ defination code**: ```cpp image::Image *mode(int size, bool threshold false, int offset 0, bool invert false, image::Image *mask nullptr) ``` #### midpoint item doc **type** func **brief** Runs the midpoint filter on the image.This filter finds the midpoint (max * bias + min * (1 bias)) of each pixel neighborhood in the image. **param** **size**: Kernel size. The actual kernel size is ((size * 2) + 1) * ((size * 2) + 1). Use 1(3x3 kernel), 2(5x5 kernel).
    **bias**: The bias of the midpoint. default is 0.5.
    **threshold**: If true, which will enable adaptive thresholding of the image which sets pixels to white or black based on a pixel’s brightness in relation to the brightness of the kernel of pixels around them.
    default is false.
    **offset**: The larger the offset value, the lower brightness pixels on the original image will be set to white. default is 0.
    **invert**: If true, the image will be inverted before the operation. default is false.
    **mask**: Mask is another image to use as a pixel level mask for the operation. The mask should be an image with just black or white pixels and should be the same size as the image being operated on.
    Only pixels set in the mask are modified. default is None.
    **return** Returns the image after the operation is completed. **static** False **C++ defination code**: ```cpp image::Image *midpoint(int size, double bias 0.5, bool threshold false, int offset 0, bool invert false, image::Image *mask nullptr) ``` #### morph item doc **type** func **brief** Convolves the image by a filter kernel. This allows you to do general purpose convolutions on an image. **param** **size**: Kernel size. The actual kernel size is ((size * 2) + 1) * ((size * 2) + 1). Use 1(3x3 kernel), 2(5x5 kernel).
    **kernel**: The kernel used for convolution. The kernel should be a list of lists of numbers. The kernel should be the same size as the actual kernel size.
    **mul**: This parameter is used to multiply the convolved pixel results. default is auto.
    **add**: This parameter is the value to be added to each convolution pixel result. default is 0.0.
    **threshold**: If true, which will enable adaptive thresholding of the image which sets pixels to white or black based on a pixel’s brightness in relation to the brightness of the kernel of pixels around them.
    default is false.
    **offset**: The larger the offset value, the lower brightness pixels on the original image will be set to white. default is 0.
    **invert**: If true, the image will be inverted before the operation. default is false.
    **mask**: Mask is another image to use as a pixel level mask for the operation. The mask should be an image with just black or white pixels and should be the same size as the image being operated on.
    Only pixels set in the mask are modified. default is None.
    **return** Returns the image after the operation is completed. **static** False **C++ defination code**: ```cpp image::Image *morph(int size, std::vector kernel, float mul 1, float add 0.0, bool threshold false, int offset 0, bool invert false, image::Image *mask nullptr) ``` #### gaussian item doc **type** func **brief** Convolves the image by a smoothing guassian kernel. **param** **size**: Kernel size. The actual kernel size is ((size * 2) + 1) * ((size * 2) + 1). Use 1(3x3 kernel), 2(5x5 kernel).
    **unsharp**: If true, this method will perform an unsharp mask operation instead of gaussian filtering operation, this improves the clarity of image edges. default is false.
    **mul**: This parameter is used to multiply the convolved pixel results. default is auto.
    **add**: This parameter is the value to be added to each convolution pixel result. default is 0.0.
    **threshold**: If true, which will enable adaptive thresholding of the image which sets pixels to white or black based on a pixel’s brightness in relation to the brightness of the kernel of pixels around them.
    default is false.
    **offset**: The larger the offset value, the lower brightness pixels on the original image will be set to white. default is 0.
    **invert**: If true, the image will be inverted before the operation. default is false.
    **mask**: Mask is another image to use as a pixel level mask for the operation. The mask should be an image with just black or white pixels and should be the same size as the image being operated on.
    Only pixels set in the mask are modified. default is None.
    **return** Returns the image after the operation is completed. **static** False **C++ defination code**: ```cpp image::Image *gaussian(int size, bool unsharp false, float mul 1, float add 0.0, bool threshold false, int offset 0, bool invert false, image::Image *mask nullptr) ``` #### laplacian item doc **type** func **brief** Convolves the image by a edge detecting laplacian kernel. **param** **size**: Kernel size. The actual kernel size is ((size * 2) + 1) * ((size * 2) + 1). Use 1(3x3 kernel), 2(5x5 kernel).
    **sharpen**: If True, this method will sharpen the image instead of an unthresholded edge detection image. Then increase the kernel size to improve image clarity. default is false.
    **mul**: This parameter is used to multiply the convolved pixel results. default is auto.
    **add**: This parameter is the value to be added to each convolution pixel result. default is 0.0.
    **threshold**: If true, which will enable adaptive thresholding of the image which sets pixels to white or black based on a pixel’s brightness in relation to the brightness of the kernel of pixels around them.
    default is false.
    **offset**: The larger the offset value, the lower brightness pixels on the original image will be set to white. default is 0.
    **invert**: If true, the image will be inverted before the operation. default is false.
    **mask**: Mask is another image to use as a pixel level mask for the operation. The mask should be an image with just black or white pixels and should be the same size as the image being operated on.
    Only pixels set in the mask are modified. default is None.
    **return** Returns the image after the operation is completed. **static** False **C++ defination code**: ```cpp image::Image *laplacian(int size, bool sharpen false, float mul 1, float add 0.0, bool threshold false, int offset 0, bool invert false, image::Image *mask nullptr) ``` #### bilateral item doc **type** func **brief** Convolves the image by a bilateral filter. **param** **size**: Kernel size. The actual kernel size is ((size * 2) + 1) * ((size * 2) + 1). Use 1(3x3 kernel), 2(5x5 kernel).
    **color_sigma**: Controls how closely colors are matched using the bilateral filter. default is 0.1.
    **space_sigma**: Controls how closely pixels space wise are blurred with each other. default is 1.
    **threshold**: If true, which will enable adaptive thresholding of the image which sets pixels to white or black based on a pixel’s brightness in relation to the brightness of the kernel of pixels around them.
    default is false.
    **offset**: The larger the offset value, the lower brightness pixels on the original image will be set to white. default is 0.
    **invert**: If true, the image will be inverted before the operation. default is false.
    **mask**: Mask is another image to use as a pixel level mask for the operation. The mask should be an image with just black or white pixels and should be the same size as the image being operated on.
    Only pixels set in the mask are modified. default is None.
    **return** Returns the image after the operation is completed. **static** False **C++ defination code**: ```cpp image::Image *bilateral(int size, double color_sigma 0.1, double space_sigma 1, bool threshold false, int offset 0, bool invert false, image::Image *mask nullptr) ``` #### linpolar item doc **type** func **brief** Re project’s and image from cartessian coordinates to linear polar coordinates. **param** **reverse**: If true, the image will be reverse polar transformed. default is false.
    **return** Returns the image after the operation is completed. **static** False **C++ defination code**: ```cpp image::Image *linpolar(bool reverse false) ``` #### logpolar item doc **type** func **brief** Re project’s and image from cartessian coordinates to log polar coordinates. **param** **reverse**: If true, the image will be reverse polar transformed. default is false.
    **return** Returns the image after the operation is completed. **static** False **C++ defination code**: ```cpp image::Image *logpolar(bool reverse false) ``` #### lens\\_corr item doc **type** func **brief** Performs a lens correction operation on the image. TODO: support in the feature **param** **strength**: The strength of the lens correction. default is 1.8.
    **zoom**: The zoom of the lens correction. default is 1.0.
    **x_corr**: The x correction of the lens correction. default is 0.5.
    **y_corr**: The y correction of the lens correction. default is 0.5.
    **return** Returns the image after the operation is completed. **static** False **C++ defination code**: ```cpp image::Image *lens_corr(double strength 1.8, double zoom 1.0, double x_corr 0.5, double y_corr 0.5) ``` #### rotation\\_corr item doc **type** func **brief** Performs a rotation correction operation on the image. TODO: support in the feature **param** **x_rotation**: The x rotation of the rotation correction. default is 0.0.
    **y_rotation**: The y rotation of the rotation correction. default is 0.0.
    **z_rotation**: The z rotation of the rotation correction. default is 0.0.
    **x_translation**: The x translation of the rotation correction. default is 0.0.
    **y_translation**: The y translation of the rotation correction. default is 0.0.
    **zoom**: The zoom of the rotation correction. default is 1.0.
    **fov**: The fov of the rotation correction. default is 60.0.
    **corners**: The corners of the rotation correction. default is None.
    **return** Returns the image after the operation is completed. **static** False **C++ defination code**: ```cpp image::Image *rotation_corr(double x_rotation 0.0, double y_rotation 0.0, double z_rotation 0.0, double x_translation 0.0, double y_translation 0.0, double zoom 1.0, double fov 60.0, std::vector corners std::vector()) ``` #### get\\_histogram item doc **type** func **brief** Gets the histogram of the image. **param** **thresholds**: You can define multiple thresholds.
    For GRAYSCALE format, you can use {{Lmin, Lmax}, ...} to define one or more thresholds.
    For RGB888 format, you can use {{Lmin, Lmax, Amin, Amax, Bmin, Bmax}, ...} to define one or more thresholds.
    Where the upper case L,A,B represent the L,A,B channels of the LAB image format, and min, max represent the minimum and maximum values of the corresponding channels.
    **invert**: If true, the thresholds will be inverted before the operation. default is false.
    **roi**: The region of interest, input in the format of (x, y, w, h), x and y are the coordinates of the upper left corner, w and h are the width and height of roi.
    default is None, means whole image.
    **bins**: The number of bins to use for the histogram.
    In GRAYSCALE format, setting range is [2, 256], default is 100.
    In rgb888 format, setting range is [2, 100], default is 100.
    **l_bins**: The number of bins to use for the l channel of the histogram. Only valid in RGB888 format.
    If an invalid value is set, bins will be used instead. The setting range is [2, 100], default is 100.
    **a_bins**: The number of bins to use for the a channel of the histogram.
    Only valid in RGB888 format.The setting range is [2, 256], default is 256.
    **b_bins**: The number of bins to use for the b channel of the histogram.
    Only valid in RGB888 format. The setting range is [2, 256], default is 256.
    **difference**: difference may be set to an image object to cause this method to operate on the difference image between the current image and the difference image object.
    default is None.
    **return** Returns the histogram of the image **static** False **C++ defination code**: ```cpp std::map> get_histogram(std::vector> thresholds std::vector>(), bool invert false, std::vector roi std::vector(), int bins 1, int l_bins 100, int a_bins 256, int b_bins 256, image::Image *difference nullptr) ``` #### get\\_statistics item doc **type** func **brief** Gets the statistics of the image. TODO: support in the feature **param** **thresholds**: You can define multiple thresholds.
    For GRAYSCALE format, you can use {{Lmin, Lmax}, ...} to define one or more thresholds.
    For RGB888 format, you can use {{Lmin, Lmax, Amin, Amax, Bmin, Bmax}, ...} to define one or more thresholds.
    Where the upper case L,A,B represent the L,A,B channels of the LAB image format, and min, max represent the minimum and maximum values of the corresponding channels.
    **invert**: If true, the image will be inverted before the operation. default is false.
    **roi**: The region of interest, input in the format of (x, y, w, h), x and y are the coordinates of the upper left corner, w and h are the width and height of roi.
    default is None, means whole image.
    **bins**: The number of bins to use for the statistics. default is 1.
    **l_bins**: The number of bins to use for the l channel of the statistics. default is 1.
    **a_bins**: The number of bins to use for the a channel of the statistics. default is 1.
    **b_bins**: The number of bins to use for the b channel of the statistics. default is 1.
    **difference**: The difference image to use for the statistics. default is None.
    **return** Returns the statistics of the image **static** False **C++ defination code**: ```cpp image::Statistics get_statistics(std::vector> thresholds std::vector>(), bool invert false, std::vector roi std::vector(), int bins 1, int l_bins 1, int a_bins 1, int b_bins 1, image::Image *difference nullptr) ``` #### get\\_regression item doc **type** func **brief** Gets the regression of the image. **param** **thresholds**: You can define multiple thresholds.
    For GRAYSCALE format, you can use {{Lmin, Lmax}, ...} to define one or more thresholds.
    For RGB888 format, you can use {{Lmin, Lmax, Amin, Amax, Bmin, Bmax}, ...} to define one or more thresholds.
    Where the upper case L,A,B represent the L,A,B channels of the LAB image format, and min, max represent the minimum and maximum values of the corresponding channels.
    **invert**: If true, the image will be inverted before the operation. default is false.
    **roi**: The region of interest, input in the format of (x, y, w, h), x and y are the coordinates of the upper left corner, w and h are the width and height of roi.
    default is None, means whole image.
    **x_stride**: The x stride to use for the regression. default is 2.
    **y_stride**: The y stride to use for the regression. default is 1.
    **area_threshold**: The area threshold to use for the regression. default is 10.
    **pixels_threshold**: The pixels threshold to use for the regression. default is 10.
    **robust**: If true, the regression will be robust. default is false.
    **return** Returns the regression of the image **static** False **C++ defination code**: ```cpp std::vector get_regression(std::vector> thresholds std::vector>(), bool invert false, std::vector roi std::vector(), int x_stride 2, int y_stride 1, int area_threshold 10, int pixels_threshold 10, bool robust false) ``` #### save item doc **type** func **brief** Save image to file **param** **path**: file path
    **quality**: image quality, by default(value is 95), support jpeg and png format
    **return** error code, err::ERR_NONE is ok, other is error **static** False **C++ defination code**: ```cpp err::Err save(const char *path, int quality 95) ``` #### flood\\_fill item doc **type** func **brief** Flood fills a region of the image starting from location x, y. **param** **x**: The x coordinate of the seed point.
    **y**: The y coordinate of the seed point.
    **seed_threshold**: The seed_threshold value controls how different any pixel in the fill area may be from the original starting pixel. default is 0.05.
    **floating_threshold**: The floating_threshold value controls how different any pixel in the fill area may be from any neighbor pixels. default is 0.05.
    **color**: The color to fill the region with. default is white.
    **invert**: If true, the image will be inverted before the operation. default is false.
    **clear_background**: If true, the background will be cleared before the operation. default is false.
    **mask**: Mask is another image to use as a pixel level mask for the operation. The mask should be an image with just black or white pixels and should be the same size as the image being operated on.
    Only pixels set in the mask are modified. default is None. FIXME: the mask image works abnormally
    **return** Returns the image after the operation is completed. **static** False **C++ defination code**: ```cpp image::Image *flood_fill(int x, int y, float seed_threshold 0.05, float floating_threshold 0.05, image::Color color image::COLOR_WHITE, bool invert false, bool clear_background false, image::Image *mask nullptr) ``` #### erode item doc **type** func **brief** Erodes the image in place. **param** **size**: Kernel size. The actual kernel size is ((size * 2) + 1) * ((size * 2) + 1). Use 1(3x3 kernel), 2(5x5 kernel).
    **threshold**: The number of pixels in the kernel that are not 0. If it is less than or equal to the threshold, set the center pixel to black. default is (kernel_size 1).
    **mask**: Mask is another image to use as a pixel level mask for the operation. The mask should be an image with just black or white pixels and should be the same size as the image being operated on.
    Only pixels set in the mask are modified. default is None.
    **return** Returns the image after the operation is completed. **static** False **C++ defination code**: ```cpp image::Image *erode(int size, int threshold 1, image::Image *mask nullptr) ``` #### dilate item doc **type** func **brief** Dilates the image in place. **param** **size**: Kernel size. The actual kernel size is ((size * 2) + 1) * ((size * 2) + 1). Use 1(3x3 kernel), 2(5x5 kernel).
    **threshold**: The number of pixels in the kernel that are not 0. If it is greater than or equal to the threshold, set the center pixel to white. default is 0.
    **mask**: Mask is another image to use as a pixel level mask for the operation. The mask should be an image with just black or white pixels and should be the same size as the image being operated on.
    Only pixels set in the mask are modified. default is None.
    **return** Returns the image after the operation is completed. **static** False **C++ defination code**: ```cpp image::Image *dilate(int size, int threshold 0, image::Image *mask nullptr) ``` #### open item doc **type** func **brief** Performs erosion and dilation on an image in order. **param** **size**: Kernel size. The actual kernel size is ((size * 2) + 1) * ((size * 2) + 1). Use 1(3x3 kernel), 2(5x5 kernel).
    **threshold**: As the threshold for erosion and dilation, the actual threshold for erosion is (kernel_size 1 threshold), the actual threshold for dialation is threshold. default is 0.
    **mask**: Mask is another image to use as a pixel level mask for the operation. The mask should be an image with just black or white pixels and should be the same size as the image being operated on.
    Only pixels set in the mask are modified. default is None.
    **return** Returns the image after the operation is completed. **static** False **C++ defination code**: ```cpp image::Image *open(int size, int threshold 0, image::Image *mask nullptr) ``` #### close item doc **type** func **brief** Performs dilation and erosion on an image in order. **param** **size**: Kernel size. The actual kernel size is ((size * 2) + 1) * ((size * 2) + 1). Use 1(3x3 kernel), 2(5x5 kernel).
    **threshold**: As the threshold for erosion and dilation, the actual threshold for erosion is (kernel_size 1 threshold), the actual threshold for dialation is threshold. default is 0.
    **mask**: Mask is another image to use as a pixel level mask for the operation. The mask should be an image with just black or white pixels and should be the same size as the image being operated on.
    Only pixels set in the mask are modified. default is None.
    **return** Returns the image after the operation is completed. **static** False **C++ defination code**: ```cpp image::Image *close(int size, int threshold 0, image::Image *mask nullptr) ``` #### top\\_hat item doc **type** func **brief** Returns the image difference of the image and Image.open()’ed image. **param** **size**: Kernel size. The actual kernel size is ((size * 2) + 1) * ((size * 2) + 1). Use 1(3x3 kernel), 2(5x5 kernel).
    **threshold**: As the threshold for open method. default is 0.
    **mask**: Mask is another image to use as a pixel level mask for the operation. The mask should be an image with just black or white pixels and should be the same size as the image being operated on.
    Only pixels set in the mask are modified. default is None.
    **return** Returns the image after the operation is completed. **static** False **C++ defination code**: ```cpp image::Image *top_hat(int size, int threshold 0, image::Image *mask nullptr) ``` #### black\\_hat item doc **type** func **brief** Returns the image difference of the image and Image.close()’ed image. **param** **size**: Kernel size. The actual kernel size is ((size * 2) + 1) * ((size * 2) + 1). Use 1(3x3 kernel), 2(5x5 kernel).
    **threshold**: As the threshold for close method. default is 0.
    **mask**: Mask is another image to use as a pixel level mask for the operation. The mask should be an image with just black or white pixels and should be the same size as the image being operated on.
    Only pixels set in the mask are modified. default is None.
    **return** Returns the image after the operation is completed. **static** False **C++ defination code**: ```cpp image::Image *black_hat(int size, int threshold 0, image::Image *mask nullptr) ``` #### find\\_blobs item doc **type** func **brief** Finds all blobs in the image and returns a list of image.Blob class which describe each Blob.\\nPlease see the image.Blob object more more information. **param** **thresholds**: You can define multiple thresholds.
    For GRAYSCALE format, you can use {{Lmin, Lmax}, ...} to define one or more thresholds.
    For RGB888 format, you can use {{Lmin, Lmax, Amin, Amax, Bmin, Bmax}, ...} to define one or more thresholds.
    Where the upper case L,A,B represent the L,A,B channels of the LAB image format, and min, max represent the minimum and maximum values of the corresponding channels.
    **invert**: if true, will invert thresholds before find blobs, default is false
    **roi**: The region of interest, input in the format of (x, y, w, h), x and y are the coordinates of the upper left corner, w and h are the width and height of roi.
    default is None, means whole image.
    **x_stride**: x stride is the number of x pixels to skip when doing the hough transform. default is 2
    **y_stride**: y_stride is the number of y pixels to skip when doing the hough transform. default is 1
    **area_threshold**: area threshold, if the blob area is smaller than area_threshold, the blob is not returned, default is 10
    **pixels_threshold**: pixels threshold, if the blob pixels is smaller than area_threshold, the blob is not returned,, default is 10.
    when x_stride and y_stride is equal to 1, pixels_threshold is equivalent to area_threshold
    **merge**: if True merges all not filtered out blobs whos bounding rectangles intersect each other. default is false
    **margin**: margin can be used to increase or decrease the size of the bounding rectangles for blobs during the intersection test.
    For example, with a margin of 1 blobs whos bounding rectangles are 1 pixel away from each other will be merged. default is 0
    **x_hist_bins_max**: if set to non zero populates a histogram buffer in each blob object with an x_histogram projection of all columns in the object. This value then sets the number of bins for that projection.
    **y_hist_bins_max**: if set to non zero populates a histogram buffer in each blob object with an y_histogram projection of all rows in the object. This value then sets the number of bins for that projection.
    **return** Return the blob when found blobs, format is (blob1, blob2, ...), you can use blob class methods to do more operations. **static** False **C++ defination code**: ```cpp std::vector find_blobs(std::vector> thresholds std::vector>(), bool invert false, std::vector roi std::vector(), int x_stride 2, int y_stride 1, int area_threshold 10, int pixels_threshold 10, bool merge false, int margin 0, int x_hist_bins_max 0, int y_hist_bins_max 0) ``` #### find\\_lines item doc **type** func **brief** Find lines in image **param** **roi**: The region of interest, input in the format of (x, y, w, h), x and y are the coordinates of the upper left corner, w and h are the width and height of roi.
    default is None, means whole image.
    **x_stride**: x stride is the number of x pixels to skip when doing the hough transform. default is 2
    **y_stride**: y_stride is the number of y pixels to skip when doing the hough transform. default is 1
    **threshold**: threshold threshold controls what lines are detected from the hough transform. Only lines with a magnitude greater than or equal to threshold are returned.
    The right value of threshold for your application is image dependent. default is 1000.
    **theta_margin**: theta_margin controls the merging of detected lines. default is 25.
    **rho_margin**: rho_margin controls the merging of detected lines. default is 25.
    **return** Return the line when found lines, format is (line1, line2, ...), you can use line class methods to do more operations **static** False **C++ defination code**: ```cpp std::vector find_lines(std::vector roi std::vector(), int x_stride 2, int y_stride 1, double threshold 1000, double theta_margin 25, double rho_margin 25) ``` #### find\\_line\\_segments item doc **type** func **brief** Finds all line segments in the image. **param** **roi**: The region of interest, input in the format of (x, y, w, h), x and y are the coordinates of the upper left corner, w and h are the width and height of roi.
    default is None, means whole image.
    **merge_distance**: The maximum distance between two lines to merge them. default is 0.
    **max_theta_difference**: The maximum difference between two lines to merge them. default is 15.
    **return** Return the line when found lines, format is (line1, line2, ...), you can use line class methods to do more operations **static** False **C++ defination code**: ```cpp std::vector find_line_segments(std::vector roi std::vector(), int merge_distance 0, int max_theta_difference 15) ``` #### find\\_circles item doc **type** func **brief** Find circles in image **param** **roi**: The region of interest, input in the format of (x, y, w, h), x and y are the coordinates of the upper left corner, w and h are the width and height of roi.
    default is None, means whole image.
    **x_stride**: x stride is the number of x pixels to skip when doing the hough transform. default is 2
    **y_stride**: y_stride is the number of y pixels to skip when doing the hough transform. default is 1
    **threshold**: threshold controls what circles are detected from the hough transform. Only circles with a magnitude greater than or equal to threshold are returned.
    The right value of threshold for your application is image dependent.
    **x_margin**: x_margin controls the merging of detected circles. Circles which are x_margin, y_margin, and r_margin pixels apart are merged. default is 10
    **y_margin**: y_margin controls the merging of detected circles. Circles which are x_margin, y_margin, and r_margin pixels apart are merged. default is 10
    **r_margin**: r_margin controls the merging of detected circles. Circles which are x_margin, y_margin, and r_margin pixels apart are merged. default is 10
    **r_min**: r_min controls the minimum circle radius detected. Increase this to speed up the algorithm. default is 2
    **r_max**: r_max controls the maximum circle radius detected. Decrease this to speed up the algorithm. default is min(roi.w / 2, roi.h / 2)
    **r_step**: r_step controls how to step the radius detection by. default is 2.
    **return** Return the circle when found circles, format is (circle1, circle2, ...), you can use circle class methods to do more operations **static** False **C++ defination code**: ```cpp std::vector find_circles(std::vector roi std::vector(), int x_stride 2, int y_stride 1, int threshold 2000, int x_margin 10, int y_margin 10, int r_margin 10, int r_min 2, int r_max 1, int r_step 2) ``` #### find\\_rects item doc **type** func **brief** Finds all rects in the image. **param** **roi**: The region of interest, input in the format of (x, y, w, h), x and y are the coordinates of the upper left corner, w and h are the width and height of roi.
    default is None, means whole image.
    **threshold**: The threshold to use for the rects. default is 10000.
    **return** Returns the rects of the image **static** False **C++ defination code**: ```cpp std::vector find_rects(std::vector roi std::vector(), int threshold 10000) ``` #### find\\_qrcodes item doc **type** func **brief** Finds all qrcodes in the image. **param** **roi**: The region of interest, input in the format of (x, y, w, h), x and y are the coordinates of the upper left corner, w and h are the width and height of roi.
    default is None, means whole image.
    **return** Returns the qrcodes of the image **static** False **C++ defination code**: ```cpp std::vector find_qrcodes(std::vector roi std::vector()) ``` #### find\\_apriltags item doc **type** func **brief** Finds all apriltags in the image. **param** **roi**: The region of interest, input in the format of (x, y, w, h), x and y are the coordinates of the upper left corner, w and h are the width and height of roi.
    default is None, means whole image.
    **families**: The families to use for the apriltags. default is TAG36H11.
    **fx**: The camera X focal length in pixels, default is 1.
    **fy**: The camera Y focal length in pixels, default is 1.
    **cx**: The camera X center in pixels, default is image.width / 2.
    **cy**: The camera Y center in pixels, default is image.height / 2.
    **return** Returns the apriltags of the image **static** False **C++ defination code**: ```cpp std::vector find_apriltags(std::vector roi std::vector(), image::ApriltagFamilies families image::ApriltagFamilies::TAG36H11, float fx 1, float fy 1, int cx 1, int cy 1) ``` #### find\\_datamatrices item doc **type** func **brief** Finds all datamatrices in the image. **param** **roi**: The region of interest, input in the format of (x, y, w, h), x and y are the coordinates of the upper left corner, w and h are the width and height of roi.
    default is None, means whole image.
    **effort**: Controls how much time to spend trying to find data matrix matches. default is 200.
    **return** Returns the datamatrices of the image **static** False **C++ defination code**: ```cpp std::vector find_datamatrices(std::vector roi std::vector(), int effort 200) ``` #### find\\_barcodes item doc **type** func **brief** Finds all barcodes in the image. **param** **roi**: The region of interest, input in the format of (x, y, w, h), x and y are the coordinates of the upper left corner, w and h are the width and height of roi.
    default is None, means whole image.
    **return** Returns the barcodes of the image **static** False **C++ defination code**: ```cpp std::vector find_barcodes(std::vector roi std::vector()) ``` #### find\\_displacement item doc **type** func **brief** Finds the displacement between the image and the template. TODO: support in the feature\\nnote: this method must be used on power of 2 image sizes **param** **template_image**: The template image.
    **roi**: The region of interest, input in the format of (x, y, w, h), x and y are the coordinates of the upper left corner, w and h are the width and height of roi.
    default is None, means whole image.
    **template_roi**: The region of interest rectangle (x, y, w, h) to work in. If not specified, it is equal to the image rectangle.
    **logpolar**: If true, it will instead find rotation and scale changes between the two images. default is false.
    **return** Returns the displacement of the image **static** False **C++ defination code**: ```cpp image::Displacement find_displacement(image::Image &template_image, std::vector roi std::vector(), std::vector template_roi std::vector(), bool logpolar false) ``` #### find\\_template item doc **type** func **brief** Finds the template in the image. **param** **template_image**: The template image.
    **threshold**: Threshold is floating point number (0.0 1.0) where a higher threshold prevents false positives while lowering the detection rate while a lower threshold does the opposite.
    **roi**: The region of interest, input in the format of (x, y, w, h), x and y are the coordinates of the upper left corner, w and h are the width and height of roi.
    default is None, means whole image. Only valid in SEARCH_EX mode.
    **step**: The step size to use for the template. default is 2. Only valid in SEARCH_EX mode
    **search**: The search method to use for the template. default is SEARCH_EX.
    **return** Returns a bounding box tuple (x, y, w, h) for the matching location otherwise None. **static** False **C++ defination code**: ```cpp std::vector find_template(image::Image &template_image, float threshold, std::vector roi std::vector(), int step 2, image::TemplateMatch search image::TemplateMatch::SEARCH_EX) ``` #### find\\_features item doc **type** func **brief** Finds the features in the image. TODO: support in the feature **param** **cascade**: The cascade to use for the features. default is CASCADE_FRONTALFACE_ALT.
    **threshold**: The threshold to use for the features. default is 0.5.
    **scale**: The scale to use for the features. default is 1.5.
    **roi**: The region of interest, input in the format of (x, y, w, h), x and y are the coordinates of the upper left corner, w and h are the width and height of roi.
    default is None, means whole image.
    **return** Returns the features of the image **static** False **C++ defination code**: ```cpp std::vector find_features(int cascade, float threshold 0.5, float scale 1.5, std::vector roi std::vector()) ``` #### find\\_lbp item doc **type** func **brief** Finds the lbp in the image. TODO: support in the feature. **param** **roi**: The region of interest, input in the format of (x, y, w, h), x and y are the coordinates of the upper left corner, w and h are the width and height of roi.
    default is None, means whole image.
    **return** Returns the lbp of the image **static** False **C++ defination code**: ```cpp image::LBPKeyPoint find_lbp(std::vector roi std::vector()) ``` #### find\\_keypoints item doc **type** func **brief** Finds the keypoints in the image. TODO: support in the feature. **param** **roi**: The region of interest, input in the format of (x, y, w, h), x and y are the coordinates of the upper left corner, w and h are the width and height of roi.
    default is None, means whole image.
    **threshold**: The threshold to use for the keypoints. default is 20.
    **normalized**: If true, the image will be normalized before the operation. default is false.
    **scale_factor**: The scale factor to use for the keypoints. default is 1.5.
    **max_keypoints**: The maximum number of keypoints to use for the keypoints. default is 100.
    **corner_detector**: The corner detector to use for the keypoints. default is CORNER_AGAST.
    **return** Returns the keypoints of the image **static** False **C++ defination code**: ```cpp image::ORBKeyPoint find_keypoints(std::vector roi std::vector(), int threshold 20, bool normalized false, float scale_factor 1.5, int max_keypoints 100, image::CornerDetector corner_detector image::CornerDetector::CORNER_AGAST) ``` #### find\\_edges item doc **type** func **brief** Finds the edges in the image. **param** **edge_type**: The edge type to use for the edges. default is EDGE_CANNY.
    **roi**: The region of interest, input in the format of (x, y, w, h), x and y are the coordinates of the upper left corner, w and h are the width and height of roi.
    default is None, means whole image.
    **threshold**: The threshold to use for the edges. default is 20.
    **return** Returns the edges of the image **static** False **C++ defination code**: ```cpp image::Image* find_edges(image::EdgeDetector edge_type, std::vector roi std::vector(), std::vector threshold std::vector({100, 200})) ``` #### find\\_hog item doc **type** func **brief** Finds the hog in the image. TODO: support in the feature **param** **roi**: The region of interest, input in the format of (x, y, w, h), x and y are the coordinates of the upper left corner, w and h are the width and height of roi.
    default is None, means whole image.
    **size**: The size to use for the hog. default is 8.
    **return** Returns the hog of the image **static** False **C++ defination code**: ```cpp image::Image* find_hog(std::vector roi std::vector(), int size 8) ``` #### match\\_lbp\\_descriptor item doc **type** func **brief** Matches the lbp descriptor of the image. TODO: support in the feature **param** **desc1**: The descriptor to use for the match.
    **desc2**: The descriptor to use for the match.
    **return** Returns the match of the image **static** False **C++ defination code**: ```cpp int match_lbp_descriptor(image::LBPKeyPoint &desc1, image::LBPKeyPoint &desc2) ``` #### match\\_orb\\_descriptor item doc **type** func **brief** Matches the orb descriptor of the image. TODO: support in the feature **param** **desc1**: The descriptor to use for the match.
    **desc2**: The descriptor to use for the match.
    **threshold**: The threshold to use for the match. default is 95.
    **filter_outliers**: If true, the image will be filter_outliers before the operation. default is false.
    **return** Returns the match of the image **static** False **C++ defination code**: ```cpp image::KPTMatch match_orb_descriptor(image::ORBKeyPoint &desc1, image::ORBKeyPoint &desc2, int threshold 95, bool filter_outliers false) ```"}} \ No newline at end of file diff --git a/maixpy/static/search_index/index_1.json b/maixpy/static/search_index/index_1.json index e8ec7a4c..77dbf9d1 100644 --- a/maixpy/static/search_index/index_1.json +++ b/maixpy/static/search_index/index_1.json @@ -1 +1 @@ -{"/maixpy/doc/zh/basic/os.html":{"title":"升级和烧录系统","content":" title: 升级和烧录系统 ## 介绍 如果你购买了官方(Sipeed)的带 TF 卡的套餐,一般来说出厂已经烧录好了系统,可以跳过这一步直接使用。 但是为了防止出厂烧录的系统版本过旧,强烈建议先按照教程升级到最新的系统。 ## 如何确认系统是否需要升级 * 在开机后的功能选择界面,点击`设置`,然后点击`设备信息`,可以看到系统的版本号。 * 到[MaixPy 发布历史页面](https://github.com/sipeed/MaixPy/releases)查看更新日志,里面有 MaixPy 固件和系统镜像的更新说明,如果在你的版本后有重要更新,建议升级。 > 如果最新系统和当前系统对比只是 MaixPy 固件的常规更新,也可以不升级,在 `设置` 中的 `更新 MaixPy` 中单独更新 `MaixPy` 即可。 ## 获得最新系统 在 [MaixPy 发布页面](https://github.com/sipeed/MaixPy/releases) 找到最新的系统镜像文件,比如`maixcam_os_20240401_maixpy_v4.1.0.xz`。 备用地址: * [Sourceforge](https://sourceforge.net/projects/maixpy/files/) ## 烧录系统到 MaixCAM 参考 [MaixCAM 系统烧录](https://wiki.sipeed.com/hardware/zh/maixcam/os.html) 教程。"},"/maixpy/doc/zh/basic/python_pkgs.html":{"title":"添加额外的 Python 软件包","content":" title: 添加额外的 Python 软件包 ## 简介 MaixPy 基于 Python 语言,提供了大量方便嵌入式应用开发的功能和 API,除此之外,你也可以使用其它的 Python 包来扩展功能。 ## 安装额外的 Python 包 > 注意可能不是所有 Python 包都支持,一般只支持纯 Python 包,不支持 C 扩展包, C 扩展包可能需要你手动在电脑交叉编译(比较复杂,这里就不介绍了)。 ### 方法一: 使用 Python 代码来安装 在 MaixVision 中使用 Python 代码来安装你需要的包,比如: ```python import os os.system(\"pip install 包名\") ``` 要更新一个包,可以使用: ```python import os os.system(\"pip install upgrade 包名\") ``` ### 方法二: 终端使用 pip 命令安装 使用[Linux 基础](./linux_basic.html)中介绍的终端使用方法,使用 `pip install 包名` 安装你需要的包。"},"/maixpy/doc/zh/basic/app_usage.html":{"title":"应用使用说明","content":" title: 应用使用说明 开机后会自动进入应用选择界面,内置各种应用均发布在 [MaixHub 应用商店](https://maixhub.com/app), 可以在这里找到对应应用的介绍和使用说明。 上手用得比较多的是 `设置 > 语言`, 以及 `设置 > WiFi`,`应用商店`应用可以用来升级和安装应用,连接上可以连接互联网的 WiFi 后即可在[MaixHub 应用商店](https://maixhub.com/app)扫码安装应用。 另外,你编写的应用也可以上传到[MaixHub 应用商店](https://maixhub.com/app)分享给其他人使用,质量合格和优秀的应用都会得到官方红包打赏,优秀应用也会得到大家的赞同和支持。 无论是小到一个采集传感器的数据小应用还是功能复杂的应用,让我们一起来创造更多有趣的东西吧!"},"/maixpy/doc/zh/basic/maixpy_upgrade.html":{"title":"更新 MaixPy","content":" title: 更新 MaixPy 有两种方法,如果第一次上手使用,为了降低难度,可以直接使用出厂 TF 卡自带的 MaixPy 固件尝试,以后再考虑更新。 不过因为不知道你拿到手的是什么时候出厂的 TF 卡,所以建议都更新一下系统。 ## 直接更新系统 按照 [升级和烧录系统](./os.html) 中的操作升级到最新的系统,里面就包含了最新的 MaixPy 固件。 ## 只更新 MaixPy 固件 在 [MaixPy 仓库 release 页面](https://github.com/sipeed/MaixPy/releases) 看到最新的版本信息和更新日志,其中包含了 MaixPy 固件信息,以及对应版本使用的系统信息。 如果不想更新系统(因为一般系统变动不大,可以看 MaixPy 更新日志中是否有系统改动相关,再决定是否更新系统),则可以只更新 MaixPy 固件。 * 在设置中设置 WiFi, 让系统联网。 * 点击设置应用中的 `更新 MaixPy` 进行更新。 > 如果你会使用终端, 也可以在终端中使用 `pip install MaixPy U` 来更新 MaixPy。"},"/maixpy/doc/zh/pro/compile_os.html":{"title":"","content":""},"/maixpy/doc/zh/vision/ai.html":{"title":"AI 视觉基本知识","content":" title: AI 视觉基本知识 update: date: 2024 04 03 author: neucrack version: 1.0.0 content: 初版文档 ## 简介 如果没有 AI 基础,在学习 AI 前可以先看[什么是人工智能(AI)和机器学习](https://wiki.sipeed.com/ai/zh/basic/what_is_ai.html) 了解一下 AI 的基本概念。 然后我们使用的视觉 AI 一般都是基于`深度神经网络学习`这个方法,有兴趣可以看看[深度神经网络(DNN)基础知识](https://wiki.sipeed.com/ai/zh/basic/dnn_basic.html) ## MaixPy 中使用视觉 AI 在 MaixPy 中使用视觉 AI 很简单,默认提供了常用的 AI 模型,不需要自己训练模型就可以直接使用,在[MaixHub 模型库](https://maixhub.com/model/zoo) 中选择`maixcam` 就可以找到。 并且在底层已经封装好的 API,只需要简单的调用就可以实现。 如果你想训练自己的模型,也可以先从[MaixHub 在线训练](https://maixhub.com/model/training/project) 开始,在线平台只需要点点点就能训练出模型,不需要购买昂贵的机器,不需要搭建复杂的开发环境,也不需要写代码,非常适合入门,也适合懒得翻代码的老手。 一般训练得到了模型文件,直接传输到设备上,调用 MaixPy 的 API 就可以使用了,具体的调用方法看后文。"},"/maixpy/doc/zh/vision/self_learn_detector.html":{"title":"MaixPy 自学习检测器","content":" title: MaixPy 自学习检测器 ## MaixPy 自学习检测器 和自学习分类器类似,不需要训练,直接拍摄几张要检测的物体照片即可实现检测,在简单检测场景下十分好用。 和自学习分类器不同的是因为是检测器,会有物体的坐标和大小。 ## MaixPy 中使用自学习检测器 TODO:"},"/maixpy/doc/zh/faq.html":{"title":"MaixPy FAQ(常见问题)","content":" title: MaixPy FAQ(常见问题) 此页面列出了 MaixPy 相关的常见问题和解决方案,如果你遇到了问题,请先在这里找寻答案。 如果这个页面找不到答案,可以到 [MaixHub 讨论版块](https://maixhub.com/discussion) 将问题的详细步骤发贴提问。 如果你使用的是 MaixCAM, 也可以参考 [MaixCAM FAQ](https://wiki.sipeed.com/hardware/zh/maixcam/faq.html) ## MaixVision 无法搜索到设备? 先确认连接方式是 WiFi 还是 USB 线, **WiFi**: * 确认 WiFi 是否正确连接上并且获取到 IP 地址, 可以在 `设置 >设备信息` 或者`设置 >WiFi` 里面看到 `ip`。 **USB线**: * 确保设备通过 Type C 数据线连接到电脑,设备处于开机状态并且进入了功能选择界面。 * 确保设备驱动已经安装: * Windows 下可以在`设备管理器`中查看是否有 USB 虚拟网卡设备,如果有感叹号则是去动没有安装好,按照[快速开始](./index.html) 中的方法安装驱动即可。 * Linux 下可以通过`ifconfig`或者`ip addr`查看是否有`usb0`设备或者`lsusb`查看所有 USB 设备。 Linux 已经自带去动,所以识别不到检查硬件连接,设备系统是否是最新,以及设备是否已经正常启动即可。 * Mac OS 同 Linux 方法。 * 另外 检查 USB 线缆的质量,换一个高质量的线缆。 * 另外 检查电脑 USB 口的质量,比如实测某些小主机 USB 口 EMI 设计太糟糕,外接一个质量好点的 USB HUB 反而可以使用了,也可以换 USB 口 或者直接换台电脑。 ## MaixVision 运行摄像头例程显示图像卡顿 默认配的 GC4653 摄像头最高帧率为 30 帧,摄像头例程正常情况下 MaixVision 的显示肉眼不会有卡顿感,如果卡顿,首先考虑传输问题: * 检查网络连接质量,比如 WiFi。 * 如果用的 USB 连接,检查 USB 线质量, 电脑 USB 口质量,可以尝试换台电脑或者 USB 口 或者 USB 线缆尝试对比。 ## MaixPy v4 和 v1 v3 有什么区别? * MaixPy v4 使用 Python 语言,是吸取了 v1 v3 经验的集大成之作,有更好的配套软件和生态,更多的功能,更简单的使用方式和更完善的文档;硬件有很大提升的同时加个和另外两者的硬件价格想当甚至更便宜;另外也做了兼容 K210 的使用体验和 API,方便用户从 v1 快速迁移到 v4。 * v1 使用了 Micropython 语言,有很多局限性,比如第三方库支持有限;同时受限于 Maix I (K210) 的硬件性能,内存不够用,AI 模型支持有限,很多编解码不支持硬件加速等缺点。 * v3 也是使用了 Python 语言,基于 Maix II Dock (v831) 硬件,硬件 AI 模型支持有限,而且全志的基础生态不够开放,API 也不够完善,此版本仅作为 Maix II Dock (v831)上面使用,不会继续更新。 ## MaixPy 目前只支持 MaixCAM 吗,用其它同款芯片的板子行不行? MaixPy 目前仅支持 MaixCAM 系列板子,其它同款芯片的板子也不支持(包括 Sipeed 的同款芯片板子 比如 LicheeRV Nano),强烈不建议尝试,导致设备损坏(比如冒烟烧屏等)后果自负。 未来 Sipeed 出的 Maix 系列的产品都将继续得到 MaixPy 支持,目前如果 MaixCAM 有什么无法满足的需求,可以到 [MaixHub 讨论版块](https://maixhub.com/discussion) 提出需求或者发送邮件到 support@sipeed.com. ## 可以用除了官方搭配的摄像头或者屏幕以外的自己的摄像头或者屏幕吗? 不建议这样操作,除非你有够丰富的软硬件知识和经验,否则可能导致设备损坏。 官方搭配的配件对应的软硬件是调教过的,表现效果是最好的,上手即可使用,其它配件可能接口不同,驱动不同,软件不同,需要自己去调教,这是一个非常复杂的过程,不建议尝试。 当然,如果你是大佬,我们也欢迎你提交 PR! ## 运行模型报错 cvimodel built for xxxcv181x CANNOT run on platform cv181x 解析模型文件失败了,一般情况是模型文件损坏造成的,确保你的模型文件是没有损坏的。 比如: * 如果是从网上下载的,保证下载没有出问题,一般网上的文件提供 sha256sum/md5 校验值,下载下来后可以对比一下,具体方法请自行搜索或者问 ChatGPT。 * 如果是来自压缩包,请确认解压过程没有出错,可以从压缩包重新解压一遍保证中间没有出错。 * 保证传输到设备的过程没有造成文件损坏,可以对比一下设备中的文件和电脑中的文件 sha256sum 值,具体方法请自性搜索或者问 ChatGPT。 ## 上电启动黑屏,屏幕无显示 * 检查是否安装了 TF(micro SD)卡。 * 检查 TF 卡里面是否烧录了最新的系统镜像(强烈推荐烧录到最新的系统镜像),具体烧录方法看文档。 * 检查 TF 卡是否完全插进到了 TF 卡口,确保没有缝隙和松动。 * 检查屏幕和摄像头排线是否正确扣紧了,不能出现松动现象。 * 检查板子上的电源灯(红灯)以及系统运行状态灯(蓝灯)是否亮起,如果红灯不亮则考虑硬件问题,比如无供电或者供电不足或者板子烧坏了。 * 用 USB 转 TTL 连接电脑和板子的串口,电脑打开串口助手,让板子重启,查看启动日志里面是否有报错。 > 如果没有日志输出,可以尝试交换一下 TX 和 RX 接线, 对于 MaixCAM, Type C 转 串口小板插的方向不一样 TX RX 可能反向,即不支持正反插。"},"/maixpy/doc/zh/basic/python.html":{"title":"Python 基础知识","content":" title: Python 基础知识 MaixPy 的教程文档里面就不涉及具体的 Python 语法教程了,因为 Python 的教程实在是太多了,都做得很好,这里只介绍需要学什么,方向和线路指导即可。 ## Python 简介 Python 是一门解释性、面向对象、动态类型的高级编程语言。 * 解释性:不需要编译,直接运行,优点是开发快速,缺点是因为每次运行都要解释一遍代码,运行速度慢一点点,但是往往瓶颈还是开发者写的代码而不是语言本身。 * 面向对象:支持面向对象编程,可以定义类和对象,相比面向过程语言,更容易组织代码。更多自行搜索。 * 动态类型:变量不需要声明类型,可以直接赋值,类型会根据赋值自动确定,这样可以减少代码量,但是也容易出现类型错误,需要开发者自己注意。 总之,对于没有接触过 Python 的开发者来说,Python 非常容易上手,有大量现成的库,开发者群体巨大,开发应用周期短,非常值得学习! ## Python 环境安装 你可以按照你学习的 Python 教程在电脑上安装 Python; 也可以在 MaixVisioin 上连接设备后使用 MaixVision 编程然后在开发板运行。 ## 使用 MaixPy 需要的 Python 基础有哪些? * Python 的基本概念。 * 面向对象编程的基本概念。 * Python 的基本语法,包括: * tab 缩进对齐语法 * 变量、函数、类、对象、注释等 * 控制语句比如 if、for、while 等等 * 模块和导入模块 * 基本数据类型比如 int、float、str、list、dict、tuple 等等 * bytes 和 str 的区别和转换 * 异常处理,try except * 常用的内置函数,比如 print、open、len、range 等等 * 常用的内置模块,比如 os、sys、time、random、math 等等 掌握以上的基础知识就可以顺畅使用 MaixPy 编程了,配合后面的教程和例程,在不懂的时候查询搜索引擎或者官方文档,或者问 ChatGPT 就能顺利完成开发。 ## 对于已经有一门面向对象编程语言经验的开发者 如果你已经会一门面向对象语言比如 C++/Java/C# 等等,那只需要快速浏览一下 Python 的语法,就可以开始使用了。 比如 [菜鸟教程](https://www.runoob.com/python3/python3 tutorial.html) 或者 [Python 官方教程](https://docs.python.org/3/tutorial/index.html)。 或者个人开发者的博客,比如 [哇!是 Python](https://neucrack.com/p/59)。 ## 对于没有面向对象编程经验但是有 C 语言经验的开发者 如果只学了 C,缺乏对面向对象的理解,那么可以先学习一下面向对象的概念,然后再学习 Python,也是比较快的,可以自行搜索视频教程入门。 跟着视频教程入门之后可以看看文档教程,比如 [菜鸟教程](https://www.runoob.com/python3/python3 tutorial.html) 或者 [Python 官方教程](https://docs.python.org/3/tutorial/index.html) 就可以开动了! 在学了入门知识后,就可以按照 MaixPy 的文档和例程开始使用 MaixPy 编程了。 ## 对于编程新手 如果你从未接触过编程,那么你需要重头开始学习 Python,Python 作为入门语言也是比较合适的,具体可以搜一搜视频教程。 在学会了基础语法后,就能按照例程使用 MaixPy 编程了。"},"/maixpy/doc/zh/basic/linux_basic.html":{"title":"Linux 基础知识","content":" title: Linux 基础知识 ## 简介 本章内容对于刚入门的同学来说,可以先跳过此章节,在学会 MaixPy 基础开发后再来学习也是可以的。 最新的 MaixPy 支持的 MaixCAM 硬件支持跑 Linux 系统,所以 MaixPy 底层都是基于 Linux 系统进行开发的。 虽然 Sipeed 开发的 MaixPy 已经为开发者们做了很多工作,即使不知道 Linux 系统知识也能愉快使用,但是以防在某些情况下需要一些底层操作,以及方便未接触过 Linux 的开发者学习,这里写一些 Linux 基础知识。 ## 为什么需要 Linux 系统 具体的原因大家可以自行查阅,这里用通俗的看起来不太专业的话语简单举几个例子方便初学者理解: * 在单片机中,我们的程序是一个死循环程序,用上 Linux 后我们可以同时跑很多程序,每个程序看起来都独立在同时运行,每个程序具体怎么执行的由操作系统实现。 * 基于 Linux 的开发者众多,需要功能和驱动可以很方便地找到,不需要自己再实现一遍。 * 基于 Linux 配套的软件工具丰富,可以很方便地进行开发和调试,比如在本教程没有提到的一些 Linux 通用工具理论上也是可以使用的。 ## 文件系统 什么是文件系统? * 就像电脑的文件系统一样,Linux 上会将硬件磁盘用文件系统进行管理,这样我们可以很方便地向磁盘读写数据。 * 对于学过单片机没有接触过文件系统开发的同学来讲,可以理解为我们有一个 Flash 或者 TF 卡,我们可以通过 API 读写 Flash 存取数据,断电后也能保存数据,但是 Flash 具有读写寿命,我们往往需要写一套程序去保证 Flash 读写寿命,而文件系统就可以理解成这样一套成熟的程序,文件系统帮我们完成了具体如何管理 Flash 空间和读写,我们只需调用文件系统的 API 即可,大大减少了我们的开发工作量并且用成熟的程序保证了稳定性和安全性。 ## 在电脑和设备(开发板)之间传输文件 既然设备有 Linux 和文件系统,那我们怎么发送文件到设备呢? 对于 MaixPy 我们配套了 MaixVision, 在后面的版本也会支持文件管理功能,在此之前可以用下面的方法: 这里我们主要介绍通过网络传输的方式,其它方式可自行探索`传输文件到 Linux`: * 确保设备和电脑连接到了同一个局域网,比如: * MaixCAM 的 USB 口连接到电脑会创建一个虚拟网卡,在电脑端的设备管理器就能看到,设备的 IP 可以在设备的`设置 >设备信息`中看到设备名和 IP。 * 也可以在设备`设置 >WiFi`中连接到和电脑相同的局域网。 * 电脑使用 SCP 或者 SFTP 协议传输文件到设备,具体的软件有很多,具体的软件和使用方法可以自行搜索,比如: * 在 Windows 上可以使用 WinSCP 或者 FileZilla,或者 scp 命令等。 * 在 Linux 上可以使用 FileZilla 或者 scp 命令 等。 * 在 Mac 上可以使用 FileZilla 或者 scp 命令 等。 ## 终端和命令行 终端就是通过`终端`这个软件与 Linux 系统进行通信和操作的工具,类似于 Windows 的`cmd`或者`PowerShell`。 比如我们可以在电脑的 Window 系统中的 powershell 或者 Linux系统中的 终端 工具中输入`ssh root@maixcam xxxx.local` 这里具体的名字在设备的`设置 >设备信息`中可以看到,这样我们就可以通过终端连接到设备了(用户名和密码都是`root`)。 然后我们通过输入命令来操作设备,比如`ls`命令可以列出设备文件系统中当前目录下的文件, `cd` 用来切换当前所在的目录(就像电脑文件管理中点击文件夹切换目录一样), ```shell cd / # 切换到根目录 ls # 显示当前目录(根目录)下的所有文件 ``` 然后会显示类似下面的内容: ```shell bin lib media root tmp boot lib64 mnt run usr dev linuxrc opt sbin var etc lost+found proc sys ``` 更多命令学习请自行搜索`Linux 命令行使用教程`,这里只是为了让初学者知道基本概念,这样有开发者提到时可以知道是什么意思。"},"/maixpy/doc/zh/basic/maixvision.html":{"title":"MaixVision -- MaixPy 编程 + 图形化积木编程","content":" title: MaixVision MaixPy 编程 + 图形化积木编程 ## 简介 MaixVision 是专为 Maix 生态打造的一款开发者编程工具,支持 MaixPy 编程和图形化积木编程,同时支持在线运行和调试,以及实时预览图像,可以同步设备显示屏的图像,方便调试和开发。 以及支持打包应用和安装应用到设备,方便用户一键生成、安装应用。 同时还集成一些方便开发的小工具,比如文件管理,阈值编辑器,二维码生成等等。 ## 使用 MaixPy 编程和在线运行 按照[快速开始](../index.html)的步骤连接设备,我们可以很方便地使用 MaixPy 编程和在线运行。 ## 实时预览图像 MaixPy 提供`display`模块,可以将图像显示到屏幕上,同时,在调用`display`模块的`show`方法时,会将图像发送到 MaixVision 显示,比如代码: ```python from maix import display, camera cam camera.Camera(640, 480) disp display.Display() while 1: disp.show(cam.read()) ``` 这里我们用摄像头读取了图像,然后通过`disp.show()`方法将图像显示到屏幕上,同时也会发送到 MaixVision 显示。 当我们点击了右上角的`暂停`按钮,就会停止发送图像到 MaixVision 显示。 ## 计算图像的直方图 在上一步中我们可以在 MaixVision 中实时看到图像,我们用鼠标框选一个区域,图像下方就能看到这个区域的直方图了,选择不同的颜色表示方法,可以看到不同的颜色通道的直方图。 这个功能方便我们在做某些图像处理算法时找到一些合适的参数。 ## 使用图形化积木编程 开发中,敬请期待。 ## 区分`设备文件系统`和`电脑文件系统` 这里我们有一个比较重要的概念需要掌握:**分清楚`设备文件系统`和`电脑文件系统`**。 * **电脑文件系统**:运行在电脑上,在 MaixVision 中打开文件或者工程都是打开的电脑里面的文件,保存也是自动保存到电脑的文件系统。 * **设备文件系统**:程序运行时会将程序发送到设备上运行,所以代码里面使用的文件都是从设备文件系统读取。 所以常见的问题是有同学在电脑上保存了文件`D:\\data\\a.jpg`,然后在设备上使用这个文件`img image.load(\"D:\\data\\a.jpg\")`,这样当然是找不到文件的,因为设备上没有`D:\\data\\a.jpg`这个文件。 具体如何将电脑的文件发送到设备上,参考下面的章节。 ## 传输文件到设备 开发中,敬请期待。 目前可以用其它工具代替: 先知道设备的 ip 地址或者设备名称,MaixVision 就可以搜索到, 或者在设备`设置 >系统信息`中看到,比如类似 `maixcam xxxx.local` 或者 `192.168.0.123`。 用户名和密码都是 `root`, 使用 `SFTP` 协议传输文件,端口号是 `22`。 然后不同系统下都有很多好用的软件: ### Windows 下 使用 [WinSCP](https://winscp.net/eng/index.php) 或者 [FileZilla](https://filezilla project.org/) 等工具连接设备,将文件传输到设备上,选择 `SFTP` 协议填写设备和账号信息连接即可。 具体不懂的可以自行搜索。 ### Linux 下 终端使用 `scp` 命令传输文件到设备上,比如: ```bash scp /path/to/your/file.py root@maixcam xxxx.local:/root ``` ### Mac 下 * **方法一**:终端使用 `scp` 命令传输文件到设备上,比如: ```bash scp /path/to/your/file.py root@maixcam xxxx.local:/root ``` * **方法二**:使用 [FileZilla](https://filezilla project.org/) 等工具连接设备,将文件传输到设备上,选择 `SFTP` 协议填写设备和账号信息连接即可。"},"/maixpy/doc/zh/basic/app.html":{"title":"应用开发和应用商店","content":" title: 应用开发和应用商店 ## 应用生态简介 为了让开发板做到开箱即用,以及方便用户无门槛地使用,以及方便开发者分享自己的有趣应用,并且能有有效的渠道获取到反馈甚至是收益,我们推出了一个简易的应用框架,包括: * **[应用商店](https://maixhub.com/app)**: 开发者上传分享应用,用户无需开发直接下载使用,开发者可以获取到一定的现金收益(来自 MaixHub 官方以及用户打赏)。 * **出厂内置大量应用**: 官方提供了一些常用的应用,比如找色块、AI 物体检测追踪、找二维码、人脸识别等等,用户可以直接使用,也可以作为串口模块直接使用。 * **MaixPy + MaixCDK** 软件开发包:使用 [MaixPy](https://github.com/sipeed/maixpy) 或者 [MaixCDK](https://github.com/sipeed/MaixCDK) 可以用 Python 或者 C/C++ 语言快速开发嵌入式 AI 视觉听觉应用,超高效率实现你的有趣想法。 * **MaixVision** 配套电脑端开发工具: 全新的电脑端代码开发工具,快速上手、调试、运行、上传代码、安装应用到设备,一键式开发,甚至支持图像化积木式编程,小学生也能轻松上手。 大家可以多多关注应用商店,也可以在应用商店中分享自己的应用,大家一起共建活跃的社区。 ## 打包应用 使用 MaixPy + MaixVison 可以方便地开发、打包、安装应用: * 在 MaixVision 中使用 MaixPy 开发应用程序,可以是单个文件,也可以是一个工程目录。 * 连接设备。 * 点点击 MaixVision 左下角的 安装 按钮,会弹出一个界面填写应用的基本信息,id 是用来判别应用的 id,一个设备不能同时安装相同 id 的不同应用,所以 id 应该与 MaixHub 上面已经有的应用 id 不同,应用名字可以重复。以及图标等。 * 点击打包应用,会将应用打包成一个安装包,如果你要上传到 [MaixHub 应用商店](https://maixhub./com/app),用这个打包好的文件即可。 * 点击 安装应用,这会将打包好的应用安装到设备。 * 断开与设备的连接,就能看到设备功能选择界面多了一个你的应用,直接点进去就能运行。 > 如果你用 MaixCDK 开发,使用 `maixcdk relrease` 就能打包出来一个应用,具体看 MaixCDK 的文档。 ## 退出应用 如果你只是写了比较简单的应用,没有做界面和返回按钮,默认可以按设备上的功能按键(一般是 USER 或者 FUNC 或者 OK 按钮)或者返回按钮(如果有这个按键,MaixCAM 默认没有这个按键)来退出应用。 ## 应用开发基本准则 * 因为默认都配了触摸屏幕,推荐都写一个简单的界面显示,最好有触摸交互。实现方法可以在例子里面找找参考。 * 界面和按钮不要太小,因为 MaixCAM 默认的屏幕是 2.3寸 552x368分辨率,PPI 比较高屏幕比较小,要让手指能很容易戳到并且不会点错。 * 每个应用实现的主要功能实现一个简单的串口交互,基于[串口协议](https://github.com/sipeed/MaixCDK/blob/master/docs/doc/convention/protocol.md) ([例程](https://github.com/sipeed/MaixPy/tree/main/examples/communication/protocol)),这样用户可以直接当成串口模块使用,比如人脸检测应用,可以在检测到人脸后通过串口输出坐标。"},"/maixpy/doc/zh/vision/qrcode.html":{"title":"MaixPy 二维码识别","content":" title: MaixPy 二维码识别 update: date: 2024 04 03 author: lxowalle version: 1.0.0 content: 初版文档 阅读本文前,确保已经知晓如何开发MaixPy,详情请阅读[MaixVision MaixPy 编程 + 图形化积木编程](../basic/maixvision.html) ## 简介 本文介绍如何使用MaixPy来识别二维码 ## 使用 MaixPy 识别二维码 MaixPy的 `maix.image.Image`中提供了`find_qrcodes`方法,用来识别二维码。 ### 如何识别二维码 一个简单的示例,实现识别二维码并画框 ```python from maix import image, camera, display cam camera.Camera(320, 240) disp display.Display() while 1: 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) ``` 步骤: 1. 导入image、camera、display模块 ```python from maix import image, camera, display ``` 2. 初始化摄像头和显示 ```python cam camera.Camera(320, 240) # 初始化摄像头,输出分辨率320x240 RGB格式 disp display.Display() ``` 3. 从摄像头获取图片并显示 ```python while 1: img cam.read() disp.show(img) ``` 4. 调用`find_qrcodes`方法识别摄像头中的二维码 ```python qrcodes img.find_qrcodes() ``` `img`是通过`cam.read()`读取到的摄像头图像,当初始化的方式为`cam camera.Camera(320, 240)`时,`img`对象是一张分辨率为320x240的RGB图。 `img.find_qrcodes`用来寻找二维码,并将查询结果保存到`qrocdes`,以供后续处理 5. 处理识别二维码的结果并显示到屏幕上 ```python 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`是通过`img.find_qrcodes()`查询二维码的结果,如果找不到二维码则`qrcodes`内部为空 `qr.corners()`用来获取已扫描到的二维码的四个顶点坐标,`img.draw_line()`利用这四个顶点坐标画出二维码的形状 `img.draw_string`用来显示二维码的内容和位置等信息,其中`qr.x()`和`qr.y()`用来获取二维码左上角坐标x和坐标y,`qr.payload()`用来获取二维码的内容 ### 常用参数说明 列举常用参数说明,如果没有找到可以实现应用的参数,则需要考虑是否使用其他算法实现,或者基于目前算法的结果扩展所需的功能 参数 说明 示例 roi 设置算法计算的矩形区域,roi [x, y, w, h],x,y表示矩形区域左上角坐标,w,h表示矩形区域的宽度和高度,默认为整张图片 计算坐标为(50,50),宽和高为100的区域
    ```img.find_qrcodes(roi [50, 50, 100, 100])``` 本文介绍常用方法,更多 API 请看 API 文档的 [image](../../../api/maix/image.html) 部分。"},"/maixpy/doc/zh/vision/camera.html":{"title":"MaixPy 摄像头使用","content":" title: MaixPy 摄像头使用 update: date: 2024 04 03 author: neucrack version: 1.0.0 content: 初版文档 ## 简介 对于 MaixCAM 默认搭载了 GC4653 摄像头,或者可选的 OS04A10 摄像头或者全局快门摄像头,甚至是 HDMI 转 MIPI 模块,都可以直接用简单的 API 调用。 ## API 文档 本文介绍常用方法,更多 API 使用参考 [maix.camera](/api/maix/camera.html) 模块的文档。 ## 摄像头切换 不同的摄像头使用不同的驱动,需要在系统中选择正确的驱动。 TODO:如何切换摄像头,比如 GC4653 和 OS04A10 之间的切换。 ## 从摄像头获取图像 使用 MaixPy 轻松获取: ```python from maix import camera cam camera.Camera(640, 480) while 1: img cam.read() print(img) ``` 这里我们从`maix`模块导入`camera`模块,然后创建一个`Camera`对象,指定图像的宽度和高度。然后在一个循环中不断读取图像, 默认出的图为`RGB`格式,如果需要`BGR`格式,其它格式请看 API 文档。 ## 跳过 开头的帧 摄像头初始化的一小段时间,可能图像采集还没稳定出现奇怪的画面,可以通过`skip_frames`函数跳过开头的几帧: ```python cam camera.Camera(640, 480) cam.skip_frames(30) # 跳过开头的30帧 ``` ## 显示图像 MaixPy 提供了`display`模块,可以方便的显示图像: ```python from maix import camera, display cam camera.Camera(640, 480) disp display.Display() while 1: img cam.read() disp.show(img) ```"},"/maixpy/doc/zh/vision/find_blobs.html":{"title":"MaixPy 寻找色块","content":" title: MaixPy 寻找色块 update: date: 2024 04 03 author: neucrack version: 1.0.0 content: 初版文档 date: 2024 04 03 author: lxowalle version: 1.0.1 content: 添加寻找色块的详细用法 阅读本文前,确保已经知晓如何开发MaixPy,详情请阅读[MaixVision MaixPy 编程 + 图形化积木编程](../basic/maixvision.html) ## 简介 本文将介绍如何使用MaixPy来寻找色块,以及如何使用MaixCam的默认应用程序寻找色块。 在视觉应用中,寻找色块是一个非常常见的需求,比如机器人找色块,自动化生产线找色块等等,即需要识别画面中的特定的颜色区域,获取这个区域的位置和大小等信息。 ## 使用 MaixPy 寻找色块 MaixPy的 `maix.image.Image`中提供了`find_blobs`方法,可以方便的找色块。 ### 如何寻找色块 一个简单的示例,实现寻找色块并画框 ```python from maix import image, camera, display cam camera.Camera(320, 240) disp display.Display() # 根据色块颜色选择对应配置 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) ``` 步骤: 1. 导入image、camera、display模块 ```python from maix import image, camera, display ``` 2. 初始化摄像头和显示 ```python cam camera.Camera(320, 240)\t# 初始化摄像头,输出分辨率320x240 RGB格式 disp display.Display() ``` 3. 从摄像头获取图片并显示 ```python while 1: img cam.read() disp.show(img) ``` 4. 调用`find_blobs`方法寻找摄像头图片中的色块,并画到屏幕上 ```python 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) ``` `img`是通过`cam.read()`读取到的摄像头图像,当初始化的方式为`cam camera.Camera(320, 240)`时,`img`对象是一张分辨率为320x240的RGB图。 `img.find_blobs`用来寻找色块, `thresholds` 是一个颜色阈值列表,每个元素是一个颜色阈值,同时找到多个阈值就传入多个,每个颜色阈值的格式为 `[L_MIN, L_MAX, A_MIN, A_MAX, B_MIN, B_MAX]`,这里的 `L`、`A`、`B` 是`LAB`颜色空间的三个通道,`L` 通道是亮度,`A` 通道是红绿通道,`B` 通道是蓝黄通道。`pixels_threshold`是一个像素点数量的阈值,用来过滤一些不需要的小色块。 `img.draw_rect`用来画色块框,`blob[0]`、`blob[1]`、`blob[1]`、`blob[1]`分别代表色块左上角坐标x,色块左上角坐标y,色块宽度w和色块高度h ### 常用参数说明 列举常用参数说明,如果没有找到可以实现应用的参数,则需要考虑是否使用其他算法实现,或者基于目前算法的结果扩展所需的功能 参数 说明 示例 thresholds 基于lab颜色空间的阈值,threshold [[l_min, l_max, a_min, a_max, b_min, b_max]],分别表示:
    亮度范围为[l_min, l_max]\\
    绿色到红色的分量范围为[l_min, l_max]
    蓝色到黄色的分量范围为[b_min, b_max]
    可同时设置多个阈值 设置两个阈值来检测红色和绿色
    ```img.find_blobs(threshold [[0, 80, 40, 80, 10, 80], [0, 80, 120, 10, 0, 30]])```
    红色阈值为[0, 80, 40, 80, 10, 80]
    绿色阈值为[0, 80, 120, 10, 0, 30] invert 使能阈值反转,使能后传入阈值与实际阈值相反,默认为False 使能阈值反转
    ```img.find_blobs(invert True)``` roi 设置算法计算的矩形区域,roi [x, y, w, h],x,y表示矩形区域左上角坐标,w,h表示矩形区域的宽度和高度,默认为整张图片 计算坐标为(50,50),宽和高为100的区域
    ```img.find_blobs(roi [50, 50, 100, 100])``` area_threshold 过滤像素面积小于area_threshold的色块,单位为像素点,默认为10。该参数可用于过滤一些无用的小色块 过滤面积小于1000的色块
    ```img.find_blobs(area_threshold 1000)``` pixels_threshold 过滤有效像素点小于pixels_threshold的色块,默认为10。该参数可用于过滤一些无用的小色块 过滤有效像素点小于1000的色块
    ```img.find_blobs(pixels_threshold 1000)``` 本文介绍常用方法,更多 API 请看 API 文档的 [image](../../../api/maix/image.html) 部分。 ## 使用寻找色块APP 为了快速验证寻找色块的功能,可以先使用MaixCam提供的寻找色块应用程序来体验寻找色块的效果。 ### 使用方法 打开设备,选择`找色块`应用,然后在下方选择要识别的颜色,或者自定义颜色,即可以识别到对应的颜色了,同时串口也会输出识别到的坐标和颜色信息。 ### 详细说明 APP界面参考如下: ![](../../../static/image/find_blobs_app.jpg) #### 使用默认配置 寻找色块APP默认提供了`red、green、blue、user`四种配置,其中`red、green和blue`用来`寻找红色、绿色和蓝色的色块`,`user`主要提供给`用户自定义寻找色块`,自定义配置的方法见下文。快速体验时通过`点击`界面下方`按钮`即可切换到对应配置, #### 寻找自定义色块 APP提供两种方式来寻找自定义的色块:通过自适应LAB阈值寻找和手动设置LAB阈值寻找 ##### 1. 自适应LAB阈值寻找色块 操作方法: 1. `点击`左下角`选项图标`,进入配置模式 2. 将`摄像头对准`需要`寻找的物体`,`点击`屏幕上的`目标物体`,此时`左侧`会显示该物体对应颜色的`矩形框`,并显示该物体颜色的LAB值。 3. 点击出现的`矩形框`,系统将会`自动设置`LAB阈值,此时画面将会画出该物体边缘。 ##### 2. 手动设置LAB阈值寻找色块 手动设置可以更精确的找到目标色块。 操作方法: 1. `点击`左下角`选项图标`,进入配置模式 2. 将`摄像头对准`需要`寻找的物体`,`点击`屏幕上的`目标物体`,此时`左侧`会显示该物体对应颜色的`矩形框`,并显示该物体颜色的`LAB值`。 3. 点击下方选项`L Min,L Max,A Min,A Max,B Min,B Max`,点击后右侧会出现滑动条来设置该选项值。这些值分别对应LAB颜色格式的L通道、A通道和B通道的最小值和最大值 4. 参考步骤2计算的物体颜色的`LAB值`,将`L Min,L Max,A Min,A Max,B Min,B Max`调整到合适的值,即可识别到对应的色块。 例如`LAB (20, 50, 80)`,由于`L 20`,为了适配一定范围让`L Min 10`,`L Max 30`;同理,由于`A 50`,让`A Min 40`,`A Max 60`; 由于`B 80`,让`B Min 70`,`B Max 90`。 #### 通过串口协议获取检测数据 寻找色块APP支持通过串口(默认波特率为115200)上报检测到的色块信息。 由于上报信息只有一条,这里直接用示例来说明上报信息的内容。 例如上报信息为: ```shell 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`:协议头部,内容固定 `14 00 00 00`:数据长度,除了协议头部和数据长度外的总长度 `E1`:标志位,用来标识串口消息标志 `08`:命令类型,对于寻找色块APP应用该值固定为0x08 `EE 00 37 00 15 01 F7 FF 4E 01 19 00 27 01 5A 00`:已找到色块的四个顶点坐标,每个值用小端格式的2字节表示。`EE 00`和`37 00`表示第一个顶点坐标为(238, 55),`15 01`和`F7 FF`表示第二个顶点坐标为(277, 9),`4E 01`和`19 00`表示第三个顶点坐标为(334, 25),`27 01`和`5A 00`表示第四个顶点坐标为(295, 90)。 `A7 20`:CRC 校验值,用以校验帧数据在传输过程中是否出错 ## 关于LAB颜色空间 LAB颜色空间和RGB颜色空间一样是一种表示颜色的方法,LAB可以表示人眼能看到的所有颜色。如果需要了解LAB可以去网络上搜索相关文章,那样更详细,而对于你应该只需要了解为什么选用LAB对于MaixPy的优势。 LAB对于MaixPy的优势: 1. LAB颜色空间的色域比RGB都要大,因此完全可以替换RGB。 2. LAB颜色空间下,由于L通道是亮度通道,我们常常设置到较大的范围即可(常用[0,80]),而编写代码时主要关注是A通道和B通道,这样可以减少大量的时间在纠结颜色阈值如何选择的问题上。 3. LAB颜色空间的颜色感知更均匀,更容易用代码调试。例如,对于只需要寻找红色色块,可以固定L通道和B通道值,只需要调整A通道的值即可(这是在颜色精度要求不高的情况下);如果是RGB通道则基本需要R、G、B三个通道同时变动才能找到合适的阈值。"},"/maixpy/doc/zh/vision/classify.html":{"title":"MaixPy 使用 AI 模型进行物体分类","content":" title: MaixPy 使用 AI 模型进行物体分类 ## 物体分类概念 比如眼前有两张图片,一张图里面是苹果,另一张是飞机,物体分类的任务就是把两张图分别依次输入给 AI 模型,模型会依次输出两个结果,一个是苹果,一个是飞机。 ## MaixPy 中使用物体分类 MaixPy 默认提供了 `imagenet` 数据集训练得到的 `1000`分类模型,可以直接使用: ```python from maix import camera, display, image, nn classifier nn.Classifier(model \"/root/models/mobilenetv2.mud\") cam camera.Camera(classifier.input_width(), classifier.input_height(), classifier.input_format()) dis display.Display() while 1: img cam.read() res classifier.classify(img) max_idx, max_prob res[0] msg f\"{max_prob:5.2f}: {classifier.labels[max_idx]}\" img.draw_string(10, 10, msg, image.COLOR_RED) dis.show(img) ``` 效果视频: 这里使用了摄像头拍摄图像,然后传给 `classifier`进行识别,得出结果后,将结果显示在屏幕上。 更多 API 使用参考 [maix.nn](/api/maix/nn.html) 模块的文档。 ## 训练自己的分类模型 请到[MaixHub](https://maixhub.com) 学习并训练分类模型,创建项目时选择`分类模型`即可。"},"/maixpy/doc/zh/vision/image_ops.html":{"title":"MaixPy 图像基础操作","content":" title: MaixPy 图像基础操作 update: date: 2024 04 03 author: neucrack version: 1.0.0 content: 初版文档 ## 简介 视觉应用中图像占据非常重要的位置,不管是图片还是视频,因为视频本质上就是一帧帧的图像,所以图像处理是视觉应用的基础。 ## API 文档 本文介绍常用方法, 更多 API 参考 [maix.image](/api/maix/image.html) 模块的文档。 ## 图像格式 MaixPy 提供基础图像模块`image`,里面最重要的就是`image.Image`类,用于图像的创建以及各种图像基础操作,以及图像加载和保存等。 图像格式有很多,一般我们用`image.Format.FMT_RGB888` 或者 `image.Format.FMT_RGBA8888` 或者 `image.Format.FMT_GRAYSCALE`或者`image.Format.FMT_BGR888`等。 大家知道 `RGB` 三色可以合成任意颜色,所以一般情况下我们使用 `image.Format.FMT_RGB888`就足够, `RGB888` 在内存中是 `RGB packed` 排列,即在内存中的排列: `像素1_红色, 像素1_绿色, 像素1_蓝色, 像素2_红色, 像素2_绿色, 像素2_蓝色, ...` 依次排列。 ## 创建图像 创建图像很简单,只需要指定图像的宽度和高度以及图像格式即可: ```python from maix import image img image.Image(320, 240, image.Format.FMT_RGB888) print(img) print(img.width(), img.height(), img.format()) ``` `320` 是图像的宽度,`240` 是图像的高度,`image.Format.FMT_RGB888` 是图像的格式,格式参数可以省略,默认是`image.Format.FMT_RGB888`。 这里通过`img.width()`、`img.height()`、`img.format()`可以获取图像的宽度、高度和格式。 ## 显示到屏幕 MaixPy 提供了`maix.display.Display`类,可以方便的显示图像: ```python from maix import image, display disp display.Display() img image.Image(320, 240, image.Format.FMT_RGB888) disp.show(img) ``` 注意这里因为没有图像数据,所以显示的是黑色的图像,修改画面看后文。 ## 从文件系统读取图像 MaixPy 提供了`maix.image.load`方法,可以从文件系统读取图像: ```python from maix import image img image.load(\"/root/image.jpg\") print(img) ``` 注意这里`/root/image.jpg` 是提前传输到了板子上的,方法可以看前面的教程。 可以支持 `jpg` 和 `png` 格式的图像。 ## 保存图像到文件系统 MaixPy 的`maix.image.Image`提供了`save`方法,可以保存图像到文件系统: ```python from maix import image img image.Image(320, 240, image.Format.FMT_RGB888) # do something with img img.save(\"/root/image.jpg\") ``` ## 画框 `image.Image`提供了`draw_rect`方法,可以在图像上画框: ```python from maix import image img image.Image(320, 240, image.Format.FMT_RGB888) img.draw_rect(10, 10, 100, 100, image.Color.from_rgb(255, 0, 0)) ``` 这里的参数依次是:`x`, `y`, `w`, `h`, `color`,`x` 和 `y` 是框的左上角坐标,`w` 和 `h` 是框的宽度和高度,`color` 是框的颜色,可以使用`image.Color.from_rgb`方法创建颜色。 可以用`thickness`指定框的线宽,默认是`1`, 也可以画实心框,传参 `thickness 1` 即可: ```python from maix import image img image.Image(320, 240, image.Format.FMT_RGB888) img.draw_rect(10, 10, 100, 100, (255, 0, 0), thickness 1) ``` ## 写字符串 `image.Image`提供了`draw_string`方法,可以在图像上写字: ```python from maix import image img image.Image(320, 240, image.Format.FMT_RGB888) img.draw_string(10, 10, \"Hello MaixPy\", image.Color.from_rgb(255, 0, 0)) ``` 这里的参数依次是:`x`, `y`, `text`, `color`,`x` 和 `y` 是文字的左上角坐标,`text` 是要写的文字,`color` 是文字的颜色,可以使用`image.Color.from_rgb`方法创建颜色。 还可以放大字体,传参 `scale` 即可: ```python img.draw_string(10, 10, \"Hello MaixPy\", image.Color.from_rgb(255, 0, 0), scale 2) ``` 获取字体的宽度和高度: ```python w, h img.string_size(\"Hello MaixPy\", scale 2) print(w, h) ``` **注意**这里`scale`是放大倍数,默认是`1`,和`draw_string`应该保持一致。 ## 画线 `image.Image`提供了`draw_line`方法,可以在图像上画线: ```python from maix import image img image.Image(320, 240, image.Format.FMT_RGB888) img.draw_line(10, 10, 100, 100, image.Color.from_rgb(255, 0, 0)) ``` 这里的参数依次是:`x1`, `y1`, `x2`, `y2`, `color`,`x1` 和 `y1` 是线的起点坐标,`x2` 和 `y2` 是线的终点坐标,`color` 是线的颜色,可以使用`image.Color.from_rgb`方法创建颜色。 ## 画圆 `image.Image`提供了`draw_circle`方法,可以在图像上画圆: ```python from maix import image img image.Image(320, 240, image.Format.FMT_RGB888) img.draw_circle(100, 100, 50, image.Color.from_rgb(255, 0, 0)) ``` 这里的参数依次是:`x`, `y`, `r`, `color`,`x` 和 `y` 是圆心坐标,`r` 是半径,`color` 是圆的颜色,可以使用`image.Color.from_rgb`方法创建颜色。 ## 缩放图像 `image.Image`提供了`resize`方法,可以缩放图像: ```python from maix import image img image.Image(320, 240, image.Format.FMT_RGB888) img_new img.resize(160, 120) print(img, img_new) ``` 注意这里`resize`方法返回一个新的图像对象,原图像不变。 ## 剪裁图像 `image.Image`提供了`crop`方法,可以剪裁图像: ```python from maix import image img image.Image(320, 240, image.Format.FMT_RGB888) img_new img.crop(10, 10, 100, 100) print(img, img_new) ``` 注意这里`crop`方法返回一个新的图像对象,原图像不变。 ## 旋转图像 `image.Image`提供了`rotate`方法,可以旋转图像: ```python from maix import image img image.Image(320, 240, image.Format.FMT_RGB888) img_new img.rotate(90) print(img, img_new) ``` 注意这里`rotate`方法返回一个新的图像对象,原图像不变。 ## 拷贝图像 `image.Image`提供了`copy`方法,可以拷贝一份独立的图像: ```python from maix import image img image.Image(320, 240, image.Format.FMT_RGB888) img_new img.copy() print(img, img_new) ``` ## 仿射变换 `image.Image`提供了`affine`方法,可以进行仿射变换,即提供当前图中三个及以上的点坐标,以及目标图中对应的点坐标,可以自动进行图像的旋转、缩放、平移等操作变换到目标图像: ```python from maix import image img image.Image(320, 240, image.Format.FMT_RGB888) img_new img.affine([(10, 10), (100, 10), (10, 100)], [(10, 10), (100, 20), (20, 100)]) print(img, img_new) ``` 更多参数和用法请参考 API 文档。 ## 画关键点 `image.Image`提供了`draw_keypoints`方法,可以在图像上画关键点: ```python from maix import image img image.Image(320, 240, image.Format.FMT_RGB888) keypoints [(10, 10), (100, 10), (10, 100)] img.draw_keypoints(keypoints, image.Color.from_rgb(255, 0, 0), size 10, thickness 1, fill False) ``` 在坐标`(10, 10)`、`(100, 10)`、`(10, 100)`画三个红色的关键点,关键点的大小是`10`,线宽是`1`,不填充。 ## 画十字 `image.Image`提供了`draw_cross`方法,可以在图像上画十字: ```python from maix import image img image.Image(320, 240, image.Format.FMT_RGB888) img.draw_cross(100, 100, image.Color.from_rgb(255, 0, 0), size 5, thickness 1) ``` 在坐标`(100, 100)`画一个红色的十字,十字的延长大小是`5`,所以线段长度为`2 * size + thickness`, 线宽是`1`。 ## 画箭头 `image.Image`提供了`draw_arrow`方法,可以在图像上画箭头: ```python from maix import image img image.Image(320, 240, image.Format.FMT_RGB888) img.draw_arrow(10, 10, 100, 100, image.Color.from_rgb(255, 0, 0), thickness 1) ``` 在坐标`(10, 10)`画一个红色的箭头,箭头的终点是`(100, 100)`,线宽是`1`。 ## 画图 `image.Image`提供了`draw_image`方法,可以在图像上画图: ```python from maix import image img image.Image(320, 240, image.Format.FMT_RGB888) img2 image.Image(100, 100, image.Format.FMT_RGB888) img2.draw_rect(10, 10, 90, 90, image.Color.from_rgb(255, 0, 0)) img.draw_image(10, 10, img2) ``` ## 转换格式 `image.Image`提供了`to_format`方法,可以转换图像格式: ```python from maix import image img image.Image(320, 240, image.Format.FMT_RGB888) img_new img.to_format(image.Format.FMT_BGR888) print(img, img_new) img_jpg img.to_format(image.Format.FMT_JPEG) print(img, img_new) ``` 注意这里`to_format`方法返回一个新的图像对象,原图像不变。 ## 和 Numpy/OpenCV 格式互相转换 另外还可以转换成`numpy`数组,这样就能给`numpy`和`opencv`等库使用: ```python from maix import image img image.Image(320, 240, image.Format.FMT_RGB888) img_np image.image2cv(img) img2 image.cv2image(img_np) print(type(img_np), img_np, img_np.shape) print(type(img2), img2) ``` ## 和 bytes 数据互相转换 `image.Image`提供了`to_bytes`方法,可以转换图像为`bytes`数据: ```python from maix import image img image.Image(320, 240, image.Format.FMT_RGB888) data img.to_bytes() print(type(data), len(data), img.data_size()) img2 image.Image(320, 240, image.Format.FMT_RGB888, data) print(img2) ``` 这里`to_bytes`获得一个新的`bytes`对象,是独立的内存,不会影响原图。 `image.Image`构造函数中传入`data`参数可以直接从`bytes`数据构造图像对象,注意新的图像也是独立的内存,不会影响到`data`。 因为涉及到内存拷贝,所以这个方法比较耗时,不建议频繁使用。 > 如果你想用不拷贝的方式优化程序(不建议轻易使用,写不好代码会导致程序容易崩溃,),请看 API 文档。 ## 更多基础 API 使用方法 更多 API 使用方法请参考 [maix.image](/api/maix/image.html) 模块的文档。"},"/maixpy/doc/zh/vision/maixhub_train.html":{"title":"使用 MaixHub 在线训练 AI 模型给 MaixPy 使用","content":" title: 使用 MaixHub 在线训练 AI 模型给 MaixPy 使用 update: date: 2024 04 03 author: neucrack version: 1.0.0 content: 初版文档 ## 简介 MaixHub 提供了在线训练 AI 模型的功能,可以直接在浏览器中训练模型,不需要购买昂贵的机器,不需要搭建复杂的开发环境,也不需要写代码,非常适合入门,也适合懒得翻代码的老手。 ## 使用 MaixHub 训练模型的基本步骤 ### 确认要识别的数据类型和模型类型 要训练一个 AI 模型,需要先确定是什么数据和模型,目前 MaixHub(2024.4)提供了图像数据的`物体分类模型`和`物体检测模型`,都是图像识别模型, `物体分类模型` 比 `物体检测模型` 更简单,因为物体检测需要标注物体在图中的位置,会比较麻烦,物体分类则只需要给出图像中是什么,不需要坐标,所以更简单, 如果是初学者建议先从物体分类开始。 ### 采集数据 如前面的 AI 基础所说,要训练模型,必须准备训练用的数据集让 AI 学习,对于图像训练,我们需要创建一个数据集,并且上传图片到数据集。 保证设备已经连接网络(WiFi)。 打开设备上的 MaixHub 应用选择 采集数据 来拍照并一键上传到 MaixHub。需要先在 MaixHub 创建数据集,然后点击 设备 上传数据,会出现一个 二维码,设备扫描二维码来与MaixHub 建立连接。 注意要分清训练集和验证集的区别,要想实机运行的效果和训练效果相当,验证集的数据一定要和实机运行拍摄的图像质量一样,训练集也建议用设备拍摄的,如果要用网上的图片,一定只能用在训练集,不要用在验证集,因为数据量小,数据集与实机运行越接近越好。 ### 标注数据 对于分类模型,在上传的时候就顺便已经标注好了,即上传时选择好了图片属于那个分类。 对于目标检测模型,上传完成后需要进行手动标注,即在每一张图中框出要被识别物体的坐标大小和分类。 这个标注过程你也可以选择自己在自己的电脑中离线用比如 labelimg 这样的软件标注完毕后使用数据集中的导入功能导入到 MaixHub。 标注时善用快捷键标注起来会更快,后面MaixHub 也会增加更多辅助标注和自动标注工具(目前在上传视频处有自动标注工具也可以尝试使用)。 ### 训练模型 选择训练参数训练,选择对应的设备平台,选择 maixcam,等待排队训练,可以实时看到训练进度,等待完成即可。 ### 部署模型 训练完成后,可以设备的 MaixHub 应用中选择 部署 功能,扫码进行部署。 设备开会自动下载模型并且运行起来,模型会被存在本地,后面也能选择再次运行。 如果你觉得识别效果很不错,可以一键分享到模型库让更多人使用。 ## 使用方法 请到 [MaixHub](https://maixhub.com) 注册账号,然后登录,主页有视频教程,学习即可。 注意教程如果是使用了 M2dock 这个开发板,和 MaixCAM也是类似的,只是设备(板子)上使用的 MaixHub 应用可能稍微有点区别,大体上是相同的,请注意举一反三。"},"/maixpy/doc/zh/index.html":{"title":"MaixPy 快速开始","content":" title: MaixPy 快速开始
    MaixPy 唯一官网: wiki.sipeed.com/maixpy
    MaixPy 例程和源码: github.com/sipeed/MaixPy

    > 关于 MaixPy 介绍请看 [MaixPy 官网首页](../../index.html) ## 获得 MaixCAM 设备 在 [Sipeed 淘宝](https://item.taobao.com/item.htm?id 784724795837) 或者 [Sipeed 速卖通](https://www.aliexpress.com/store/911876460) 店铺购买 MaixCAM 开发板。 **建议购买带 `TF 卡`、`摄像头`、`2.3寸触摸屏`、`外壳`、`Type C 数据线`、 `Type C一转二小板`、`4P串口座子+线`的套餐**,方便后续使用和开发,**后面的教程都默认你已经有了这些配件**(包括屏幕)。 如果你没有购买 TF 卡,则你需要**自备**一个 **TF 读卡器**用来烧录系统。 >! 注意,目前只支持 MaixCAM 开发板,其它同型号芯片的开发板均不支持,包括 Sipeed 的同型号芯片开发板,请注意不要买错造成不必要的时间和金钱浪费。 ## 上手配置 ### 准备 TF 镜像卡和插入到设备 如果你买的套餐里面有 TF 卡,里面已经有出厂镜像了,如果出厂时 TF 卡没有安装到设备,需要先小心打开外壳(注意里面有排线连接不要扯断了),然后插入 TF 卡。另外因为出厂的固件可能比较老旧,可以插按照[升级和烧录系统](https://wiki.sipeed.com/maixpy/doc/zh/basic/os.html)先将系统升级到最新版本。 如果没买 TF 卡,则需要将系统烧录进自备的 TF 卡中,烧录方法请看[升级和烧录系统](./basic/os.html),然后再安装到板子。 ### 上电开机 使用 `Type C` 数据线连接 `MaixCAM` 设备给设备供电,等待设备开机,开机会进入功能选择界面。 ![maixcam_font](../../static/image/maixcam_font.png) 如果屏幕没有显示 * 请确认购买了配套的 TF 卡,如果确认有 TF 卡,并且已经插入到设备,可以**尝试[更新到最新的系统](./basic/os.html)**。 * 如果你没有购买 TF 卡套餐,你需要按照[升级和烧录系统](./basic/os.html)的方法烧录最新的系统到 TF 卡。 * 另外请确认屏幕和摄像头的排线没有松动,屏幕的排线在拆开外壳时很容易脱落,需要注意。 ### 联网 首次运行需要连接网络,后面会激活设备和使用 IDE 会用到。 * 设备上点击 `设置`(`Settings`),选择`WiFi`,点击 `扫描` 按钮开始扫描周围 `WiFi`, 可以多次点击刷新列表。 * 找到你的 WiFi 热点,如果没有路由器可以用手机开一个热点。 * 输入密码点击`连接`按钮进行连接。 * 等待获取到 `IP` 地址,这可能需要 `10` 到 `30` 秒,如果界面没有刷新可以退出`WiFi`功能重新进入查看,或者在`设置` > `设备信息` 中也可以看到 `IP` 信息。 ### 升级运行库 **这一步很重要 !!!** 这一步如果不做好,其它应用和功能可能无法运行(比如闪退等)。 * 首先保证上一步连接 WiFi 已经完成,并且获取到 IP 地址能访问公网。 * 设备上点击 `设置`(`Settings`),选择`安装运行库`。 * 安装完成后可以看到更新到了最新版本,然后退出即可。 如果显示`Request failed` 或者`请求失败`,请先检查网络是否已经连接,需要能连接到互联网,如果还不行,请拍照联系客服处理即可。 ### 使用内置应用 内置了很多应用,比如 找色块,AI 检测器,巡线等等,找色块举例: 其它的请自行摸索,以后还会更新更多应用,使用文档以及应用更新请看 [MaixHub 应用商店](https://maixhub.com/app) 。 **注意:应用只包含了 MaixPy 能实现的一部分功能,使用 MaixPy 能创造更多功能**。 ## 作为串口模块使用 > 如果是想把设备当成主控使用(或者你还不懂什么是串口模块)可以跳过这一步。 内置的各种应用可以直接当成串口模块使用,比如`找色块`、`找人脸`、`找二维码`等等, 使用方法: * 硬件连接: 可以给设备接上`Type C一转二小板`,这样我们就能将设备通过串口连接到你的主控上了,比如`Arduino`、`树莓派`、`STM32`等等。 * 打开你想用的应用,比如二维码识别,当设备扫描到二维码就会通过串口把结果发送给你的主控了。 > 发送的串口波特率是 `115200`,数据格式是 `8N1`,协议遵循 [Maix 串口通信协议标准](https://github.com/sipeed/MaixCDK/blob/master/docs/doc/convention/protocol.md),可以在[MaixHub APP](https://maixhub.com/app) 找到对应的应用介绍查看协议。 ## 准备连接电脑和设备 为了后面电脑(PC)能和 设备(MaixCAM)通信,我们要让它们在同一个局域网内,提供了两种方式: * **方法一 (强烈推荐)**:无线连接, 设备使用 WiFi 连接到电脑连接的同一个路由器或者 WiFi 热点下: 在设备的`设置 > WiFi 设置`中连接到你的 WiFi 即可。 * **方法二**:有线连接, 设备通过 USB 线连接到电脑,设备会虚拟成一个 USB 网卡,这样和电脑就通过 USB 在同一局域网了。 > 方案二因为要用 USB 和驱动,可能会遇到一些问题,所以推荐直接用 WiFi 开始,可以在 [FAQ](./faq.html) 中找常见问题。 .. details::方案二在不同电脑系统中有不同设置方法,点击展开 * **Linux**: 无需额外设置,插上 USB 线即可, 使用 `ifconfig` 或者 `ip addr` 查看到 `usb0` 网卡,**注意** 这里看到的 ip 比如 `10.131.167.100` 是电脑的 ip, 设备的 ip 是最后一位改为`1` 即 `10.131.167.1`。 * **Windows**: 可以先确认`网络适配器`里面是否多了一个 RNDIS 设备,如果有就直接能用。否则需要手动安装 RNDIS 网卡驱动: * 打开电脑的`设备管理器`。 * 然后在`其它设备`里面找个一个带问号的 RNDIS 设备,右键选择`更新驱动程序`。 * 选择`浏览计算机以查找驱动程序`,然后选择`让我从计算机上的可用驱动程序列表中选择`。 * 选择`网络适配器`,然后点击`下一步`。 * 左边选择`Microsoft`,右边选择`远程 NDIS 兼容设备`,然后点击`下一步`, 选择`是`。 * 装好后的效果 ![RNDIS](../../static/image/rndis_windows.jpg) * **MacOS**: 无需额外设置,插上 USB 线即可, 使用 `ifconfig` 或者 `ip addr` 查看到 `usb0` 网卡,**注意** 这里看到的 ip 比如 `10.131.167.100` 是电脑的 ip, 设备的 ip 是最后一位改为`1` 即 `10.131.167.1`。 ## 开发环境准备 * 下载 [MaixVision](https://wiki.sipeed.com/maixvision) 并安装。 * 使用 Type C 连接设备和电脑,打开 MaixVision,点击左下角的`“连接”`按钮,会自动搜索设备,稍等一下就能看到设备,点击设备有点的连接按钮以连接设备。 如果**没有扫描到设备**,你也可以在**设备**的 `设置 > 设备信息` 中查看设备的 IP 地址手动输入, 也可以在 [FAQ](./faq.html) 中找到解决方法。 **连接成功后,设备的功能选择界面会消失,屏幕会黑屏,释放了所有硬件资源,如果仍然有画面显示,可以断开连接重连。** 这里有 MaixVision 的使用示例视频: ## 运行例程 点击 MaixVision 左侧的`示例代码`,选择一个例程,点击左下角`运行`按钮将代码发送到设备上运行。 比如: * `hello_maix.py`,点击`运行`按钮,就能看到 MaixVision 终端有来自设备打印的消息,以及右上角出现了图像。 * `camera_display.py`,这个例程会打开摄像头并在屏幕上显示摄像头的画面。 ```python from maix import camera, display, app disp display.Display() # 构造一个显示对象,并初始化屏幕 cam camera.Camera(640, 480) # 构造一个摄像头对象,手动设置了分辨率为 640x480, 并初始化摄像头 while not app.need_exit(): # 一直循环,直到程序退出(可以通过按下设备的功能按键退出或者 MaixVision 点击停止按钮退出) img cam.read() # 读取摄像头画面保存到 img 变量,可以通过 print(img) 来打印 img 的详情 disp.show(img) # 将 img 显示到屏幕上 ``` * `yolov5.py` 会检测摄像头画面中的物体框出来并显示到屏幕上,支持 80 种物体的检测,具体请看[YOLOv5 物体检测](./vision/yolov5.html)。 其它例程可以自行尝试。 > 如果你使用相机例程遇到了图像显示卡顿,可能是网络不通畅,或者 USB 线质量或者主机 USB 质量太差造成,可以更换连接方式或者更换线缆、主机 USB 口或者电脑等。 ## 安装应用到设备 上面是在设备中运行代码,`MaixVision` 断开后代码就会停止运行,如果想让代码出现在开机菜单中,可以打包成应用安装到设备上。 点击 `MaixVision` 左下侧的安装应用按钮,填写应用信息,会将应用安装到设备上,然后在设备上就能看到应用了。 也可以选择打包应用,将你的应用分享到[MaixHub 应用商店](https://maixhub.com/app)。 > 默认例程没有显式编写退出功能,进入应用后按下设备的功能按键即可退出应用。(对于 MaixCAM 是 user 键) 如果想让程序开机自启动,可以在 `设置 > 开机启动` 中设置。 ## 下一步 看到这里,如果你觉得不错,**请务必来 [github](https://github.com/sipeed/MaixPy) 给 MaixPy 开源项目点一个 star(需要先登录 github), 你的 star 和认同是我们不断维护和添加新功能的动力!** 到这里你已经体验了一遍使用和开发流程了,接下来可以学习 `MaixPy` 语法和功能相关的内容,请按照左边的目录进行学习,如果遇到 `API` 使用问题,可以在[API 文档](/api/)中查找。 学习前最好带着自己学习的目的学,比如做一个有趣的小项目,这样学习效果会更好,项目和经验都可以分享到[MaixHub 分享广场](https://maixhub.com/share),会获得现金奖励哦! ## 分享交流 * **[MaixHub 项目和经验分享](https://maixhub.com/share)** :分享你的项目和经验,获得现金打赏,获得官方打赏的基本要求: * **可复现型**:较为完整的项目制作复现过程。 * **炫耀型**:无详细的项目复现过程,但是项目展示效果吸引人。 * Bug 解决经验型:解决了某个难题的过程和具体解决方法分享。 * [MaixPy 官方论坛](https://maixhub.com/discussion/maixpy)(提问和交流) * QQ 群: (建议在 QQ 群提问前先发个帖,方便群友快速了解你需要了什么问题,复现过程是怎样的) * MaixPy (v4) AI 视觉交流大群: 862340358 * Telegram: [MaixPy](https://t.me/maixpy) * MaixPy 源码问题: [MaixPy issue](https://github.com/sipeed/MaixPy/issues) * 商业合作或批量购买请联系 support@sipeed.com 。"},"/maixpy/doc/zh/video/jpeg_streaming.html":{"title":"MaixPy 视频流 JPEG 推流 / 发送图片到服务器","content":" title: MaixPy 视频流 JPEG 推流 / 发送图片到服务器 update: date: 2024 04 03 author: neucrack version: 1.0.0 content: 初版文档 ## 简介 有时需要将图像发送到服务器,或者将摄像头的视频推送到服务器,这里提供一个最简单的方法,即压缩成 `JPEG` 图片,然后一张一张地发送到服务器。 注意,这是一种最简单的方法,不算很正规的视频推流方法,也不适合高分辨率高帧率的视频流,因为这只是一张一张发送图片,如果要高效推送视频流,请使用后文的 `RTSP` 或者 `RTMP` 模块。 ## 使用方法 ```python 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 carefully, 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) ``` 可以看到,先将图片转换成了 `JPEG` 格式,然后将 `JPEG` 图片的二进制数据通过`TCP`发送到服务器。"},"/maixpy/doc/zh/source_code/faq.html":{"title":"MaixPy 源代码常见问题","content":"MaixPy 源代码常见问题 ## subprocess.CalledProcessError: Command '('lsb_release', ' a')' returned non zero exit status 1. 以 root 身份编辑 `/usr/bin/lsb_release`,将第一行从 `#!/usr/bin/python3` 更改为 `python3`。 然后重新编译,应该就可以工作了。 ## ImportError: arg(): could not convert default argument 'format: maix::image::Format' in method '.**init**' into a Python object (type not registered yet?) Pybind11 需要你先注册 `image::Format`,然后才能在 `camera::Camera` 中使用它,所以我们必须先在生成的 `build/maixpy_wrapper.cpp` 源文件中定义 `image::Format`。 要实现这一点,请编辑 `components/maix/headers_priority.txt`,被依赖的应该放在依赖它的前面。 例如: ``` maix_image.hpp maix_camera.hpp ```"},"/maixpy/doc/zh/source_code/build.html":{"title":"MaixPy 开发源代码指南","content":" title: MaixPy 开发源代码指南 ## 获取源代码 ```shell git clone https://github.com/sipeed/MaixPy cd MaixPy ``` ## 构建并打包成 wheel 文件 ```shell python setup.py bdist_wheel maixcam ``` `maixcam` 可以被替换为其他板卡配置, 请查看 [setup.py]([./configs](https://github.com/sipeed/MaixPy/blob/main/setup.py)) 中的 `platform_names` 变量。 构建成功后, 你会在 `dist` 目录中找到 wheel 文件, 使用 `pip install U MaixPy****.wheel` 在你的设备上安装或升级。 > `python setup.py bdist_wheel maixcam skip build` 不会执行构建命令, 只会打包 wheel 文件, 因此你可以先使用 `maixcdk menuconfig` 和 `maixcdk build` 来自定义构建。 ## 手动构建 ```shell maixcdk build ``` ## 修改源代码后运行测试 * 首先, 构建源代码 ```shell maixcdk build ``` * 如果为 PC 自身构建(平台 `linux`): 然后执行 `./run.sh your_test_file_name.py` 来运行 Python 脚本。 ```shell cd test ./run.sh examples/hello_maix.py ``` * 如果为板卡交叉编译: * 最快的方式是将 `maix` 目录复制到设备的 `/usr/lib/python3.11/site packages/` 目录, 然后在设备上运行脚本。 * 或者打包 wheel 文件并在设备上使用 `pip install U MaixPy****.wheel` 安装, 然后在设备上运行脚本。 ## 本地预览文档 文档位于 [docs](https://github.com/sipeed/MaixPy/tree/main/docs) 目录, 使用 `Markdown` 格式, 你可以使用 [teedoc](https://github.com/teedoc/teedoc) 来生成网页版本的文档。 API 文档会在构建 MaixPy 固件时生成, **如果你没有构建 MaixPy, API 文档将会是空的**。 ```shell pip install teedoc U cd docs teedoc install i https://pypi.tuna.tsinghua.edu.cn/simple teedoc serve ``` 然后访问 `http://127.0.0.1:2333` 在网页浏览器中预览文档。 ## 对于想要贡献的开发者 请查看 [MaixPy 开发源代码指南](./contribute.html) 如果在使用源代码时遇到任何问题, 请先参考 [FAQ](./faq.html)。"},"/maixpy/doc/zh/source_code/maixcdk.html":{"title":"切换到 MaixCDK 使用 C/C++ 开发应用","content":" title: 切换到 MaixCDK 使用 C/C++ 开发应用 除了使用 MaixPy 开发,还有对应的 C/C++ SDK 可以使用,项目名称为 [MaixCDK](https://github.com/sipeed/MaixCDK)。 ## MaixCDK 介绍 MaixPy 基于 MaixCDK 构建,MaixPy 的大多数 API 都是基于 MaixCDK 的 API 自动生成的,所以 MaixPy 有的功能 MaixCDK 都包含。 如果你更熟悉 C/C++ 编程,或者需要更高的性能,可以使用 MaixCDK 进行开发。 ## MaixCDK 使用 MaixCDK 代码仓库地址:[github.com/sipeed/MaixCDK](https://github.com/sipeed/MaixCDK), 你可以在这里找到 MaixCDK 的代码和文档。"},"/maixpy/doc/zh/peripheral/gpio.html":{"title":"","content":""},"/maixpy/doc/zh/peripheral/uart.html":{"title":"","content":""},"/maixpy/doc/zh/peripheral/pwm.html":{"title":"","content":""},"/maixpy/doc/zh/vision/yolov5.html":{"title":"MaixPy 使用 YOLOv5 模型进行目标检测","content":" title: MaixPy 使用 YOLOv5 模型进行目标检测 ## 目标检测概念 目标检测是指在图像或视频中检测出目标的位置和类别,比如在一张图中检测出苹果、飞机等物体,并且标出物体的位置。 和分类不同的是多了一个位置信息,所以目标检测的结果一般是一个矩形框,框出物体的位置。 ## MaixPy 中使用目标检测 MaixPy 默认提供了 `YOLOv5` 模型,可以直接使用: ```python from maix import camera, display, image, nn, app detector nn.YOLOv5(model \"/root/models/yolov5s.mud\") cam camera.Camera(detector.input_width(), detector.input_height(), detector.input_format()) dis display.Display() while not app.need_exit(): img cam.read() objs detector.detect(img, conf_th 0.5, iou_th 0.45) for obj in objs: img.draw_rect(obj.x, obj.y, obj.w, obj.h, color image.COLOR_RED) msg f'{detector.labels[obj.class_id]}: {obj.score:.2f}' img.draw_string(obj.x, obj.y, msg, color image.COLOR_RED) dis.show(img) ``` 效果视频: