python - 如何区分视差图像的好坏

标签 python image opencv

将numpy导入为np
从sklearn.preprocessing导入规范化
导入cv2

print('loading images...')
imgL = cv2.imread("C:/Users/admin/jupyter/car/challenge_pictrue/right/right2.jpg ")
imgR = cv2.imread("C:/Users/admin/jupyter/car/challenge_pictrue/left/left2.jpg ")

# SGBM Parameters -----------------
window_size = 3                     # wsize default 3; 5; 7 for SGBM reduced size image; 15 for SGBM full size image (1300px and above); 5 Works nicely

left_matcher = cv2.StereoSGBM_create(
    minDisparity=0,
    numDisparities=160,             # max_disp has to be dividable by 16 f. E. HH 192, 256
    blockSize=5,
    P1=8 * 3 * window_size ** 2,    # wsize default 3; 5; 7 for SGBM reduced size image; 15 for SGBM full size image (1300px and above); 5 Works nicely
    P2=32 * 3 * window_size ** 2,
    disp12MaxDiff=1,
    uniquenessRatio=15,
    speckleWindowSize=0,
    speckleRange=2,
    preFilterCap=63,
    mode=cv2.STEREO_SGBM_MODE_SGBM_3WAY
)

right_matcher = cv2.ximgproc.createRightMatcher(left_matcher)

# FILTER Parameters
lmbda = 80000
sigma = 1.2
visual_multiplier = 1.0

wls_filter = cv2.ximgproc.createDisparityWLSFilter(matcher_left=left_matcher)
wls_filter.setLambda(lmbda)
wls_filter.setSigmaColor(sigma)

print('computing disparity...')
displ = left_matcher.compute(imgL, imgR)  # .astype(np.float32)/16
dispr = right_matcher.compute(imgR, imgL)  # .astype(np.float32)/16
displ = np.int16(displ)
dispr = np.int16(dispr)
filteredImg = wls_filter.filter(displ, imgL, None, dispr)  # important to put "imgL" here!!!

filteredImg = cv2.normalize(src=filteredImg, dst=filteredImg, beta=0, alpha=255, norm_type=cv2.NORM_MINMAX);
filteredImg = np.uint8(filteredImg)
cv2.imshow('Disparity Map', filteredImg)
cv2.waitKey()
cv2.destroyAllWindows()

我不知道如何区分这张视差图像的好坏。
谁能帮助我说明这个差异图像?

最佳答案

要获得良好的视差图:

  • 您的场景应具有随机纹理。如果场景是高纹理的,您将获得良好的视差图。

  • 差视差图:
  • 校准数据出现错误时。您应该正确获得校准数据。
  • 当您的场景具有重复性模式或没有纹理时,视差是map将会丢失更多数据。我们不能直接将其称为错误 map ,而是其预期行为。
  • 关于python - 如何区分视差图像的好坏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62447982/

    相关文章:

    javascript - 使用 JavaScript 随机化一组现有图像的布局

    c++ - 如何让 OpenCV 成为我的 qt 项目的默认库?

    f# - 从 F# 使用 OpenCV

    python - Matplotlib 子图未绘制

    python - IPython Notebook Tab-Complete -- 显示文档字符串

    python - 在 python 中解析文本

    python - Django:CSV 模型导入

    css - 在 GWT 中,是否可以将图像小部件缩放到小于其原始大小?

    php - 当宽度大于 PHP 中的高度时自动旋转图像

    image-processing - Blob 的中轴(正交骨架化)