iT邦幫忙

2022 iThome 鐵人賽

0

https://ithelp.ithome.com.tw/upload/images/20221121/20151839sERE3QA9wX.png

!pip install opencv-python
!pip install matplotlib
import cv2
import numpy as np
import matplotlib.pyplot as plt
import glob
from IPython.display import clear_output

以上皆為測試cv2函數能正常使用!

pip install opencv-python==4.5.1.48

這個是為了以下的code去做python的更新,因為detector.detect語法太新,需要用更高的python版本去執行

import cv2
import numpy as np
 
# Read image
im = cv2.imread("123.jpg", cv2.IMREAD_GRAYSCALE)
 
# Set up the detector with default parameters.
detector = cv2.SimpleBlobDetector()
 
# Detect blobs.
keypoints = detector.detect(im)
 
# Draw detected blobs as red circles.
# cv2.DRAW_MATCHES_FLAGS_DRAW_RICH_KEYPOINTS ensures the size of the circle corresponds to the size of blob
im_with_keypoints = cv2.drawKeypoints(im, keypoints, np.array([]), (0,0,255), cv2.DRAW_MATCHES_FLAGS_DRAW_RICH_KEYPOINTS)
 
# Show keypoints
cv2.imshow("Keypoints", im_with_keypoints)
cv2.waitKey(0)

https://ithelp.ithome.com.tw/upload/images/20221121/20151839RPi7tRadn8.png


上一篇
Day26- Blob用途
下一篇
Day28- 實戰演練(圖片描邊)
系列文
大四要畢業了但還不太會python合理嗎30
圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友留言

立即登入留言