Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

depth estimation

I am using stereocalibrate and stereorectify to get the Q matrix. I am giving this as input to cv.ReprojectImageto3D to get the depth map. But when I try to show the results, many values are calculated as infinity.

Do I need to change or scale anything before reprojecting. And is the result which we get in pixels?

(roi1,roi2) = cv.StereoRectify(camMatrix1, camMatrix2, d1, d2,(320,240), r, t, r1, r2, p1, p2, q, cv.CV_CALIB_ZERO_DISPARITY, -1, (0, 0))
np.savetxt('Q_mat.txt',q)
disparity  = getDisparity(img_r, img_l, "BM")
disp = cv.fromarray(disparity)
Image = cv.CreateMat(disp.rows, disp.cols, cv.CV_32FC3)
Q = np.loadtxt('Q_mat.txt')
Q = np.reshape(Q,(4,4))
Q1 = cv.fromarray(Q)
cv.ReprojectImageTo3D(disp, Image, Q1, 0)

Thanks in advance

depth estimationopencv ReprojectImageto3D gives values tending to infinity

I am using stereocalibrate and stereorectify to get the Q matrix. I am giving this as input to cv.ReprojectImageto3D to get the depth map. But when I try to show the results, many values are calculated as infinity.

Do I need to change or scale anything before reprojecting. And is the result which we get in pixels?

(roi1,roi2) = cv.StereoRectify(camMatrix1, camMatrix2, d1, d2,(320,240), r, t, r1, r2, p1, p2, q, cv.CV_CALIB_ZERO_DISPARITY, -1, (0, 0))
np.savetxt('Q_mat.txt',q)
disparity  = getDisparity(img_r, img_l, "BM")
disp = cv.fromarray(disparity)
Image = cv.CreateMat(disp.rows, disp.cols, cv.CV_32FC3)
Q = np.loadtxt('Q_mat.txt')
Q = np.reshape(Q,(4,4))
Q1 = cv.fromarray(Q)
cv.ReprojectImageTo3D(disp, Image, Q1, 0)

Thanks in advance

click to hide/show revision 3
retagged

updated 2013-11-25 01:58:28 -0600

berak gravatar image

opencv ReprojectImageto3D gives values tending to infinity

I am using stereocalibrate and stereorectify to get the Q matrix. I am giving this as input to cv.ReprojectImageto3D to get the depth map. But when I try to show the results, many values are calculated as infinity.

Do I need to change or scale anything before reprojecting. And is the result which we get in pixels?

(roi1,roi2) = cv.StereoRectify(camMatrix1, camMatrix2, d1, d2,(320,240), r, t, r1, r2, p1, p2, q, cv.CV_CALIB_ZERO_DISPARITY, -1, (0, 0))
np.savetxt('Q_mat.txt',q)
disparity  = getDisparity(img_r, img_l, "BM")
disp = cv.fromarray(disparity)
Image = cv.CreateMat(disp.rows, disp.cols, cv.CV_32FC3)
Q = np.loadtxt('Q_mat.txt')
Q = np.reshape(Q,(4,4))
Q1 = cv.fromarray(Q)
cv.ReprojectImageTo3D(disp, Image, Q1, 0)

Thanks in advance