Example #1
0
def run(brain):
    print '[emulator.py] Running game...'

    for i in xrange(100):
        for _ in range(12):
            controller.D_UP()
        for _ in range(6):
            controller.D_LEFT()

        screenshot = screen.takeScreenshot()
        if screenshot == None:
            time.sleep(MOVE_WAIT)
            continue
        if imgUtils.gameHasEnded(screenshot):
            break
        # grid = imgUtils.cropBoard2Player(screenshot)
        # grid = imgUtils.filterBackground(grid)
        grid = imgUtils.cropBoard1Player(screenshot)
        grid = imgUtils.filterBackground1Player(grid)

        # Generate board model.
        inputRows = [[-1] * board.WIDTH for _ in range(board.HEIGHT)]
        for square, rowIndex, colIndex in imgUtils.parseSquaresFromBoard(grid):
            val, score = imgUtils.getSquareClassification(
                square, rowIndex, colIndex)
            inputRows[rowIndex][colIndex] = Piece(val)

        # Get next action and perform.
        b = board.Board(inputRows=inputRows)
        print '---BOARD---'
        b.printBoard()
        moves = brain.getNextMoves(b)
        print '---MOVES---'
        print moves
        print ''
        cursor_pos = performMoves(moves, (0, 0))

        # End loop.
    print '[emulator.py] Done running game.'
Example #2
0
def run(brain):
  print '[emulator.py] Running game...'

  for i in xrange(100):
    for _ in range(12): controller.D_UP()
    for _ in range(6): controller.D_LEFT()

    screenshot = screen.takeScreenshot()
    if screenshot == None:
      time.sleep(MOVE_WAIT)
      continue
    if imgUtils.gameHasEnded(screenshot):
      break
    # grid = imgUtils.cropBoard2Player(screenshot)
    # grid = imgUtils.filterBackground(grid)
    grid = imgUtils.cropBoard1Player(screenshot)
    grid = imgUtils.filterBackground1Player(grid)

    # Generate board model.
    inputRows = [[-1] * board.WIDTH for _ in range(board.HEIGHT)]
    for square, rowIndex, colIndex in imgUtils.parseSquaresFromBoard(grid):
      val, score = imgUtils.getSquareClassification(square, rowIndex, colIndex)
      inputRows[rowIndex][colIndex] = Piece(val)

    # Get next action and perform.
    b = board.Board(inputRows=inputRows)
    print '---BOARD---'
    b.printBoard()
    moves = brain.getNextMoves(b)
    print '---MOVES---'
    print moves
    print ''
    cursor_pos = performMoves(moves, (0, 0))

    # End loop.
  print '[emulator.py] Done running game.'
Example #3
0
import misc
misc.menu()

import screenshot
import imageManager
import txtManager
import UIManager
import beeper
from time import sleep

i, a = 0, 0

beeper.c()
while True:
    img = screenshot.takeScreenshot('screenshots/sample_'+str(i)+'.jpg',1)
    thresh = imageManager.threshold(('screenshots/sample_'+str(i)+'.jpg'))
    txt = txtManager.getText(thresh)
    
    sleep(1)

    if 'Alan' in txt:
        beeper.C()
        screenshot.takeScreenshot('screenshots/alan/alan_'+str(a)+'.jpg',0)
        a+=1
        UIManager.like()

    else:
        UIManager.dislike()
    i+=1

beeper.A()
Example #4
0
def triggerLogin():
    '''Trigger Auth0 and collect email address.'''
    pass

def reportDogSighting(userid):
    '''Reports dog sighting to server.'''
    pass

def displayDogs(dogs):
    '''
    Send dogs to electron for display.
    This can be asynchronous if we can remove the display dogs from the screenshot.
    '''
    pass

def getFriendDogsSightings():
    '''Requests list of friends' dog sightings from flask server.'''
    pass

def detectDog(imgFilename):
    pass

if __name__ == '__main__':
    userid = triggerLogin()
    while True:
        if detectDog(takeScreenshot()):
            reportDogSighting(userid)
        dogs_of_friends = getFriendDogsSightings()
        displayDogs(dogs_of_friends)
Example #5
0
lastTime = 0.0
while True:
    constants.updateTimestamp()
    # 1) Find MWO window, set error and wait if not found
    hwnd = findWindow('mechwarrior online')
    if (not constants.debugFakeInput == 1 and not hwnd):
        debugOutputString("Mwo not found, waiting")
        hideOverlay()
        cv2.waitKey(5000)
        continue
    # 2) take screenshot
    if (constants.debugFakeInput == 1):
        debugOutputString("using debug screen")
        screen = cv2.imread("screenshot_debug.png")
    else:
        screen = takeScreenshot(hwnd)

    if (len(screen) < 30):
        debugOutputString("Not a valid screenshot (mwo minimized?) ")
        hideOverlay()
        cv2.waitKey(3000)
        continue
    finalImage = screen.copy()
    ocrImage = screen.copy()

    # 3) Determine screenshot-type
    scoreBoardType = determineScoreboard(screen)
    if (scoreBoardType == ""):
        if (constants.debugOutputConsole == 1):
            if (firstNVSmessage == 1):
                print(
Example #6
0
	def take_screenshot(self, widget):
		pixmap = screenshot.takeScreenshot()
		filename = ("/tmp/droplr-%d.png"%time())
		pixmap.save(filename, "png")
    sec = Youtube.sec

'''
# Watch Youtube via pynput
if min:
    if sec:
        time.sleep(int(min)*60 + int(sec))
        print('waited:', str(int(min)*60 + int(sec)))
    else:
        time.sleep(int(min)*60)
        print('waited:', str(int(min)*60))
else:
    time.sleep(int(sec))
    print('waited:', str(int(sec)))
'''

time.sleep(5)   # test

# like video
getId.mouse_left(1002, 964)

# screenshot proof
getId.mouse_left(39, 325)
getId.scroll_down()
screenshot.takeScreenshot()

# Add screenshot