How to find one image inside of another?

前端 未结 4 1159
难免孤独
难免孤独 2020-11-27 15:06

I have 2 bmp images. ImageA is a screenshot (example) ImageB is a subset of that. Say for example, an icon.

I want to find the X,Y coordinates of ImageB within Imag

4条回答
  •  误落风尘
    2020-11-27 16:07

    1. So is there any warping of ImageB in ImageA?
    2. How "exact" are the images, as in, pixel-for-pixel they will be the same?
    3. How much computational power do you have for this?

    If the answers to the first two questions are No and Yes, then you have a simple problem. It also helps to know the answer to Q3.

    Update:

    The basic idea's this: instead of matching a window around every pixel in imageB with every pixel in imageA and checking the correlation, let's identify points of interest (or features) in both images which will be trackable. So it looks like corners are really trackable since the area around it is kinda similar (not going into details) - hence, let's find some really strong corners in both images and search for corners which look most similar.

    This reduces the problem of searching every pixel in B with A to searching for, say, 500 corners in B with a 1000 corners in A (or something like that) - much faster.

    And the awesome thing is you have several such corner detectors at your disposal in OpenCV. If you don't feel using emguCV (C# varriant), then use the FAST detector to find matching corners and thus locate multiple features between your images. Once you have that, you can find the location of the top-left corner of the image.

提交回复
热议问题