I want to find out PSNR and SSIM of two video files in python using openCv and numpy. How to find PSNR in python
I tried below code for SSIM
# comput
You can read the video frames by frames and use this function to compute similarity between frames and find mean.
Make sure you provide full path of the image.
def compare(ImageAPath, ImageBPath):
img1 = cv2.imread(ImageAPath) # queryImage
img2 = cv2.imread(ImageBPath)
image1 = cv2.cvtColor(img1, cv2.COLOR_BGR2GRAY)
image2 = cv2.cvtColor(img2, cv2.COLOR_BGR2GRAY) # trainImage
score, diff = compare_ssim(image1, image2, full=True, multichannel=False)
print("SSIM: {}".format(score))
If you Image is colourful and you don't wish to use gray image, pass
multichannel=True