Giter VIP home page Giter VIP logo

Comments (2)

QuickMash avatar QuickMash commented on July 2, 2024
  • Forgot to fix the version

from game-bot.

QuickMash avatar QuickMash commented on July 2, 2024

I simplified the code, it opens the next files.
`# Arda Mavi

QuickMash's Fix for create_dataset.py

import os
import numpy as np
import scipy.misc
from PIL import ImageGrab
from game_control import *
import predict
from game_control import get_id
from get_dataset import save_img
from multiprocessing import Process
from keras.models import model_from_json
from pynput.mouse import Listener as mouse_listener
from pynput.keyboard import Listener as key_listener

def get_screenshot():
img = ImageGrab.grab()
img = np.array(img)[:,:,:3] # Get first 3 channel from image as numpy array.
img = imresize(img, (150, 150, 3)).astype('float32')/255.
return img

def save_event_keyboard(data_path, event, key):
key = get_id(key)
data_path = data_path + '/-1,-1,{0},{1}'.format(event, key)
screenshot = get_screenshot()
save_img(data_path, screenshot)
return

def save_event_mouse(data_path, x, y):
data_path = data_path + '/{0},{1},0,0'.format(x, y)
screenshot = get_screenshot()
save_img(data_path, screenshot)
return

def listen_mouse():
data_path = 'Data/Train_Data/Mouse'
if not os.path.exists(data_path):
os.makedirs(data_path)

def on_click(x, y, button, pressed):
    save_event_mouse(data_path, x, y)

def on_scroll(x, y, dx, dy):
    pass

def on_move(x, y):
    pass

with mouse_listener(on_move=on_move, on_click=on_click, on_scroll=on_scroll) as listener:
    listener.join()

def listen_keyboard():
data_path = 'Data/Train_Data/Keyboard'
if not os.path.exists(data_path):
os.makedirs(data_path)

def on_press(key):
    save_event_keyboard(data_path, 1, key)

def on_release(key):
    save_event_keyboard(data_path, 2, key)

with key_listener(on_press=on_press, on_release=on_release) as listener:
    listener.join()

def main():
dataset_path = 'Data/Train_Data/'
if not os.path.exists(dataset_path):
os.makedirs(dataset_path)

# Start to listening mouse with new process:
Process(target=listen_mouse, args=()).start()
listen_keyboard()
return

if name == 'main':
main()

QuickMash wuz here`

from game-bot.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.