Skip to content
This repository was archived by the owner on Nov 14, 2023. It is now read-only.

Commit f62409c

Browse files
committed
Update preview_camerax.py
1 parent f441b44 commit f62409c

File tree

1 file changed

+5
-22
lines changed

1 file changed

+5
-22
lines changed

src/camera4kivy/preview_camerax.py

+5-22
Original file line numberDiff line numberDiff line change
@@ -129,24 +129,13 @@ def connect_camera(self,
129129
self._configure_camera(True)
130130

131131
# destroy camera
132+
@run_on_ui_thread
132133
def disconnect_camera(self):
134+
self.stop_capture_video()
133135
self._deschedule_pipeline()
134136
if self._camera:
135-
if not self.capture_in_progress:
136-
self.do_disconnect_camera()
137-
else:
138-
self._disconnect_ev = Clock.schedule_interval(
139-
self.can_disconnect_camera, 1 / 30)
140-
141-
def can_disconnect_camera(self,dt):
142-
if not self.capture_in_progress:
143-
self.do_disconnect_camera()
144-
Clock.unschedule(self._disconnect_ev)
145-
146-
@run_on_ui_thread
147-
def do_disconnect_camera(self):
148-
self._camera.unbind_camera()
149-
self._camera = None
137+
self._camera.unbind_camera()
138+
self._camera = None
150139

151140
# configure camera
152141
def _configure_camera(self, start):
@@ -276,6 +265,7 @@ def select_camera(self, facing):
276265
else:
277266
self.facing = 'back'
278267

268+
# may have to wait for a capture to complete
279269
if not self.capture_in_progress:
280270
self.do_select_camera()
281271
else:
@@ -345,13 +335,6 @@ def _create_fbo(self, texture_size, rotation):
345335
elif rotation == 270:
346336
translate = (long_edge - short_edge) /2
347337

348-
# move to canvas_callback
349-
#if self.facing == 'front':
350-
# if rotation == 90 or rotation == 270:
351-
# scaley = -1
352-
# else:
353-
# scalex = -1
354-
355338
if texture_size[0] < texture_size[1]:
356339
translate = -translate
357340
scalex = -scalex

0 commit comments

Comments
 (0)