utay / dino-ml

🦎 Simple AI to teach Google Chrome's offline dino to jump obstacles
48 stars 23 forks source link

Use a cross platform tool instead of screencapture #1

Closed rsohlot closed 5 years ago

rsohlot commented 6 years ago

ERROR:'screencapture' is not recognized as an internal or external command, operable program or batch file. can you please explain the line"os.system("screencapture -R{},{},{},{} tmp.png".format(x, y, w, h))"

midora41 commented 6 years ago

hey @rsohlot as i did a search after i got the same error this screencapture command work for mac os so i returned to the readme and found out it says the keys are for macos for now you have to make it crossplatform so i found out this code is for mac not for windows and u have to make it work for windows good luck i am gonna try my best as i learned python yesterday and i will keep u updated

vdmitriyev commented 6 years ago

I use the following code on my side:

def screenshot(x, y, w, h):
    #f_name = 'tmp-{0}.png'.format(datetime.utcnow().isoformat('-').replace(':', '-'))
    f_name = 'tmp.png'
    os.system("screenshot.exe -rc {0} {1} {2} {3} -o {4}".format(x, y, w, h, f_name))
    img = Image.open(f_name)
    return img

And in parallel used the following light utility for windows machine - https://github.com/chuntaro/screenshot-cmd. You need to add this exe file to the folder where all *.py files are located.

utay commented 6 years ago

Hey @rsohlot, as mentionned above, screencapture is the cli tool I used to take screenshots. A possible improvement could be to use https://pypi.org/project/pyscreenshot/ for example so that it can be download and use by everyone on every OS :+1:

rsohlot commented 6 years ago

@utay thank you> I will try it.