標籤:block pre real show basic err rgb odi raspberry
可以看看這篇部落格
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 npimport cv2from matplotlib import pyplot as plt #import the libraryleft_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 stereodisparity = matching.compute(left_img,right_img) #make the depth mapcv2.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