Open dprov opened 2 years ago
Ok so having gone through the code more in depth, it would seem clear to me that the answer to point 3 above is "No".
The second image is pre-warped using the calibration vector, and only then do we iteratively solve for the disparity. Since the calibration field is never added back to the disparity, I would have expected the following correspondence between the first and second raw images: (u,v) -> (u + disp.x + calibField(u,v).x, v + disp.y + calibField(u,v).y)
To test this, I've found a few ground truth correspondences manually between the provided robot1.png/robot2.png images as well as for 5 pairs of images I took (and used the appropriate calibration fields). What I find very puzzling, is that for each image, results are significantly closer when skipping the y component of the calibration field, i.e.: (u,v) -> (u + disp.x + calibField(u,v).x, v + disp.y)
This makes me uncertain regarding stereo reconstruction (e.g. would I get better results by taking out the y component of the calibration field form the disparity?)
Any insight on this issue would be helpful.
1) K0,D0,K1,D1 are all used because of the way I solved the trajectory field. It involves projecting a point from image0 to an arbitrary surface then reproject to image1. To project out of image0, we need K0,D0 and to reproject to image1, we need K1,D1. Maybe this video will help. https://www.youtube.com/watch?v=fbv_LJxHEKQ @4:54
2) The tscale is only used to generate a vector and get the direction. In the end, the vector is normalized, so the magnitude initial translation from tscale is ignored.
3) You are right. The disparity is after calibration, so if you try to generate the second image by warping using the disparities, you'll get a calibrated second image.
4) This is definitely a bug. For future reference, the conversion.cu is only added for visualization. In the paper, I didn't evaluate (accuracy etc.) using depth, but only with disparity.
This looks correct: (u,v) -> (u + disp.x + calibField(u,v).x, v + disp.y + calibField(u,v).y) However, I am not sure what you are trying to confirm. What kind of result do you mean is "significantly closer" (e.g. depth, disparity, image, warped image)?
Thanks for your reply and the video link!
Thanks for the clarification.
(+ comment at the end of your answer) : I want to confirm whether the computed disparity is correct (i.e. validate that the vector field generation for my camera model works, the combination of solver parameters I selected makes sense, results good enough for my use case, etc.). The easiest way for me to do this was to manually find some ground truth correspondences between images and compare those to the computed disparity. Obviously, computed disparities were way off from the raw image to raw image ground truth (which in hindsight is to be expected). That's what got me investigating and realize that correspondences should be of the form (u,v) -> (u + disp.x + calibField(u,v).x, v + disp.y + calibField(u,v).y)
However, when averaging the absolute disparity error across multiple correspondences in an image pair, adding the calibField improves results along x, but degrades them along y. This is what confuses me and makes me wonder if there's a bug or if I misunderstand something. For reference, I found at least 5 correspondences across 5 of my own image pairs, and also in the robot1/2 samples provided. The same conclusion applies to each of those image pairs individually. For example:
``` # Disparity check for image pair (robot1.png, robot2.png) # NOTE: GT is found manually between pairs of raw images # (dx,dy) = (disp.x, disp.y) vs GT mean(|dx_GT - dx|) = 6.87 mean(|dy_GT - dy|) = 1.09 mean(sqrt((dx_GT-dx)² + (dy_GT-dy)²)) = 6.98 # (dx,dy) = (disp.x + calibField.x, disp.y + calibField.y) vs GT mean(|dx_GT - dx|) = 3.64 mean(|dy_GT - dy|) = 3.81 mean(sqrt((dx_GT-dx)² + (dy_GT-dy)²)) = 6.19 # (dx,dy) = (disp.x + calibField.x, disp.y) vs GT mean(|dx_GT - dx|) = 3.64 mean(|dy_GT - dy|) = 1.09 mean(sqrt((dx_GT-dx)² + (dy_GT-dy)²)) = 4.29 ```
Hi, thanks for making this repo available! I've been trying to get this to work for a different camera model (cv.omnidir in OpenCV contrib), so I've spent quite a bit of time trying to understand what's going on overall and generating the vector fields. I'm nearly there, but I have a few questions that are still puzzling me. If you can help clear that up a bit, that would be very appreciated.
1) In https://gist.github.com/menandro/b829667f616e72aded373479aca61770, when generating vectorxforward and vectorxbakward, a mix of K0 and D1 is used and that confuses me. I don't understand the paper 100%, but I would have thought the second camera's distortion was already included in the calibration field. Note however, that using any combination of D0,D1,K0,K1 has relatively little impact on the disparity results (aka I've got bigger problems :P)
2) In https://gist.github.com/menandro/cd5f4b5309f16f1a0f1987fcb2baf057, the translateScale is not the same in the forward and backward direction. I don't understand the logic behind that. In my case, I used the same scale in forward/backward direction, but using either a scale of 1 or 0.01 also has little impact on disparity maps.
3) Just to make sure, does the disparity relate to the raw (i.e. distorted) images? (e.g. a given point in the first image at position (u,v) will be at (u+disp.x, v+disp.y) in the second image?). Asking because for the equidistant dataset, the disparities I get are coherent with that. However, both for the t265 "robot" image (Kannala-Brandt model) and for my own data (Mei model), the disparity maps look pretty good in general, but the values themselves seem off. E.g. for a large patch of an image where I expect a x disparity of ~ -40, the results are smooth and coherent, but the disparity is ~ -20. I've tried quite a few variations of parameters (nLevel, fScale, nWarpIters, nSolverIters, lambda, limitRange) and this remains.
4) In https://github.com/menandro/vfs/blob/master/stereotgv/conversion.cu, I don't quite understand how the triangulation is done, but it feels like
Should rather be
xprime0 = (u0 - cx) / focalx
and so on. Is that correct?