3
3
import cv2
4
4
5
5
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" )
7
7
ap .add_argument ("-t" , "--threshold" , type = float , default = 100.0 , help = "focus measures that fall below this value will be considered 'blurry'" )
8
8
args = vars (ap .parse_args ())
9
9
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"
15
14
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"
18
17
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