This code works as the official document code is only compatible with particular version of opencv and not updated there after
from __future__ import print_function
import cv2
img = cv2.imread('simple.jpg',0)
img = cv2.imread(f,0)
# Initiate FAST object with default values
fast = cv2.FastFeatureDetector_create(threshold=25)
# find and draw the keypoints
kp = fast.detect(img,None)
img2 = cv2.drawKeypoints(img, kp, None,color=(255,0,0))
print("Threshold: ", fast.getThreshold())
print("nonmaxSuppression: ", fast.getNonmaxSuppression())
print("neighborhood: ", fast.getType())
print("Total Keypoints with nonmaxSuppression: ", len(kp))
img2_vis = cv2.resize(img2, (1600, 1000))
cv2.imshow('fast_true',img2_vis),cv2.waitKey()
# Disable nonmaxSuppression
fast.setNonmaxSuppression(0)
kp = fast.detect(img,None)
print("Total Keypoints without nonmaxSuppression: ", len(kp))
img3 = cv2.drawKeypoints(img, kp, None, color=(255,0,0))
img3_vis = cv2.resize(img3, (1600, 1000))
cv2.imshow('fast_false',img3_vis),cv2.waitKey()