python - 如何通过线条链接找到的形状边缘?
问题描述
我有一个 Python 脚本,可以检测图片上的形状边缘。我需要逐行链接这些边缘。有没有人对如何做到这一点有任何建议,或者如何找到形状边缘然后链接它们的更好方法?
提前致谢。
def dstf(path):
img = image(path)
(H, W) = img.shape[:2]
blob = cv2.dnn.blobFromImage(img, scalefactor = 1.0, size = (W, H),
mean=(104.00698793, 116.66876762, 122.67891434),
swapRB = False, crop = False)
net.setInput(blob)
hed = net.forward()
hed = cv2.resize(hed[0, 0], (W, H))
hed = (255 * hed).astype("uint8")
dst = cv2.cornerHarris(np.float32(hed), 2, 3, 0.04)
dst = cv2.dilate(dst, None)
img[dst > 0.01 * dst.max()] = [0, 0, 255]
return img
发现边缘:
原来的:
解决方案
推荐阅读
- google-data-studio - 使用 CASE WHEN 语句和聚合创建字段失败
- angular - 从 Angular 应用程序启动/停止 docker 的容器
- mongodb - 包含日期范围的最佳 Mongo 索引策略是什么
- django - 如何覆盖 Django 管理员/表单用于外键的查询集
- mysql - SQL 查询建议
- javascript - 如何编写使用异步函数和流的函数?
- spartacus-storefront - 接收页面模板的延迟加载模块
- nativescript - 更改 Rad SideDrawer 的内容(原为“第二(第三,...)侧抽屉”
- http - Flutter Web - 如何选择 PDF 文件并 POST 到 API?
- json - IIS 与 API 的交互