title: Kivy Camera as KV language widget
body: <p>I am using Kivy with a webcam. I have followed <a href="https://stackoverflow.com/questions/30294385/python-kivy-camera-widget-error-with-opencv">this example</a> by @Arnav of using opencv to form and display the camera as a widget. I have "extended" the layout within python it to add two buttons as a test, in preparation for a more complicated layout.</p>
  
  <pre><code>class CamApp(App):
      def build(self):
          self.capture = cv2.VideoCapture(0)
          self.my_camera = KivyCamera(capture=self.capture, fps=30,resolution=(1920,1080))
          root = BoxLayout(orientation = 'vertical')
          root.add_widget(self.my_camera,1)
          box2 = BoxLayout(orientation = 'vertical')
          btn1 = Button(text='Hello world 1')
          btn2 = Button(text='Hello world 2')
          box2.add_widget(btn1)
          box2.add_widget(btn2)
          root.add_widget(box2, 0)
          return root
          #return Builder.load_string(kv)
  </code></pre>
  
  <p>While this works I would prefer to move the UI components out of python and into a <code>kv language</code> file.
  The problem is knowing how to "describe" the <code>self.my_camera</code> in the <code>kv</code> file?</p>
  
  <p>I am not sure whether to inherit the <code>KivyCamera</code> class as a <code>widget</code> within the <code>kv</code> file i.e.</p>
  
  <pre><code>kv = '''
  &lt;Cam1@KivyCamera&gt;:
      texture: self.my_camera
      resolution: (1920, 1080)
      pos: self.pos
      size: self.size
  </code></pre>
  
  <p>Or whether to use the <code>canvas</code> widget</p>
  
  <pre><code>&lt;MyWidget&gt;:
      canvas:
          Rectangle:
              source: self.my_camera
              pos: self.pos
              size: self.size
  </code></pre>
  
  <p>I have tried other "hacked" implementations, but in all cases the problem is linking through the <code>self.my_camera</code> into the <code>kv</code> file.</p>
  
  <p>Any suggestions?</p>