Skip to content Skip to sidebar Skip to footer

Compare Frame Of Video With Another Image Python?

I would like compare a frame of video with another image but i don't know how can i do it with python. Someone can help me please

Solution 1:

You can use various metrics, look them up to see how they're calculated and when you should use them. In Python this can be achieved easily with scikit-image.

import cv2
from skimage.measure import compare_mse, compare_nrmse, compare_ssim, compare_psnr

img1 = cv2.imread('img1.jpg')
img2 = cv2.imread('img2.jpg')

# mean squared error
compare_mse(img1, img2)
# normalized root-mean-square
compare_nrmse(img1, img2)
# peak signal-to-noise ratio
compare_psnr(img1, img2)
# structural similarity index
compare_ssim(img1, img2, multichannel=True)

The images must have the same size.

Post a Comment for "Compare Frame Of Video With Another Image Python?"