Beispiel #1
0
class CameraWidget(AnchorLayout):
    passes = 0

    def __init__(self, **kwargs):
        super(CameraWidget, self).__init__(**kwargs)
        self.bind(size=self.update)

    #when the size updates, we place the camera widget appropriately
    #currently only functions after the function has been called three times, as kivy
    #does some weird stuff with updating the size variable, leading to divisions by zero
    #needs to be looked into for a more solid fix
    def update(self, *args):
        print self.passes
        print self.size
        if self.passes == 2:
            print 'Camera Size Changed to', self.size
            width_ratio = (self.size[1] * (9. / 16.0)) / self.size[0]
            print width_ratio
            self._camera = AndroidCamera(size=self.size,
                                         size_hint=(width_ratio, 1))
            self.add_widget(self._camera)
            self.unbind(size=self.update)
        else:
            self.passes += 1

    #Starts Camera
    def start(self):
        print 'Start camera'
        self._camera.start()

    #Stops Camera
    def stop(self):
        print 'Stop camera'
        self._camera.stop()
Beispiel #2
0
class CameraWidget(AnchorLayout):
	passes = 0

	def __init__(self, **kwargs):
		super(CameraWidget, self).__init__(**kwargs)
		self.bind(size=self.update)
	#when the size updates, we place the camera widget appropriately
	#currently only functions after the function has been called three times, as kivy
	#does some weird stuff with updating the size variable, leading to divisions by zero
	#needs to be looked into for a more solid fix
	def update(self, *args):
		print self.passes
		print self.size
		if self.passes == 2:
			print 'Camera Size Changed to', self.size
			width_ratio = (self.size[1] * (9./16.0) )  / self.size[0]
			print width_ratio
			self._camera = AndroidCamera(size=self.size, size_hint=(width_ratio, 1))
		        self.add_widget(self._camera)
			self.unbind(size=self.update)
		else:
			self.passes+=1

	#Starts Camera
	def start(self):
		print 'Start camera'
		self._camera.start()

	#Stops Camera
	def stop(self):
		print 'Stop camera'
		self._camera.stop()
Beispiel #3
0
 def update(self, *args):
     print self.passes
     print self.size
     if self.passes == 2:
         print 'Camera Size Changed to', self.size
         width_ratio = (self.size[1] * (9. / 16.0)) / self.size[0]
         print width_ratio
         self._camera = AndroidCamera(size=self.size,
                                      size_hint=(width_ratio, 1))
         self.add_widget(self._camera)
         self.unbind(size=self.update)
     else:
         self.passes += 1
Beispiel #4
0
	def update(self, *args):
		print self.passes
		print self.size
		if self.passes == 2:
			print 'Camera Size Changed to', self.size
			width_ratio = (self.size[1] * (9./16.0) )  / self.size[0]
			print width_ratio
			self._camera = AndroidCamera(size=self.size, size_hint=(width_ratio, 1))
		        self.add_widget(self._camera)
			self.unbind(size=self.update)
		else:
			self.passes+=1