OpenCV template matching and transparency

前端 未结 7 1231
春和景丽
春和景丽 2020-11-29 00:23

What\'s the way OpenCV handles transparency in image during template matching?

The problem is that the template image needs to have transparent parts, because in the

7条回答
  •  无人及你
    2020-11-29 00:49

    OpenCV 3.0 offers native support for template matching with masked templates. Refer to the new documentation:

    Parameters:

    image ...

    templ ...

    result ...

    method ...

    mask Mask of searched template. It must have the same datatype and size with templ. It is not set by default.

    [Slight Digression]

    Note that template matching with masked reference images (the larger image) is not possible though. And that makes sense, given OpenCV uses FFT based template matching.

    Therefore, if you need to perform template matching only at specific regions of your reference images, you will need to implement your own method for that or mask the output of cv::matchTemplate.

    Implementing it from scratch should compensate for cases where you only want to search for the template at very specific regions (i.e.: around harris corners).

提交回复
热议问题