How to find PSNR and SSIM of two video files in python using openCV and other libraries?

后端 未结 1 1745
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-21 23:21

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         


        
相关标签:
1条回答
  • 2020-12-21 23:52

    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
    
    0 讨论(0)
提交回复
热议问题