码迷,mamicode.com
首页 > 编程语言 > 详细

OpenCV---Python----Depth Map

时间:2017-10-27 19:55:20      阅读:632      评论:0      收藏:0      [点我收藏+]

标签: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 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

标签:block   pre   real   show   basic   err   rgb   odi   raspberry   

原文地址:http://www.cnblogs.com/kprac/p/7744827.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!