diff --git a/README.md b/README.md
index 126e24cdff67895a70850f8a421467a603574265..bd90d747a1488761b1392bddb639592881e24265 100644
--- a/README.md
+++ b/README.md
@@ -80,6 +80,10 @@ Lockzhiner Vision Module 拥有丰富的 IO 接口,其接口图片如下图所
这一部分教程将引导你从零开始训练并部署各种深度学习模型,包括分类模型、检测模型、分割模型和 OCR 模型。通过这些实战教程,你将学习到如何利用 Lockzhiner Vision Module 的高性能计算能力以及借助飞桨生态系统的丰富资源,轻松实现视觉任务的训练和部署。
+### OpenCV 案例
+
+* [OpenCV 圆形检测案例](example/opencv_example/opencv_circle_detection)
+* [OpenCV 边缘检测案例](example/opencv_example/opencv_edge_detection)
### 👍 目标分类案例
目标分类(Object Classification)是深度学习中的一项核心任务,旨在为输入图像分配一个或多个类别标签。这是计算机视觉的基础问题之一,主要用于识别和区分图像中的主要物体类别,而不关心物体的位置或数量。一般来说,目标分类任务的标注过程比较轻松,适合不需要知道目标位置的场景。
@@ -89,6 +93,7 @@ Lockzhiner Vision Module 拥有丰富的 IO 接口,其接口图片如下图所
* [凌智视觉模块猫狗分类部署指南](example/special/cat_and_dog_classification)
* [凌智视觉模块花卉分类部署指南](example/special/flower_classfication/)
* [凌智视觉模块口罩佩戴分类部署指南](example/special/maskwear_classfication)
+
### 👍 目标检测案例
目标检测(Object Detection)是深度学习中计算机视觉领域的重要任务之一,旨在识别图像或视频中所有感兴趣的物体,并准确地定位这些物体的边界框(Bounding Box)。与目标分类不同,目标检测不仅需要预测物体的类别,还需要标注它们在图像中的位置。一般来说,目标检测任务的标注过程比较复杂,适合既需要对目标进行分类,有需要对目标进行定位的场景。
@@ -108,6 +113,7 @@ Lockzhiner Vision Module 拥有丰富的 IO 接口,其接口图片如下图所
* [凌智视觉模块人脸检测部署指南](example/vision/face_detection)
* [凌智视觉模块人脸识别部署指南](example/vision/face_recognition)
+* [凌智视觉模块人脸识别系统部署指南](example/special/face_system)
## 🐛 Bug反馈
diff --git a/example/opencv_example/OpenCV_API.md b/example/opencv_example/OpenCV_API.md
new file mode 100644
index 0000000000000000000000000000000000000000..2b2a0605ea646fbdd3373f39ef77dd46169d29a1
--- /dev/null
+++ b/example/opencv_example/OpenCV_API.md
@@ -0,0 +1,129 @@
+**OPENCV_API 文档**
+
+``` markdown
+def arcLength(curve, closed):
+ return cv2.arcLength(curve, closed)
+
+
+def approxPolyDP(curve, epsilon, closed):
+ return cv2.approxPolyDP(curve, epsilon, closed)
+
+
+def boundingRect(rect):
+ return cv2.boundingRect(rect)
+
+
+def Canny(img, threshold1, threshold2, apertureSize=3, L2gradient=False):
+ return cv2.Canny(img, threshold1, threshold2, apertureSize, L2gradient)
+
+
+def circle(img, center, radius, color, thickness=1, lineType=8, shift=0):
+ temp_center = convert2point(center)
+ temp_color = convert2scalar(color)
+ cv2.circle(img, temp_center, radius, temp_color, thickness, lineType, shift)
+
+
+def cvtColor(src, code, dstCn=0):
+ return cv2.cvtColor(src, code, dstCn)
+
+
+def findContours(image, mode, method, point=cv2.Point()):
+ contours, hierarchy = cv2.findContours(image, mode, method, point)
+ return contours, hierarchy
+
+
+def GaussianBlur(src, ksize, sigmaX, sigmaY=0, borderType=cv2.BORDER_DEFAULT):
+ temp_ksize = convert2size(ksize)
+ return cv2.GaussianBlur(src, temp_ksize, sigmaX, sigmaY, borderType)
+
+
+def HoughCircles(image, method, dp, minDist, param1, param2, minRadius, maxRadius):
+ return [cv2.HoughCircles(
+ image, method, dp, minDist, param1, param2, minRadius, maxRadius
+ )]
+
+
+def HoughLines(
+ image, rho, theta, threshold, srn=0, stn=0, min_theta=0, max_theta=cv2.CV_PI
+):
+ return [cv2.HoughLines(image, rho, theta, threshold, srn, stn, min_theta, max_theta)]
+
+
+def HoughLinesP(image, rho, theta, threshold, minLineLength=0, maxLineGap=0):
+ return [cv2.HoughLinesP(image, rho, theta, threshold, minLineLength, maxLineGap)]
+
+
+def line(img, pt1, pt2, color, thickness=1, lineType=8, shift=0):
+ temp_pt1 = convert2point(pt1)
+ temp_pt2 = convert2point(pt2)
+ temp_color = convert2scalar(color)
+ cv2.line(img, temp_pt1, temp_pt2, temp_color, thickness, lineType, shift)
+
+
+def polylines(img, pts, isClosed, color, thickness=1, lineType=8, shift=0):
+ # 判读 pts 是否为 list
+ if not isinstance(pts, list):
+ raise TypeError("pts must be point list")
+ if len(pts) == 0:
+ return img
+
+ if not isinstance(pts[0], list):
+ raise TypeError("pts[0] must be point list")
+ if len(pts[0]) == 0:
+ return img
+
+ temp_pts = [convert2point(pt) for pt in pts[0]]
+ temp_color = convert2scalar(color)
+ cv2.polylines(img, temp_pts, isClosed, temp_color, thickness, lineType, shift)
+
+
+def putText(
+ img,
+ text,
+ org,
+ fontFace,
+ fontScale,
+ color,
+ thickness=1,
+ lineType=8,
+ bottomLeftOrigin=False,
+):
+ temp_org = convert2point(org)
+ temp_color = convert2scalar(color)
+ cv2.putText(
+ img,
+ text,
+ temp_org,
+ fontFace,
+ fontScale,
+ temp_color,
+ thickness,
+ lineType,
+ bottomLeftOrigin,
+ )
+
+
+def rectangle(img, pt1, pt2, color, thickness=1, lineType=8, shift=0):
+ temp_pt1 = convert2point(pt1)
+ temp_pt2 = convert2point(pt2)
+ temp_color = convert2scalar(color)
+ cv2.rectangle(img, temp_pt1, temp_pt2, temp_color, thickness, lineType, shift)
+
+
+def threshold(src, thresh, maxval, type):
+ computed_threshold, dst = cv2.threshold(src, thresh, maxval, type)
+ return computed_threshold, dst
+def convertScaleAbs(src, alpha=1, beta=0):
+ return cv2.convertScaleAbs(src, alpha, beta)
+
+
+def inRange(src, lowerb, upperb):
+ return cv2.inRange(src, lowerb, upperb)
+def imread(filename, flags=cv2.ImreadModes.IMREAD_COLOR):
+ return cv2.imread(filename, flags)
+
+
+def imwrite(filename, mat):
+ return cv2.imwrite(filename, mat)
+
+```
\ No newline at end of file
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..fbd49b9b4b116956ac6dec4858ebf2da29b7efaf
--- /dev/null
+++ b/example/opencv_example/opencv_circle_detection/README.md
@@ -0,0 +1,99 @@
+
凌智视觉模块圆形检测案例
+
+发布版本:V0.0.0
+
+日期:2024-11-28
+
+文件密级:□绝密 □秘密 □内部资料 ■公开
+
+---
+
+**免责声明**
+
+本文档按**现状**提供,福州凌睿智捷电子有限公司(以下简称**本公司**)不对本文档中的任何陈述、信息和内容的准确性、可靠性、完整性、适销性、适用性及非侵权性提供任何明示或暗示的声明或保证。本文档仅作为使用指导的参考。
+
+由于产品版本升级或其他原因,本文档可能在未经任何通知的情况下不定期更新或修改。
+
+**读者对象**
+
+本教程适用于以下工程师:
+
+- 技术支持工程师
+- 软件开发工程师
+
+**修订记录**
+
+| **日期** | **版本** | **作者** | **修改说明** |
+|:-----------| -------- |--------| ------------ |
+| 2024/11/28 | 0.0.0 | 钟海滨 | 初始版本 |
+
+## 1 简介
+
+OpenCV作为计算机图像处理库,提供了丰富的功能。我们在凌智视觉模块上适配了OpenCV的霍夫圆检测算法,并封装了相关函数,使得用户能够快速使用OpenCV的霍夫圆检测算法进行检测。
+
+## 2 在凌智视觉模块上进行边缘检测案例
+[OPENCV API 文档](../OpenCV_API.md)
+为了快速上手,我们提供了边缘检测案例
+```python
+import lockzhiner_vision_module.cv2 as cv2
+# 读取图像
+image_path = 'circle.png'
+img = cv2.imread(image_path)
+
+if img is None:
+ print("Error: Image not loaded.")
+else:
+ # 转换为灰度图像
+ gray = cv2.cvtColor(img, 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=0, maxRadius=0)
+ if circles is not None:
+ # 在图像上绘制检测到的圆
+ for i in circles[0]:
+ center = (int(i[0]), int(i[1]))
+ radius = int(i[2])
+
+ # 绘制圆心
+ cv2.circle(img, center, 1, (0, 100, 100), 3)
+
+ # 绘制圆
+ cv2.circle(img, center, radius, (0, 255, 0), 3)
+
+ # # 保存结果图像
+ cv2.imwrite('img_circles.png', img)
+
+```
+## 3 上传并测试 Python 程序
+
+参考 [连接设备指南](../../../docs/introductory_tutorial/connect_device_using_ssh.md) 正确连接 Lockzhiner Vision Module 设备。
+
+
+
+请使用 Electerm Sftp 依次上传以下文件:
+
+- 进入存放 **test_canny.py** 脚本文件的目录,将 **test_hough_circle.py]** 上传到 Lockzhiner Vision Module
+- 进入存放 **待检测图片** 存放的目录,将 **待检测图片** 上传到 Lockzhiner Vision Module
+
+上传文件
+
+
+请使用 Electerm Ssh 并在命令行中执行以下命令:
+
+```bash
+python test_hough_circle.py
+```
+
+运行程序后,屏幕上输出
+
+下载结果
+
+边缘检测结果图片
+
+
+
+
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/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_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..19c63f536185277008e287d36c165ded8e86b30f
--- /dev/null
+++ b/example/opencv_example/opencv_circle_detection/python/test_hough_circle.py
@@ -0,0 +1,31 @@
+import lockzhiner_vision_module.cv2 as cv2
+# 读取图像
+image_path = 'circle.png'
+img = cv2.imread(image_path)
+
+if img is None:
+ print("Error: Image not loaded.")
+else:
+ # 转换为灰度图像
+ gray = cv2.cvtColor(img, 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=0, maxRadius=0)
+ if circles is not None:
+ # 在图像上绘制检测到的圆
+ for i in circles[0]:
+ center = (int(i[0]), int(i[1]))
+ radius = int(i[2])
+
+ # 绘制圆心
+ cv2.circle(img, center, 1, (0, 100, 100), 3)
+
+ # 绘制圆
+ cv2.circle(img, center, radius, (0, 255, 0), 3)
+
+ # # 保存结果图像
+ cv2.imwrite('img_circles.png', img)
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..716cbe111a5d54ff810197d832fc262e9b26b285
--- /dev/null
+++ b/example/opencv_example/opencv_edge_detection/README.md
@@ -0,0 +1,95 @@
+凌智视觉模块边缘检测案例
+
+发布版本:V0.0.0
+
+日期:2024-11-28
+
+文件密级:□绝密 □秘密 □内部资料 ■公开
+
+---
+
+**免责声明**
+
+本文档按**现状**提供,福州凌睿智捷电子有限公司(以下简称**本公司**)不对本文档中的任何陈述、信息和内容的准确性、可靠性、完整性、适销性、适用性及非侵权性提供任何明示或暗示的声明或保证。本文档仅作为使用指导的参考。
+
+由于产品版本升级或其他原因,本文档可能在未经任何通知的情况下不定期更新或修改。
+
+**读者对象**
+
+本教程适用于以下工程师:
+
+- 技术支持工程师
+- 软件开发工程师
+
+**修订记录**
+
+| **日期** | **版本** | **作者** | **修改说明** |
+|:-----------| -------- |--------| ------------ |
+| 2024/11/28 | 0.0.0 | 钟海滨 | 初始版本 |
+
+## 1 简介
+
+OpenCV作为计算机图像处理库,提供了丰富的功能。我们在凌智视觉模块上适配了OpenCV的边缘检测算法,并封装了相关函数,使得用户能够快速使用OpenCV的边缘检测算法进行边缘检测。
+
+## 2 在凌智视觉模块上进行边缘检测案例
+[OPENCV API 文档](../OpenCV_API.md)
+为了快速上手,我们提供了边缘检测案例
+```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)
+print("转换为灰度图像")
+
+# 高斯模糊
+blurred = cv2.GaussianBlur(gray, (3, 3), 0)
+print("应用高斯模糊")
+
+# 阈值操作
+_, thresholded = cv2.threshold(blurred, 100, 255, cv2.THRESH_BINARY)
+print("应用阈值操作")
+cv2.imwrite('thresholded.png', thresholded)
+# 使用 Canny 边缘检测
+edges = cv2.Canny(thresholded, 20, 10)
+print("使用 Canny 边缘检测")
+# 保存边缘检测结果
+cv2.imwrite('edges.png', edges)
+```
+## 3 上传并测试 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..13580f82d324f524d08060a3ecb6258e2c54cb0f
--- /dev/null
+++ b/example/opencv_example/opencv_edge_detection/python/test_canny.py
@@ -0,0 +1,26 @@
+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)
+print("转换为灰度图像")
+
+# 高斯模糊
+blurred = cv2.GaussianBlur(gray, (3, 3), 0)
+print("应用高斯模糊")
+
+# 阈值操作
+_, thresholded = cv2.threshold(blurred, 100, 255, cv2.THRESH_BINARY)
+print("应用阈值操作")
+cv2.imwrite('thresholded.png', thresholded)
+# 使用 Canny 边缘检测
+edges = cv2.Canny(thresholded, 20, 10)
+print("使用 Canny 边缘检测")
+# 保存边缘检测结果
+cv2.imwrite('edges.png', edges)
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..fc2d752cca85df63e1364bd71d214f1b26b9b232
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_detected.png b/example/opencv_example/opencv_line_detection/python/images/line_detected.png
new file mode 100644
index 0000000000000000000000000000000000000000..f7e3df3ac65acf8df4d59f0b50271b928f452225
Binary files /dev/null and b/example/opencv_example/opencv_line_detection/python/images/line_detected.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..c679edfa3b4b749b2a30a19d45e777de7ac908ae
--- /dev/null
+++ b/example/opencv_example/opencv_line_detection/python/test_line.py
@@ -0,0 +1,72 @@
+# import cv2
+#
+# # import lockzhiner_vision_module.cv2 as cv2
+# # 定义π
+# pi = 3.14159265358979323846
+#
+# # 读取图片
+# image = cv2.imread('img.png')
+#
+# # 转换为灰度图像
+# gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
+# print("转换为灰度图像")
+#
+# # 高斯模糊
+# blurred = cv2.GaussianBlur(gray, (3, 3), 0)
+#
+# # 使用 Canny 边缘检测
+# edges = cv2.Canny(blurred, 30, 80)
+# print("使用Canny边缘检测")
+# cv2.imwrite('edges.png', edges)
+#
+# # 使用霍夫变换检测直线
+# # 注意这里使用的是 cv2.HoughLinesP 而不是 cv2.HoughLines
+# lines = cv2.HoughLinesP(edges, 1, pi / 180, threshold=90, minLineLength=30, maxLineGap=10)
+# print("使用霍夫变换检测直线")
+# print(lines.shape)
+# # 绘制检测到的直线
+# if lines is not None:
+# for line in lines:
+# # 注意这里的line格式,它是一个列表,包含了两个点坐标[x1, y1, x2, y2]
+# x1, y1, x2, y2 = line[0]
+# cv2.line(image, (x1, y1), (x2, y2), (0, 0, 255), 2)
+#
+# # 显示原始边缘检测图像和带有检测直线的图像
+# cv2.imshow('Edges', edges)
+# cv2.imshow('Line Detection', image)
+# cv2.waitKey(0)
+# cv2.destroyAllWindows()
+#
+# # 保存带有检测直线的图片
+# cv2.imwrite('line_detected.png', image)
+import lockzhiner_vision_module.cv2 as cv2
+# import cv2
+
+# import cv2
+pi = 3.1415926535897932384626433832795
+# 读取图片
+image = cv2.imread('img.png')
+
+# 检查图片是否成功读
+
+# 转换为灰度图像
+gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
+print("转换为灰度图像")
+# 使用高斯模糊减少噪声
+# blurred = cv2.GaussianBlur(gray, (5, 5), 0.5)
+print("高斯滤波")
+# 使用 Canny 边缘检测
+edges = cv2.Canny(gray, 50, 150)
+print("使用Canny边缘检测")
+# 使用霍夫变换检测直线
+lines = cv2.HoughLinesP(edges, 1, pi / 180, threshold=100, minLineLength=50, maxLineGap=20)
+print("使用霍夫变换检测直线")
+# 绘制检测到的直线
+if lines is not None:
+ # print(lines.tolist())
+ for line in lines[0]:
+ # print(type(line))
+ x1, y1, x2, y2 = line
+ cv2.line(image, (x1, y1), (x2, y2), (0, 255, 0), 2)
+
+cv2.imwrite('line_detected.png', image)