Skip to content

Commit

Permalink
Added debugging parameters to quality test
Browse files Browse the repository at this point in the history
  • Loading branch information
fernando79513 committed Oct 16, 2023
1 parent 4f5ea43 commit 2ba2d25
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions providers/base/bin/camera_quality_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
THRESHOLD = 60


def brisque(device: str = "video0"):
def brisque(device: str = "video0", file: str = "", save: bool = False):
"""
Captures an image to a file and computes the quality using the
Blinded/Unreferenced Spatial Image Quality Evaluator (BRISQUE). If the
Expand All @@ -58,14 +58,17 @@ def brisque(device: str = "video0"):
print("Cannot read from the selected device", file=sys.stderr)
return 1

# Save it in a temporary file
# Create a temporary file
f = NamedTemporaryFile(prefix='camera_test_brisque_%s_' % device,
suffix='.jpg', delete=False)
suffix='.jpg', delete=not save)
cv2.imwrite(f.name, image)
print("Image saved to %s" % f.name)
if save:
print("Image saved to %s" % f.name)

# Compute the BRISQUE score
score = brisque.score(f.name)
f.close()

if isnan(score):
print("Unable to compute BRISQUE score", file=sys.stderr)
return 1
Expand All @@ -81,6 +84,10 @@ def brisque(device: str = "video0"):
parser = argparse.ArgumentParser(description="Run the image quality test")
parser.add_argument("-d", "--device", default="video0",
help="Device for the webcam to use")
parser.add_argument("-f", "--file", default="",
help="Parse a file instead of a device")
parser.add_argument("-s", "--save", action="store_true",
help="Keep the image file after the test")
args = parser.parse_args()

sys.exit(brisque(args.device))
sys.exit(brisque(args.device, args.file, not args.save))

0 comments on commit 2ba2d25

Please sign in to comment.