Calculates the derivatives Dx and Dy of mhi and then calculates gradient orientation as:
orientation(x,y)=arctan(Dy(x,y)/Dx(x,y))
where both Dx(x,y)' and Dy(x,y)' signs are taken into account (as in cvCartToPolar function). After that mask is filled to indicate where the orientation is valid (see delta1 and delta2 description).

C# | Visual Basic | Visual C++ |
public static void cvCalcMotionGradient( IntPtr mhi, IntPtr mask, IntPtr orientation, double delta1, double delta2, int apertureSize )

- mhi (IntPtr)
- Motion history image
- mask (IntPtr)
- Mask image; marks pixels where motion gradient data is correct. Output parameter.
- orientation (IntPtr)
- Motion gradient orientation image; contains angles from 0 to ~360.
- delta1 (Double)
- The function finds minimum (m(x,y)) and maximum (M(x,y)) mhi values over each pixel (x,y) neihborhood and assumes the gradient is valid only if min(delta1,delta2) <= M(x,y)-m(x,y) <= max(delta1,delta2).
- delta2 (Double)
- The function finds minimum (m(x,y)) and maximum (M(x,y)) mhi values over each pixel (x,y) neihborhood and assumes the gradient is valid only if min(delta1,delta2) <= M(x,y)-m(x,y) <= max(delta1,delta2).
- apertureSize (Int32)
- Aperture size of derivative operators used by the function: CV_SCHARR, 1, 3, 5 or 7 (see cvSobel).