git-svn-id: http://moon:8086/svn/software/trunk/projects/opencv@310 b431acfa-c32f-4a4a-93f1-934dc6c82436
66 lines
2.1 KiB
Python
Executable File
66 lines
2.1 KiB
Python
Executable File
# import the necessary packages
|
|
from __future__ import print_function
|
|
from PiVideoStream import PiVideoStream
|
|
from imutils.video import FPS
|
|
from picamera.array import PiRGBArray
|
|
from picamera import PiCamera
|
|
import numpy as np
|
|
import argparse
|
|
import imutils
|
|
import time
|
|
import cv2
|
|
|
|
# construct the argument parse and parse the arguments
|
|
ap = argparse.ArgumentParser()
|
|
ap.add_argument("-n", "--num-frames", type=int, default=100,
|
|
help="# of frames to loop over for FPS test")
|
|
ap.add_argument("-d", "--display", type=int, default=-1,
|
|
help="Whether or not frames should be displayed")
|
|
args = vars(ap.parse_args())
|
|
|
|
# created a *threaded *video stream, allow the camera sensor to warmup,
|
|
# and start the FPS counter
|
|
print("[INFO] sampling THREADED frames from `picamera` module...")
|
|
vs = PiVideoStream(resolution=(640,480), framerate=30).start()
|
|
time.sleep(2.0)
|
|
fps = FPS().start()
|
|
|
|
# Initiate FAST object with default values
|
|
fast = cv2.FastFeatureDetector_create()
|
|
fast.setNonmaxSuppression(True)
|
|
|
|
# loop over some frames...this time using the threaded stream
|
|
while fps._numFrames < args["num_frames"]:
|
|
# grab the frame from the threaded video stream
|
|
frame = vs.read()
|
|
temp = frame
|
|
|
|
# find and draw the keypoints
|
|
kp = fast.detect(frame,None)
|
|
img2 = cv2.drawKeypoints(frame, kp, outImage=temp, color=(255,0,0))
|
|
|
|
# Print all default params
|
|
print ("Threshold: " + str(fast.getThreshold()))
|
|
print ("nonmaxSuppression: " + str(fast.getNonmaxSuppression()))
|
|
print ("neighborhood: " + str(fast.getType()))
|
|
print ("Total Keypoints with nonmaxSuppression: " + str(len(kp)))
|
|
|
|
# check to see if the frame should be displayed to our screen
|
|
cv2.imshow("Frame", img2)
|
|
key = cv2.waitKey(1) & 0xFF
|
|
|
|
# update the FPS counter
|
|
fps.update()
|
|
|
|
# stop the timer and display FPS information
|
|
fps.stop()
|
|
vs.stop()
|
|
print("[INFO] elasped time: {:.2f}".format(fps.elapsed()))
|
|
print("[INFO] approx. FPS: {:.2f}".format(fps.fps()))
|
|
print("[INFO] Camera : elasped time: {:.2f}".format(vs.getfps().elapsed()))
|
|
print("[INFO] Camera: approx. FPS: {:.2f}".format(vs.getfps().fps()))
|
|
|
|
# do a bit of cleanup
|
|
cv2.destroyAllWindows()
|
|
|