Hi MamoonIsmailKhalid,
You can extract depth data directly with depthai.node.StereoDepth.depth (reference to docs). One example which might help you, compares manual depth calculation (the formula you have been using above) to directly accessing depth trough ".depth" attribute.
Hope this helps.
Jaka