Beispiel #1
0
 def screenshot(self, *args):
     pattern = 'screenshot_{:03d}.png'
     directory = self.settings['screenshot_directory']
     i = 0
     while os.path.exists(os.path.join(directory, pattern.format(i))):
         i += 1
     Window.screenshot(name=os.path.join(directory, pattern.format(i)))
 def _on_keyboard_down(self,keyboard,keycode,text,modifiers):
     if(keycode[1] == 'up'):
         self.draw_up()
     if(keycode[1] == 'left'):
         self.draw_left()
     if(keycode[1] == 'down'):
         self.draw_down()
     if(keycode[1] == 'right'):
         self.draw_right()
     if(keycode[1] == 'r'):
         self.output_eval()
     ## START TESTING WHEN ENTER IS PUSHED ##
     if(keycode[1] == 'enter'):
         self.current_position_X = 200
         self.current_position_Y = 200
         self.togglewriting()
         if self.writing == True:
             self.path = [Point(self.current_position_X,self.current_position_Y)]
             self.goals.createNewGoal(self.current_position_X,self.current_position_Y)
             self.draw_goal()
         if self.writing == False:
             self.canvas.clear()
             self.canvas.add(self.boxes)
     if keycode[1] == "s":
         Window.screenshot(name='screenshot.jpg')
Beispiel #3
0
    def guess(self,instance):

        Window.screenshot(name='sample.png')

        # preprocessing the image to be fed
        image=cv2.imread('sample0001.png')
        image=image[51:,:]

        # print(image.shape)
        img_predict = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
        img_predict = cv2.resize(img_predict, (28, 28))
        img_predict = np.reshape(img_predict, (1, 28, 28, 1))
        # print(img_predict.shape)

        prediction=model.predict(img_predict)
        # print(prediction)
        guessed_number=np.argmax(prediction)

        print('Guess: ',guessed_number)

        self.second.remove_widget(self.Guess)
        guessed_number_string='My Guess: '+str(guessed_number)
        self.Guess = Label(text=guessed_number_string,size_hint=(.3, .17), pos_hint={'top': 1})
        self.second.add_widget(self.Guess)

        if os.path.exists('sample0001.png'):
            os.remove('sample0001.png')
Beispiel #4
0
 def readbtn(self, obj):
     Window.screenshot(name='digit.png')
     image = resizer.resize(f"digit0001.png")
     image = 255. - np.mean(image, axis=2).reshape(1, -1)
     prediction = model.predict_number(image)
     print(prediction)
     self.resultlbl.text = f"[color=3333ff][b]result: {prediction}[/b][/color]"
     removeFiles()
Beispiel #5
0
    def increment_time(self, interval):

        self.number += 1
        if self.number<10:
            #export_to_png(self.ids.camera, filename=os.path.normpath(os.path.join(os.getcwd(),'videos',self.tag+'im0'+str(self.number)+'.png')))
            Window.screenshot(name=os.path.normpath(os.path.join(os.getcwd(),'videos','im0'+str(self.number)+'_'+self.tag+'.png')))
        else:
            #export_to_png(self.ids.camera, filename=os.path.normpath(os.path.join(os.getcwd(),'videos',self.tag+'im'+str(self.number)+'.png')))
            Window.screenshot(name=os.path.normpath(os.path.join(os.getcwd(),'videos','im'+str(self.number)+'_'+self.tag+'.png')))
Beispiel #6
0
 def take_screenshot(self):
     path = expanduser(
         '~/Saved Games/Coatirane Adventures/screenshots/').replace(
             '\\', '/')
     if not exists(path):
         mkdir(path)
     Window.screenshot(
         f'{path}Coatirane Adventures - {datetime.now().strftime("%d-%m-%Y %H-%M-%S")}.png'
     )
    def Capturar_display(self):
        #        self.CAM_WIDGET.clear_widgets()

        try:
            #  Window.screenshot(name='captura.png')

            Window.screenshot(
                name='../../../../../storage/sdcard1/Picture/captura.png')

        except:
            Window.screenshot(
                name='../../../../../storage/sdcard0/Picture/captura.png')
 def doscreenshot(self,*largs):
       outname='site_'+self.site.text+'sample_'+self.sample.text+'_im%(counter)04d.png'
       Window.screenshot(name=outname)
       # get newest file
       filelist = os.listdir(os.getcwd())
       filelist = filter(lambda x: not os.path.isdir(x), filelist)
       newest = max(filelist, key=lambda x: os.stat(x).st_mtime)
       # read that file in as greyscale, crop and save under new name
       im = Image.open(newest).convert("L")
       region = cropcentral(im)
       newfile = newest.split('.')[0]+'_g.png'
       region.save(newfile)
Beispiel #9
0
    def TomarFoto(self, *args):
        try:
            Window.screenshot(name='../../../../../mnt/sdcard/DCIM/imagen.png')
            pass
        except:
            print "No se pudo tomar  la foto"
            pass
#           pass
        try:
            Window.screenshot(name='imagen.png')
            pass
        except:
            print "No se pudo tomar  la foto"
            pass

        try:
            #  Window.screenshot(name='captura.png')

            Window.screenshot(
                name='../../../../../storage/sdcard1/Picture/captura.png')
            pass

        except:
            Window.screenshot(
                name='../../../../../storage/sdcard0/Picture/captura.png')
            pass

        pass
Beispiel #10
0
 def TomarFoto(self, *args):
     #  Layout = RelativeLayout()
     #    wid2 = Widget()
     #   Mensaje = getoutput("pwd")
     #  LBL1 = Label()
     #   LBL1.pos = 150, 200
     #   LBL1.text = Mensaje
     #    print Mensaje
     #    wid2.add_widget(LBL1)
     # Layout.add_widget(wid2)
     #   self.DisposicionRelativa.add_widget(wid2)
     try:
         Window.screenshot(name='../../../../../mnt/sdcard/DCIM/imagen.png')
     except:
         print "No se pudo tomar  la foto"
Beispiel #11
0
    def replay(self, instance):
        screen = Window.screenshot('screen.png')
        srce = str(screen)
        for i in srce:
            i = srce
        x = srce.split("/")
        self.str = x[len(x) - 1]
        al = AnchorLayout()
        lal= BoxLayout(orientation='vertical')

        al.add_widget(Button(text='', background_normal='', background_color=[1,1,1,1]))
        bl = BoxLayout(orientation='vertical', padding=[50], spacing=8)
        wmimg = Image(source='photo/images.png')
        widget = Widget()
        with widget.canvas:
            widget = wmimg
        bl.add_widget(Widget())
        lal.add_widget(widget)
        lal.add_widget(Widget())
        bl.add_widget(Widget())
        bl.add_widget(Widget())
        bl.add_widget(Label(text='SMILES:', color=[0,0,0,1]))
        bl.add_widget(Button(text='здесь должен быть SMILES', color=[0,0,0,1], background_normal='', background_color=[0, 1, 0, 1]))
        bl.add_widget(Button(text="Главное меню", color=[.1, .1, .1, 1], background_normal='', background_color=[.5,.5,.5, 1]))
        self.Al.add_widget(al)
        self.Al.add_widget(lal)
        self.Al.add_widget(bl)
        return self.Al
Beispiel #12
0
 def take(self, wid, label, *largs):
     Window.screenshot("number.png")
     PATH = os.path.join(os.getcwd() + "\\" + "number0001.png")
     img_array = cv2.imread(PATH, cv2.IMREAD_GRAYSCALE)
     img_array = img_array[100:480, 160:622]  # Crop the image
     img_array = cv2.resize(img_array, (28, 28))
     os.remove(PATH)  # Delete the saved image
     transform = transforms.Compose([
         transforms.ToTensor(),
         transforms.Normalize((0.1307, ), (0.3081, ))
     ])
     img_array = transform(img_array)
     img_array = img_array.unsqueeze(1)  # add a channel dimension
     output = model(img_array)
     output = torch.argmax(output)
     label.text = str(output.item())
    def Reset(self, instance):

	Window.screenshot(name='screenshot{:04d}.png')
	print "\n\n\nnew image\n\n\n"
	
	self.Xturn = True
        self.buttons_pressed = 0
	self.game_done = False

	for kid in self.button_layout.children:
		#kid.text = ""
		kid.cb_pressed = False
		kid.background_normal = self.button_start
		#'atlas://data/images/defaulttheme/button' #makes white background for buttons
		kid.background_color = [1,1,1,1]
	# resets the game\

	self.message.text = "Player 1's turn"
    def Reset(self, instance):

        Window.screenshot(name='screenshot{:04d}.png')
        print "\n\n\nnew image\n\n\n"

        self.Xturn = True
        self.buttons_pressed = 0
        self.game_done = False

        for kid in self.button_layout.children:
            #kid.text = ""
            kid.cb_pressed = False
            kid.background_normal = self.button_start
            #'atlas://data/images/defaulttheme/button' #makes white background for buttons
            kid.background_color = [1, 1, 1, 1]
        # resets the game\

        self.message.text = "Player 1's turn"
Beispiel #15
0
    def _real_screenshot():
        import tempfile
        from kivy.core.window import Window
        from kivy.utils import platform
        try:
            fd = tempfile.NamedTemporaryFile(suffix=".png", delete=False)
            # XXX hack, Window.screenshot doesn't respect our filename
            screenshot_fn = fd.name.rsplit(".")[-2] + "0001.png"
            fd.close()

            if platform == "ios":
                from kivy.graphics.opengl import glReadPixels, GL_RGBA, GL_UNSIGNED_BYTE
                from kivy.core.image import ImageLoader
                # hacky, as Window don't have correct system size (why, i don't
                # know.)
                width, height = Window._win._get_gl_size()
                Window.dispatch("on_draw")
                data = glReadPixels(0, 0, width, height, GL_RGBA, GL_UNSIGNED_BYTE)
                # save using standard imageloader, but in rgba
                loader = [x for x in ImageLoader.loaders if x.can_save()][0]
                loader.save(screenshot_fn, width, height, "rgba", data, True)
                """
                # strides issue
                data = list(data)
                del data[3::4]
                data = "".join(data)
                Window._win.save_bytes_in_png(screenshot_fn, data, width,
                        height)
                """
            else:
                Window.screenshot(name=fd.name)
            with open(screenshot_fn, "rb") as fd:
                data = fd.read()
            _result[:] = [width, height, base64.encodestring(data)]
        except:
            import traceback
            traceback.print_exc()
        finally:
            try:
                os.unlink(screenshot_fn)
                os.unlink(fd.name)
            except:
                pass
            _event.set()
Beispiel #16
0
    def popme(self, obj):

        Window.screenshot(name='test.png')
        img = cv2.imread('test0001.png')
        inverted = cv2.bitwise_not(img)
        self.textt = pytesseract.image_to_string(inverted, lang='eng')

        popbtn = Button(text='Retry')
        popbtn.bind(on_release=self.clear_canvas)

        box = BoxLayout(orientation='vertical')
        box.add_widget(Label(text=self.textt))
        box.add_widget(popbtn)

        self.popupp = Popup(title='Trying to predict what is written...:',
                            content=box,
                            size_hint=(None, None),
                            size=(400, 400))
        os.remove('test0001.png')
        self.popupp.open()
Beispiel #17
0
 def print_screen(self):
     import glob
     arquivos = glob.glob('img/numero*')
     Window.screenshot(name=('img/numero.jpg'))
     numero = (len(arquivos))+1
     if(numero<10):
         name = "numero000" + str(numero)
     elif(numero>9) and (numero<100):
         name = "numero00" + str(numero)
     elif (numero > 99):
         name = "numero" + str(numero)
     app = App.get_running_app()
     app.vcGenerator = ModuleViCompGenerator()
     app.vcGenerator.readAndCreate(fileName=name)
     Window.size = (1280,720)
     pincel = self.buscaWidget('pincel')
     pincel.clearScreen()
     app.vcGenerator.vector.insert(0,1)
     print(app.vcGenerator.vector)
     self.manager.current = 'InformarDado'
    def photo(self,obj):

        s=''
        nb=len(str(self.n))
        for i in range(4-nb):s+='0'


        if platform == 'android'or platform == 'linux':
            Window.screenshot(name='./img.png')
            numpy_image=file_to_minst('./img'+s+str(self.n)+'.png' )
            remove('./img'+s+str(self.n)+'.png' )

        if platform == 'win':
            Window.screenshot(name='img.png')
            numpy_image=file_to_minst('img'+s+str(self.n)+'.png' )
            remove('img'+s+str(self.n)+'.png')

        res=(self.model.predict(numpy_image))
        self.prediction="The result is "+str(np.argmax(res[0]))
        self.label.text=self.prediction
Beispiel #19
0
    def export(self, *args):
        print("Hello there export")
        photo = Window.screenshot("test.png")
        im = imageio.imread(photo, as_gray=False)
        print(im.shape)
        plt.imshow(im)

        im2 = im[0:1199, 0:1199, :]
        #im2 = np.array(im2, np.uint8)
        # send the image to the server
        global n
        n.send(pickle.dumps("im2"))
 async def main(cls, *, widgets, ctx):
     # NOTE: For some reason, 'Widget.export_as_image()' doesn't work so uses 'Window.screenshot()' instead.
     # NOTE: Screenshot sometimes f****d up (maybe) depending on the window size.
     from os.path import join as ospath_join
     from kivy.core.window import Window
     import asynckivy as ak
     from ._utils import show_yes_no_dialog, open_file_with_default_os_app, temp_dir
     if await show_yes_no_dialog(text_main='take a screenshot of the entire app?\n(Sorry, you cannot just save the canvas for now. )') == 'yes':
         await ak.sleep(.3)
         actual_filepath = Window.screenshot(ospath_join(temp_dir(), 'screenshot.png'))
         open_file_with_default_os_app(actual_filepath)
     for c in widgets['toolbox'].children:
         c.state = 'normal'
Beispiel #21
0
 def _real_screenshot():
     import tempfile
     from kivy.core.window import Window
     try:
         fd = tempfile.NamedTemporaryFile(suffix=".png", delete=False)
         # XXX hack, Window.screenshot doesn't respect our filename
         screenshot_fn = fd.name.rsplit(".")[-2] + "0001.png"
         fd.close()
         width, height = Window.size
         Window.screenshot(name=fd.name)
         with open(screenshot_fn, "rb") as fd:
             data = fd.read()
         _result[:] = [width, height, base64.encodestring(data)]
     except:
         import traceback
         traceback.print_exc()
     finally:
         try:
             os.unlink(screenshot_fn)
             os.unlink(fd.name)
         except:
             pass
         _event.set()
Beispiel #22
0
def _rpc_screenshot(ev, result):
    import base64
    filename = None
    data = None
    try:
        from kivy.core.window import Window
        filename = Window.screenshot()
        with open(filename, "rb") as fd:
            data = fd.read()
        os.unlink(filename)
        return True
    finally:
        result.append({
            "filename": filename,
            "data": base64.b64encode(data).decode("utf-8")
        })
        ev.set()
Beispiel #23
0
 def doscreenshot(self,*largs):
       Window.screenshot(name='screenshot.jpg')
Beispiel #24
0
 def screenshot(self, filename=None):
     Window.screenshot(filename)
Beispiel #25
0
 def save_canvas(self):
     # 時間があるときに一時的にcanvas.beforeに背景を塗り潰す処理を加えるの
     # https://kivy.org/docs/api-kivy.core.window.html?highlight=screenshot#kivy.core.window.WindowBase.screenshot
     Window.screenshot()
Beispiel #26
0
 def screen(self, instance):
     Window.screenshot('image2.png')
Beispiel #27
0
 def doscreenshot(self,*largs):
    Window.screenshot(name='screenshot%(counter)04d.jpg')
 def on_paused(self, dt):
     print str(self.root.ids.video.position)
     Window.screenshot()
     self.root.ids.video.state = 'play'
     Clock.schedule_once(self.on_loaded, 1)
Beispiel #29
0
 def screen(self, instance):
     Window.screenshot('screen.png')
Beispiel #30
0
 def doscreenshot(self,*largs):
       Logger.info('Progress: Made it to screenshot')
       Window.screenshot(name='top04d.jpg')
 def screenshot_canvas(self, instance):
     file_name = input("Enter file name ") + '.png'
     Window.screenshot(file_name)
Beispiel #32
0
    def photo(self, instance):
        # ici on creer le chemin du screenshot
        try:

            if platform == 'android':
                Window.screenshot(name='/storage/emulated/0/Pictures/Screenshots/Screenshot.png')
                content = Button(text='Image enregistre', font_size=50)
                popup = Popup(title='Votre image est enregistre dans Pictures/Screenshots', content=content,
                              size_hint=(0.5, 0.5))
                content.bind(on_press=popup.dismiss)
                popup.open()
            else:
                if platform == 'linux':
                    Window.screenshot(name='Screenshot.png')
                    content = Button(text='Image enregistre', font_size=50)
                    popup = Popup(title='Votre image est enregistre dans le dossier de votre application',
                                  content=content, size_hint=(0.5, 0.5))
                    content.bind(on_press=popup.dismiss)
                    popup.open()
                else:
                    if platform == 'win':
                        Window.screenshot(name='Screenshot.png')
                        content = Button(text='Image enregistre', font_size=50)
                        popup = Popup(title='Votre image est enregistre dans le dossier de votre application',
                                      content=content, size_hint=(0.5, 0.5))
                        content.bind(on_press=popup.dismiss)
                        popup.open()
                    else:
                        if platform == 'macosx':
                            Window.screenshot(name='Screenshot.png')
                            content = Button(text='Image enregistre', font_size=50)
                            popup = Popup(title='Votre image est enregistre dans le dossier de votre application',
                                          content=content, size_hint=(0.5, 0.5))
                            content.bind(on_press=popup.dismiss)
                            popup.open()
                        else:
                            if platform == 'ios':
                                Window.screenshot(name='Screenshot.png')
                                content = Button(text='Image enregistre', font_size=50)
                                popup = Popup(title='Votre image est enregistre dans le dossier de votre application',
                                              content=content, size_hint=(0.5, 0.5))
                                content.bind(on_press=popup.dismiss)
                                popup.open()

                            else:
                                Window.screenshot(name='Screenshot.png')
                                content = Button(text='Image enregistre', font_size=50)
                                popup = Popup(title='Votre image est enregistre dans le dossier de votre application',
                                              content=content, size_hint=(0.5, 0.5))
                                content.bind(on_press=popup.dismiss)
                                popup.open()

        except:
            pass
Beispiel #33
0
def save_shot(self, t):
    # method1
    Window.screenshot(name='kivy04-2-1.png')
    # method2
    self.export_to_png('kivy04-2-2.png')
Beispiel #34
0
 def Screenshot(obj):
     global Screenshotnum
     Window.screenshot(name="Screenshot.png")
    def screengrab(self, *largs):
        #take a screen shot of the window and save it as sh, and then open that png as ti
        sh = Window.screenshot("screenshot.png")
        ti = Image.open(sh)
        #get the width and height of the png
        width, height = ti.size

        #copy image
        img = ti.copy()

        #crop out the two number and symbol in white boxes and saved respectively
        num1 = img.crop((30, 120, 310, 400))
        #num1.save(sh[:-4]+"num1.png")
        num2 = img.crop((480, 120, 760, 400))
        #num2.save(sh[:-4]+"num2.png")

        #Crop the middle small square for tha symbol
        arthm = img.crop((325, 185, 465, 325))
        #arthm.save(sh[:-4]+"arthm.png")

        #Convert cropped images to 8px X 8px
        smallnum1 = num1.resize((8, 8), Image.BILINEAR)
        smallnum2 = num2.resize((8, 8), Image.BILINEAR)
        smallarthm = arthm.resize((8, 8), Image.BILINEAR)

        #Convert small images to gray scale and turn them into numpy arrays
        smallnum1gray = smallnum1.convert('L')
        smallnum1gray = np.array(smallnum1gray)

        smallnum2gray = smallnum2.convert('L')
        smallnum2gray = np.array(smallnum2gray)

        smallarthmgray = smallarthm.convert('L')
        smallarthmgray = np.array(smallarthmgray)

        #convert 8 bit color to 4 bit color to match the scikit learn digit data
        fbit1 = np.floor(interp(smallnum1gray, [0, 255], [16, 0]))
        fbit2 = np.floor(interp(smallnum2gray, [0, 255], [16, 0]))
        smallarthmgray = np.floor(interp(smallarthmgray, [0, 255], [16, 0]))

        # print(fbit2.ravel())

        #convert fbit's to single array instead of 2d(image)
        predarthm = clf2.predict([smallarthmgray.ravel()])
        pred1 = clf.predict([fbit1.ravel()])
        pred2 = clf.predict([fbit2.ravel()])

        pnum1, pnum2, parth = pred1, pred2, predarthm
        panswer = 0
        #print(pnum1, pnum2, parth)
        #print(digits.data[pred1])
        #print(digits.data[pred])

        #{1,2,3,4}={+,-,x,/}
        if parth == 1:
            print(pnum1, ' + ', pnum2)
            panswer = pnum1 + pnum2

        if parth == 2:
            print(pnum1, ' - ', pnum2)
            panswer = pnum1 - pnum2

        if parth == 3:
            print(pnum1, ' x ', pnum2)
            panswer = pnum1 * pnum2

        if parth == 4:
            print(pnum1, ' / ', pnum2)
            panswer = pnum1 / pnum2

        print("answer:")
        #add plot of drawn image vs what the model that it was,
        plt.figure(figsize=(14, 8))
        for index, (image,
                    label) in enumerate(zip([fbit1, fbit2], [pred1, pred2])):
            plt.subplot(2, 2, index + 1)
            plt.imshow(image, cmap=plt.get_cmap('gray'))
            plt.title('Prediction: %i\n' % label, fontsize=15)
            plt.axis('off')
        plt.subplot(2, 2, 3)
        plt.imshow(np.reshape(digits.data[pred1], (-1, 8)),
                   cmap=plt.get_cmap('gray'))
        plt.title('similar to: %i\n' % pred1)
        plt.axis('off')
        plt.subplot(2, 2, 4)
        plt.imshow(np.reshape(digits.data[pred2], (-1, 8)),
                   cmap=plt.get_cmap('gray'))
        plt.title('similar to: %i\n' % pred2)
        plt.axis('off')

        #Show the plots, must close plot first before using the app again
        #plt.show()

        return pnum1, pnum2, parth, panswer
Beispiel #36
0
 def take_screenshot(self, filename):
     KivyWindow.screenshot(name=filename)
Beispiel #37
0
 def export(self, *args):
     print("Hello there export")
     photo = Window.screenshot("test.png")
     im = imageio.imread(photo, as_gray=False)
     print(im.shape)
     plt.imshow(im)
Beispiel #38
0
 def screengrab(self, *largs):
     outname = self.fileprefix + '_%(counter)04d.png'
     Window.screenshot(name=outname)
Beispiel #39
0
 def screenshot(self, filename=None):
     Window.screenshot(filename)
Beispiel #40
0
 def doscreenshot(self,*largs):
       Window.screenshot(name='screenshot%(counter)04d.jpg')