def distance_meet(self, i): global marker_coord, gncn, nnpal self.comp_logo.append(i) self.remove_widget(self.marker[i]) self.marker[i] = MapMarkerPopup(lat=float(marker_coord[i][0]), lon=float(marker_coord[i][1]), source=self.marker_image[i]) print("kando!!!!!!") Clock.schedule_once(lambda dt: (self.add_widget(self.marker[i])), 2) if (self.marker_image[i] == "new_nepal.png"): # vibrator.vibrate(time=2) nnpal = nnpal + 1 cam = Camera(resolution=(320, 240), play=True) # self.add_widget(cam) # self.vector.pop(i) # marker_coord = np.delete(marker_coord, i, 0) elif (self.marker_image[i] == "greencoin.png"): # vibrator.vibrate(time=2) gncn = gncn + 1 cam = Camera(resolution=(320, 240), play=True)
def build(self): camwidget = Widget() self.cam = Camera() self.cam = Camera(resolution=(640, 480), size=(500, 500), play=True) camwidget.add_widget(self.cam) self.check_qr = Clock.schedule_interval(self.doscreenshot, 1) return camwidget
def toggle_camera_source(self): self.cur_source = (self.cur_source + 1) % 2 if self.cur_source == 0: if not self.cam0: self.cam0 = Camera(index=0, resolution=(640, 480)) self.player = self.cam0 elif self.cur_source == 1: if not self.cam1: self.cam1 = Camera(index=1, resolution=(640, 480)) self.player = self.cam1 self.clear_widgets() self.add_widget(self.player)
def build(self): camwidget = Widget() #Create a camera Widget cam = Camera() #Get the camera cam=Camera(resolution=(640,480), size=(500,500)) cam.play=True #Start the camera camwidget.add_widget(cam) button=Button(text='screenshot',size_hint=(0.12,0.12)) button.bind(on_press=self.doscreenshot) camwidget.add_widget(button) #Add button to Camera Widget return camwidget
def build(self): # create a floating layout as base camlayout = FloatLayout(size=(600, 600)) cam = Camera() # Get the camera cam = Camera(resolution=(1024, 1024), size=(100, 100)) cam.play = True # Start the camera camlayout.add_widget(cam) #button = Button(text='Take Picture', size_hint=(0.12, 0.12)) #button.bind(on_press=self.screengrab) #camlayout.add_widget(button) # Add button to Camera Layout self.fileprefix = 'snap' return camlayout
def build(self): layout = BoxLayout(orientation='vertical') # create a camera object self.cameraObject = Camera(play=False) self.cameraObject.play = True self.cameraObject.resolution = (300, 300) # Define resolution # button for taking photograph( can also be defined in kv file ) self.camaraClick = Button(text="capture") self.camaraClick.size_hint = (.5, .2) self.camaraClick.pos_hint = {'x': .25, 'y': .75} self.camaraClick.bind(on_press=self.onCameraClick) layout.add_widget(self.cameraObject) layout.add_widget(self.camaraClick) return layout
def __init__(self, **kwargs): super(TestCameraBox, self).__init__(**kwargs) #Create the classifier and train the model. self.classifier = Classifier(trainImgPaths, maskImgPaths) self.classifier.train() #Start the camera self.camera = Camera(resolution=(640, 480)) self.camera.play = True; #Define buttons and bind to handlers self.captureButton = Button(text="Capture") self.captureButton.bind(on_press=self.capture) self.captureButton.size_hint_y = None self.captureButton.height='48dp' self.classifyButton = Button(text="Classify") self.classifyButton.bind(on_press=self.classify) self.classifyButton.size_hint_y = None self.classifyButton.height='48dp' self.classifyButton.disabled=True #Add widgets to layouts self.orientation='vertical' self.buttonLayout = BoxLayout(orientation='horizontal') self.buttonLayout.add_widget(self.captureButton) self.buttonLayout.add_widget(self.classifyButton) self.add_widget(self.camera) self.add_widget(self.buttonLayout)
def on_enter_camera(self, cameraheader): if cameraheader.content is None: index = int(cameraheader.text[-1]) - 1 # the camera is not created until used because it can # begin reading from the user's hardware in the constructor, # and they might not be planning to use it if not self.ensure_permission('CAMERA'): return self.tabbedpanel.switch_to(self.settingsheader) # TODO: android only wants one camera object, whereas desktop seems to prefer separate ones. # probably prioritise android, as desktop usually has only 1 camera cameraheader.content = Camera(index = index, resolution = (960, 720), play = True) # this hack works around a control flow issue with adding # a widget inside the on_content event handler, where it # is replaced with the previous content # see https://github.com/kivy/kivy/issues/7221 # this rest of this if block should likely be removed if that issue is closed self.tabbedpanel.clear_widgets() self.tabbedpanel.add_widget(cameraheader.content) correct_clear_widgets = self.tabbedpanel.clear_widgets def restore_clear_widgets(): self.tabbedpanel.clear_widgets = correct_clear_widgets self.tabbedpanel.clear_widgets = restore_clear_widgets else: cameraheader.content.play = True cameraheader.content._camera.bind(on_texture = self.on_update_camera) detection = self.config.get('settings', 'detection') if detection == 'OCR': self.ocr = OCR()
def build(self): layout = BoxLayout(orientation='vertical') # Create a camera object self.cameraObject = Camera(play=False) self.cameraObject.play = True self.cameraObject.resolution = (300, 300) # Specify the resolution # Create a button for taking photograph self.camaraClick = Button(text="Take Photo") self.camaraClick.size_hint = (.5, .2) self.camaraClick.pos_hint = {'x': .25, 'y': .75} # bind the button's on_press to onCameraClick self.camaraClick.bind(on_press=self.onCameraClick) # add camera and button to the layout layout.add_widget(self.cameraObject) layout.add_widget(self.camaraClick) # return the root widget return layout
def __init__(self, sn_root, **kwargs): super().__init__(**kwargs) self.sn_root = sn_root self.cameraObject = Camera(play=False) self.cameraObject.play = True self.cameraObject.resolution = (500, 500) self.cameraObject.pos_hint = {'x': 0, 'y': 0.2} anchor1 = AnchorLayout(anchor_x='left', anchor_y='bottom') home_button = Button(text="Home", size_hint=(0.33, .30)) home_button.bind(on_press=self.go_home) anchor1.add_widget(home_button) self.add_widget(anchor1) anchor2 = AnchorLayout(anchor_x='center', anchor_y='bottom') cameraClick = Button(text="Take Photo", size_hint=(0.33, .30)) cameraClick.bind(on_press=self.onCameraClick) anchor2.add_widget(cameraClick) self.add_widget(anchor2) anchor3 = AnchorLayout(anchor_x='right', anchor_y='bottom') cameraClick = Button(text="Evaluate", size_hint=(0.33, .30)) cameraClick.bind(on_press=self.go_results) anchor3.add_widget(cameraClick) self.add_widget(anchor3) self.add_widget(self.cameraObject)
def read_qr(self): """Abre la camara para leer un codigo de QR""" self.content = Widget() if platform == 'android': self.detector = ZbarQrcodeDetector() self.detector.bind(symbols=self.connect_qr) self.content.add_widget(self.detector) #~ self.dialog = MDDialog(title="Enfoque el codigo QR",content=self.content, size_hint=(.8, None),height=dp(500),auto_dismiss=False) #~ self.dialog.add_action_button("Cerrar", action= lambda x: self.close_dialog()) #~ self.dialog.open() self.detector.start() else: if self.cam == None: self.cam = Camera(resolution=(640, 480), size=(400, 400), play=True) #~ self.add_widget(self.cam) else: self.cam.play = True self.content.size_hint = None, None self.content.height = dp(400) self.content.add_widget(self.cam) self.check_qr = Clock.schedule_interval(self.detect_qr, 1) self.dialog = MDDialog(title="Enfoque el codigo QR", content=self.content, size_hint=(.8, None), height=dp(500), auto_dismiss=False) self.dialog.add_action_button("Cerrar", action=lambda x: self.close_dialog()) self.dialog.open()
def build(self): #LAYOUT FLOAT layout = FloatLayout() #CONFIGURAÇÕES DA CAMERA self.cameraObject = Camera(play=False) self.cameraObject.play = True self.cameraObject.resolution = (480, 350) self.cameraObject.size_hint = (.4, 1) self.cameraObject.pos_hint = {'x': .55, 'y': .10} #CONFIGURAÇÕES DO BOTÃO 1 self.botaoClick1 = Button(text="BOTÃO 1 ") self.botaoClick1.size_hint = (.2, .1) self.botaoClick1.pos_hint = {'x': .55, 'y': .20} #CONFIGURAÇÕES DO BOTÃO 2 self.botaoClick2 = Button(text="BOTÃO 2 ") self.botaoClick2.size_hint = (.2, .1) self.botaoClick2.pos_hint = {'x': .75, 'y': .20} #FUNÇÃO DE CLICK DOS BOTÕES self.botaoClick1.bind(on_press=self.botaoclickone) self.botaoClick2.bind(on_press=self.botaoclicktwo) #CAMPOS DE CADASTRO #LAYOUT PARA MOSTRAR OS WIDGET NA TELA layout.add_widget(self.cameraObject) layout.add_widget(self.botaoClick1) layout.add_widget(self.botaoClick2) #RETORNA PARA O WIDGET return layout
def __init__(self, **kwargs): super().__init__(**kwargs) self._request_android_permissions() self.camera = Camera(play=False, resolution=(640, 480)) self.camera._camera.bind(on_texture=self.capture) if self.is_android(): gyroscope.enable() Clock.schedule_interval(self.get_rotation, 1 / 10)
def build(self): self.kivy_cam = Camera(index=1, resolution=(640, 480), play=True) print(type(self.kivy_cam)) layout = BoxLayout() layout.add_widget(self.kivy_cam) self.capture = cv2.VideoCapture(0) self.my_camera = KivyCamera(capture=self.capture, fps=30) return layout, self.my_camera
def make_photo(self): try: self.add_widget(CameraLayout()) except: cam = Camera(resolution=(640, 480), play=True) if cam.texture: cam.texture.save() sm.current = 'messages'
def Mostrar_cam(self): global Cam Cam = Camera() Cam.resolution = (640, 480) Cam.size = (680, 460) Cam.pos = (100, 100) # Cam.texture self.CAM_WIDGET.add_widget(Cam)
def add_webcam(self): self.cameraObject = Camera(play=False) self.cameraObject.play = True self.cameraObject.resolution = (int(1.2*480), int(1.2*640)) # Specify the resolution self.cameraObject.pos = (256,1200) self.cameraObject.size = (int(1.2*480),int(1.2*640)) self.GUI_widget.add_widget(self.cameraObject) return
def build(self): self.cam=Camera(index=0, resolution=(-1,-1),play=False) bl=BoxLayout() btt=Button(text='1',on_press=self.g) self.lbl=Label(text='0') bl.add_widget(self.lbl) bl.add_widget(btt) return bl
def build(self): rl = RelativeLayout() cam = Camera(resolution=(640, 360), size=(1000, 600), pos=(0, 0), play=True) rl.add_widget(cam) return rl
def __init__(self, **kwargs): super(PanneauVideo, self).__init__(**kwargs) self.liste_video = list() self.liste_video_view = ListeView([], False, self.on_affiche_video) #self.consultation.add_widget(self.liste_video) self.current_video = None self.popup = Popup(title='Video', on_dismiss=self.resume_video) self.popup.size_hint = (.8, .8) self.camera = Camera(resolution=(640, 480), play=False)
def Mostrar_cam(self): global Cam Cam = Camera() Cam.resolution = (1, 1) # Cam.fullscreen=-1,-1 Cam.size = (680, 460) #Cam.pos=(100,100) Cam.play = True self.CAM_WIDGET.add_widget(Cam)
def __init__(self, **kwargs): super(CameraScreen, self).__init__(**kwargs) self.add_widget(Camera(play=True, resolution=(320, 240))) self.add_widget( buttons.PipButton(upper=True, text=self.name.upper(), size_hint=(0, 0), size=(50, 20), pos=(25, 215)))
def build(self): #initialize the FaceDetector by calculating face encodings for all available skype pictures self.face_detector = FaceDetector() self.face_detector.get_face_encodings() self.root = BoxLayout(orientation='vertical') """create the first horizontal box with a camera object on the left and a resulting picture on the right""" self.horizontalBox1 = BoxLayout(orientation='horizontal') # Create a camera object self.cameraObject = Camera(play=False) self.cameraObject.play = True #self.cameraObject.resolution = (1024, 1024) # Specify the resolution #self.cameraObject.size = (500, 500) self.im1 = Image(source="input_image.png") self.horizontalBox1.add_widget(self.im1) """create the second horizontal box with resulting text""" self.horizontalBox2 = Label( text="Which colleague looks most like you!?", font_size='20sp') """create the third horizontal box with a button to start the lookalike process""" self.horizontalBox3 = BoxLayout(orientation='horizontal') # Create a button for taking photograph self.cameraButton = Button(text="Show me my lookalike!", size_hint=(.3, .3), background_normal='', background_color=(255, 0, 0, 0.2), pos_hint={ 'center_x': 0.5, 'center_y': 0.5 }) # bind the button's on_press to onCameraClick self.cameraButton.bind(on_press=self.onCameraClick) self.horizontalBox3.add_widget(self.cameraButton) """create the second horizontal box with a button to start the lookalike process""" self.horizontalBox3 = BoxLayout(orientation='horizontal') # Create a button for taking photograph self.cameraButton = Button(text="Show me my lookalike!", size_hint=(.3, .3), pos_hint={ 'center_x': 0.5, 'center_y': 0.5 }) # bind the button's on_press to onCameraClick self.cameraButton.bind(on_press=self.onCameraClick) self.horizontalBox3.add_widget(self.cameraButton) """add all boxes to the root of the Kivy app""" self.root.add_widget(self.horizontalBox1) self.root.add_widget(self.horizontalBox2) self.root.add_widget(self.horizontalBox3) # return the root widget return self.root
def build(self): camwidget = Widget() #Create a camera Widget cam = Camera(play=True, index=1) #Start the camera camwidget.add_widget(cam) button = Button(text='screenshot', size_hint=(0.12, 0.12)) button.bind(on_press=self.doscreenshot) camwidget.add_widget(button) #Add button to Camera Widget cam.play = True return camwidget
def build(self): main_layout = FloatLayout(size=(300, 300)) self.camera = Camera(resolution=(640, 480), play=True, pos_hint={'x': 0, 'y': .25}, size_hint=(1, .65)) photo_button = Button(text='Photo', background_color=[0, 1, 1], font_size=20, pos_hint={'x': .15, 'y': 0}, size_hint=(.7, .2)) photo_button.bind(on_press=self.photo) main_layout.add_widget(photo_button) return main_layout
def toggle_video_mode(self): if self.cur_mode == 'recorded': self.cur_mode = 'live' if self.cur_source == 0: if not self.cam0: self.cam0 = Camera(index=0, resolution=(640, 480)) self.player = self.cam0 elif self.cur_source == 1: if not self.cam1: self.cam1 = Camera(index=1, resolution=(640, 480)) self.player = self.cam1 elif self.cur_mode == 'live': self.cur_mode = 'recorded' # release camera (Kivy can't do that right now) self.player = VideoPlayer() self.clear_widgets() self.add_widget(self.player)
def __init__(self, **kwargs): super(LoginScreen, self).__init__(**kwargs) self.cols = 2 self.add_widget(Label(text='User Name')) self.username = TextInput(multiline=False) self.add_widget(self.username) self.add_widget(Label(text='password')) self.password = TextInput(password=True, multiline=False) self.add_widget(self.password) cam = Camera(play=True)
def start(self): if not self._camera: self._camera = Camera(resolution=self.camera_size, size_hint=(None, None)) self.add_widget(self._camera) self.bind(size=self._camera.setter('size')) self.bind(pos=self._camera.setter('pos')) else: self._camera._camera.init_camera() self._camera.play = True Clock.schedule_interval(self._detect_qrcode_frame, 1 / 15)
def build(self): self.layout = FloatLayout() self.touch = Foo() # Create a camera object. Use index=0 for rear camera and index=1 for front camera. self.cameraObject = Camera(index=0, resolution=(960,540), play=True) self.display = IMG() self.layout.add_widget(self.display) self.layout.add_widget(self.touch) # we have to add that object to the layout to detects touches. Logger.info(f'Schedule interval is {round(1 / FPS, 3)} seconds') Clock.schedule_interval(self.update, round(1 / FPS, 3)) return self.layout
def Camara(self): camwidget = Widget() #Create a camera Widget cam = Camera() #Get the camera cam.resolution = (640, 480) cam.size = 1000, 800 cam.pos = (-100, -100) cam.play = True #Start the camera camwidget.add_widget(cam) self.WIDGET1.add_widget(camwidget)