首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >解释cv2方法的结果: phaseCorrelate?| python opencv

解释cv2方法的结果: phaseCorrelate?| python opencv
EN

Stack Overflow用户
提问于 2019-08-23 20:47:24
回答 1查看 1.3K关注 0票数 4

我已经写了一个简单的脚本,返回两个图像之间的相位相关性。为此,我调用了cv2方法: cv2.phaseCorrelate

我知道它返回两个图像之间的亚像素相移,但是,我不清楚返回对象的每个组件的具体细节(方法返回一个包含一个元组和一个浮点数的列表)。

任何帮助都是非常感谢的,提前谢谢你。

代码语言:javascript
运行
复制
import cv2
import math
import time
import numpy as np

class CorrelationCalculator(object):
    'TODO: class description'

    version = '0.1'

    def __init__(self, initial_frame, detection_threshold=4):
        self.initial_frame = np.float32(cv2.cvtColor(initial_frame, cv2.COLOR_BGR2GRAY))
        self.detection_threshold = detection_threshold

    def detect_phase_shift(self, current_frame):    
        'returns detected sub-pixel phase shift between two arrays'
        self.current_frame = np.float32(cv2.cvtColor(current_frame, cv2.COLOR_BGR2GRAY))
        shift = cv2.phaseCorrelate(self.initial_frame, self.current_frame)
        return shift

# implementation

import cv2

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

obj = CorrelationCalculator(img)
shift = obj.detect_phase_shift(img2)

print(str(shift)

输出:

((4.3597901057868285,-2.8767423065464186),0.4815432178477446)

代码语言:javascript
运行
复制
EN

回答 1

Stack Overflow用户

发布于 2019-08-23 22:42:13

返回的第一个元组告诉您在x和y坐标上imgimg2之间的移位量。例如,考虑下面的两个图像。

这个方法被认为是找出矩形在像素值中的移位。其他值表示我们从相位相关过程中获得的响应值。您可能会认为它是计算确定性的一种度量。您可以在phaseCorrelate标题下找到OpenCv documentation的详细信息。

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/57626656

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档