title: How to schedule the kivy camera to read the texture continuously?
body: <p>I have been trying to create a kivy camera scanner from a number of sources (I would use the zbarcam if I could, but the garden.xcamera module will not import, therefore I am trying to create something similar).  </p>
  
  <h3>Problem</h3>
  
  <p>The problem is the camera does not read or update the texture continuously nor is there a way that I can find to capture frame-for-frame from the camera.  This means I only get the texture on initialization.</p>
  
  <h3>Tried</h3>
  
  <p>Firstly, I have tried scheduling an event that will update the texture instance every 0.5 seconds.  I could not get the texture instance of the camera because there is some delay in the camera to load, which caused an error.
  <p>
  Secondly, I created an <code>on_texture</code> event in my kv string, but it only reads the texture on initialization.
  <p>
  Thirdly, I tried binding the <code>on_texture</code> event a bit later in the python script, by creating a binding function and calling it as a scheduled event.  It did not even get the instance.
  <p>
  Fourthly, I <code>created_triggers</code> and <code>ask_update(callbacks)</code> to the <code>_on_texture()</code> event, but again the script loads to fast before the camera can instantiate crashing the script. 
  <p>
  Fifthly, I noticed there is a <code>kivy.core.video</code> module that contains a <code>on_frame</code> attribute.  Did re-write my script to use it in conjunction with the <code>kivy.uix.video</code> module, but noticed that the video cannot run without first loading a video file. </p>
  
  <h3>Code</h3>
  
  <pre><code>import kivy
  import gi
  kivy.require('1.11.1')
  gi.require_version('Gst', '1.0')
  
  from collections import namedtuple
  from PIL import Image
  from kivy.app import App
  from kivy.clock import Clock
  from kivy.lang import Builder
  from kivy.uix.boxlayout import BoxLayout
  from kivy.properties import ListProperty, ObjectProperty
  from kivy.uix.camera import Camera
  import time
  from gi.repository import Gst
  import pyzbar.pyzbar
  from kivy.uix.modalview import ModalView
  
  Builder.load_string('''
  #: import Window kivy.core.window.Window
  &lt;ScanPreview&gt;:
      auto_dismiss: False
      size_hint_x: 0.6
      size_hint_y: None
      height: Window.height / 9
      pos_hint: {'top':0.7, 'x': 0.1}
      background_normal: ''
      background_color: (1, 1, 1, 0)
      background: 'white.png'
      Label:
          id: sc_data
          text: 'See me...'
  &lt;ScanCamera&gt;:
      orientation: 'vertical'
      The_Camera:
          id: camera
          resolution: root.resolution
          on_texture: root._on_texture(camera)
      ToggleButton:
          text: 'Stop'
          on_press: camera.play = not camera.play
          size_hint_y: None
          height: '48dp'
  ''')
  class ScanPreview(ModalView):
      pass
  class The_Camera(Camera):
      pass
  class ScanCamera(BoxLayout):
      resolution = ListProperty([640, 480])
      symbols = ListProperty([])
      code_types = ListProperty(set(pyzbar.pyzbar.ZBarSymbol))
      cam_cam = ObjectProperty(The_Camera())
      the_preview = ObjectProperty(ScanPreview())
      Symb = namedtuple('Symb', ['type','data'])
      def __init__(self, **kwargs):
          super(ScanCamera, self).__init__(**kwargs)
          self.cam_cam.play = True
      def _on_texture(self, instance):
          #source: https://github.com/kivy-garden/garden.zbarcam/blob/develop
          #/zbarcam/zbarcam.py
          print(instance)
          if  not instance.texture == None:
              print(instance.texture)
              self.symbols = self._detect_qrcode_frame(
                  texture=instance.texture, code_types=self.code_types)
      def _detect_qrcode_frame(cls, texture, code_types):
          image_data = texture.pixels
          size = texture.size
          #source: https://github.com/kivy-garden/garden.zbarcam/blob/develop
          #/zbarcam/zbarcam.py
          # Fix for mode mismatch between texture.colorfmt and data returned
          #by
          # texture.pixels. texture.pixels always returns RGBA, so that 
          #should
          # be passed to PIL no matter what texture.colorfmt returns. refs:
          # https://github.com/AndreMiras/garden.zbarcam/issues/41
          pil_image = Image.frombytes(mode='RGBA', size=size,
                                          data=image_data)
          symbols = []
          print(pil_image)
          print(size)
          print(texture.tex_coords)
          print(texture.target)
          codes = pyzbar.pyzbar.decode(pil_image, symbols=code_types)
          for code in codes:
              symbol = CameraClick.Symb(type=code.type, data=code.data)
              symbols.append(symbol)
          print(symbols)
          return symbols
  
  class TestCamera(App):
      title = 'Scan Camera'
      def build(self):
          return ScanCamera()
      def on_stop(self):
          cc = The_Camera()
          print('Stop')
          cc.play = False
      def on_pause(self):
          return True
      def on_resume(self):
          pass
  
  TestCamera().run()
  </code></pre>
  
  <h3>Desired result</h3>
  
  <p>The camera's texture must continuously update, which will allow the pyzbar and PIL module to decode the texture?</p>