diff --git a/README.md b/README.md
index e60d2692b2f204cd81657e52904024d5928278ac..b60c36f1486b1e6c9812e6fa7e8e8bcc9c7c6d10 100644
--- a/README.md
+++ b/README.md
@@ -80,6 +80,16 @@ Lockzhiner Vision Module 拥有丰富的 IO 接口,其接口图片如下图所
这一部分教程将引导你从零开始训练并部署各种深度学习模型,包括分类模型、检测模型、分割模型和 OCR 模型。通过这些实战教程,你将学习到如何利用 Lockzhiner Vision Module 的高性能计算能力以及借助飞桨生态系统的丰富资源,轻松实现视觉任务的训练和部署。
+### 👍 OpenCV 案例
+
+OpenCV 是一个开源的计算机视觉库,它提供了一组功能强大的函数,用于处理图像和视频,并进行各种图像处理和计算机视觉任务。它由一系列 C++ 类构成,并提供了 Python 接口。
+
+* [凌智视觉模块 OpenCV 边缘检测案例](example/opencv_example/opencv_edge_detection)
+* [凌智视觉模块 OpenCV 直线检测部署指南](example/opencv_example/opencv_line_detection)
+* [凌智视觉模块 OpenCV 三角形检测部署指南](example/opencv_example/opencv_triangle_detection)
+* [凌智视觉模块 OpenCV 矩形检测部署指南](example/opencv_example/opencv_rectangle_detection)
+* [凌智视觉模块 OpenCV 圆形检测部署指南](example/opencv_example/opencv_circle_detection)
+
### 👍 目标分类案例
目标分类(Object Classification)是深度学习中的一项核心任务,旨在为输入图像分配一个或多个类别标签。这是计算机视觉的基础问题之一,主要用于识别和区分图像中的主要物体类别,而不关心物体的位置或数量。一般来说,目标分类任务的标注过程比较轻松,适合不需要知道目标位置的场景。
@@ -88,7 +98,8 @@ Lockzhiner Vision Module 拥有丰富的 IO 接口,其接口图片如下图所
* [凌智视觉模块手写数字分类部署指南](./example/special/digit_handwritten_recognition)
* [凌智视觉模块猫狗分类部署指南](example/special/cat_and_dog_classification)
* [凌智视觉模块花卉分类部署指南](example/special/flower_classfication/)
-* [凌智视觉模块口罩佩戴分类模型部署指南](example/special/maskwear_classfication)
+* [凌智视觉模块口罩佩戴分类部署指南](example/special/maskwear_classfication)
+
### 👍 目标检测案例
目标检测(Object Detection)是深度学习中计算机视觉领域的重要任务之一,旨在识别图像或视频中所有感兴趣的物体,并准确地定位这些物体的边界框(Bounding Box)。与目标分类不同,目标检测不仅需要预测物体的类别,还需要标注它们在图像中的位置。一般来说,目标检测任务的标注过程比较复杂,适合既需要对目标进行分类,有需要对目标进行定位的场景。
@@ -108,6 +119,7 @@ Lockzhiner Vision Module 拥有丰富的 IO 接口,其接口图片如下图所
* [凌智视觉模块人脸检测部署指南](example/vision/face_detection)
* [凌智视觉模块人脸识别部署指南](example/vision/face_recognition)
+* [凌智视觉模块人脸识别系统部署指南](example/special/face_system)
## 🐛 Bug反馈
diff --git a/docs/device_parameters.md b/docs/device_parameters.md
index 6f35fdbdaebc6ca814da21d3646b1c8ad6c2f4ed..e9e8410cf523031a4a042d9f305f3bc0e087e03a 100644
--- a/docs/device_parameters.md
+++ b/docs/device_parameters.md
@@ -1,8 +1,8 @@
凌智视觉模块设备详细参数文档
-发布版本:V0.0.0
+发布版本:V0.0.1
-日期:2024-09-27
+日期:2024-11-25
文件密级:□绝密 □秘密 □内部资料 ■公开
@@ -24,9 +24,10 @@
**修订记录**
-| **日期** | **版本** | **作者** | **修改说明** |
-|:-----------|--------|--------|----------|
-| 2024/09/27 | 0.0.0 | 郑必城 | 初始版本 |
+| **日期** | **版本** | **作者** | **修改说明** |
+|:-----------|--------|--------|-----------|
+| 2024/09/27 | 0.0.0 | 郑必城 | 初始版本 |
+| 2024/11/25 | 0.0.1 | 郑必城 | 更新最新的产品信息 |
## 1 简介
@@ -38,35 +39,45 @@
## 2 主控芯片参数
+凌智视觉模块搭载单核 ARM Cortex-A7 处理器,并集成了 NEON 和 FPU, 以更出色地处理 SIMD 和浮点计算。同时,该模块支持 Int8 量化,内置 1 TOPs 的 NPU, 足以应对绝大多数的视觉应用场景。其主控芯片更详细的参数如下表:
+
| 芯片参数 | 凌智视觉模块 | OpenMV4 H7 PLUS |
|:------:|:--------------------------:|:--------------------:|
| 主控芯片 | RV1106G3 | STM32H743II |
| 芯片架构 | ARM Cortex-A7 + NEON + FPU | ARM Cortex M7 |
| 主频 | 1.2GHz | 480 MHz |
| 内存 | 256MB DDR3L | 1MB RAM + 2 MB flash |
-| NPU | 1 T int8 | 无 |
+| NPU | 1 T int8 | 无 |
| ISP | 最大输入5M @30fps | 无 |
| 摄像头接口 | MIPI CSI 2-lane | 未知 |
| 默认存储介质 | SD 卡 | SD 卡 |
## 3 外设参数
-| 外设信息 | 参数介绍 |
-|:-----:|---------------------------------------------------------------------------------------------------------------------|
-| ADC | 1. 10 bit 分辨率
2. 1 MSPS 采样率
3. 单端输入,输入范围 0V - 1.8V |
-| Capture | 1. 最大分辨率为(2304x1296)
2. 提供 opencv 库来调用摄像头
3. 可自由设置长宽为 8 的倍数 |
-| GPIO | 1. 高电平 3.3V
2. 可产生中断
3. 支持电平触发和边沿触发
4. 可配置电平触发中断的极性
5. 配置上升沿,下降沿和双边沿触发中断
6. 可配置弱上拉或弱下拉
7. 可配置驱动能力 |
-| PWM | 1. 可编程对总线时钟的预分频
2. 32 位定时器计数器
3. 支持捕获模式
4. 支持连续模式或单次模式;提供参考模式,并能输出多种占空比的波形
5. 兼容IR应用 |
-| USART | 1. 嵌入 2 路 64 字节 FIFO,RX 和 TX 独立操作
2. 5-8位串行数据发送或接收
3. 标准异步通信位,如起始,停止,校验
4. 波特率高达 4 Mbps
5. 支持自动流控模式 |
+| 外设信息 | 参数介绍 |
+|:-------:|---------------------------------------------------------------------------------------------------------------------|
+| ADC | 1. 10 bit 分辨率
2. 1 MSPS 采样率
3. 单端输入,输入范围 0V - 1.8V |
+| Capture | 1. 最大分辨率为(2304x1296)
2. 提供 opencv 库来调用摄像头
3. 可自由设置长宽为 8 的倍数 |
+| GPIO | 1. 高电平 3.3V
2. 可产生中断
3. 支持电平触发和边沿触发
4. 可配置电平触发中断的极性
5. 配置上升沿,下降沿和双边沿触发中断
6. 可配置弱上拉或弱下拉
7. 可配置驱动能力 |
+| PWM | 1. 可编程对总线时钟的预分频
2. 32 位定时器计数器
3. 支持捕获模式
4. 支持连续模式或单次模式;提供参考模式,并能输出多种占空比的波形
5. 兼容IR应用 |
+| USART | 1. 嵌入 2 路 64 字节 FIFO,RX 和 TX 独立操作
2. 5-8位串行数据发送或接收
3. 标准异步通信位,如起始,停止,校验
4. 波特率高达 4 Mbps
5. 支持自动流控模式 |
## 4 内置算法参数
-| 算法名称 | 摄像头输入尺寸 | 模型输入尺寸 | 是否支持 | FPS | 是否实时 |
-|:--------------------------:|:-------:|:---------:|:----:|:---:|:----:|
-| 目标分类(PaddleClas 定制模型) | 任意 | (224x224) | 支持 | 40 | 是 |
-| 目标检测(PaddleDetection 定制模型) | 任意 | (320x320) | 支持 | 25 | 是 |
-| 手写数字识别(PaddleClas 定制模型) | 任意 | (224x224) | 支持 | 35 | 是 |
-| 二维码识别(优化 zxing-cpp 算法) | 任意 | - | 支持 | 50 | 是 |
+为了让用户能够快速上手凌智视觉模块,我们在模块内部集成了以下算法(案例),算法的详细输入参数如下表
+
+| 算法名称 | 摄像头输入尺寸 | 模型输入尺寸 | 是否支持 | FPS | 是否实时 |
+|:-------:|:-------:|:---------:|:----:|:---:|:----:|
+| 通用目标分类 | 任意 | (224x224) | 支持 | 40 | 是 |
+| 手写数字分类 | 任意 | (224x224) | 支持 | 35 | 是 |
+| 猫狗分类 | 任意 | (224x224) | 支持 | 35 | 是 |
+| 花卉分类 | 任意 | (224x224) | 支持 | 35 | 是 |
+| 口罩佩戴分类 | 任意 | (224x224) | 支持 | 35 | 是 |
+| 通用目标检测 | 任意 | (320x320) | 支持 | 25 | 是 |
+| 条形码检测识别 | 任意 | - | 支持 | 50 | 是 |
+| 二维码检测识别 | 任意 | - | 支持 | 50 | 是 |
+| 人脸检测 | 任意 | (320x320) | 支持 | 25 | 是 |
+| 人脸识别 | 任意 | (112x112) | 支持 | 38 | 是 |
> 注:
>
@@ -78,36 +89,3 @@
|:-------:|:--------------------:|
| 电池 | 预留锂电池,3.7 V,XH2.0连接器 |
| WIFI 模组 | - |
-
-## 6 同类产品对比
-
-### 6.1 外设参数对比
-
-| 外设信息 | 凌智视觉模块 | OpenMV4 H7 PLUS | 编程方式 |
-|:-----:|:-----------:|:---------------:|:------:|
-| ADC | 支持 | 支持 | Python |
-| I2C | 支持中 | 支持 | Python |
-| GPIO | 最高支持 7 个 | 仅支持 2 个 | Python |
-| PWM | 支持 | 支持 | Python |
-| USART | 最高支持 2 个 | 支持 2 个 | Python |
-| 摄像头 | (2304x1296) | (2592×1944) | Python |
-
-> 注:
->
-> - OpenMV4 H7 PLUS 最高支持摄像头分辨率为 (2592×1944) ,但一般只能在 (320×240)及以下的分辨率时,实现简单算法 25 FPS(实时)
- ;凌智视觉模块最高支持的摄像头分辨率为(2304x1296),但可以在 (960x540) 分辨率甚至更高的分辨率上的情况下,实现复杂算法 25
- FPS(实时)
-> - 凌智视觉模块在不挂载 WIFI 模组的情况下最高支持 7 个 GPIO 同时使用,挂载 WIFI 模组的情况下,最高支持 2 个 GPIO 同时使用
-> - 凌智视觉模块的最高支持两个串口,但其中一个串口已经用于作为 Debug 口,暂不对外开放
-
-### 6.2 算法参数对比
-
-| 算法名称 | 凌智视觉模块 | OpenMV4 H7 PLUS | 编程方式 |
-|:------:|------------------------------------------------------|----------------------------------------------------|:------:|
-| 目标分类 | 1. 输入尺寸: (224x224)
2. 帧率: 最高 40 FPS | 1. 输入尺寸: (240x240)
2. 帧率: 15 FPS | Python |
-| 目标检测 | 1. 输入尺寸: (320x320)
2. 帧率: 最高 25 FPS | 不支持 | Python |
-| 手写数字识别 | 1. 输入尺寸: (224x224)
2. 帧率: 最高 35 FPS
3. 提供预训练模型 | 1. 输入尺寸: (240x240)
2. 帧率: 15 FPS
3. 不提供预训练模型 | Python |
-| 二维码识别 | 1. 输入尺寸: 任意
2. 帧率: (640x480)下达到 50 FPS | 1. 输入尺寸: 任意
2. 帧率: 25-50 FPS | Python |
-| 人脸检测 | 支持中 | 支持 | Python |
-| 口罩佩戴检测 | 支持中 | 支持 | Python |
-| 人脸识别 | 支持中 | 支持 | Python |
diff --git a/docs/introductory_tutorial/python_development_environment.md b/docs/introductory_tutorial/python_development_environment.md
index 5aaa28c1c1b29a394027afb5b3daf54df370624c..7465b1d0958f1360b1fba61fae3599a1a829be8c 100644
--- a/docs/introductory_tutorial/python_development_environment.md
+++ b/docs/introductory_tutorial/python_development_environment.md
@@ -33,7 +33,7 @@ Lockzhiner Vision Module 的 Python 开发不需要像 C++ 一样的交叉编译
## 2 下载/更新 LockzhinerVisionModule SDK
-点击 [Lockzhiner Vision Module SDK 下载链接](https://gitee.com/LockzhinerAI/LockzhinerVisionModule/releases/download/v0.0.4/lockzhiner_vision_module_sdk.zip) 下载 Lockzhiner Vision Module SDK。解压到本地后,请使用解压软件解压 SDK,一般我们推荐使用 Bandzip。
+点击 [Lockzhiner Vision Module SDK 下载链接](https://gitee.com/LockzhinerAI/LockzhinerVisionModule/releases/download/v0.0.5/lockzhiner_vision_module_sdk.zip) 下载 Lockzhiner Vision Module SDK。解压到本地后,请使用解压软件解压 SDK,一般我们推荐使用 Bandzip。

diff --git a/example/opencv_example/opencv_circle_detection/README.md b/example/opencv_example/opencv_circle_detection/README.md
new file mode 100644
index 0000000000000000000000000000000000000000..70a3705221e9006eda84de2d3502529de3662cb1
--- /dev/null
+++ b/example/opencv_example/opencv_circle_detection/README.md
@@ -0,0 +1,40 @@
+凌智视觉模块 OpenCV 圆形检测部署指南
+
+发布版本:V0.0.0
+
+日期:2024-11-29
+
+文件密级:□绝密 □秘密 □内部资料 ■公开
+
+---
+
+**免责声明**
+
+本文档按**现状**提供,福州凌睿智捷电子有限公司(以下简称**本公司**)不对本文档中的任何陈述、信息和内容的准确性、可靠性、完整性、适销性、适用性及非侵权性提供任何明示或暗示的声明或保证。本文档仅作为使用指导的参考。
+
+由于产品版本升级或其他原因,本文档可能在未经任何通知的情况下不定期更新或修改。
+
+**读者对象**
+
+本教程适用于以下工程师:
+
+- 技术支持工程师
+- 软件开发工程师
+
+**修订记录**
+
+| **日期** | **版本** | **作者** | **修改说明** |
+|:-----------| -------- |--------| ------------ |
+| 2024/11/29 | 0.0.0 | 钟海滨 | 初始版本 |
+
+## 1 简介
+
+在计算机视觉领域,圆形检测是一项常见的任务,广泛应用于工业检测、医疗影像分析、自动驾驶等多个领域。准确地检测圆形不仅可以提高系统的自动化程度,还能显著提升工作效率。本文将详细介绍如何使用 OpenCV 库在凌智视觉模块上实现高效的圆形检测功能。
+
+## 2 在凌智视觉模块上部署圆形检测案例
+
+下载模型后,请参考以下教程使用 Python 在凌智视觉模块上部署分类模型例程:
+
+- [凌智视觉模块 OpenCV 圆形检测 Python 部署指南](./python)
+
+
diff --git a/example/opencv_example/opencv_circle_detection/python/README.md b/example/opencv_example/opencv_circle_detection/python/README.md
new file mode 100644
index 0000000000000000000000000000000000000000..7cf822d27ab8e5188a4d0cfde01d8e63b942c036
--- /dev/null
+++ b/example/opencv_example/opencv_circle_detection/python/README.md
@@ -0,0 +1,189 @@
+凌智视觉模块 OpenCV 圆形检测 Python 部署指南
+
+发布版本:V0.0.0
+
+日期:2024-11-29
+
+文件密级:□绝密 □秘密 □内部资料 ■公开
+
+---
+
+**免责声明**
+
+本文档按**现状**提供,福州凌睿智捷电子有限公司(以下简称**本公司**)不对本文档中的任何陈述、信息和内容的准确性、可靠性、完整性、适销性、适用性及非侵权性提供任何明示或暗示的声明或保证。本文档仅作为使用指导的参考。
+
+由于产品版本升级或其他原因,本文档可能在未经任何通知的情况下不定期更新或修改。
+
+**读者对象**
+
+本教程适用于以下工程师:
+
+- 技术支持工程师
+- 软件开发工程师
+
+**修订记录**
+
+| **日期** | **版本** | **作者** | **修改说明** |
+|:-----------| -------- |--------| ------------ |
+| 2024/11/29 | 0.0.0 | 钟海滨 | 初始版本 |
+
+## 1 简介
+
+在计算机视觉领域,圆形检测是一项常见的任务,广泛应用于工业检测、医疗影像分析、自动驾驶等多个领域。准确地检测圆形不仅可以提高系统的自动化程度,还能显著提升工作效率。 本文将详细介绍如何使用 OpenCV 库在凌智视觉模块上实现高效的圆形检测功能。
+
+
+## 2 Python API 文档
+
+```python
+
+def cvtColor(src, code, dstCn=0):
+ """
+ 转换图像颜色空间。
+ 参数:
+ - src: 输入图像。
+ - code: 颜色空间转换代码。
+ - dstCn: 目标图像的通道数,如果为0则根据code自动确定。
+ 返回:
+ - 转换后的图像。
+ """
+
+def GaussianBlur(src, ksize, sigmaX, sigmaY=0, borderType=cv2.BORDER_DEFAULT):
+ """
+ 使用高斯滤波模糊图像。
+ 参数:
+ - src: 输入图像。
+ - ksize: 滤波器的大小,必须是正奇数。
+ - sigmaX: 水平方向的标准差。
+ - sigmaY: 垂直方向的标准差,如果为0则与sigmaX相同。
+ - borderType: 边界处理方式,默认为cv2.BORDER_DEFAULT。
+ 返回:
+ - 模糊后的图像。
+ """
+
+def HoughCircles(image, method, dp, minDist, param1, param2, minRadius, maxRadius):
+ """
+ 使用霍夫变换检测图像中的圆。
+ 参数:
+ - image: 输入图像,应为8位单通道(灰度)图像。
+ - method: 检测方法,通常为cv2.HOUGH_GRADIENT。
+ - dp: 累加器分辨率与图像分辨率的反比。
+ - minDist: 检测到的圆的中心之间的最小距离。
+ - param1: 梯度值阈值。
+ - param2: 累加器阈值。
+ - minRadius: 最小圆半径。
+ - maxRadius: 最大圆半径。
+ 返回:
+ - 检测到的圆的数组,每个圆包含三个值:圆心坐标(x, y)和半径。
+ """
+
+def circle(img, center, radius, color, thickness=1, lineType=8, shift=0):
+ """
+ 在图像上绘制圆。
+ 参数:
+ - img: 输入图像。
+ - center: 圆心坐标。
+ - radius: 圆的半径。
+ - color: 圆的颜色,为一个包含BGR值的元组。
+ - thickness: 圆轮廓的厚度,正值表示轮廓厚度,负值表示填充圆。
+ - lineType: 线条类型,默认为8连接线。
+ - shift: 圆心坐标和半径的缩放比例,默认为0表示无缩放。
+ """
+
+```
+
+## 3 在凌智视觉模块上进行边缘检测案例
+
+为了方便大家入手,我们提供了 OpenCV 圆形检测的 Python 例程。该程序可以使用摄像头进行端到端推理。
+
+
+```python
+from lockzhiner_vision_module.cv2 import VideoCapture
+import lockzhiner_vision_module.cv2 as cv2
+from lockzhiner_vision_module.edit import Edit
+import time
+import sys
+pi = 3.14159265358979323846
+if __name__ == "__main__":
+ args = sys.argv
+ if len(args) != 3:
+ print("Need model path. Example: python test_capture.py width height")
+ exit(1)
+
+ edit = Edit()
+ edit.start_and_accept_connection()
+
+ video_capture = VideoCapture()
+ video_capture.set_width(int(args[1]))
+ video_capture.set_height(int(args[2]))
+ if video_capture.open(0) is False:
+ print("Failed to open capture")
+ exit(1)
+
+ while True:
+ read_index = 0
+ total_time_ms = 0
+ for i in range(30):
+ start_time = time.time()
+ ret, mat = video_capture.read()
+ if ret is False:
+ continue
+ end_time = time.time()
+ # 转换为灰度图像
+ # 转换为灰度图像
+ gray = cv2.cvtColor(mat, cv2.COLOR_BGR2GRAY)
+
+ # 使用高斯模糊减少噪声
+ blurred = cv2.GaussianBlur(gray, (9, 9), 2)
+
+ # 使用 HoughCircles 检测圆形
+ circles = cv2.HoughCircles(blurred, cv2.HOUGH_GRADIENT, dp=1, minDist=50,
+ param1=50, param2=30, minRadius=120, maxRadius=250)
+ # print(circles)
+ if circles is not None:
+ # 在图像上绘制检测到的圆
+ for i in circles[0]:
+ center = (int(i[0]), int(i[1]))
+ radius = int(i[2])
+ cv2.putText(mat, "circle", (50, 50), cv2.FONT_HERSHEY_SIMPLEX, 1, (0, 0, 255), 2)
+ # 绘制圆心
+ cv2.circle(mat, center, 1, (0, 100, 100), 3)
+
+ # 绘制圆
+ cv2.circle(mat, center, radius, (0, 255, 0), 3)
+
+ edit.print(mat)
+ total_time_ms += end_time - start_time
+ read_index += 1
+ print(f"FPS is {1.0 / (total_time_ms/read_index)}")
+
+```
+## 4 上传并测试 Python 程序
+
+参考 [连接设备指南](../../../../docs/introductory_tutorial/connect_device_using_ssh.md) 正确连接 Lockzhiner Vision Module 设备。
+
+
+
+请使用 Electerm Sftp 依次上传以下文件:
+
+- 进入存放 **test_hough_circle.py** 脚本文件的目录,将 **test_hough_circle.py** 上传到 Lockzhiner Vision Module
+
+上传文件
+
+
+请使用 Electerm Ssh 并在命令行中执行以下命令:
+
+```bash
+python test_hough_circle.py 640 480
+```
+
+运行程序后,屏幕上输出
+
+
+
+
+圆形检测结果图片
+
+
+
+
+
diff --git a/example/opencv_example/opencv_circle_detection/python/images/circle.png b/example/opencv_example/opencv_circle_detection/python/images/circle.png
new file mode 100644
index 0000000000000000000000000000000000000000..bc0b5c320099a6fa8ba58004efad59a10825c87a
Binary files /dev/null and b/example/opencv_example/opencv_circle_detection/python/images/circle.png differ
diff --git a/example/opencv_example/opencv_circle_detection/python/images/circle_img.png b/example/opencv_example/opencv_circle_detection/python/images/circle_img.png
new file mode 100644
index 0000000000000000000000000000000000000000..71b2d9f5326aa9e384a406631cfedf352061d999
Binary files /dev/null and b/example/opencv_example/opencv_circle_detection/python/images/circle_img.png differ
diff --git a/example/opencv_example/opencv_circle_detection/python/images/img.png b/example/opencv_example/opencv_circle_detection/python/images/img.png
new file mode 100644
index 0000000000000000000000000000000000000000..2c047655beddc6f7f822bdf096761cc9353210c8
Binary files /dev/null and b/example/opencv_example/opencv_circle_detection/python/images/img.png differ
diff --git a/example/opencv_example/opencv_circle_detection/python/images/img_1.png b/example/opencv_example/opencv_circle_detection/python/images/img_1.png
new file mode 100644
index 0000000000000000000000000000000000000000..f74688e562892755003e0b90412ad2c6d69c1119
Binary files /dev/null and b/example/opencv_example/opencv_circle_detection/python/images/img_1.png differ
diff --git a/example/opencv_example/opencv_circle_detection/python/images/img_2.png b/example/opencv_example/opencv_circle_detection/python/images/img_2.png
new file mode 100644
index 0000000000000000000000000000000000000000..19415f3d71c88ac9cdd2b2a7ea271449d90d748c
Binary files /dev/null and b/example/opencv_example/opencv_circle_detection/python/images/img_2.png differ
diff --git a/example/opencv_example/opencv_circle_detection/python/images/img_3.png b/example/opencv_example/opencv_circle_detection/python/images/img_3.png
new file mode 100644
index 0000000000000000000000000000000000000000..7c2616b9a277eb2c88fd8881aff99655f17e20d6
Binary files /dev/null and b/example/opencv_example/opencv_circle_detection/python/images/img_3.png differ
diff --git a/example/opencv_example/opencv_circle_detection/python/images/img_circles.png b/example/opencv_example/opencv_circle_detection/python/images/img_circles.png
new file mode 100644
index 0000000000000000000000000000000000000000..577048a4321ec150540646bcc400407827218cfb
Binary files /dev/null and b/example/opencv_example/opencv_circle_detection/python/images/img_circles.png differ
diff --git a/example/opencv_example/opencv_circle_detection/python/images/result.png b/example/opencv_example/opencv_circle_detection/python/images/result.png
new file mode 100644
index 0000000000000000000000000000000000000000..d4b20f7159e447e5acab52add3f6b8727afe5f00
Binary files /dev/null and b/example/opencv_example/opencv_circle_detection/python/images/result.png differ
diff --git a/example/opencv_example/opencv_circle_detection/python/images/ssh.png b/example/opencv_example/opencv_circle_detection/python/images/ssh.png
new file mode 100644
index 0000000000000000000000000000000000000000..15072073dc5d93e2cd87451ff75c008bad07e311
Binary files /dev/null and b/example/opencv_example/opencv_circle_detection/python/images/ssh.png differ
diff --git a/example/opencv_example/opencv_circle_detection/python/test_hough_circle.py b/example/opencv_example/opencv_circle_detection/python/test_hough_circle.py
new file mode 100644
index 0000000000000000000000000000000000000000..bf8b9b1c5b51371ecd789a1a29c1c98e88edf2ba
--- /dev/null
+++ b/example/opencv_example/opencv_circle_detection/python/test_hough_circle.py
@@ -0,0 +1,58 @@
+from lockzhiner_vision_module.cv2 import VideoCapture
+import lockzhiner_vision_module.cv2 as cv2
+from lockzhiner_vision_module.edit import Edit
+import time
+import sys
+pi = 3.14159265358979323846
+if __name__ == "__main__":
+ args = sys.argv
+ if len(args) != 3:
+ print("Need model path. Example: python test_capture.py width height")
+ exit(1)
+
+ edit = Edit()
+ edit.start_and_accept_connection()
+
+ video_capture = VideoCapture()
+ video_capture.set_width(int(args[1]))
+ video_capture.set_height(int(args[2]))
+ if video_capture.open(0) is False:
+ print("Failed to open capture")
+ exit(1)
+
+ while True:
+ read_index = 0
+ total_time_ms = 0
+ for i in range(30):
+ start_time = time.time()
+ ret, mat = video_capture.read()
+ if ret is False:
+ continue
+ end_time = time.time()
+ # 转换为灰度图像
+ # 转换为灰度图像
+ gray = cv2.cvtColor(mat, cv2.COLOR_BGR2GRAY)
+
+ # 使用高斯模糊减少噪声
+ blurred = cv2.GaussianBlur(gray, (9, 9), 2)
+
+ # 使用 HoughCircles 检测圆形
+ circles = cv2.HoughCircles(blurred, cv2.HOUGH_GRADIENT, dp=1, minDist=50,
+ param1=50, param2=30, minRadius=120, maxRadius=250)
+ # print(circles)
+ if circles is not None:
+ # 在图像上绘制检测到的圆
+ for i in circles[0]:
+ center = (int(i[0]), int(i[1]))
+ radius = int(i[2])
+ cv2.putText(mat, "circle", (50, 50), cv2.FONT_HERSHEY_SIMPLEX, 1, (0, 0, 255), 2)
+ # 绘制圆心
+ cv2.circle(mat, center, 1, (0, 100, 100), 3)
+
+ # 绘制圆
+ cv2.circle(mat, center, radius, (0, 255, 0), 3)
+
+ edit.print(mat)
+ total_time_ms += end_time - start_time
+ read_index += 1
+ print(f"FPS is {1.0 / (total_time_ms/read_index)}")
\ No newline at end of file
diff --git a/example/opencv_example/opencv_edge_detection/README.md b/example/opencv_example/opencv_edge_detection/README.md
new file mode 100644
index 0000000000000000000000000000000000000000..7f5f99273a1c6632f1881d83bd4856f08502a131
--- /dev/null
+++ b/example/opencv_example/opencv_edge_detection/README.md
@@ -0,0 +1,39 @@
+凌智视觉模块 OpenCV 边缘检测部署指南
+
+发布版本:V0.0.0
+
+日期:2024-11-29
+
+文件密级:□绝密 □秘密 □内部资料 ■公开
+
+---
+
+**免责声明**
+
+本文档按**现状**提供,福州凌睿智捷电子有限公司(以下简称**本公司**)不对本文档中的任何陈述、信息和内容的准确性、可靠性、完整性、适销性、适用性及非侵权性提供任何明示或暗示的声明或保证。本文档仅作为使用指导的参考。
+
+由于产品版本升级或其他原因,本文档可能在未经任何通知的情况下不定期更新或修改。
+
+**读者对象**
+
+本教程适用于以下工程师:
+
+- 技术支持工程师
+- 软件开发工程师
+
+**修订记录**
+
+| **日期** | **版本** | **作者** | **修改说明** |
+|:-----------| -------- |--------| ------------ |
+| 2024/11/29 | 0.0.0 | 钟海滨 | 初始版本 |
+
+## 1 简介
+
+在现代计算机视觉应用中,边缘检测是一项基础而重要的任务,它能够帮助系统理解和解析图像中的关键结构信息。边缘检测技术广泛应用于图像分割、目标识别、特征提取等多个领域。
+本指南将详细介绍如何使用 OpenCV 库在凌智视觉模块上部署高效的边缘检测算法,旨在为开发者提供一个清晰、实用的操作步骤。
+
+## 2 在凌智视觉模块上部署边缘检测案例
+
+- [凌智视觉模块 OpenCV 边缘检测 Python 部署指南](./python/README.md)
+
+
diff --git a/example/opencv_example/opencv_edge_detection/python/README.md b/example/opencv_example/opencv_edge_detection/python/README.md
new file mode 100644
index 0000000000000000000000000000000000000000..b6bf2dd07e40f60a81d34bde1a18a59a3f623e1f
--- /dev/null
+++ b/example/opencv_example/opencv_edge_detection/python/README.md
@@ -0,0 +1,144 @@
+凌智视觉模块 OpenCV 边缘检测 Python 部署指南
+
+发布版本:V0.0.0
+
+日期:2024-11-29
+
+文件密级:□绝密 □秘密 □内部资料 ■公开
+
+---
+
+**免责声明**
+
+本文档按**现状**提供,福州凌睿智捷电子有限公司(以下简称**本公司**)不对本文档中的任何陈述、信息和内容的准确性、可靠性、完整性、适销性、适用性及非侵权性提供任何明示或暗示的声明或保证。本文档仅作为使用指导的参考。
+
+由于产品版本升级或其他原因,本文档可能在未经任何通知的情况下不定期更新或修改。
+
+**读者对象**
+
+本教程适用于以下工程师:
+
+- 技术支持工程师
+- 软件开发工程师
+
+**修订记录**
+
+| **日期** | **版本** | **作者** | **修改说明** |
+|:-----------| -------- |--------| ------------ |
+| 2024/11/29 | 0.0.0 | 钟海滨 | 初始版本 |
+
+## 1 简介
+
+在现代计算机视觉应用中,边缘检测是一项基础而重要的任务,它能够帮助系统理解和解析图像中的关键结构信息。边缘检测技术广泛应用于图像分割、目标识别、特征提取等多个领域。
+本指南将详细介绍如何使用 OpenCV 库在凌智视觉模块上部署高效的边缘检测算法,旨在为开发者提供一个清晰、实用的操作步骤。
+
+
+## 2 Python API 文档
+
+```python
+def GaussianBlur(src, ksize, sigmaX, sigmaY=0, borderType=cv2.BORDER_DEFAULT):
+ """
+ 对图像进行高斯模糊处理。
+ 参数:
+ - src: 输入图像。
+ - ksize: 高斯核的大小,可以是一个整数或两个整数的元组。
+ - sigmaX: 高斯核在X方向上的标准差。
+ - sigmaY: 高斯核在Y方向上的标准差,默认为0。
+ - borderType: 图像边界的处理方式,默认为cv2.BORDER_DEFAULT。
+ 返回:
+ - 模糊处理后的图像。
+ """
+
+def threshold(src, thresh, maxval, type):
+ """
+ 对图像进行阈值处理。
+ 参数:
+ - src: 输入图像。
+ - thresh: 阈值。
+ - maxval: 最大值,应用于type所指定的阈值类型。
+ - type: 阈值处理的类型。
+ 返回:
+ - 计算得到的阈值。
+ - 阈值处理后的图像。
+ """
+
+def Canny(img, threshold1, threshold2, apertureSize=3, L2gradient=False):
+ """
+ 使用Canny算法检测图像中的边缘。
+ 参数:
+ - img: 输入图像。
+ - threshold1: 第一个阈值,用于边缘检测。
+ - threshold2: 第二个阈值,用于边缘检测。
+ - apertureSize: Sobel算子的孔径大小,默认为3。
+ - L2gradient: 一个布尔值,表示是否使用更精确的L2范数进行梯度计算,默认为False。
+ 返回:
+ - 边缘检测后的图像。
+ """
+```
+
+
+## 3 在凌智视觉模块上进行边缘检测案例
+
+为了快速上手,我们提供了边缘检测案例
+**测试图片下载链接:**[边缘检测图片](https://gitee.com/LockzhinerAI/LockzhinerVisionModule/releases/download/v0.0.4/car.png)
+
+```python
+import lockzhiner_vision_module.cv2 as cv2
+# 读取图片
+image = cv2.imread('car.png')
+# 检查图像是否成功读取
+if image is None:
+ print("Error: Unable to load image.")
+ exit()
+# 转换为灰度图像
+gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
+# 高斯模糊
+blurred = cv2.GaussianBlur(gray, (3, 3), 0)
+# 阈值操作
+_, thresholded = cv2.threshold(blurred, 100, 255, cv2.THRESH_BINARY)
+# 使用 Canny 边缘检测
+edges = cv2.Canny(thresholded, 20, 10)
+# 保存边缘检测结果
+cv2.imwrite('edges.png', edges)
+```
+
+## 4 上传并测试 Python 程序
+
+参考 [连接设备指南](../../../docs/introductory_tutorial/connect_device_using_ssh.md) 正确连接 Lockzhiner Vision Module 设备。
+
+
+
+请使用 Electerm Sftp 依次上传以下文件:
+
+- 进入存放 **test_canny.py** 脚本文件的目录,将 **test_canny.py** 上传到 Lockzhiner Vision Module
+- 进入存放 **待检测图片** 存放的目录,将 **待检测图片** 上传到 Lockzhiner Vision Module
+
+上传文件
+
+
+
+请使用 Electerm Ssh 并在命令行中执行以下命令:
+
+```bash
+python test_canny.py
+```
+
+运行程序后,屏幕上输出
+
+
+
+下载结果
+
+
+
+边缘检测原图
+
+
+
+边缘检测结果图片
+
+
+
+
+
+
diff --git a/example/opencv_example/opencv_edge_detection/python/images/car.png b/example/opencv_example/opencv_edge_detection/python/images/car.png
new file mode 100644
index 0000000000000000000000000000000000000000..1362b71e8bad37acb9b208d13b8e280bbff8d52d
Binary files /dev/null and b/example/opencv_example/opencv_edge_detection/python/images/car.png differ
diff --git a/example/opencv_example/opencv_edge_detection/python/images/edges.png b/example/opencv_example/opencv_edge_detection/python/images/edges.png
new file mode 100644
index 0000000000000000000000000000000000000000..c28c472fa658836151e169f4b1e8332e47e6490f
Binary files /dev/null and b/example/opencv_example/opencv_edge_detection/python/images/edges.png differ
diff --git a/example/opencv_example/opencv_edge_detection/python/images/img.png b/example/opencv_example/opencv_edge_detection/python/images/img.png
new file mode 100644
index 0000000000000000000000000000000000000000..bf6d465d1122afe0bfe758a70dc1b6d4f81caf01
Binary files /dev/null and b/example/opencv_example/opencv_edge_detection/python/images/img.png differ
diff --git a/example/opencv_example/opencv_edge_detection/python/images/img_1.png b/example/opencv_example/opencv_edge_detection/python/images/img_1.png
new file mode 100644
index 0000000000000000000000000000000000000000..a82d7a8d8d73fa414fbc3d3fff02011942e11367
Binary files /dev/null and b/example/opencv_example/opencv_edge_detection/python/images/img_1.png differ
diff --git a/example/opencv_example/opencv_edge_detection/python/images/img_2.png b/example/opencv_example/opencv_edge_detection/python/images/img_2.png
new file mode 100644
index 0000000000000000000000000000000000000000..7a672eb61b8b075f4465fb3316004127c95a1999
Binary files /dev/null and b/example/opencv_example/opencv_edge_detection/python/images/img_2.png differ
diff --git a/example/opencv_example/opencv_edge_detection/python/images/thresholded.png b/example/opencv_example/opencv_edge_detection/python/images/thresholded.png
new file mode 100644
index 0000000000000000000000000000000000000000..673fcf9354f60cb872e79c4b2cbb98f96f3d7c5c
Binary files /dev/null and b/example/opencv_example/opencv_edge_detection/python/images/thresholded.png differ
diff --git a/example/opencv_example/opencv_edge_detection/python/test_canny.py b/example/opencv_example/opencv_edge_detection/python/test_canny.py
new file mode 100644
index 0000000000000000000000000000000000000000..c3b35382ab098335a1275ec7c6e1270361f76e0e
--- /dev/null
+++ b/example/opencv_example/opencv_edge_detection/python/test_canny.py
@@ -0,0 +1,17 @@
+import lockzhiner_vision_module.cv2 as cv2
+# 读取图片
+image = cv2.imread('car.png')
+# 检查图像是否成功读取
+if image is None:
+ print("Error: Unable to load image.")
+ exit()
+# 转换为灰度图像
+gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
+# 高斯模糊
+blurred = cv2.GaussianBlur(gray, (3, 3), 0)
+# 阈值操作
+_, thresholded = cv2.threshold(blurred, 100, 255, cv2.THRESH_BINARY)
+# 使用 Canny 边缘检测
+edges = cv2.Canny(thresholded, 20, 10)
+# 保存边缘检测结果
+cv2.imwrite('edges.png', edges)
diff --git a/example/opencv_example/opencv_line_detection/README.md b/example/opencv_example/opencv_line_detection/README.md
new file mode 100644
index 0000000000000000000000000000000000000000..e2a532499b34f75e002ae75ce384dd78dfa0794d
--- /dev/null
+++ b/example/opencv_example/opencv_line_detection/README.md
@@ -0,0 +1,38 @@
+凌智视觉模块 OpenCV 直线检测部署指南
+
+发布版本:V0.0.0
+
+日期:2024-11-29
+
+文件密级:□绝密 □秘密 □内部资料 ■公开
+
+---
+
+**免责声明**
+
+本文档按**现状**提供,福州凌睿智捷电子有限公司(以下简称**本公司**)不对本文档中的任何陈述、信息和内容的准确性、可靠性、完整性、适销性、适用性及非侵权性提供任何明示或暗示的声明或保证。本文档仅作为使用指导的参考。
+
+由于产品版本升级或其他原因,本文档可能在未经任何通知的情况下不定期更新或修改。
+
+**读者对象**
+
+本教程适用于以下工程师:
+
+- 技术支持工程师
+- 软件开发工程师
+
+**修订记录**
+
+| **日期** | **版本** | **作者** | **修改说明** |
+|:-----------| -------- |--------| ------------ |
+| 2024/11/29 | 0.0.0 | 钟海滨 | 初始版本 |
+
+## 1 简介
+
+直线检测是计算机视觉中的一个基本任务,广泛应用于图像处理、机器视觉和自动驾驶等领域。通过检测图像中的直线,可以实现道路边缘识别、物体边界检测等多种应用场景。本指南将详细介绍如何使用 OpenCV 库在凌智视觉模块上部署直线检测功能。
+
+## 2 在凌智视觉模块上部署直线检测案例
+
+- [凌智视觉模块 OpenCV 直线检测 Python 部署指南](./python/README.md)
+
+
diff --git a/example/opencv_example/opencv_line_detection/python/README.md b/example/opencv_example/opencv_line_detection/python/README.md
new file mode 100644
index 0000000000000000000000000000000000000000..8eab3ba0d3e5f441486601dc55df5e46493acc3b
--- /dev/null
+++ b/example/opencv_example/opencv_line_detection/python/README.md
@@ -0,0 +1,180 @@
+凌智视觉模块 OpenCV 直线检测 Python 部署指南
+
+发布版本:V0.0.0
+
+日期:2024-11-29
+
+文件密级:□绝密 □秘密 □内部资料 ■公开
+
+---
+
+**免责声明**
+
+本文档按**现状**提供,福州凌睿智捷电子有限公司(以下简称**本公司**)不对本文档中的任何陈述、信息和内容的准确性、可靠性、完整性、适销性、适用性及非侵权性提供任何明示或暗示的声明或保证。本文档仅作为使用指导的参考。
+
+由于产品版本升级或其他原因,本文档可能在未经任何通知的情况下不定期更新或修改。
+
+**读者对象**
+
+本教程适用于以下工程师:
+
+- 技术支持工程师
+- 软件开发工程师
+
+**修订记录**
+
+| **日期** | **版本** | **作者** | **修改说明** |
+|:-----------| -------- |--------| ------------ |
+| 2024/11/29 | 0.0.0 | 钟海滨 | 初始版本 |
+
+## 1 简介
+
+直线检测是计算机视觉中的一个基本任务,广泛应用于图像处理、机器视觉和自动驾驶等领域。通过检测图像中的直线,可以实现道路边缘识别、物体边界检测等多种应用场景。本指南将详细介绍如何使用 OpenCV 库在凌智视觉模块上部署直线检测功能。
+
+## 2 Python API 文档
+
+```python
+def cvtColor(src, code, dstCn=0):
+ """
+ 转换图像的颜色空间。
+ 参数:
+ - src: 输入图像。
+ - code: 颜色空间转换的代码。
+ - dstCn: 目标图像的通道数,默认为0。
+ 返回:
+ - 颜色空间转换后的图像。
+ """
+
+def GaussianBlur(src, ksize, sigmaX, sigmaY=0, borderType=cv2.BORDER_DEFAULT):
+ """
+ 对图像进行高斯模糊处理。
+ 参数:
+ - src: 输入图像。
+ - ksize: 高斯核的大小,可以是一个整数或两个整数的元组。
+ - sigmaX: 高斯核在X方向上的标准差。
+ - sigmaY: 高斯核在Y方向上的标准差,默认为0。
+ - borderType: 图像边界的处理方式,默认为cv2.BORDER_DEFAULT。
+ 返回:
+ - 模糊处理后的图像。
+ """
+
+def Canny(img, threshold1, threshold2, apertureSize=3, L2gradient=False):
+ """
+ 使用Canny算法检测图像中的边缘。
+ 参数:
+ - img: 输入图像。
+ - threshold1: 第一个阈值,用于直线检测。
+ - threshold2: 第二个阈值,用于直线检测。
+ - apertureSize: Sobel算子的孔径大小,默认为3。
+ - L2gradient: 一个布尔值,表示是否使用更精确的L2范数进行梯度计算,默认为False。
+ 返回:
+ - 直线检测后的图像。
+ """
+
+def HoughLinesP(image, rho, theta, threshold, minLineLength=0, maxLineGap=0):
+ """
+ 使用霍夫变换检测图像中的线段。
+ 参数:
+ - image: 输入图像。
+ - rho: 距离的分辨率。
+ - theta: 角度的分辨率。
+ - threshold: 累计器的阈值。
+ - minLineLength: 最小线段长度,默认为0。
+ - maxLineGap: 线段之间的最大间隔,默认为0。
+ 返回:
+ - 检测到的线段信息列表。
+ """
+
+
+```
+
+
+## 3 在凌智视觉模块上进行直线检测案例
+
+为了快速上手,我们提供了直线检测案例
+
+```python
+from lockzhiner_vision_module.cv2 import VideoCapture
+import lockzhiner_vision_module.cv2 as cv2
+from lockzhiner_vision_module.edit import Edit
+import time
+import sys
+pi = 3.14159265358979323846
+if __name__ == "__main__":
+ args = sys.argv
+ if len(args) != 3:
+ print("Need model path. Example: python test_capture.py width height")
+ exit(1)
+
+ edit = Edit()
+ edit.start_and_accept_connection()
+
+ video_capture = VideoCapture()
+ video_capture.set_width(int(args[1]))
+ video_capture.set_height(int(args[2]))
+ if video_capture.open(0) is False:
+ print("Failed to open capture")
+ exit(1)
+
+ while True:
+ read_index = 0
+ total_time_ms = 0
+ for i in range(30):
+ start_time = time.time()
+ ret, mat = video_capture.read()
+ if ret is False:
+ continue
+ end_time = time.time()
+ # 转换为灰度图像
+ gray = cv2.cvtColor(mat, cv2.COLOR_BGR2GRAY)
+ # 使用高斯模糊减少噪声
+ blurred = cv2.GaussianBlur(gray, (5, 5), 1)
+ # 使用 Canny 边缘检测
+ edges = cv2.Canny(gray, 50, 150)
+ # 使用霍夫变换检测直线
+ lines = cv2.HoughLinesP(edges, 1, pi / 180, threshold=100, minLineLength=40, maxLineGap=40)
+ # 绘制检测到的直线
+ if lines is not None:
+ for line in lines[0]:
+ x1, y1, x2, y2 = line
+ cv2.putText(mat, "line", (50, 50), cv2.FONT_HERSHEY_SIMPLEX, 1, (0, 0, 255), 2)
+ cv2.line(mat, (x1, y1), (x2, y2), (0, 255, 0), 2)
+
+ edit.print(mat)
+ total_time_ms += end_time - start_time
+ read_index += 1
+ print(f"FPS is {1.0 / (total_time_ms/read_index)}")
+
+```
+
+## 4 上传并测试 Python 程序
+
+参考 [连接设备指南](../../../../docs/introductory_tutorial/connect_device_using_ssh.md) 正确连接 Lockzhiner Vision Module 设备。
+
+
+
+请使用 Electerm Sftp 依次上传以下文件:
+
+- 进入存放 **test_line.py** 脚本文件的目录,将 **test_line.py** 上传到 Lockzhiner Vision Module
+
+上传文件
+
+
+
+请使用 Electerm Ssh 并在命令行中执行以下命令:
+
+```bash
+python test_line.py 640 480
+```
+
+运行程序后,屏幕上输出
+
+
+
+直线检测结果图片
+
+
+
+
+
+
diff --git a/example/opencv_example/opencv_line_detection/python/images/dowmresults.png b/example/opencv_example/opencv_line_detection/python/images/dowmresults.png
new file mode 100644
index 0000000000000000000000000000000000000000..603b895fbb50ff23a58f8aefc4f44f7c8f64d91d
Binary files /dev/null and b/example/opencv_example/opencv_line_detection/python/images/dowmresults.png differ
diff --git a/example/opencv_example/opencv_line_detection/python/images/img.png b/example/opencv_example/opencv_line_detection/python/images/img.png
new file mode 100644
index 0000000000000000000000000000000000000000..90373fe2a10c15cba6a197774b4415e480662e3e
Binary files /dev/null and b/example/opencv_example/opencv_line_detection/python/images/img.png differ
diff --git a/example/opencv_example/opencv_line_detection/python/images/img_detected.png b/example/opencv_example/opencv_line_detection/python/images/img_detected.png
new file mode 100644
index 0000000000000000000000000000000000000000..8211a5ef610e253dcbad7fe1aa92141ebf32a379
Binary files /dev/null and b/example/opencv_example/opencv_line_detection/python/images/img_detected.png differ
diff --git a/example/opencv_example/opencv_line_detection/python/images/line.png b/example/opencv_example/opencv_line_detection/python/images/line.png
new file mode 100644
index 0000000000000000000000000000000000000000..dc3473432771503de73ffd3480d8c063d9e531a0
Binary files /dev/null and b/example/opencv_example/opencv_line_detection/python/images/line.png differ
diff --git a/example/opencv_example/opencv_line_detection/python/images/line_results.png b/example/opencv_example/opencv_line_detection/python/images/line_results.png
new file mode 100644
index 0000000000000000000000000000000000000000..992d1b12e7adab0b3dc84713a1e9a3965fae7a38
Binary files /dev/null and b/example/opencv_example/opencv_line_detection/python/images/line_results.png differ
diff --git a/example/opencv_example/opencv_line_detection/python/images/run.png b/example/opencv_example/opencv_line_detection/python/images/run.png
new file mode 100644
index 0000000000000000000000000000000000000000..4ee4df22882f1a9c26145945cb5e5d01fceb4447
Binary files /dev/null and b/example/opencv_example/opencv_line_detection/python/images/run.png differ
diff --git a/example/opencv_example/opencv_line_detection/python/images/upload.png b/example/opencv_example/opencv_line_detection/python/images/upload.png
new file mode 100644
index 0000000000000000000000000000000000000000..0413baa83f822f61009f7e82d8956f6eae69e3fb
Binary files /dev/null and b/example/opencv_example/opencv_line_detection/python/images/upload.png differ
diff --git a/example/opencv_example/opencv_line_detection/python/test_line.py b/example/opencv_example/opencv_line_detection/python/test_line.py
new file mode 100644
index 0000000000000000000000000000000000000000..a8911f355df4939c4ef1444791206a0b2da4a953
--- /dev/null
+++ b/example/opencv_example/opencv_line_detection/python/test_line.py
@@ -0,0 +1,50 @@
+from lockzhiner_vision_module.cv2 import VideoCapture
+import lockzhiner_vision_module.cv2 as cv2
+from lockzhiner_vision_module.edit import Edit
+import time
+import sys
+pi = 3.14159265358979323846
+if __name__ == "__main__":
+ args = sys.argv
+ if len(args) != 3:
+ print("Need model path. Example: python test_capture.py width height")
+ exit(1)
+
+ edit = Edit()
+ edit.start_and_accept_connection()
+
+ video_capture = VideoCapture()
+ video_capture.set_width(int(args[1]))
+ video_capture.set_height(int(args[2]))
+ if video_capture.open(0) is False:
+ print("Failed to open capture")
+ exit(1)
+
+ while True:
+ read_index = 0
+ total_time_ms = 0
+ for i in range(30):
+ start_time = time.time()
+ ret, mat = video_capture.read()
+ if ret is False:
+ continue
+ end_time = time.time()
+ # 转换为灰度图像
+ gray = cv2.cvtColor(mat, cv2.COLOR_BGR2GRAY)
+ # 使用高斯模糊减少噪声
+ blurred = cv2.GaussianBlur(gray, (5, 5), 1)
+ # 使用 Canny 边缘检测
+ edges = cv2.Canny(gray, 50, 150)
+ # 使用霍夫变换检测直线
+ lines = cv2.HoughLinesP(edges, 1, pi / 180, threshold=100, minLineLength=40, maxLineGap=40)
+ # 绘制检测到的直线
+ if lines is not None:
+ for line in lines[0]:
+ x1, y1, x2, y2 = line
+ cv2.putText(mat, "line", (50, 50), cv2.FONT_HERSHEY_SIMPLEX, 1, (0, 0, 255), 2)
+ cv2.line(mat, (x1, y1), (x2, y2), (0, 255, 0), 2)
+
+ edit.print(mat)
+ total_time_ms += end_time - start_time
+ read_index += 1
+ print(f"FPS is {1.0 / (total_time_ms/read_index)}")
\ No newline at end of file
diff --git a/example/opencv_example/opencv_rectangle_detection/README.md b/example/opencv_example/opencv_rectangle_detection/README.md
new file mode 100644
index 0000000000000000000000000000000000000000..2d9b97f15b1343e5973e37c33f41b14ad4c9cc9b
--- /dev/null
+++ b/example/opencv_example/opencv_rectangle_detection/README.md
@@ -0,0 +1,40 @@
+凌智视觉模块 OpenCV 矩形检测部署指南
+
+发布版本:V0.0.0
+
+日期:2024-11-29
+
+文件密级:□绝密 □秘密 □内部资料 ■公开
+
+---
+
+**免责声明**
+
+本文档按**现状**提供,福州凌睿智捷电子有限公司(以下简称**本公司**)不对本文档中的任何陈述、信息和内容的准确性、可靠性、完整性、适销性、适用性及非侵权性提供任何明示或暗示的声明或保证。本文档仅作为使用指导的参考。
+
+由于产品版本升级或其他原因,本文档可能在未经任何通知的情况下不定期更新或修改。
+
+**读者对象**
+
+本教程适用于以下工程师:
+
+- 技术支持工程师
+- 软件开发工程师
+
+**修订记录**
+
+| **日期** | **版本** | **作者** | **修改说明** |
+|:-----------| -------- |--------| ------------ |
+| 2024/11/29 | 0.0.0 | 钟海滨 | 初始版本 |
+
+## 1 简介
+
+在现代计算机视觉应用中,矩形检测是一项基本但重要的任务,广泛应用于物体识别、场景理解、文档扫描等领域。本指南将详细介绍如何使用 OpenCV 库在凌智视觉模块上部署高效的矩形检测算法。
+
+## 2 在凌智视觉模块上部署矩形检测案例
+
+下载模型后,请参考以下教程使用 Python 在凌智视觉模块上部署分类模型例程:
+
+- [凌智视觉模块 OpenCV 矩形检测 Python 部署指南](./python/README.md)
+
+
diff --git a/example/opencv_example/opencv_rectangle_detection/python/README.md b/example/opencv_example/opencv_rectangle_detection/python/README.md
new file mode 100644
index 0000000000000000000000000000000000000000..6ec4037c86edf9a4d90e4c7ae5fa0e249a0a7f16
--- /dev/null
+++ b/example/opencv_example/opencv_rectangle_detection/python/README.md
@@ -0,0 +1,217 @@
+凌智视觉模块 OpenCV 矩形检测 Python 部署指南
+
+发布版本:V0.0.0
+
+日期:2024-11-29
+
+文件密级:□绝密 □秘密 □内部资料 ■公开
+
+---
+
+**免责声明**
+
+本文档按**现状**提供,福州凌睿智捷电子有限公司(以下简称**本公司**)不对本文档中的任何陈述、信息和内容的准确性、可靠性、完整性、适销性、适用性及非侵权性提供任何明示或暗示的声明或保证。本文档仅作为使用指导的参考。
+
+由于产品版本升级或其他原因,本文档可能在未经任何通知的情况下不定期更新或修改。
+
+**读者对象**
+
+本教程适用于以下工程师:
+
+- 技术支持工程师
+- 软件开发工程师
+
+**修订记录**
+
+| **日期** | **版本** | **作者** | **修改说明** |
+|:-----------| -------- |--------| ------------ |
+| 2024/11/29 | 0.0.0 | 钟海滨 | 初始版本 |
+
+## 1 简介
+
+在现代计算机视觉应用中,矩形检测是一项基本但重要的任务,广泛应用于物体识别、场景理解、文档扫描等领域。本指南将详细介绍如何使用 OpenCV 库在凌智视觉模块上部署高效的矩形检测算法。 本文将详细介绍如何使用 OpenCV 库在凌智视觉模块上实现高效的矩形检测功能。
+
+
+## 2 Python API 文档
+
+```python
+
+def cvtColor(src, code, dstCn=0):
+ """
+ 转换图像颜色空间。
+ 参数:
+ - src: 输入图像。
+ - code: 颜色空间转换代码。
+ - dstCn: 目标图像的通道数,如果为0则根据code自动确定。
+ 返回:
+ - 转换后的图像。
+ """
+
+def GaussianBlur(src, ksize, sigmaX, sigmaY=0, borderType=cv2.BORDER_DEFAULT):
+ """
+ 使用高斯滤波模糊图像。
+ 参数:
+ - src: 输入图像。
+ - ksize: 高斯核的大小,必须是奇数。
+ - sigmaX: 高斯核在X方向的标准差。
+ - sigmaY: 高斯核在Y方向的标准差,如果为0则与sigmaX相同。
+ - borderType: 图像边界的处理方式,默认为cv2.BORDER_DEFAULT。
+ 返回:
+ - 模糊后的图像。
+ """
+
+def threshold(src, thresh, maxval, type):
+ """
+ 对图像应用阈值处理。
+ 参数:
+ - src: 输入图像。
+ - thresh: 阈值。
+ - maxval: 阈值处理后的最大值。
+ - type: 阈值处理的类型。
+ 返回:
+ - 计算出的阈值。
+ - 阈值处理后的图像。
+ """
+
+def drawContours(img, contours, contourIdx, color, thickness=1, lineType=8, shift=0):
+ """
+ 在图像上绘制轮廓。
+ 参数:
+ - img: 输入图像。
+ - contours: 要绘制的轮廓列表。
+ - contourIdx: 要绘制的轮廓索引,-1表示绘制所有轮廓。
+ - color: 轮廓的颜色。
+ - thickness: 轮廓线的厚度。
+ - lineType: 轮廓线的类型。
+ - shift: 轮廓坐标的小数位数。
+ """
+
+def findContours(image, mode, method, point=cv2.Point()):
+ """
+ 在二值图像中检测轮廓。
+ 参数:
+ - image: 输入的二值图像。
+ - mode: 轮廓的检索模式。
+ - method: 轮廓的近似方法。
+ - point: 轮廓检索的起始点。
+ 返回:
+ - 检测到的轮廓列表。
+ - 轮廓的层次结构。
+ """
+
+def arcLength(curve, closed):
+ """
+ 计算曲线的长度。
+ 参数:
+ - curve: 输入的曲线,由点序列组成。
+ - closed: 曲线是否封闭。
+ 返回:
+ - 曲线的长度。
+ """
+
+def approxPolyDP(curve, epsilon, closed):
+ """
+ 使用Douglas-Peucker算法近似曲线。
+ 参数:
+ - curve: 输入的曲线,由点序列组成。
+ - epsilon: 近似精度,通常为原始曲线长度的百分之一。
+ - closed: 曲线是否封闭。
+ 返回:
+ - 近似后的曲线。
+ """
+
+```
+
+## 3 在凌智视觉模块上进行边缘检测案例
+
+为了方便大家入手,我们提供了 OpenCV 矩形检测的 Python 例程。该程序可以使用摄像头进行端到端推理。
+
+```python
+from lockzhiner_vision_module.cv2 import VideoCapture
+import lockzhiner_vision_module.cv2 as cv2
+from lockzhiner_vision_module.edit import Edit
+import time
+import sys
+
+pi = 3.14159265358979323846
+if __name__ == "__main__":
+ args = sys.argv
+ if len(args) != 3:
+ print("Need model path. Example: python test_capture.py width height")
+ exit(1)
+
+ edit = Edit()
+ edit.start_and_accept_connection()
+
+ video_capture = VideoCapture()
+ video_capture.set_width(int(args[1]))
+ video_capture.set_height(int(args[2]))
+ if video_capture.open(0) is False:
+ print("Failed to open capture")
+ exit(1)
+
+ while True:
+ read_index = 0
+ total_time_ms = 0
+ for i in range(30):
+ start_time = time.time()
+ ret, mat = video_capture.read()
+ if ret is False:
+ continue
+ end_time = time.time()
+ # 转换为灰度图像
+ gray = cv2.cvtColor(mat, cv2.COLOR_BGR2GRAY)
+ # 高斯模糊
+ blurred = cv2.GaussianBlur(gray, (5, 5), 0)
+ # 二值化
+ _, binary = cv2.threshold(blurred, 127, 255, cv2.THRESH_BINARY_INV)
+ edges = cv2.Canny(binary, 30, 200)
+ contours, _ = cv2.findContours(edges.copy(), cv2.RETR_LIST, cv2.CHAIN_APPROX_SIMPLE)
+ for contour in contours:
+ # 近似轮廓
+ # 计算轮廓周长
+ epsilon = 0.02 * cv2.arcLength(contour, True)
+ # 将轮廓近似为多边形
+ if epsilon < 15:
+ continue
+ approx = cv2.approxPolyDP(contour, epsilon, True)
+ # 如果近似轮廓有4个顶点,则认为是矩形
+ if len(approx) == 4:
+ cv2.putText(mat, "Rectangle", (50,50), cv2.FONT_HERSHEY_SIMPLEX, 1, (0, 0, 255), 2)
+ cv2.drawContours(mat, [approx], -1, (0, 255, 0), 2)
+ edit.print(mat)
+ total_time_ms += end_time - start_time
+ read_index += 1
+ print(f"FPS is {1.0 / (total_time_ms / read_index)}")
+
+
+```
+## 4 上传并测试 Python 程序
+
+参考 [连接设备指南](../../../../docs/introductory_tutorial/connect_device_using_ssh.md) 正确连接 Lockzhiner Vision Module 设备。
+
+
+
+请使用 Electerm Sftp 依次上传以下文件:
+
+- 进入存放 **test_rectangle.py** 脚本文件的目录,将 **test_rectangle.py** 上传到 Lockzhiner Vision Module
+
+上传文件
+
+
+
+请使用 Electerm Ssh 并在命令行中执行以下命令:
+
+```bash
+python test_rectangle.py 640 480
+```
+运行程序后,屏幕上输出
+
+
+
+矩形检测结果图片
+
+
+
+
+
diff --git a/example/opencv_example/opencv_rectangle_detection/python/images/dowm_result.png b/example/opencv_example/opencv_rectangle_detection/python/images/dowm_result.png
new file mode 100644
index 0000000000000000000000000000000000000000..7c86faea28d6b49a1d8e7d58718c04427f686869
Binary files /dev/null and b/example/opencv_example/opencv_rectangle_detection/python/images/dowm_result.png differ
diff --git a/example/opencv_example/opencv_rectangle_detection/python/images/img_rectangle.png b/example/opencv_example/opencv_rectangle_detection/python/images/img_rectangle.png
new file mode 100644
index 0000000000000000000000000000000000000000..443bec4a97a237159ada9e228acbef120e2986ad
Binary files /dev/null and b/example/opencv_example/opencv_rectangle_detection/python/images/img_rectangle.png differ
diff --git a/example/opencv_example/opencv_rectangle_detection/python/images/rectangle.png b/example/opencv_example/opencv_rectangle_detection/python/images/rectangle.png
new file mode 100644
index 0000000000000000000000000000000000000000..6fe90303778242710cecf1e5734fe04b419589eb
Binary files /dev/null and b/example/opencv_example/opencv_rectangle_detection/python/images/rectangle.png differ
diff --git a/example/opencv_example/opencv_rectangle_detection/python/images/rectangle_result.png b/example/opencv_example/opencv_rectangle_detection/python/images/rectangle_result.png
new file mode 100644
index 0000000000000000000000000000000000000000..3e7591e73bd2835af642adcb30d642e19de9c60e
Binary files /dev/null and b/example/opencv_example/opencv_rectangle_detection/python/images/rectangle_result.png differ
diff --git a/example/opencv_example/opencv_rectangle_detection/python/images/results.png b/example/opencv_example/opencv_rectangle_detection/python/images/results.png
new file mode 100644
index 0000000000000000000000000000000000000000..97837e5d4fcf75bb6c8bd56f3ed5b8d14bb1d31f
Binary files /dev/null and b/example/opencv_example/opencv_rectangle_detection/python/images/results.png differ
diff --git a/example/opencv_example/opencv_rectangle_detection/python/images/sftp.png b/example/opencv_example/opencv_rectangle_detection/python/images/sftp.png
new file mode 100644
index 0000000000000000000000000000000000000000..ef67eccfed06a391f760556cd3d33a9ddc2c24c1
Binary files /dev/null and b/example/opencv_example/opencv_rectangle_detection/python/images/sftp.png differ
diff --git a/example/opencv_example/opencv_rectangle_detection/python/test_rectangle.py b/example/opencv_example/opencv_rectangle_detection/python/test_rectangle.py
new file mode 100644
index 0000000000000000000000000000000000000000..79a7a9fa70e44427205c9a991b8bc43889da3783
--- /dev/null
+++ b/example/opencv_example/opencv_rectangle_detection/python/test_rectangle.py
@@ -0,0 +1,56 @@
+from lockzhiner_vision_module.cv2 import VideoCapture
+import lockzhiner_vision_module.cv2 as cv2
+from lockzhiner_vision_module.edit import Edit
+import time
+import sys
+
+pi = 3.14159265358979323846
+if __name__ == "__main__":
+ args = sys.argv
+ if len(args) != 3:
+ print("Need model path. Example: python test_capture.py width height")
+ exit(1)
+
+ edit = Edit()
+ edit.start_and_accept_connection()
+
+ video_capture = VideoCapture()
+ video_capture.set_width(int(args[1]))
+ video_capture.set_height(int(args[2]))
+ if video_capture.open(0) is False:
+ print("Failed to open capture")
+ exit(1)
+
+ while True:
+ read_index = 0
+ total_time_ms = 0
+ for i in range(30):
+ start_time = time.time()
+ ret, mat = video_capture.read()
+ if ret is False:
+ continue
+ end_time = time.time()
+ # 转换为灰度图像
+ gray = cv2.cvtColor(mat, cv2.COLOR_BGR2GRAY)
+ # 高斯模糊
+ blurred = cv2.GaussianBlur(gray, (5, 5), 0)
+ # 二值化
+ _, binary = cv2.threshold(blurred, 127, 255, cv2.THRESH_BINARY_INV)
+ edges = cv2.Canny(binary, 30, 200)
+ contours, _ = cv2.findContours(edges.copy(), cv2.RETR_LIST, cv2.CHAIN_APPROX_SIMPLE)
+ for contour in contours:
+ # 近似轮廓
+ # 计算轮廓周长
+ epsilon = 0.02 * cv2.arcLength(contour, True)
+ # 将轮廓近似为多边形
+ if epsilon < 15:
+ continue
+ approx = cv2.approxPolyDP(contour, epsilon, True)
+ # 如果近似轮廓有4个顶点,则认为是矩形
+ if len(approx) == 4:
+ cv2.putText(mat, "Rectangle", (50,50), cv2.FONT_HERSHEY_SIMPLEX, 1, (0, 0, 255), 2)
+ cv2.drawContours(mat, [approx], -1, (0, 255, 0), 2)
+ edit.print(mat)
+ total_time_ms += end_time - start_time
+ read_index += 1
+ print(f"FPS is {1.0 / (total_time_ms / read_index)}")
diff --git a/example/opencv_example/opencv_triangle_detection/README.md b/example/opencv_example/opencv_triangle_detection/README.md
new file mode 100644
index 0000000000000000000000000000000000000000..9a31085e533f91b923ab19a1da19ba81230740af
--- /dev/null
+++ b/example/opencv_example/opencv_triangle_detection/README.md
@@ -0,0 +1,40 @@
+凌智视觉模块 OpenCV 三角形检测部署指南
+
+发布版本:V0.0.0
+
+日期:2024-11-29
+
+文件密级:□绝密 □秘密 □内部资料 ■公开
+
+---
+
+**免责声明**
+
+本文档按**现状**提供,福州凌睿智捷电子有限公司(以下简称**本公司**)不对本文档中的任何陈述、信息和内容的准确性、可靠性、完整性、适销性、适用性及非侵权性提供任何明示或暗示的声明或保证。本文档仅作为使用指导的参考。
+
+由于产品版本升级或其他原因,本文档可能在未经任何通知的情况下不定期更新或修改。
+
+**读者对象**
+
+本教程适用于以下工程师:
+
+- 技术支持工程师
+- 软件开发工程师
+
+**修订记录**
+
+| **日期** | **版本** | **作者** | **修改说明** |
+|:-----------| -------- |--------| ------------ |
+| 2024/11/29 | 0.0.0 | 钟海滨 | 初始版本 |
+
+## 1 简介
+
+在计算机视觉领域,形状检测是一项基本而重要的任务,尤其在工业检测、机器人导航、图像分析等领域有着广泛应用。本指南将详细介绍如何使用 OpenCV 库在凌智视觉模块上部署三角形检测功能。
+
+## 2 在凌智视觉模块上部署三角形检测案例
+
+下载模型后,请参考以下教程使用 Python 在凌智视觉模块上部署分类模型例程:
+
+- [凌智视觉模块 OpenCV 三角形检测 Python 部署指南](./python/README.md)
+
+
diff --git a/example/opencv_example/opencv_triangle_detection/python/README.md b/example/opencv_example/opencv_triangle_detection/python/README.md
new file mode 100644
index 0000000000000000000000000000000000000000..d2df83faaf163849728193085cb02e1675844ff9
--- /dev/null
+++ b/example/opencv_example/opencv_triangle_detection/python/README.md
@@ -0,0 +1,221 @@
+凌智视觉模块 OpenCV 三角形检测 Python 部署指南
+
+发布版本:V0.0.0
+
+日期:2024-11-29
+
+文件密级:□绝密 □秘密 □内部资料 ■公开
+
+---
+
+**免责声明**
+
+本文档按**现状**提供,福州凌睿智捷电子有限公司(以下简称**本公司**)不对本文档中的任何陈述、信息和内容的准确性、可靠性、完整性、适销性、适用性及非侵权性提供任何明示或暗示的声明或保证。本文档仅作为使用指导的参考。
+
+由于产品版本升级或其他原因,本文档可能在未经任何通知的情况下不定期更新或修改。
+
+**读者对象**
+
+本教程适用于以下工程师:
+
+- 技术支持工程师
+- 软件开发工程师
+
+**修订记录**
+
+| **日期** | **版本** | **作者** | **修改说明** |
+|:-----------| -------- |--------| ------------ |
+| 2024/11/29 | 0.0.0 | 钟海滨 | 初始版本 |
+
+## 1 简介
+
+在现代计算机视觉应用中,三角形检测是一项基本但重要的任务,广泛应用于物体识别、场景理解、文档扫描等领域。本指南将详细介绍如何使用 OpenCV 库在凌智视觉模块上部署高效的三角形检测算法。 本文将详细介绍如何使用 OpenCV 库在凌智视觉模块上实现高效的三角形检测功能。
+
+## 2 Python API 文档
+
+```python
+
+def cvtColor(src, code, dstCn=0):
+ """
+ 转换图像颜色空间。
+ 参数:
+ - src: 输入图像。
+ - code: 颜色空间转换代码。
+ - dstCn: 目标图像的通道数,如果为0则根据code自动确定。
+ 返回:
+ - 转换后的图像。
+ """
+
+def GaussianBlur(src, ksize, sigmaX, sigmaY=0, borderType=cv2.BORDER_DEFAULT):
+ """
+ 使用高斯滤波模糊图像。
+ 参数:
+ - src: 输入图像。
+ - ksize: 高斯核的大小,必须是奇数。
+ - sigmaX: 高斯核在X方向的标准差。
+ - sigmaY: 高斯核在Y方向的标准差,如果为0则与sigmaX相同。
+ - borderType: 图像边界的处理方式,默认为cv2.BORDER_DEFAULT。
+ 返回:
+ - 模糊后的图像。
+ """
+
+def threshold(src, thresh, maxval, type):
+ """
+ 对图像应用阈值处理。
+ 参数:
+ - src: 输入图像。
+ - thresh: 阈值。
+ - maxval: 阈值处理后的最大值。
+ - type: 阈值处理的类型。
+ 返回:
+ - 计算出的阈值。
+ - 阈值处理后的图像。
+ """
+
+def drawContours(img, contours, contourIdx, color, thickness=1, lineType=8, shift=0):
+ """
+ 在图像上绘制轮廓。
+ 参数:
+ - img: 输入图像。
+ - contours: 要绘制的轮廓列表。
+ - contourIdx: 要绘制的轮廓索引,-1表示绘制所有轮廓。
+ - color: 轮廓的颜色。
+ - thickness: 轮廓线的厚度。
+ - lineType: 轮廓线的类型。
+ - shift: 轮廓坐标的小数位数。
+ """
+
+def findContours(image, mode, method, point=cv2.Point()):
+ """
+ 在二值图像中检测轮廓。
+ 参数:
+ - image: 输入的二值图像。
+ - mode: 轮廓的检索模式。
+ - method: 轮廓的近似方法。
+ - point: 轮廓检索的起始点。
+ 返回:
+ - 检测到的轮廓列表。
+ - 轮廓的层次结构。
+ """
+
+def arcLength(curve, closed):
+ """
+ 计算曲线的长度。
+ 参数:
+ - curve: 输入的曲线,由点序列组成。
+ - closed: 曲线是否封闭。
+ 返回:
+ - 曲线的长度。
+ """
+
+def approxPolyDP(curve, epsilon, closed):
+ """
+ 使用Douglas-Peucker算法近似曲线。
+ 参数:
+ - curve: 输入的曲线,由点序列组成。
+ - epsilon: 近似精度,通常为原始曲线长度的百分之一。
+ - closed: 曲线是否封闭。
+ 返回:
+ - 近似后的曲线。
+ """
+
+```
+
+## 3 在凌智视觉模块上进行边缘检测案例
+
+为了方便大家入手,我们提供了 OpenCV 三角形检测的 Python 例程。该程序可以使用摄像头进行端到端推理。
+**测试图片下载链接:**[三角形检测图片](https://gitee.com/LockzhinerAI/LockzhinerVisionModule/releases/download/v0.0.4/triangle.png)
+
+```python
+from lockzhiner_vision_module.cv2 import VideoCapture
+import lockzhiner_vision_module.cv2 as cv2
+from lockzhiner_vision_module.edit import Edit
+import time
+import sys
+
+pi = 3.14159265358979323846
+if __name__ == "__main__":
+ args = sys.argv
+ if len(args) != 3:
+ print("Need model path. Example: python test_capture.py width height")
+ exit(1)
+
+ edit = Edit()
+ edit.start_and_accept_connection()
+
+ video_capture = VideoCapture()
+ video_capture.set_width(int(args[1]))
+ video_capture.set_height(int(args[2]))
+ if video_capture.open(0) is False:
+ print("Failed to open capture")
+ exit(1)
+
+ while True:
+ read_index = 0
+ total_time_ms = 0
+ for i in range(30):
+ start_time = time.time()
+ ret, mat = video_capture.read()
+ if ret is False:
+ continue
+ end_time = time.time()
+ # 转换为灰度图像
+ # 转换为灰度图像
+ gray = cv2.cvtColor(mat, cv2.COLOR_BGR2GRAY)
+ blurred = cv2.GaussianBlur(gray, (3, 3), 0)
+ _, thresh = cv2.threshold(blurred, 127, 255, cv2.THRESH_BINARY)
+ edges = cv2.Canny(thresh, 50, 150)
+
+ # 3. 查找轮廓
+ contours, _ = cv2.findContours(edges, cv2.RETR_LIST, cv2.CHAIN_APPROX_NONE)
+ print(f"len:{len(contours)}")
+ # 4. 筛选轮廓
+ for contour in contours:
+ # 计算轮廓的周长
+ perimeter = cv2.arcLength(contour, True)
+ if perimeter<15:
+ continue
+ # 近似轮廓
+ approx = cv2.approxPolyDP(contour, 0.04 * perimeter, True)
+
+ # 如果近似轮廓有3个顶点,则认为它是三角形
+ if len(approx) == 3:
+ # 5. 绘制结果
+ cv2.putText(mat, "Triangle", (50,50), cv2.FONT_HERSHEY_SIMPLEX, 1, (0, 0, 255), )
+ cv2.drawContours(mat, [approx], -1, (0, 255, 0), 2)
+ # cv2.imwrite("blurred.png", blurred)
+ edit.print(mat)
+ total_time_ms += end_time - start_time
+ read_index += 1
+ print(f"FPS is {1.0 / (total_time_ms / read_index)}")
+
+
+```
+## 4 上传并测试 Python 程序
+
+参考 [连接设备指南](../../../../docs/introductory_tutorial/connect_device_using_ssh.md) 正确连接 Lockzhiner Vision Module 设备。
+
+
+
+请使用 Electerm Sftp 依次上传以下文件:
+
+- 进入存放 **test_rectangle.py** 脚本文件的目录,将 **test_rectangle.py** 上传到 Lockzhiner Vision Module
+
+上传文件
+
+
+
+请使用 Electerm Ssh 并在命令行中执行以下命令:
+
+```bash
+python test_trangle.py 640 480
+```
+
+运行程序后,屏幕上输出
+
+三角形检测结果图片
+
+
+
+
+
diff --git a/example/opencv_example/opencv_triangle_detection/python/images/dowmresult.png b/example/opencv_example/opencv_triangle_detection/python/images/dowmresult.png
new file mode 100644
index 0000000000000000000000000000000000000000..c6f5c90339fa3cc57b69bdf55715098ae505812a
Binary files /dev/null and b/example/opencv_example/opencv_triangle_detection/python/images/dowmresult.png differ
diff --git a/example/opencv_example/opencv_triangle_detection/python/images/result_triangle.png b/example/opencv_example/opencv_triangle_detection/python/images/result_triangle.png
new file mode 100644
index 0000000000000000000000000000000000000000..f7b1796a89a9fccf6d76a38687abe81c4a431588
Binary files /dev/null and b/example/opencv_example/opencv_triangle_detection/python/images/result_triangle.png differ
diff --git a/example/opencv_example/opencv_triangle_detection/python/images/run.png b/example/opencv_example/opencv_triangle_detection/python/images/run.png
new file mode 100644
index 0000000000000000000000000000000000000000..70858cfa5787e74d4f0d08d4bb6a9b561918ce68
Binary files /dev/null and b/example/opencv_example/opencv_triangle_detection/python/images/run.png differ
diff --git a/example/opencv_example/opencv_triangle_detection/python/images/triangle-rest.png b/example/opencv_example/opencv_triangle_detection/python/images/triangle-rest.png
new file mode 100644
index 0000000000000000000000000000000000000000..309318bf15533ea22fd624c6f3b64477ea3a87d5
Binary files /dev/null and b/example/opencv_example/opencv_triangle_detection/python/images/triangle-rest.png differ
diff --git a/example/opencv_example/opencv_triangle_detection/python/images/triangle.png b/example/opencv_example/opencv_triangle_detection/python/images/triangle.png
new file mode 100644
index 0000000000000000000000000000000000000000..17cb98478ed1d1490ee6e3e6e6fbccbd49d7b814
Binary files /dev/null and b/example/opencv_example/opencv_triangle_detection/python/images/triangle.png differ
diff --git a/example/opencv_example/opencv_triangle_detection/python/images/uploads.png b/example/opencv_example/opencv_triangle_detection/python/images/uploads.png
new file mode 100644
index 0000000000000000000000000000000000000000..1c9e33335e3bb772527bbd6da5ec50d58c9429b2
Binary files /dev/null and b/example/opencv_example/opencv_triangle_detection/python/images/uploads.png differ
diff --git a/example/opencv_example/opencv_triangle_detection/python/test_trangle.py b/example/opencv_example/opencv_triangle_detection/python/test_trangle.py
new file mode 100644
index 0000000000000000000000000000000000000000..cbfd2db679edac753917256d9f8c54fbf347c971
--- /dev/null
+++ b/example/opencv_example/opencv_triangle_detection/python/test_trangle.py
@@ -0,0 +1,60 @@
+from lockzhiner_vision_module.cv2 import VideoCapture
+import lockzhiner_vision_module.cv2 as cv2
+from lockzhiner_vision_module.edit import Edit
+import time
+import sys
+
+pi = 3.14159265358979323846
+if __name__ == "__main__":
+ args = sys.argv
+ if len(args) != 3:
+ print("Need model path. Example: python test_capture.py width height")
+ exit(1)
+
+ edit = Edit()
+ edit.start_and_accept_connection()
+
+ video_capture = VideoCapture()
+ video_capture.set_width(int(args[1]))
+ video_capture.set_height(int(args[2]))
+ if video_capture.open(0) is False:
+ print("Failed to open capture")
+ exit(1)
+
+ while True:
+ read_index = 0
+ total_time_ms = 0
+ for i in range(30):
+ start_time = time.time()
+ ret, mat = video_capture.read()
+ if ret is False:
+ continue
+ end_time = time.time()
+ # 转换为灰度图像
+ gray = cv2.cvtColor(mat, cv2.COLOR_BGR2GRAY)
+ blurred = cv2.GaussianBlur(gray, (3, 3), 0)
+ _, thresh = cv2.threshold(blurred, 127, 255, cv2.THRESH_BINARY)
+ edges = cv2.Canny(thresh, 50, 150)
+
+ # 3. 查找轮廓
+ contours, _ = cv2.findContours(edges, cv2.RETR_LIST, cv2.CHAIN_APPROX_NONE)
+ print(f"len:{len(contours)}")
+ # 4. 筛选轮廓
+ for contour in contours:
+ # 计算轮廓的周长
+ perimeter = cv2.arcLength(contour, True)
+ if perimeter<15:
+ continue
+ # 近似轮廓
+ approx = cv2.approxPolyDP(contour, 0.04 * perimeter, True)
+
+ # 如果近似轮廓有3个顶点,则认为它是三角形
+ if len(approx) == 3:
+ # 5. 绘制结果
+ cv2.putText(mat, "Triangle", (50,50), cv2.FONT_HERSHEY_SIMPLEX, 1, (0, 0, 255), )
+ cv2.drawContours(mat, [approx], -1, (0, 255, 0), 2)
+ # cv2.imwrite("blurred.png", blurred)
+ edit.print(mat)
+ total_time_ms += end_time - start_time
+ read_index += 1
+ print(f"FPS is {1.0 / (total_time_ms / read_index)}")
diff --git a/example/special/face_system/README.md b/example/special/face_system/README.md
new file mode 100644
index 0000000000000000000000000000000000000000..acaa9877bb40d69d236e3b3ef10e4fb8d855b8ac
--- /dev/null
+++ b/example/special/face_system/README.md
@@ -0,0 +1,52 @@
+凌智视觉模块人脸识别系统部署指南
+
+发布版本:V0.0.0
+
+日期:2024-11-28
+
+文件密级:□绝密 □秘密 □内部资料 ■公开
+
+---
+
+**免责声明**
+
+本文档按**现状**提供,福州凌睿智捷电子有限公司(以下简称**本公司**)不对本文档中的任何陈述、信息和内容的准确性、可靠性、完整性、适销性、适用性及非侵权性提供任何明示或暗示的声明或保证。本文档仅作为使用指导的参考。
+
+由于产品版本升级或其他原因,本文档可能在未经任何通知的情况下不定期更新或修改。
+
+**读者对象**
+
+本教程适用于以下工程师:
+
+- 技术支持工程师
+- 软件开发工程师
+
+**修订记录**
+
+| **日期** | **版本** | **作者** | **修改说明** |
+|:-----------| -------- |--------| ------------ |
+| 2024/11/28 | 0.0.0 | 郑必城、钟海滨 | 初始版本 |
+
+## 1 简介
+
+基于 Lockzhiner Vision Module 的 LZ-Picodet 模型训练的人脸检测模型 LZ-Face,以及ArcFace人脸识别模型,实现了一个人脸识别系统。
+
+## 2 运行前的准备
+
+* 请确保你已经下载了 [凌智视觉模块人脸检测模型](https://gitee.com/LockzhinerAI/LockzhinerVisionModule/releases/download/v0.0.3/LZ-Face.rknn)
+* 请确保你已经下载了 [凌智视觉模块人脸识别模型](https://gitee.com/LockzhinerAI/LockzhinerVisionModule/releases/download/v0.0.0/LZ-ArcFace.rknn)
+
+## 3 在凌智视觉模块上部署模型
+
+训练完模型后,请参考以下教程在凌智视觉模块上部署检测模型例程:
+
+
+* [凌智视觉模块人脸识别系统 Python 部署指南](./python/README.md)
+
+## 4 各模型性能指标
+
+以下测试数据为模型执行 Predict 函数运行 1000 次耗时的平均时间
+
+| 人脸识别系统 | FPS(帧/s) | 精度(%) |
+|:------------------:|:--------:|:----:|
+| LZ-Face+LZ-Arcface | 23 | - |
\ No newline at end of file
diff --git a/example/special/face_system/python/README.md b/example/special/face_system/python/README.md
new file mode 100644
index 0000000000000000000000000000000000000000..363f9b4e96baa56db14352eeecd491c7747e0c41
--- /dev/null
+++ b/example/special/face_system/python/README.md
@@ -0,0 +1,204 @@
+凌智视觉模块人脸识别系统 Python 部署指南
+
+发布版本:V0.0.0
+
+日期:2024-11-28
+
+文件密级:□绝密 □秘密 □内部资料 ■公开
+
+---
+
+**免责声明**
+
+本文档按**现状**提供,福州凌睿智捷电子有限公司(以下简称**本公司**)不对本文档中的任何陈述、信息和内容的准确性、可靠性、完整性、适销性、适用性及非侵权性提供任何明示或暗示的声明或保证。本文档仅作为使用指导的参考。
+
+由于产品版本升级或其他原因,本文档可能在未经任何通知的情况下不定期更新或修改。
+
+**读者对象**
+
+本教程适用于以下工程师:
+
+- 技术支持工程师
+- 软件开发工程师
+
+**修订记录**
+
+| **日期** | **版本** | **作者** | **修改说明** |
+|:-----------| -------- |---------| ------------ |
+| 2024/11/28 | 0.0.0 | 郑必城、钟海滨 | 初始版本 |
+
+## 1 简介
+
+接下来让我们基于 Python 来部署 ArcFace 人脸识别模型。在开始本章节前:
+
+* 请确保你已经下载了 [凌智视觉模块人脸检测模型](https://gitee.com/LockzhinerAI/LockzhinerVisionModule/releases/download/v0.0.3/LZ-Face.rknn)
+* 请确保你已经下载了 [凌智视觉模块人脸识别模型](https://gitee.com/LockzhinerAI/LockzhinerVisionModule/releases/download/v0.0.0/LZ-ArcFace.rknn)
+- 请确保你已经按照 [开发环境搭建指南](../../../../docs/introductory_tutorial/python_development_environment.md) 正确配置了开发环境。
+
+## 2 Python API 文档
+
+```python
+from ...LockzhinerVisionModule_wapper import vision
+
+
+class FaceRecognitionSystem:
+ def __init__(self):
+ """
+ FaceRecognitionSystem 类 - 用于人脸识别系统的封装
+ 该类封装了 InsightFace 框架下的 ArcFace 人脸识别模型以及PaddleDet
+ 框架下的目标检测模型,提供了初始化和预测的方法
+ """
+
+ self.model = vision.FaceRecognitionSystem()
+
+ def initialize(
+ self,
+ face_det_model_path,
+ face_rec_model_path,
+ face_det_param_path="",
+ face_rec_param_path="",
+ ):
+ """
+ 初始化模型
+ - 加载预训练的 PaddlePaddle 模型
+ - 加载预训练的 ArcFace 模型
+ Args:
+ face_det_model_path, 人脸检测模型文件的路径
+ face_rec_model_path, 人脸识别模型文件的路径
+ face_det_param_path="", 默认为空,不需填写
+ face_rec_param_path="", 默认为空,不需填写
+
+ Returns:
+ bool: 初始化是否成功。
+ """
+ return self.model.initialize(
+ face_det_model_path,
+ face_rec_model_path,
+ face_det_param_path,
+ face_rec_param_path,)
+
+ def buildDatabase(self, database_root, crop_root=""):
+ """
+ 构建人脸识别数据库
+
+ Args:
+ database_root 用户人脸存储路径
+ crop_root="" 裁剪图片存储路径(DEBUG时可开启)
+ Returns:
+ bool: 数据库构建是否成功。
+ """
+ return self.model.buildDatabase(database_root, crop_root)
+
+ def predict(self, input_mat):
+ """
+ 进行预测 - 使用加载的人脸检测模型和人脸是被模型进行预测
+ Args:
+ input_mat (cv2.Mat): 输入的图像数据,通常是一个 cv2.Mat 变量。
+
+ Returns:
+ FaceFeatureResults: 识别到的用户,余弦相似度分数,检测到的目标框
+ """
+ return self.model.predict(input_mat)
+
+```
+
+## 3 项目介绍
+
+为了方便大家入手,我们做了一个简易的人脸识别例程。该程序可以使用摄像头进行端到端推理。
+
+```python
+import sys
+import time
+
+from lockzhiner_vision_module.cv2 import VideoCapture, imread, imwrite
+from lockzhiner_vision_module.vision import FaceRecognitionSystem, visualize
+from lockzhiner_vision_module.edit import Edit
+
+
+# 主程序入口
+if __name__ == '__main__':
+ # 获取命令行参数
+ args = sys.argv
+ # 确保提供了足够的参数
+ if len(args) != 5:
+ print("Need model path. Example: python face_system.py LZ-Face.rknn LZ-ArcFace.rknn baseDataset crop_root")
+ exit(1)
+
+ # 初始化面部识别系统
+ face_system = FaceRecognitionSystem()
+ # 验证面部识别系统的初始化是否成功
+ if face_system.initialize(args[1], args[2]) is False:
+ print("Failed to initialize face_system model")
+ exit(1)
+ # 构建面部数据库
+ face_system.buildDatabase(args[3],args[4])
+
+ # 初始化图像编辑处理对象
+ edit = Edit()
+ # 开始并接受连接,准备进行图像编辑处理
+ edit.start_and_accept_connection()
+ # 初始化视频捕捉对象
+ video_capture = VideoCapture()
+ # 验证摄像头是否成功打开
+ if video_capture.open(0) is False:
+ print("Failed to open capture")
+ exit(1)
+ # 主循环,用于持续捕捉和处理视频帧
+ while True:
+ read_index = 0
+ total_time_ms = 0
+ for i in range(100):
+ # 从摄像头读取帧
+ ret, input_mat = video_capture.read()
+ # 如果读取失败,则继续循环直到成功读取
+ if ret is False:
+ continue
+ # 预测调用predict方法
+ start_time = time.time()
+ results = face_system.predict(input_mat)
+ end_time = time.time()
+ total_time_ms += end_time - start_time
+ read_index += 1
+ # 可视化处理结果
+ vis_mat = visualize(input_mat, results)
+ # 打印处理后的图像
+ edit.print(vis_mat)
+ print(f"FPS is {1.0 / (total_time_ms / read_index)}")
+
+```
+
+## 4 上传并测试 Python 程序
+
+参考 [连接设备指南](../../../../docs/introductory_tutorial/connect_device_using_ssh.md) 正确连接 Lockzhiner Vision Module 设备。
+
+
+
+请使用 Electerm Sftp 依次上传以下文件:
+
+- 进入存放 **face_system.py** 脚本文件的目录,将 **face_system.py** 上传到 Lockzhiner Vision Module
+- 进入存放 **LZ-ArcFace.rknn(也可能是其他模型)** 模型存放的目录(模型存放在训练模型后下载的 output 文件夹内),将 **LZ-ArcFace.rknn** 上传到 Lockzhiner Vision Module
+- 进入存放 **LZ-Face.rknn(也可能是其他模型)** 模型存放的目录(模型存放在训练模型后下载的 output 文件夹内),将 **LZ-Face.rknn** 上传到 Lockzhiner Vision Module
+
+人脸数据库文件夹结构示意图
+
+
+
+上传文件
+
+
+
+
+
+
+请使用 Electerm Ssh 并在命令行中执行以下命令:
+
+```bash
+python face_system.py LZ-Face.rknn LZ-ArcFace.rknn BaseDataset crop_root
+```
+
+运行程序后,屏幕上开始打印数据库构建的相关信息,并在一段时间后输出
+
+
+
+
+
diff --git a/example/special/face_system/python/face_system.py b/example/special/face_system/python/face_system.py
new file mode 100644
index 0000000000000000000000000000000000000000..8c5b2def46b465a609443b9e961d27262428e592
--- /dev/null
+++ b/example/special/face_system/python/face_system.py
@@ -0,0 +1,57 @@
+import sys
+import time
+
+from lockzhiner_vision_module.cv2 import VideoCapture, imread, imwrite
+from lockzhiner_vision_module.vision import FaceRecognitionSystem, visualize
+from lockzhiner_vision_module.edit import Edit
+
+
+# 主程序入口
+if __name__ == '__main__':
+ # 获取命令行参数
+ args = sys.argv
+ # 确保提供了足够的参数
+ if len(args) != 5:
+ print("Need model path. Example: python face_system.py LZ-Face.rknn LZ-ArcFace.rknn baseDataset_root crop_root")
+ exit(1)
+
+ # 初始化面部识别系统
+ face_system = FaceRecognitionSystem()
+ # 验证面部识别系统的初始化是否成功
+ if face_system.initialize(args[1], args[2]) is False:
+ print("Failed to initialize face_system model")
+ exit(1)
+ # 构建面部数据库
+ face_system.buildDatabase(args[3],args[4])
+
+ # 初始化图像编辑处理对象
+ edit = Edit()
+ # 开始并接受连接,准备进行图像编辑处理
+ edit.start_and_accept_connection()
+ # 初始化视频捕捉对象
+ video_capture = VideoCapture()
+ # 验证摄像头是否成功打开
+ if video_capture.open(0) is False:
+ print("Failed to open capture")
+ exit(1)
+ # 主循环,用于持续捕捉和处理视频帧
+ while True:
+ read_index = 0
+ total_time_ms = 0
+ for i in range(100):
+ # 从摄像头读取帧
+ ret, input_mat = video_capture.read()
+ # 如果读取失败,则继续循环直到成功读取
+ if ret is False:
+ continue
+ # 预测调用predict方法
+ start_time = time.time()
+ results = face_system.predict(input_mat)
+ end_time = time.time()
+ total_time_ms += end_time - start_time
+ read_index += 1
+ # 可视化处理结果
+ vis_mat = visualize(input_mat, results)
+ # 打印处理后的图像
+ edit.print(vis_mat)
+ print(f"FPS is {1.0 / (total_time_ms / read_index)}")
\ No newline at end of file
diff --git a/example/special/face_system/python/images/build_database.png b/example/special/face_system/python/images/build_database.png
new file mode 100644
index 0000000000000000000000000000000000000000..817bc3c45e115ef927164c4f97acc3e7e0684d93
Binary files /dev/null and b/example/special/face_system/python/images/build_database.png differ
diff --git a/example/special/face_system/python/images/connect.png b/example/special/face_system/python/images/connect.png
new file mode 100644
index 0000000000000000000000000000000000000000..dca991881cd5b5813ef5a9e108251c55169fbe88
Binary files /dev/null and b/example/special/face_system/python/images/connect.png differ
diff --git a/example/special/face_system/python/images/fps.png b/example/special/face_system/python/images/fps.png
new file mode 100644
index 0000000000000000000000000000000000000000..889f2d5f848c37c14ea4dddc76152f317d57cf9d
Binary files /dev/null and b/example/special/face_system/python/images/fps.png differ
diff --git a/example/special/face_system/python/images/img.png b/example/special/face_system/python/images/img.png
new file mode 100644
index 0000000000000000000000000000000000000000..69cbca641ad96fc8ba9d91972ee2d55f86618d21
Binary files /dev/null and b/example/special/face_system/python/images/img.png differ
diff --git a/example/special/face_system/python/images/img_1.png b/example/special/face_system/python/images/img_1.png
new file mode 100644
index 0000000000000000000000000000000000000000..415ca050420d563faf4b332120d1f6ec49ebec73
Binary files /dev/null and b/example/special/face_system/python/images/img_1.png differ
diff --git a/example/special/face_system/python/test_face_system.py b/example/special/face_system/python/test_face_system.py
new file mode 100644
index 0000000000000000000000000000000000000000..7c29e3914324824478bf9900a467378f3ec4bc69
--- /dev/null
+++ b/example/special/face_system/python/test_face_system.py
@@ -0,0 +1,120 @@
+import os
+import sys
+from lockzhiner_vision_module.cv2 import VideoCapture,imread,imwrite
+from lockzhiner_vision_module.vision import PaddleDet, ArcFace, visualize, cosine_similarity
+from lockzhiner_vision_module.edit import Edit
+import time
+import sys
+
+def predict_face(det_model, rec_model, face_mat):
+ if face_mat.empty():
+ return None, None
+
+ det_results = det_model.predict(face_mat)
+ result_size = len(det_results)
+ if result_size != 1:
+ print(f"Failed to find face. The size of faces is {result_size}, but need 1.")
+ return None, None
+
+ det_result = det_results[0]
+ face_roi = det_result.box
+ crop_mat = input_mat.crop(face_roi)
+ if crop_mat.empty():
+ return None, None
+
+ rec_result = rec_model.predict(crop_mat)
+ return det_results, rec_result
+
+
+if __name__ == '__main__':
+ args = sys.argv
+ if len(args) != 3:
+ print("Need model path. Example: python face_system.py LZ-Face.rknn LZ-ArcFace.rknn")
+ exit(1)
+
+ face_det = PaddleDet()
+ if face_det.initialize(args[1]) is False:
+ print("Failed to initialize face_det model")
+ exit(1)
+
+ face_rec = ArcFace()
+ if face_rec.initialize(args[2]) is False:
+ print("Failed to initialize face_rec model")
+ exit(1)
+
+ # 原始数据路径
+ base_dataset_path = 'BaseDataset'
+ # 裁剪后的数据路径
+ crop_dataset_path = 'CropDataset'
+
+ # 如果裁剪文件夹不存在,则创建
+ if not os.path.exists(crop_dataset_path):
+ os.makedirs(crop_dataset_path)
+ # 构建数据库
+ # 临时存储特征向量的字典
+ face_dict = {}
+ # 遍历BaseDataset中的每个文件夹
+ for user_folder in os.listdir(base_dataset_path):
+ user_path = os.path.join(base_dataset_path, user_folder)
+ if os.path.isdir(user_path) is False:
+ continue
+ # 创建对应用户的裁剪文件夹
+ user_crop_path = os.path.join(crop_dataset_path, user_folder)
+ if not os.path.exists(user_crop_path):
+ os.makedirs(user_crop_path)
+ # 初始化用户的特征向量列表
+ face_dict[user_folder] = []
+ for img_name in os.listdir(user_path):
+ img_path = os.path.join(user_path, img_name)
+ print(img_path)
+
+ # 读取图片并检测图片是否为空
+ input_mat = imread(img_path)
+ if input_mat.empty():
+ print(f"{img_path} is empty.")
+ continue
+
+ _, feature_result = predict_face(face_det, face_rec, input_mat)
+ if feature_result is None:
+ print(f"Failed to find face in {img_path}.")
+ continue
+ face_dict[user_folder].append(feature_result)
+
+ edit = Edit()
+ edit.start_and_accept_connection()
+
+ video_capture = VideoCapture()
+ if video_capture.open(0) is False:
+ print("Failed to open capture")
+ exit(1)
+
+ while True:
+ ret, input_mat = video_capture.read()
+ if ret is False:
+ continue
+ # 预测
+ result_0, result_1 = predict_face(face_det, face_rec, input_mat)
+ if result_0 is None or result_1 is None:
+ print(f"Failed to find face on video.")
+ continue
+ vis_mat = visualize(input_mat, result_0)
+ edit.print(vis_mat)
+
+ max_name = "None"
+ max_similarity = 0.0
+ for name, feature_results in face_dict.items():
+ for feature_result in feature_results:
+ similarity = cosine_similarity(result_1, feature_result)
+ if max_similarity < similarity:
+ max_similarity = similarity
+ max_name = name
+ print(f"User: {max_name}, score: {max_similarity}")
+
+
+
+
+
+
+
+
+
diff --git a/example/special/qr_code_recognition/README.md b/example/special/qr_code_recognition/README.md
index bf0e834f4264df1c2aff472ae5451627c83f4bb2..99e1bc756df26cbf491b3cc00c689526d1026aa7 100644
--- a/example/special/qr_code_recognition/README.md
+++ b/example/special/qr_code_recognition/README.md
@@ -37,7 +37,7 @@
- [凌智视觉模块二维码识别 Python 部署指南](./python)
-## 4 模型性能指标
+## 3 模型性能指标
以下测试数据为模型执行 Predict 函数运行 1000 次耗时的平均时间
diff --git a/example/vision/classification/python/test_classification.py b/example/vision/classification/python/test_classification.py
index 8199e86343070bde8849a80feb151d26c4d5d7ee..f5f90ab5fb36a85fa81592f49adfcf2b50cea5f5 100644
--- a/example/vision/classification/python/test_classification.py
+++ b/example/vision/classification/python/test_classification.py
@@ -1,10 +1,13 @@
-from lockzhiner_vision_module.cv2 import VideoCapture, imread
-from lockzhiner_vision_module.vision import PaddleClas
-import time
+from lockzhiner_vision_module.cv2 import VideoCapture
+from lockzhiner_vision_module.vision import PaddleClas, visualize
+from lockzhiner_vision_module.edit import Edit
import sys
+import time
def predict_video(cls_model):
+ edit = Edit()
+ edit.start_and_accept_connection()
video_capture = VideoCapture()
if video_capture.open(0) is False:
print("Failed to open capture")
@@ -24,14 +27,16 @@ def predict_video(cls_model):
total_time_ms += end_time - start_time
read_index += 1
print(result.label_id, result.score)
- print(f"FPS is {1.0 / (total_time_ms/read_index)}")
+ vis_mat = visualize(mat, result)
+ edit.print(vis_mat)
+ print(f"FPS is {1.0 / (total_time_ms / read_index)}")
def predict_image(cls_model, image_path):
image = imread(image_path)
result = cls_model.predict(image)
print(result.label_id, result.score)
-
+
if __name__ == "__main__":
args = sys.argv
@@ -47,6 +52,12 @@ if __name__ == "__main__":
exit(1)
if len(args) == 2:
+ print("\n")
+ print("-----------------------------------------------------------------------")
+ print("Open the LockzhinerVisionModuleImageFetcher and select the connection")
predict_video(model)
+
+
+
elif len(args) == 3:
- predict_image(model, args[2])
\ No newline at end of file
+ predict_image(model, args[2])