OpenCV---Python----Depth Map
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了OpenCV---Python----Depth Map相关的知识,希望对你有一定的参考价值。
可以看看这篇博客
http://blog.csdn.net/taily_duan/article/details/52165458
测试图片可以从这里找
https://www.raspberrypi.org/blog/real-time-depth-perception-with-the-compute-module/
以下两行代码似乎因为版本更替原因都无效了
deparsity = cv2.StereoBM(cv2.STEREO_BM_BASIC_PRESET,ndisparities=16, SADWindowSize=15)
deparsity = cv2.createStereoBM(numDisparities=16, blockSize=25)
#测试代码如下:
# -*- coding: UTF-8 -*- import numpy as np import cv2 from matplotlib import pyplot as plt #import the library left_img = cv2.imread(‘Tsukuba_L.png‘,0) #read the left_image(grey) left_img_rgb = cv2.imread(‘Tsukuba_L.png‘,cv2.IMREAD_COLOR) #read the left_image(colorful) right_img = cv2.imread(‘Tsukuba_R.png‘,0) #read the right_image(grey) right_img_rgb = cv2.imread(‘Tsukuba_R.png‘,cv2.IMREAD_COLOR) #read the right_image(colorful) matching=cv2.StereoBM_create(numDisparities=16, blockSize=15) #set the parameters of the stereo disparity = matching.compute(left_img,right_img) #make the depth map cv2.imshow("left_img",left_img_rgb) #show the left_image(colorful) cv2.imshow("right_img",right_img_rgb) #show the right_image(colorful) plt.imshow(disparity,‘gray‘) #show the depth map(grey) plt.show()
#
以上是关于OpenCV---Python----Depth Map的主要内容,如果未能解决你的问题,请参考以下文章