python opencv角點檢測連線功能的實現(xiàn)代碼
更新時間:2020年11月24日 10:28:13 作者:圖像處理大大大大大牛啊
這篇文章主要介紹了python opencv角點檢測連線功能的實現(xiàn)代碼,本文給大家介紹的非常詳細,對大家的學習或工作具有一定的參考借鑒價值,需要的朋友可以參考下
原始圖

角點檢測
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 cv2
import numpy as np
img=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角點檢測 連線功能的實現(xiàn)代碼的文章就介紹到這了,更多相關python opencv角點檢測內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關文章希望大家以后多多支持腳本之家!
相關文章
jupyter?notebook內(nèi)核配置的圖文教程
Jupyter?Notebook是基于網(wǎng)頁的用于交互計算的應用程序,下面這篇文章主要給大家介紹了關于jupyter?notebook內(nèi)核配置的相關資料,文中通過實例代碼介紹的非常詳細,需要的朋友可以參考下2022-02-02
python的random模塊及加權隨機算法的python實現(xiàn)方法
下面小編就為大家?guī)硪黄猵ython的random模塊及加權隨機算法的python實現(xiàn)方法。小編覺得挺不錯的,現(xiàn)在就分享給大家,也給大家做個參考。一起跟隨小編過來看看吧2017-01-01
python中內(nèi)置函數(shù)ord()返回字符串的ASCII數(shù)值實例詳解
ord()?函數(shù)是?chr()?函數(shù)(對于?8?位的?ASCII?字符串)的配對函數(shù),它以一個字符串(Unicode?字符)作為參數(shù),返回對應的?ASCII?數(shù)值,或者?Unicode?數(shù)值,這篇文章主要介紹了python?中內(nèi)置函數(shù)ord()返回字符串的ASCII數(shù)值,需要的朋友可以參考下2022-07-07

