我是 Python 和 openCV 的新手,所以如果这很简单,我提前道歉。我正在尝试遵循http://altruisticrobot.tistory.com/219上的深度图代码。在下面的代码中ConvertScale
引发以下错误:
src.size == dst.size && src.channels() == dst.channels()
我花了几天时间,不知道为什么。任何指针将不胜感激。提前致谢。
im_l = cv.LoadImage('C:\Python27\project\captureL6324.png',cv.CV_LOAD_IMAGE_GRAYSCALE)
im_r = cv.LoadImage('C:\Python27\project\captureR6324.png',cv.CV_LOAD_IMAGE_GRAYSCALE)
imsize = cv.GetSize(im_l)
disp = cv.CreateImage(imsize,cv.IPL_DEPTH_16S,1)# to receive Disparity
#run stereo Correspondence-- returns a single channel 16 bit signed disparity
disparity = cv.FindStereoCorrespondenceBM(im_r,im_l,disp,cv.CreateStereoBMState())
#convert to a real disparity by dividing it by 16-- first create variable to hold the converted scale
real_disparity = cv.CreateImage(imsize,cv.IPL_DEPTH_16S,1)
cv.ConvertScale(disparity, real_disparity, -16,0)
#get the point cloud
depth = cv.CreateImage(cv.GetSize(im_l),cv.IPL_DEPTH_32F,3)
cv.ReprojectIMageTo3D(real_disparity,depth, ReprojectMatrix)