1 | initial version |
xyz is an output argument; after the function runs it will contain a 'vertex map', which is basically a matrix with 3 channels for each of the X,Y,Z coordinates of the 3D points you get back.
Your problem is with the Q matrix, also known as the reprojection matrix. To construct Q, you need to know the intrinsic parameters of your left camera (principal points and focal length) and possibly the principal point of the right camera. Unfortunately, without camera calibration you won't get these; you need to calibrate your cameras and run stereoRectify()
, which will give you Q directly.
Technically, the error is occurring because reprojectImageTo3D()
expects Q to be a 4x4 matrix, and whatever you gave it is not, but more generally, you can't produce Q with the information you have. I'd suggest reading the book 'Learning OpenCV' if you have access to it, it explains the relevant theory pretty well. There seem to be a few PDFs floating around on university course pages online, if you can't find it elsewhere.