How to refresh Image.texture from CoreImage.texture?

6 views
Skip to first unread message

Pawel Pilkowski

unread,
Apr 9, 2015, 12:21:57 AM4/9/15
to kivy-...@googlegroups.com
Hello,
I'm looking for a way to refresh camera miniature images from snapshots. I have this piece of code, but after first refresh (not the one in the reloadMiniatures thread) i get blackness.
I have tried other solutions but showing 6x mjpeg streams was to heavy (and I don't really need high framerate). Had some success with AsyncImage and saving images to file, but it wasn't very efficient and I had this loading_image to get rid of.

from kivy.app import App
from kivy.uix.image import Image
import time
import threading
import urllib
from kivy.core.image import Image as CoreImage
from io import BytesIO

class TestApp(App):
    def reloadMiniatures(self):
        while True:
            data = BytesIO(urllib.urlopen("http://10.0.13.206:9000/?action=snapshot").read())
            time.sleep(3)
            self.image.texture = CoreImage(data, ext='jpg').texture

    def build(self):
        data = BytesIO(urllib.urlopen("http://10.0.13.206:9000/?action=snapshot").read())
        self.image = Image()
        self.image.texture = CoreImage(data, ext='jpg').texture

        miniatures = threading.Thread(target=self.reloadMiniatures)
        miniatures.daemon = True
        miniatures.start()

        return self.image

TestApp().run()
Reply all
Reply to author
Forward
0 new messages