Opencv The result data of function matchshape is inf

your code does not show the matching, but imo, you should match (single) contours, not (whole) images here