First time here? Check out the FAQ!
answered 2017-08-04 05:11:07 -0600
Use mask in minMaxLoc :
Mat mask=depth>0; minMaxLoc( depth,&minX,&maxX,&pMin,&pMax,mask);