Matrixchung / EDAutopilot-v2

An autopilot bot for Elite: Dangerous based on computer vision
MIT License
49 stars 12 forks source link

Can't quite get all the template images to match #3

Closed yazoooo closed 1 year ago

yazoooo commented 2 years ago

First off: Thanks for building this code. I have experience with cv and python building a couple bots for Star Trek Online. I have been thinking about building one for Elite. It is so nice to read someone else's code and see similar patterns and how they solve problems. And I agree that carriers are too expensive! That is hundreds of days of "just playing the game" to amass the 5b + services + reserve. I would rather put 200 hours into a coding project that then made the money for me :)

Ok, the issue I am having is probably due to slight differences in the graphics settings. I followed your instructions: color pallete, fov, etc. I tried all the intensities 4-8. 5 seems closest. Some images match, some don't. For example, the Plot (highlighted) button on the galaxy map doesn't seem to match,. If I replace the image in templates with one I make from my game screen it DOES match. I notice that my text in my images are "slightly" ore blurry than yours. Could you share your exact graphics "quality settings" so I can see if this is supersampling, texture quality, filtering or something else? I would rather use your images than recapture all of them myself.

DLAcoding commented 2 years ago

Same issue here, some work others not. There are also some images in the themes folder that belongs to the orange color pallete

Matrixchung commented 2 years ago

I'm unaware that the detailed graphic settings may cause differences in image recognition. Going to check them Meanwhile, the weird detecting function in OpenCV and Python usually confuses me a lot. Those related steps are the most buggy during my test as well. :(

Matrixchung commented 2 years ago

see 5c4ed0851af9acdaad61f50622595df95e56a780

DLAcoding commented 2 years ago

After testing I found just two cases when image are not matching:

Case 1: GalaxyMap (map_bookmark and map_plotroute) The best matching found (in the map_bookmark case) is always the white dot of a random star in the map, so it enters in a loop selecting random stars. If I grab the image and substitute it then is found and keep with the process. It stucks again when trying to find the map_plotroute. Again if I do the screenshot and save the icon then is found.

My solution: I found easier use the the keys in the game rather than use image matching which may cause some issues. I modified the setDest function so no more image matching is needed (just need the destination image which was working):

def setDest(session,dest):
    if session.guiFocus != 'GalaxyMap':
        session.sendKey('UI_OpenGalaxyMap') # Toggle Map
        session.sleep(3)
        session.sendKey('UI_NextTab',repeat=2,repeat_delay=0.5)

    session.sleep(2)
    if dest == 'Sothis': destLoc = locateButtons(map_sothis,map_sothisHL,confidence1=0.8,confidence2=0.8)
    elif dest == 'Robigo': destLoc = locateButtons(map_robigo,map_robigoHL,confidence1=0.7,confidence2=0.7)
    else : return False
    session.sleep(1)
    mouseClick(destLoc)
    session.sleep(3)
    session.sendKey('space')
    session.sleep(3)
    session.sendKey('UI_OpenGalaxyMap')
    return True

Case 2: Robigo I had to grab the image and substitute it in the code so I could do the match. I leave a screenshot here. I am pretty sure I have the config said. Do you see any difference with how is shown in your game?

image

I also found that the left panel (for selecting stations, points of interest,etc) varies depending of the ship. I tested in two different ships where in the Anaconda (which I assume is the one you are using) the sirius atmosfera image is found with no issues. Nevertheless, when testing it with my kraith phantom, neither the sirius atmosfera image or my custom matching for Robigo where working. I could notice how the inclination of the text varies depending on the ships, it must be that I guess...

Matrixchung commented 2 years ago

After testing I found just two cases when image are not matching:

Case 1: GalaxyMap (map_bookmark and map_plotroute) The best matching found (in the map_bookmark case) is always the white dot of a random star in the map, so it enters in a loop selecting random stars. If I grab the image and substitute it then is found and keep with the process. It stucks again when trying to find the map_plotroute. Again if I do the screenshot and save the icon then is found.

My solution: I found easier use the the keys in the game rather than use image matching which may cause some issues. I modified the setDest function so no more image matching is needed (just need the destination image which was working):

def setDest(session,dest):
    if session.guiFocus != 'GalaxyMap':
        session.sendKey('UI_OpenGalaxyMap') # Toggle Map
        session.sleep(3)
        session.sendKey('UI_NextTab',repeat=2,repeat_delay=0.5)

    session.sleep(2)
    if dest == 'Sothis': destLoc = locateButtons(map_sothis,map_sothisHL,confidence1=0.8,confidence2=0.8)
    elif dest == 'Robigo': destLoc = locateButtons(map_robigo,map_robigoHL,confidence1=0.7,confidence2=0.7)
    else : return False
    session.sleep(1)
    mouseClick(destLoc)
    session.sleep(3)
    session.sendKey('space')
    session.sleep(3)
    session.sendKey('UI_OpenGalaxyMap')
    return True

Case 2: Robigo I had to grab the image and substitute it in the code so I could do the match. I leave a screenshot here. I am pretty sure I have the config said. Do you see any difference with how is shown in your game?

image

I also found that the left panel (for selecting stations, points of interest,etc) varies depending of the ship. I tested in two different ships where in the Anaconda (which I assume is the one you are using) the sirius atmosfera image is found with no issues. Nevertheless, when testing it with my kraith phantom, neither the sirius atmosfera image or my custom matching for Robigo where working. I could notice how the inclination of the text varies depending on the ships, it must be that I guess...

Maybe that is the point I guess. The panel's size varies from ships to ships, unfortunately I have no idea of how to solve it currently... Improve the setDest function, see facced9cefaf27841e5e21cbda753a44b93cf4b1