rbaron/omr

How to get a new corner features,such as a black square

Closed this issue · 2 comments

CORNER_FEATS = (
0.322965313273202,
0.19188334690998524,
1.1514327482234812,
0.998754685666376,
)

Hi @leaf918,

This list of features is one that would be outputted by the get_features function:

def get_features(contour):
        return (
            get_contour_area_by_hull_area(contour),
            get_contour_area_by_bounding_box_area(contour),
            get_contour_perim_by_hull_perim(contour),
            get_contour_perim_by_bounding_box_perim(contour),
)

In principle, you can pass any contour to this function and get the according features list. Contour in this context is the one defined by opencv, which you can get with cv2.findContours. It's a matter of finding which contour corresponds to the shape you're interested in in your input image. One approach is to draw around one contour at a time, in your input image, until you find the one you're interested in. Then calculate the features on that.

In practice, it's nice to choose shapes that are not frequently found in your domain. For example, a simple black square might occur naturally in your input, other than in these "anchor" points. This can make life complicated when looking for these shapes in order to re-orient the region of interest.

Closing due to inactivity. Let me know if you have any more questions @leaf918.