Nicen coding style
This commit is contained in:
parent
4f82f5f8f0
commit
ef37a30e7d
15
imgrate.py
15
imgrate.py
@ -1,9 +1,9 @@
|
||||
#!/usr/bin/env python3
|
||||
import cv2
|
||||
import numpy as np
|
||||
from argparse import ArgumentParser
|
||||
from functools import wraps
|
||||
|
||||
import cv2
|
||||
import numpy as np
|
||||
|
||||
|
||||
def image_required(fun):
|
||||
@ -16,11 +16,11 @@ def image_required(fun):
|
||||
return wrapper
|
||||
|
||||
|
||||
|
||||
class imgrate:
|
||||
def __init__(self, imgfile=None):
|
||||
self.image = None
|
||||
if imgfile: self.load_image(imgfile)
|
||||
if imgfile:
|
||||
self.load_image(imgfile)
|
||||
|
||||
def load_image(self, imgfile):
|
||||
image = cv2.imread(imgfile)
|
||||
@ -47,7 +47,6 @@ class imgrate:
|
||||
return Th / (F.shape[0] * F.shape[1])
|
||||
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
from os import remove
|
||||
from sys import exit
|
||||
@ -66,8 +65,10 @@ if __name__ == '__main__':
|
||||
|
||||
|
||||
def run(args):
|
||||
try: ratings = {image: getattr(imgrate(image), args.method) for image in args.images}
|
||||
except AttributeError: exit('Invalid --method option!')
|
||||
try:
|
||||
ratings = {image: getattr(imgrate(image), args.method) for image in args.images}
|
||||
except AttributeError:
|
||||
exit('Invalid --method option!')
|
||||
maximum = max(ratings, key=ratings.get)
|
||||
|
||||
for rating in ratings.keys():
|
||||
|
Loading…
Reference in New Issue
Block a user