예제 #1
0
def sample_data(reader, input_data=None, target_fps=15):
    #As long as the listener is running, continue taking screenshots
    loop_time = time()
    telemetry_data = reader.getData()

    speed, steering_angle = telemetry_data.get(
        'speed') / 300, telemetry_data.get('steerAngle')

    #Collect screenshot
    screenshot = np.array(take_screenshot(window))

    if input_data == None:
        #Collect input at that time
        input_for_screenshot = cur_input.copy()
    else:
        input_for_screenshot = input_data

    new_data = [screenshot, input_for_screenshot, [speed, steering_angle]]

    #Determine fps
    fps = time_to_loop(loop_time)

    if target_fps != None:
        #Force program to wait until we are beneath the target_fps
        while fps > target_fps:
            fps = time_to_loop(loop_time)

    #print(fps)
    return new_data
예제 #2
0
def take_screenshot_process(event):
    global img
    take_screenshot()

    global working_root, working_canvas, img

    working_root = Toplevel(tk)
    working_canvas = Canvas(working_root, width=1920, height=1080, bg='black')
    working_canvas.pack()
    img = PhotoImage(file="screenshot.png")
    working_canvas.create_image(0, 0, image=img, anchor=NW)
    working_canvas.bind("<Button-1>", callback1)
    working_canvas.bind("<ButtonRelease-1>", callback2)
    working_canvas.bind("<B1-Motion>", callback3)
    working_canvas.bind("<Control-c>", copy_to_clipboard)
    working_canvas.focus_set()
    working_canvas.pack()
예제 #3
0
파일: main.py 프로젝트: cdsupina/scopeshot
 def on_click_screenshot(self):
     self.image_data = take_screenshot()
     if self.image_data != None:
         pixmap = QPixmap()
         pixmap.loadFromData(self.image_data, "PNG")
         self.screenshot_image.setPixmap(pixmap)
         self.info_label.setText(
             'Screenshot taken. Take another screenshot or save this one.')
     else:
         self.info_label.setText('Resource not found.')
예제 #4
0
async def echo(message: types.Message):
    try:
        url = re.match(pattern, message.text).group(0)
    except Exception:
        await message.answer('Your URL adress not correct, please try again')
    else:
        filename = time.time()
        if not take_screenshot(url, filename):
            await message.answer('Somethink wrong with screenshot')
        with open(f'screenshots/{filename}.jpg', 'rb') as photo:
            await message.reply_photo(photo, caption='Your screeshot')
예제 #5
0
 def sc_btnOnButtonClick(self, event):
     self.src_text.Clear()
     self.dst_text.Clear()
     self.info_text.SetValue(str_help)
     self.Iconize(True)
     time.sleep(0.5)
     # self.Hide()
     screenshot.take_screenshot()
     #get screenshot and get the chars
     if os.path.exists('workspace/1.png'):
         self.Iconize(False)
         # self.Show()
     lang_list = [
         'CHN_ENG', 'CHN_ENG', 'ENG', 'FRE', 'SPA', 'POR', 'ITA', 'GER',
         'JAP', 'KOR'
     ]
     lang = lang_list[self.src_choice.GetSelection()]
     src_str = ocr_getstr.run(lang)
     self.src_text.SetValue(src_str)
     event.Skip()
예제 #6
0
파일: climgur.py 프로젝트: csettles/climgur
    def main(self):
        args = self.args
        if args.screenshot:
            if args.path.endswith('.png') or args.path.endswith('.bmp'):
                from screenshot import take_screenshot
                take_screenshot(args.path, args.delay)
                pic_id = self.upload_pic(args.path, self.metadata)
                print('Upload complete.')
                webbrowser.open(self.client.get_image(pic_id).link)
            else:
                sys.exit('File must be saved as a bitmap or png.')

        elif os.path.isfile(args.path):
            pic_id = self.upload_pic(args.path, self.metadata)
            print('Upload complete.')
            webbrowser.open(self.client.get_image(pic_id).link)

        elif os.path.isdir(self.args.path):
            album_id = self.upload_album()
            print('Upload complete.')
            webbrowser.open(self.client.get_album(album_id).link)

        else:
            sys.exit("\nWhat you are trying to upload does not exist")
예제 #7
0
def run_action_loop(model,
                    hidden,
                    window,
                    reader,
                    fps_target=15,
                    take_action=True):
    loop_time = time()

    screenshot = np.array(take_screenshot(window))

    img = prep_DaiLE_img(screenshot)

    telemetry_data = reader.getData()
    speed, steering_angle = telemetry_data.get(
        'speed') / 300, telemetry_data.get('steerAngle')
    print(speed, steering_angle)
    tel = torch.Tensor([speed, steering_angle]).unsqueeze(0).cuda()

    model_inputs, hidden, logits = get_predictions(model, img, tel, hidden)

    #Enact model key presses
    if take_action:
        input_network_recommendation(model_inputs, window)

    fps = time_to_loop(loop_time)

    draw_cv_window(screenshot, logits, fps)

    if fps_target != None:
        #Limit loop to TARGET_FPS
        while fps > fps_target:
            fps = time_to_loop(loop_time)

    #Clean up variables
    del model_inputs, img, screenshot

    return hidden, fps
예제 #8
0
from tkinter import *
from screenshot import take_screenshot

root = Tk()
root.title("Simpel Screenshot")
root.geometry('275x200')

window_icon = PhotoImage(file="./window_icon.png")
root.iconphoto(False, window_icon)

text_font = "Consolas"

welcome_lbl = Label(
    root,
    text="Simpel Screenshot App",
    # rg="black"
    font=text_font
).place(x=45, y=5)

screenshot_button = Button(
    root,
    command=lambda:take_screenshot(root),
    text="Take Screenshot",
    bg="black",
    fg="white",
    font=text_font
).place(x=50, y=100)

root.mainloop()
예제 #9
0
import converter
# from Drawer import Drawer
from screenshot import take_screenshot
import sys, os


def sleep_until_correct_time():
    time.sleep(15)


try:
    url = sys.argv[1]
except:
    url = "http://localhost:3000"

if __name__ == "__main__":
    # with Drawer() as drawer:
    while True:
        print("Taking screenshot")
        screenshot_path = take_screenshot(url)
        print("Converting")
        black, red = converter.convert(screenshot_path)
        print("Drawing")
        # drawer.draw(black, red)

        print("Sleeping")
        sleep_until_correct_time()

else:
    raise Exception("cannot be imported")
예제 #10
0
    def open_sidebar(self):
        # main screen of meeting
        print("waiting to enter into meeting")
        self.driver.save_screenshot("enter.png")
        element_present = EC.presence_of_element_located(
            (By.CSS_SELECTOR, "[class=NzPR9b] [role=button]:first-of-type"))
        WebDriverWait(self.driver, config.timeout).until(element_present)
        try:
            self.driver.execute_script(
                f"""Array(...document.querySelectorAll("audio")).forEach(ele=>{{ele.muted=true}})"""
            )
            self.driver.execute_script(
                f"""document.querySelectorAll("[class=NzPR9b] [role=button]:first-of-type")[0].click()"""
            )
        except:
            sleep(10)
            self.driver.execute_script(
                f"""document.querySelectorAll("{config.sidebar_btn}")[3].click()"""
            )

        print("Entered into Meeting..")

        element_present = EC.presence_of_element_located(
            (By.CSS_SELECTOR, config.tab_btn))
        WebDriverWait(self.driver, config.timeout).until(element_present)
        self.driver.execute_script(f"""
        document.querySelectorAll("{config.tab_btn}")[0].click()""")

        element_present = EC.visibility_of_element_located(
            (By.CSS_SELECTOR, config.tab_panel))
        WebDriverWait(self.driver, config.timeout).until(element_present)
        add_data = self.driver.find_elements(By.CSS_SELECTOR, ".Dxboad")
        names = []
        self.driver.save_screenshot("people.png")
        sr, cl, sw = self.driver.execute_script(f"""
        let sr=document.querySelector("[role=tabpanel]").scrollHeight;
        let sw=document.querySelector("[role=tabpanel]").scrollWidth;
        let cl=document.querySelector("[role=tabpanel]").clientHeight;
        return [sr,cl,sw]
        """)
        self.driver.execute_script(f"""
        document.querySelector("[role=tabpanel]").scrollTo(0,0);
        """)
        count = 0
        while sr > (-cl):
            self.driver.save_screenshot(f"people{count}.png")
            add_data = self.driver.find_elements(By.CSS_SELECTOR, ".Dxboad")
            for i in add_data:
                names.append(i.text)
            print(names)
            count += 1
            add_data = self.driver.execute_script(f"""
            const data=[]
            document.querySelector("[role=tabpanel]").scrollTo(0,{count*cl});
            Array(...document.getElementsByClassName("Dxboad")).forEach(ele=>{{
            data.push(ele.textContent)
            return data}})
            """)
            sr -= cl
        print(names)
        names = set(names)
        print(names)
        names = list(names)
        names.sort()
        print(names)
        names.insert(0, datetime.now().strftime("%d-%m-%Y (%I:%M %p)"))
        whconfig["meeting_data"].append(names)
        write_data(whconfig)
        sidepanel = self.driver.find_element_by_css_selector(config.tab_panel)
        imagename = datetime.now().strftime("%d-%m-%Y (%I;%M %p)") + ".png"
        print(imagename)
        take_screenshot(
            self.driver,
            config.tab_panel,
            os.path.join(whconfig["image_location"], imagename),
        )
        sleep(3)
예제 #11
0
     speak('opening google')
     webbrowser.open_new_tab('https://google.com')
     wait(5)
 elif user_input in ['open maps', 'maps']:
     speak("Opening maps")
     webbrowser.open_new_tab('https://www.google.co.in/maps')
     wait(5)
 elif user_input in ['who are you']:
     speak("I am your personal voice assistant")
     wait(3)
 elif user_input in ['what is your name', "what's your name"]:
     speak('My name is Zola')
     wait(3)
 elif user_input in ['take a screenshot', 'screenshot']:
     speak("Screenshot is taking")
     take_screenshot()
     speak("Your screenshot stored in Images folder")
     wait(3)
 elif user_input in [
         'take a picture', 'capture a picture', 'take a photo', 'photo',
         ''
 ]:
     speak("Picture is taking smile please")
     picture_is_taking()
     speak("Your photo stored in Images folder")
     wait(2)
 elif user_input in ['Hey Zola', 'Zola', 'Hey', 'are you there']:
     speak("Yes Boss, I am listening")
     wait(1)
 elif user_input in [
         'date', 'time', 'What is the time now', 'what is today'
예제 #12
0
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
import screenshot as scs

DRIVER_PATH = './chromedriver'


def __init_driver():
    options = Options()
    options.add_argument("--headless")
    options.add_argument("--disable-notifications")
    options.add_argument("--incognito")

    return webdriver.Chrome(chrome_options=options,
                            executable_path=DRIVER_PATH)


if __name__ == '__main__':
    driver = __init_driver()

    driver.get('https://selenium-python.readthedocs.io/')
    scs.take_screenshot(driver, 'full_screenshot')

    driver.close()
예제 #13
0
import vision
import screenshot
import time

unique_messages = set()
old_messages = list()
new_messages = list()

api_calls = 0

while True:
    text = vision.detect_text(screenshot.take_screenshot())
    api_calls += 1

    print('\n\n\n\n\n\n\n\n\n\n\n')
    print('API CALLS: ' + str(api_calls))

    old_messages = list.copy(new_messages)
    new_messages.clear()

    for l in str.splitlines(text):
        if ':' in l[8:] and '-' not in l and "'" not in l and 'Eye of the Herald' not in l and '!' not in l\
                and 'Kill Reward' not in l:
            new_messages.append(l)

    for m in new_messages:
        if m in old_messages:
            unique_messages.add(m)

    for m in unique_messages:
        print(m)
예제 #14
0
def command_test(args):
    global config
    print args
    print config
    screenshot.take_screenshot("tests/test.png", target=screenshot.ENTIRE_DESKTOP)