python opencv角点检测连线功能的实现代码
原始图
角点检测
points = cv2.goodFeaturesToTrack(gray, 100, 0.01, 10)points = np.int0(points).reshape(-1,2)for point in points: x, y = point.ravel() cv2.circle(img, (x, y), 10, (0, 255, 0), -1)
连线
cv2.line(img, (0, y1), (1000, y1), (0, 255, 0), thickness=3, lineType=8)cv2.line(img, (0, y2), (1000, y2), (0, 255, 0), thickness=3, lineType=8)
完整代码
''' @author: qq群686070107''' import cv2import numpy as npimg=cv2.imread('1.jpg')gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)points = cv2.goodFeaturesToTrack(gray, 100, 0.01, 10)points = np.int0(points).reshape(-1,2)for point in points: x, y = point.ravel() cv2.circle(img, (x, y), 10, (0, 255, 0), -1)y1 = min(points[:,1])y2 = max(points[:,1])## small and big enough cv2.line(img, (0, y1), (1000, y1), (0, 255, 0), thickness=3, lineType=8)cv2.line(img, (0, y2), (1000, y2), (0, 255, 0), thickness=3, lineType=8)cv2.imshow('img', img)cv2.waitKey(0)
到此这篇关于python opencv角点检测 连线功能的实现代码的文章就介绍到这了,更多相关python opencv角点检测内容请搜索好吧啦网以前的文章或继续浏览下面的相关文章希望大家以后多多支持好吧啦网!
相关文章:
1. css代码优化的12个技巧2. .NET SkiaSharp 生成二维码验证码及指定区域截取方法实现3. jsp网页实现贪吃蛇小游戏4. CentOS邮件服务器搭建系列—— POP / IMAP 服务器的构建( Dovecot )5. MyBatis JdbcType 与Oracle、MySql数据类型对应关系说明6. 在JSP中使用formatNumber控制要显示的小数位数方法7. 存储于xml中需要的HTML转义代码8. ASP中实现字符部位类似.NET里String对象的PadLeft和PadRight函数9. ASP中if语句、select 、while循环的使用方法10. ASP基础入门第八篇(ASP内建对象Application和Session)
