python - 将python中的图像与opencv进行比较的最快方法是什么
问题描述
我必须将所有视频帧与一张图像进行比较,并且使用 compare_ssim 需要很长时间。我可以用什么最快的方法将图像与图像的相似程度进行比较?
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import cv2
from skimage.measure import compare_ssim as ssim
import time
start_time = time.time()
# Load File
opening = cv2.VideoCapture("/content/drive/My Drive/Skipper/DrStone-OP1.webm")
episode = cv2.VideoCapture("/content/drive/My Drive/Skipper/[Erai-raws] Dr. Stone - 06 [720p].mkv")
# Get First
opening.set(1, 0)
off_ret, opening_firstframe = opening.read()
opening_firstframe = cv2.cvtColor(opening_firstframe, cv2.COLOR_BGR2GRAY)
# (H, W) = opening_firstframe.shape
# Iterate over the episode
while episode.isOpened():
ep_ret, ep_frame = episode.read()
if ep_ret:
frames = episode.get(cv2.CAP_PROP_POS_FRAMES)
#ep_frame = cv2.resize(ep_frame, (W, H))
ep_frame = cv2.cvtColor(ep_frame, cv2.COLOR_BGR2GRAY)
sim_index = ssim(opening_firstframe, ep_frame) * 100
print(str(frames) + " : " + str(sim_index))
else:
break
print("--- %s seconds ---" % (time.time() - start_time))
解决方案
您可以使用均方误差 (mse) 或峰值信噪比 (psnr) 来比较图像。它们通常用于衡量编解码器的质量。
推荐阅读
- makefile - 带有 Eclipse 但没有 Makefile 的 LUFA
- node.js - Redis time() 有时会返回未来的时间
- javascript - 如何在 Firebase 中查询和聚合多个集合
- javascript - 尝试通过 Vue.js 中的 API 控制 Plyr
- spss - 如何在 SPSS 中从单独的月份和年份变量创建单个日期变量
- php - Ajax 返回 HTML 代码和我的预期输出
- javascript - 使用 servlet 生成 HTML 表格
- python - 虚拟环境应该驻留在 envs 文件夹中吗?
- swiftui - 给出的错误消息:无法推断通用参数“数据”
- android - 如何在原生 android 2019 中使用 WebRTC