Hu moment invariants can be used for both object matching and recognition. In this section, we are going to see how to match contours based on Hu moment invariants. OpenCV provides cv2.matchShapes(), which can be used to compare two contours using three comparison methods. All these methods use Hu moment invariants. The three implemented methods are cv2.CONTOURS_MATCH_I1, cv2.CONTOURS_MATCH_I2, and cv2.CONTOURS_MATCH_I3.
If A denotes the first object and B denotes the second object, then the following applies:
are the Hu moments ...