赞
踩
参考代码很多:https://blog.csdn.net/update7/article/details/105927539
只是简单的将图像获取路径换成摄像头采集,也能运行,但是运行结果是图片的显示,关闭后又显示下一帧图像,无法实时视频流级别的显示检测结果。
初学者摸索的修改版代码,测试可以使用。仅供自己以后学习参考。
- 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)
- #读取内容
-
- # Initiate FAST object with default values
- fast = cv2.FastFeatureDetector_create()
- # find and draw the keypoints
- kp = 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
- #随时准备按q退出
- cap.release()
- cv2.destroyAllWindows()
cap.set(cv2.CAP_PROP_FPS, 10) 第一个是参数名,第二个是赋值,代表每秒10帧
参考:https://blog.csdn.net/weixin_41010198/article/details/88535234
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。