以下实验为左图
以下为实验右图
实验代码
import os
import time
import cv2 as cv
import numpy as np
import matplotlib.pyplot as plt
from numba import jit
# lres = census(limg[:, maxDisparity:w])
# maxDisparity = 12 # 最大视差,也就是搜索范围,搜索范围越大耗时越长
# window_size = 5 # 滑动窗口大小,窗口越大匹配成功难度越高
# same = np.int64(window_size / 2) # 窗口大小的一半向下取整,比如用来衡量窗口左上角与窗口中点的距离的x与y坐标
@jit
def census(img):
size = np.shape(img)[0:2]
h = size[0]
w = size[1]
census = np.zeros((h - 2 * same, w - 2 * same), dtype=np.int64)
# census就是经过变换后的图像
cp = img[same:h - same, same:w - same]
# cp是变换中心点的坐标,0,0点作为左上角的窗口中,中心点就是(same,same)
offsets = [(u, v) for v in range(window_size) for u in range(window_size) if not u