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

Commit 7d241b4

Browse files
committed
picamera2
1 parent 47e9406 commit 7d241b4

File tree

5 files changed

+30
-32
lines changed

5 files changed

+30
-32
lines changed

Diff for: README.md

+4-7
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,6 @@ Camera4Kivy
7373
* [OpenCV](#opencv)
7474
* [GStreamer](#gstreamer)
7575
* [Picamera](#picamera)
76-
* [Picamera2](#picamera2)
7776
* [AVFoundation](#avfoundation)
7877
- [Known Behavior](#known-behavior)
7978
* [Behavior: Android .mp4 Orientation](#behavior--android-mp4-orientation)
@@ -659,7 +658,7 @@ Nothing to do with a camera, it is a physical property of a screen. A scalar mea
659658

660659
## Camera Provider
661660

662-
Camera4Kivy depends on a 'camera provider' to access the OS camera api. On most platforms this uses the same provider as Kivy, with modified defaults.
661+
Camera4Kivy depends on a 'camera provider' to access the OS camera api. On most platforms this uses the same provider as Kivy, with modified defaults. On Android, iOS, and MacOS there is only a single provider.
663662

664663
| Platform | Provider | Requires |
665664
|-------------|---------------|----------------|
@@ -668,8 +667,7 @@ Camera4Kivy depends on a 'camera provider' to access the OS camera api. On most
668667
| Macos | [AVFoundation](https://github.com/Android-for-Python/camera4kivy#avfoundation)| OSX >= 10.7 |
669668
| Linux | [Gstreamer](https://github.com/Android-for-Python/camera4kivy#gstreamer) |
670669
| | [OpenCV](https://github.com/Android-for-Python/camera4kivy#opencv) |
671-
| Rasberry | [Picamera](https://github.com/Android-for-Python/camera4kivy#picamera) | <= Buster |
672-
| | [Picamera2](https://github.com/Android-for-Python/camera4kivy#picamera2) | >= Bullseye |
670+
| Rasberry | [Picamera](https://github.com/Android-for-Python/camera4kivy#picamera)(2) | |
673671
| | [Gstreamer](https://github.com/Android-for-Python/camera4kivy#gstreamer) | |
674672
| |[OpenCV](https://github.com/Android-for-Python/camera4kivy#opencv) | |
675673
| Android | [CameraX](https://github.com/Android-for-Python/camera4kivy#android-camera-provider) | Android >= 5.0 |
@@ -721,10 +719,9 @@ Depends on the Linux flavor, but commonly:
721719
`sudo apt-get install gstreamer1.0-dev`
722720

723721
### Picamera
724-
Pre-installed on Buster.
722+
This uses either the Picamera or Picamera2 package, depending on which is installed (they are mutually exclusive).
725723

726-
### Picamera2
727-
May be pre-instaled on Bullseye. Additional features for native Pi cameras: higher resolution photos, video optionally with audio, zoom, pan when zoom'd, sensor rotation. USB cameras are not currently supported.
724+
If Picamera2 is installed there are additional features for native Pi cameras: higher resolution photos, video (optionally with audio), zoom, pan when zoom'd, sensor rotation. However USB cameras are not currently supported.
728725

729726
### AVFoundation
730727
Pre-installed

Diff for: index.md

-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,6 @@ Camera4Kivy
7373
* [OpenCV](https://github.com/Android-for-Python/Camera4Kivy#opencv)
7474
* [GStreamer](https://github.com/Android-for-Python/Camera4Kivy#gstreamer)
7575
* [Picamera](https://github.com/Android-for-Python/Camera4Kivy#picamera)
76-
* [Picamera2](https://github.com/Android-for-Python/Camera4Kivy#picamera2)
7776
* [AVFoundation](https://github.com/Android-for-Python/Camera4Kivy#avfoundation)
7877
- [Known Behavior](https://github.com/Android-for-Python/Camera4Kivy#known-behavior)
7978
* [Behavior: Android .mp4 Orientation](https://github.com/Android-for-Python/Camera4Kivy#behavior--android-mp4-orientation)

Diff for: setup.cfg

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[metadata]
22
name = camera4kivy
3-
version = 0.2.1.dev
3+
version = 0.3.0.dev0
44
author = Robert Flatt
55
description = Yet Another Camera for Kivy
66
long_description = file: index.md
@@ -19,7 +19,7 @@ package_dir =
1919
packages = find:
2020
python_requires = >=3.7
2121
install_requires =
22-
gestures4kivy >= 0.1.2
22+
gestures4kivy >= 0.1.3
2323

2424
[options.packages.find]
2525
where = src

Diff for: src/camera4kivy/based_on_kivy_core/camera/camera_picamera2.py

+24-19
Original file line numberDiff line numberDiff line change
@@ -422,43 +422,48 @@ def _yuv_to_rgba(self, fmt, y, u, v, size, tsize):
422422
isize = tsize
423423
translate = 0
424424
origin = (tsize[0]//2, tsize[1]//2)
425-
if self.previous_fmt != fmt:
426-
self.fbo = None
427-
if self.previous_size[0] != size[0] or\
428-
self.previous_size[1] != size[1]:
429-
self.fbo = None
430-
if self.previous_tsize[0] != tsize[0] or\
431-
self.previous_tsize[1] != tsize[1]:
432-
self.fbo = None
433-
if not self.fbo:
434-
if fmt == 'YUV420':
435-
uv_size = (size[0]//2, size[1]//2 )
436-
else:
437-
uv_size = (size[0]//2, size[1])
425+
if fmt == 'YUV420':
426+
uv_size = (size[0]//2, size[1]//2 )
427+
else:
428+
uv_size = (size[0]//2, size[1])
429+
430+
if self.previous_size[0] != size[0] or self.previous_size[1] != size[1]:
438431
self.tex_y = Texture.create(size= size, colorfmt='luminance')
439432
self.tex_u = Texture.create(size= uv_size, colorfmt='luminance')
440433
self.tex_v = Texture.create(size= uv_size, colorfmt='luminance')
434+
435+
if self.previous_tsize[0] != tsize[0] or\
436+
self.previous_tsize[1] != tsize[1] or\
437+
self.fbo == None:
438+
self.previous_tsize = tsize
441439
self.fbo = Fbo(size=tsize) # size for bilt to self._texture
442440
self.fbo.texture.flip_vertical()
443441
with self.fbo:
444-
BindTexture(texture=self.tex_u, index=1)
445-
BindTexture(texture=self.tex_v, index=2)
442+
self.b_u = BindTexture(texture=self.tex_u, index=1)
443+
self.b_v = BindTexture(texture=self.tex_v, index=2)
446444
Rotate(origin = origin, angle = 360-self._rotate,
447445
axis = (0, 0, 1))
448446
Translate(0, translate)
449-
Rectangle(size=isize, texture=self.tex_y)
447+
self.r_y = Rectangle(size=isize, texture=self.tex_y)
450448
self.fbo.shader.fs = self.YUV_RGB_FS
451449
self.fbo['tex_y'] = 0
452450
self.fbo['tex_u'] = 1
453451
self.fbo['tex_v'] = 2
452+
453+
if self.previous_size[0] != size[0] or self.previous_size[1] != size[1]:
454+
self.previous_size = size
455+
self.r_y.size = isize
456+
self.r_y.texture = self.tex_y
457+
self.b_u.texture = self.tex_u
458+
self.b_v.texture = self.tex_v
459+
# Repeat previous pixels to prevent flicker on change
460+
return bytes(self.fbo.texture.pixels)
461+
454462
self.tex_y.blit_buffer(y, colorfmt='luminance')
455463
self.tex_u.blit_buffer(u, colorfmt='luminance')
456464
self.tex_v.blit_buffer(v, colorfmt='luminance')
457465
self.fbo.ask_update()
458466
self.fbo.draw()
459-
self.previous_fmt = fmt
460-
self.previous_size = size
461-
self.previous_tsize = tsize
462467
return self.fbo.texture.pixels
463468

464469

Diff for: src/camera4kivy/preview_kivycamera.py

-3
Original file line numberDiff line numberDiff line change
@@ -239,9 +239,6 @@ def torch(self, state):
239239
def focus(self, x, y):
240240
pass
241241

242-
def zoom_delta(self, delta_scale):
243-
pass
244-
245242
#############################################
246243
# Parse Arguments
247244
#############################################

0 commit comments

Comments
 (0)