網站首頁 編程語言 正文
效果展示
中心的三個沒檢測到
import cv2 import numpy as np import matplotlib.pyplot as plt w = 20 h = 5 params = cv2.SimpleBlobDetector_Params() # Setup SimpleBlobDetector parameters. print('params') print(params) print(type(params)) # Filter by Area. params.filterByArea = True params.minArea = 10e1 params.maxArea = 10e3 params.minDistBetweenBlobs = 25 # params.filterByColor = True params.filterByConvexity = False # tweak these as you see fit # Filter by Circularity # params.filterByCircularity = False # params.minCircularity = 0.2 # params.blobColor = 0 # # # Filter by Convexity # params.filterByConvexity = True # params.minConvexity = 0.87 # Filter by Inertia # params.filterByInertia = True # params.filterByInertia = False # params.minInertiaRatio = 0.01 # img = cv2.imread("circles/circels.jpg",1) img = cv2.imread("circles/Snap_001.jpg",1) gray= cv2.cvtColor(img,cv2.COLOR_BGR2GRAY) # Detect blobs. # image = cv2.resize(gray_img, (int(img.shape[1]/4),int(img.shape[0]/4)), 1, 1, cv2.INTER_LINEAR) # image = cv2.resize(gray_img, dsize=None, fx=0.25, fy=0.25, interpolation=cv2.INTER_LINEAR) minThreshValue = 120 _, gray = cv2.threshold(gray, minThreshValue, 255, cv2.THRESH_BINARY) gray = cv2.resize(gray, dsize=None, fx=2, fy=2, interpolation=cv2.INTER_LINEAR) # plt.imshow(gray) # cv2.imshow("gray",gray) detector = cv2.SimpleBlobDetector_create(params) keypoints = detector.detect(gray) print(len(keypoints)) fig = plt.figure() # im_with_keypoints = cv2.drawKeypoints(gray, keypoints, np.array([]), (0, 0, 255), cv2.DRAW_MATCHES_FLAGS_DRAW_RICH_KEYPOINTS) im_with_keypoints = cv2.drawKeypoints(gray, keypoints, np.array([]), (0, 0, 255), cv2.DRAW_MATCHES_FLAGS_DRAW_RICH_KEYPOINTS) plt.imshow(cv2.cvtColor(im_with_keypoints, cv2.COLOR_BGR2RGB),interpolation='bicubic') fname = "key points" titlestr = '%s found %d keypoints' % (fname, len(keypoints)) plt.title(titlestr) plt.show() # cv2.imshow("graykey",gray) # cv2.waitKey() fig.canvas.set_window_title(titlestr) ret, corners = cv2.findCirclesGrid(gray, (w, h), flags=(cv2.CALIB_CB_SYMMETRIC_GRID + cv2.CALIB_CB_CLUSTERING ), blobDetector=detector ) if corners is not None: cv2.drawChessboardCorners(img, (w, h), corners, corners is not None) print("find blob") # # cv2.imshow('findCorners', img) # cv2.waitKey() plt.imshow(img) plt.show()
原文鏈接:https://blog.csdn.net/moonlightpeng/article/details/124002491
相關推薦
- 2022-07-20 輕松手寫Spring的IOC
- 2023-04-10 詳解Go語言中的數據庫操作_Golang
- 2022-06-30 go-micro集成RabbitMQ實戰和原理詳解_Golang
- 2022-03-18 C語言回溯法解八皇后問題(八皇后算法)_C 語言
- 2022-07-26 淺談Redis的事件驅動模型_Redis
- 2022-05-25 文字解說Golang?Goroutine和線程的區別_Golang
- 2022-03-31 Docker使用鏡像倉庫的方法_docker
- 2022-07-22 git倉庫的第一次上傳以及修改上傳項目
- 最近更新
-
- window11 系統安裝 yarn
- 超詳細win安裝深度學習環境2025年最新版(
- Linux 中運行的top命令 怎么退出?
- MySQL 中decimal 的用法? 存儲小
- get 、set 、toString 方法的使
- @Resource和 @Autowired注解
- Java基礎操作-- 運算符,流程控制 Flo
- 1. Int 和Integer 的區別,Jav
- spring @retryable不生效的一種
- Spring Security之認證信息的處理
- Spring Security之認證過濾器
- Spring Security概述快速入門
- Spring Security之配置體系
- 【SpringBoot】SpringCache
- Spring Security之基于方法配置權
- redisson分布式鎖中waittime的設
- maven:解決release錯誤:Artif
- restTemplate使用總結
- Spring Security之安全異常處理
- MybatisPlus優雅實現加密?
- Spring ioc容器與Bean的生命周期。
- 【探索SpringCloud】服務發現-Nac
- Spring Security之基于HttpR
- Redis 底層數據結構-簡單動態字符串(SD
- arthas操作spring被代理目標對象命令
- Spring中的單例模式應用詳解
- 聊聊消息隊列,發送消息的4種方式
- bootspring第三方資源配置管理
- GIT同步修改后的遠程分支