Maybe you guys can help me wrap my head around this, probably in a way that doesn't kill the CPU every frame.
Say we have a picture of the world map, let's call it Background Map:
And we have a screenshot of the game:
The screenshot needs to be aligned to the corresponding Background Map, with a 100% pixel precision. I'm currently able to obtain the coordinates of the camera, but it still doesn't map very well. Here's an example result:
The thing is, these alignment problems never go beyond 10-20 pixels or the like. I don't have any control over this, all I need to do is find a way to align the image back to where it should be. So the marked red area means what I would use to search for the possible correct position.
The end result should be something like this, mapping the screenshot to the correct coordinate.
What I can't wrap my head around so far is how could I try to align this? Keep in mind the screenshot's contents could obviously be different from the world map(in this case, there's the Mario sprite there).
I thought about searching from the outer edges and comparing in the search area, but I'm not really sure if that would work for every area. At least I can reduce the search area drastically by using the camera values. Got any smart ideas on how to do this?
I should clarify that performance isn't very critical, but it shouldn't take 2 seconds to do it.