# Stereo SGBM for single pixel

I am working in a stereo vision system with epipolar geometrics within 10º angles between cameras.

I am trying to figure out how to get the position (throught disparity) of a ROI of my image which I get using open tld system.

With the extrinsic and intrinsic matrix of my system, I prepare and launch ssgbm in order to get the disparity map. Finally, with this disparity and my Q matrix, I calculate the position of the center of my ROI and in fact, my object.

The point is, that now that I have completed all this integration, I am having timing issues.

For now, I am trying to find a way to calculate the disparity with this method only for this pixels. I have been studying the code of the opencv Stereo SGBM algorithm implementation, I was thinking, maybe I would be able to modify it to my purpose, but I was wrong and now I am more confused.

Could anyone give me a clue or tell me if I there is a easier way?

**What I have:**

- I have passed throught all the stereocalibration and stereorectification steps.
- I am able to retrieve the position of an object in real world coordinates with origin in left.

**What I want:**

- Reach a faster implementation of this method, by calculating only Stereo SGBM of my ROI discarding the rest of the images disparities which I don't mind.

Thanks for your attention and help.

Did you try to use 3way mode ins sgbm? Did you try to calculate disparity for downscaled images? Did you try stereobm + post filtering (http://docs.opencv.org/master/d3/d14/...

I didn't try the first to option (or I think I haven't tried). I will look around about this way. About the second option, yes, I have downscale the image size its half. For stereobm, it does not give me the accuracy I am looking for, and the link you post is broken..

Here it is: http://docs.opencv.org/master/d3/d14/...