def test_reading_images(): path_accepted_android = '../img/acceptable/android/*.jpg' path_accepted_ios = '../img/acceptable/ios/*.jpg' path_non_accepted = '../img/non-acceptable/*.jpg' print("", end="\n") # a new line for im in glob.glob(path_accepted_android): print("loading " + im) assert Images.imread( file_name=im) is not None, "image " + im + " can not be loaded" for im in glob.glob(path_accepted_ios): print("loading " + im) assert Images.imread( file_name=im) is not None, "image " + im + " can not be loaded" for im in glob.glob(path_non_accepted): print("loading " + im) assert Images.imread( file_name=im) is not None, "image " + im + " can not be loaded"
def test_template_matching_non_acceptable(): path_accepted_android = '../img/non-acceptable/*.jpg' print("", end="\n") # a new line for im in glob.glob(path_accepted_android): image = Images.imread(file_name=im) height, width, channels = image.shape new_image = Preprocessing.run(image=image, height=height, width=width, channels=channels) status, _, _ = Check.run( # check if the image is sent through gadget image=new_image # image after pre-processing ) assert status is False, "the validation check of " + im + " was not established"
def main(): # file_name = f'../img/non-acceptable/im1.jpg' file_name = f'../img/acceptable/android/im1.jpg' try: # import image file image = Images.imread(file_name) except InputValue: raise InputValue( "The image file does not exist in the specified directory..." ) except Exception as exc: raise UnknownException(exc) else: height, width, channels = image.shape print( "The shape of %s is: (%d, %d, %d)" % ( file_name, height, width, channels) ) try: # do some shape processing new_image = Preprocessing.run(image, height, width, channels) except InvalidRequest as exc: InvalidRequest(exc) else: try: print( "The result of gadget validation is %s - Center:%s and Radius:%s" % # print the result - center - radius of the circle Check.run( # check if the image is sent through gadget new_image # image after pre-processing ) ) except InvalidRequest as exc: InvalidRequest(exc) finally: print( "The validation result of %s is printed on the screen." % file_name )
def test_pre_processing_2(): path_accepted_ios = '../img/acceptable/ios/*.jpg' print("", end="\n") # a new line for im in glob.glob(path_accepted_ios): image = Images.imread(file_name=im) height, width, channels = image.shape new_image = Preprocessing.run(image=image, height=height, width=width, channels=channels) assert new_image is not None, "required pre-processing for " + im + " can not be done" print("the shape of %s before processing is (%d, %d, %d)" % (im, height, width, channels)) new_height, new_width, new_channels = new_image.shape print("the shape of %s after processing is (%d, %d, %d)" % (im, new_height, new_width, new_channels)) assert (width > height and new_width < new_height) or \ (width < height), "the shape of " + im + " can not be changed"