image_comparison.py
def image_comparison(src_file, dest_file):
    """Compare the images listed in input csv file
        and outputs the score,elapsed time along with it
        into the output csv file"""
    try:
        with open(str(src_file), mode='r') as f, open(str(dest_file), mode="w") as csv_file:
            fieldnames = ["Image1", "Image2", "Similar", "Elapsed"]
            writer = csv.DictWriter(csv_file, fieldnames=fieldnames)
            writer.writeheader()
            reader = csv.reader(f)
            image_list = list(reader)
            for item in range(1, len(image_list)):
                src = Image.open(image_list[item][0])
                dest = Image.open(image_list[item][1])
                start_time = time.time()
                score = calculate_rms(src, dest)
                end_time = time.time()
                elapsed_time = round(end_time - start_time, 4)
                writer.writerow({"Image1": image_list[item][0], "Image2": image_list[item][1],
                                 "Similar": score, "Elapsed": elapsed_time})
    except IOError as exception:
        if exception.strerror == "No such file or directory":
            print(f"Please check the file exists or not - {exception.strerror}")
        else:
            print(f"Here is the Error - {exception.strerror}")
Compare the images listed in input csv file
        and outputs the score,elapsed time along with it
        into the output csv file
Compare the images listed in input csv file
and outputs the score,elapsed time along with it
into the output csv file
Compare the images listed in input csv file and outputs the score elapsed time along with it into the output csv file
def image_comparison(src_file, dest_file):
    try:
        with open(str(src_file), mode='r') as f, open(str(dest_file), mode="w") as csv_file:
            fieldnames = ["Image1", "Image2", "Similar", "Elapsed"]
            writer = csv.DictWriter(csv_file, fieldnames=fieldnames)
            writer.writeheader()
            reader = csv.reader(f)
            image_list = list(reader)
            for item in range(1, len(image_list)):
                src = Image.open(image_list[item][0])
                dest = Image.open(image_list[item][1])
                start_time = time.time()
                score = calculate_rms(src, dest)
                end_time = time.time()
                elapsed_time = round(end_time - start_time, 4)
                writer.writerow({"Image1": image_list[item][0], "Image2": image_list[item][1],
                                 "Similar": score, "Elapsed": elapsed_time})
    except IOError as exception:
        if exception.strerror == "No such file or directory":
            print(f"Please check the file exists or not - {exception.strerror}")
        else:
            print(f"Here is the Error - {exception.strerror}")
def image_comparison ( src_file , dest_file ) : try : with open ( str ( src_file ) , mode = 'r' ) as f , open ( str ( dest_file ) , mode = "w" ) as csv_file : fieldnames = [ "Image1" , "Image2" , "Similar" , "Elapsed" ] writer = csv . DictWriter ( csv_file , fieldnames = fieldnames ) writer . writeheader ( ) reader = csv . reader ( f ) image_list = list ( reader ) for item in range ( 1 , len ( image_list ) ) : src = Image . open ( image_list [ item ] [ 0 ] ) dest = Image . open ( image_list [ item ] [ 1 ] ) start_time = time . time ( ) score = calculate_rms ( src , dest ) end_time = time . time ( ) elapsed_time = round ( end_time - start_time , 4 ) writer . writerow ( { "Image1" : image_list [ item ] [ 0 ] , "Image2" : image_list [ item ] [ 1 ] , "Similar" : score , "Elapsed" : elapsed_time } ) except IOError as exception : if exception . strerror == "No such file or directory" : print ( f"Please check the file exists or not - {exception.strerror}" ) else : print ( f"Here is the Error - {exception.strerror}" )
Compare the images listed in input csv file
and outputs the score,elapsed time along with it
into the output csv file
Compare the images listed in input csv file and outputs the score elapsed time along with it into the output csv file
"""Compare the images listed in input csv file
        and outputs the score,elapsed time along with it
        into the output csv file"""
src_file
dest_file