Python-OpenCV学习--电脑外接摄像头实时采集FAST角点并显示
生活随笔
收集整理的這篇文章主要介紹了
Python-OpenCV学习--电脑外接摄像头实时采集FAST角点并显示
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
?一、一般的Python OpenCV代碼是對現(xiàn)有的圖片提取fast角點
參考代碼很多:https://blog.csdn.net/update7/article/details/105927539
?
二、采用臺式機外接USB攝像頭采集圖像,實時檢測fast角點并顯示。(可設(shè)置攝像頭采集幀率)
? ? ? ? 只是簡單的將圖像獲取路徑換成攝像頭采集,也能運行,但是運行結(jié)果是圖片的顯示,關(guān)閉后又顯示下一幀圖像,無法實時視頻流級別的顯示檢測結(jié)果。
? ? ? ? 初學(xué)者摸索的修改版代碼,測試可以使用。僅供自己以后學(xué)習(xí)參考。
import numpy as np import cv2 from matplotlib import pyplot as plt cap = cv2.VideoCapture(0) cap.set(cv2.CAP_PROP_FPS, 10) while True:ret, frame = cap.read()# cv2.imshow("Video", frame)#讀取內(nèi)容# Initiate FAST object with default valuesfast = cv2.FastFeatureDetector_create()# find and draw the keypointskp = fast.detect(frame,None)img2 = cv2.drawKeypoints(frame, kp, None, color=(255,0,0))# Print all default params# print( "Threshold: {}".format(fast.getThreshold()) )# print( "nonmaxSuppression:{}".format(fast.getNonmaxSuppression()) )# print( "neighborhood: {}".format(fast.getType()) )# print( "Total Keypoints with nonmaxSuppression: {}".format(len(kp)) )# cv2.imwrite('fast_true.png',img2)cv2.imshow("Video", img2)# plt.imshow(img2)# plt.show("display")if cv2.waitKey(10) == ord("q"):break #隨時準(zhǔn)備按q退出 cap.release() cv2.destroyAllWindows()?
?
三、幀率設(shè)置: 參考一下表格中的參數(shù)。
cap.set(cv2.CAP_PROP_FPS, 10) 第一個是參數(shù)名,第二個是賦值,代表每秒10幀參考:https://blog.csdn.net/weixin_41010198/article/details/88535234
總結(jié)
以上是生活随笔為你收集整理的Python-OpenCV学习--电脑外接摄像头实时采集FAST角点并显示的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Python-OpenCV学习--USB
- 下一篇: Python-OpenCV学习--外接摄