Hu moment invariants

Hu moment invariants are invariant with respect to translation, scale, and rotation and all the moments (except the seventh one) are invariant to reflection. In the case of the seventh one, the sign has been changed by reflection, which enables it to distinguish mirror images. OpenCV provides cv2.HuMoments() to calculate the seven Hu moment invariants.

The signature for this method is as follows:

cv2.HuMoments(m[, hu]) → hu

Here, m corresponds to the moments calculated with cv2.moments(). The output hu corresponds to the seven Hu invariant moments.

The seven Hu moment invariants are defined as follows:

stands for ...

Get Mastering OpenCV 4 with Python now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.