Skip to content

Commit b6429fe

Browse files
committed
Modify Blur Detection
1 parent c27c206 commit b6429fe

File tree

1 file changed

+10
-11
lines changed

1 file changed

+10
-11
lines changed

blurDetection.py

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,18 @@
33
import cv2
44

55
ap = argparse.ArgumentParser()
6-
ap.add_argument("-i", "--images", required=True, help="path to input directory of images")
6+
ap.add_argument("-i", "--image", required=True, help="path to input directory of images")
77
ap.add_argument("-t", "--threshold", type=float, default=100.0, help="focus measures that fall below this value will be considered 'blurry'")
88
args = vars(ap.parse_args())
99

10-
for imagePath in paths.list_images(args["images"]):
11-
image = cv2.imread(imagePath)
12-
gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
13-
fm = cv2.Laplacian(image, cv2.CV_64F).var()
14-
text = "Not Blurry"
10+
image = cv2.imread(args["image"])
11+
gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
12+
fm = cv2.Laplacian(image, cv2.CV_64F).var()
13+
text = "Not Blurry"
1514

16-
if fm < args["threshold"]: #keep tweeking the threshold as per your requirements
17-
text = "Blurry"
15+
if fm < args["threshold"]: #keep tweeking the threshold as per your requirements
16+
text = "Blurry"
1817

19-
cv2.putText(image, "{}: {:.2f}".format(text, fm), (10, 30), cv2.FONT_HERSHEY_SIMPLEX, 0.8, (0, 0, 255), 3)
20-
cv2.imshow("Image", image)
21-
key = cv2.waitKey(0)
18+
cv2.putText(image, "{}: {:.2f}".format(text, fm), (10, 30), cv2.FONT_HERSHEY_SIMPLEX, 0.8, (0, 0, 255), 3)
19+
cv2.imshow("Image", image)
20+
key = cv2.waitKey(0)

0 commit comments

Comments
 (0)