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

Commit f7fbd63

Browse files
committed
Update README.md
1 parent 75426dd commit f7fbd63

File tree

1 file changed

+117
-53
lines changed

1 file changed

+117
-53
lines changed

README.md

Lines changed: 117 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,80 @@ Camera4Kivy
33

44
*Yet Another Camera for Kivy*
55

6-
This document has these sections [Overview](https://github.com/Android-for-Python/camera4kivy#overview), [Install](https://github.com/Android-for-Python/camera4kivy#install), [Examples](https://github.com/Android-for-Python/camera4kivy#examples), [Preview Widget](https://github.com/Android-for-Python/camera4kivy#preview-widget), [Image Analysis](https://github.com/Android-for-Python/camera4kivy#image-analysis), [Camera Behavior](https://github.com/Android-for-Python/camera4kivy#camera-behavior), [Camera Provider](https://github.com/Android-for-Python/camera4kivy#camera-provider), and [Known Behavior](https://github.com/Android-for-Python/camera4kivy#known-behavior).
7-
8-
On Android only:
9-
- Do not [install an arm7 build on an arm8 device](#behavior-android-armeabi-v7a-build-installed-on-an-arm64-v8a-device).
6+
7+
8+
- [Overview](#overview)
9+
- [Install](#install)
10+
* [Install Camera4Kivy on Desktop](#install-camera4kivy-on-desktop)
11+
* [Install Camera4Kivy on Android](#install-camera4kivy-on-android)
12+
+ [buildozer.spec:](#buildozerspec-)
13+
+ [Run Time Permissions](#run-time-permissions)
14+
* [Install Camera4Kivy on iOS](#install-camera4kivy-on-ios)
15+
+ [Run Time Permissions](#run-time-permissions-1)
16+
- [Examples](#examples)
17+
* [Tested Examples](#tested-examples)
18+
+ [[C4K-Photo-Example](https://github.com/Android-for-Python/c4k_photo_example)](#-c4k-photo-example--https---githubcom-android-for-python-c4k-photo-example-)
19+
+ [[C4K-QR-Example](https://github.com/Android-for-Python/c4k_qr_example)](#-c4k-qr-example--https---githubcom-android-for-python-c4k-qr-example-)
20+
+ [[C4K-OpenCV-Example.](https://github.com/Android-for-Python/c4k_opencv_example)](#-c4k-opencv-example--https---githubcom-android-for-python-c4k-opencv-example-)
21+
+ [[C4K-MLKit-Example](https://github.com/Android-for-Python/c4k_mlkit_example)](#-c4k-mlkit-example--https---githubcom-android-for-python-c4k-mlkit-example-)
22+
+ [[C4K-TFLite-Example](https://github.com/Android-for-Python/c4k_tflite_example)](#-c4k-tflite-example--https---githubcom-android-for-python-c4k-tflite-example-)
23+
* [Tested Platforms](#tested-platforms)
24+
- [Preview Widget](#preview-widget)
25+
* [Preview Widget Properties](#preview-widget-properties)
26+
+ [aspect_ratio](#aspect-ratio)
27+
+ [letterbox_color](#letterbox-color)
28+
+ [orientation](#orientation)
29+
* [Preview Widget API](#preview-widget-api)
30+
+ [Connect Camera](#connect-camera)
31+
- [camera_id](#camera-id)
32+
- [mirrored](#mirrored)
33+
- [filepath_callback](#filepath-callback)
34+
- [sensor_resolution](#sensor-resolution)
35+
- [analyze_pixels_resolution](#analyze-pixels-resolution)
36+
- [enable_analyze_pixels](#enable-analyze-pixels)
37+
- [enable_analyze_imageproxy](#enable-analyze-imageproxy)
38+
- [enable_zoom_gesture](#enable-zoom-gesture)
39+
- [enable_focus_gesture](#enable-focus-gesture)
40+
- [imageproxy_data_format:](#imageproxy-data-format-)
41+
+ [Disconnect Camera](#disconnect-camera)
42+
+ [Capture](#capture)
43+
- [location](#location)
44+
- [subdir](#subdir)
45+
- [name](#name)
46+
+ [Select Camera](#select-camera)
47+
+ [Zoom](#zoom)
48+
+ [Flash](#flash)
49+
+ [Torch](#torch)
50+
+ [Focus](#focus)
51+
+ [camera_connected](#camera-connected)
52+
- [Image analysis](#image-analysis)
53+
* [Overview and Examples](#overview-and-examples)
54+
* [User Interaction](#user-interaction)
55+
* [Coordinates and image encoding](#coordinates-and-image-encoding)
56+
* [Analysis Configuration](#analysis-configuration)
57+
* [Debugging](#debugging)
58+
* [Performance](#performance)
59+
- [Camera Behavior](#camera-behavior)
60+
* [A Physical Camera](#a-physical-camera)
61+
* [Resolution](#resolution)
62+
+ [Sensor Resolution](#sensor-resolution)
63+
+ [Cropped Sensor Resolution](#cropped-sensor-resolution)
64+
+ [Preview Resolution](#preview-resolution)
65+
+ [Capture Resolution](#capture-resolution)
66+
+ [Analysis Resolution](#analysis-resolution)
67+
+ [Display Resolution.](#display-resolution)
68+
- [Camera Provider](#camera-provider)
69+
* [Android Camera Provider](#android-camera-provider)
70+
* [OpenCV](#opencv)
71+
* [GStreamer](#gstreamer)
72+
* [Picamera](#picamera)
73+
* [Picamera2](#picamera2)
74+
* [AVFoundation](#avfoundation)
75+
- [Known Behavior](#known-behavior)
76+
* [Behavior: Android .mp4 Orientation](#behavior--android-mp4-orientation)
77+
* [Behavior: Android .jpg Orientation.](#behavior--android-jpg-orientation)
78+
* [Behavior: Android armeabi-v7a build installed on an arm64-v8a device](#behavior--android-armeabi-v7a-build-installed-on-an-arm64-v8a-device)
79+
* [Behavior: Android "No supported surface combination"](#behavior--android--no-supported-surface-combination-)
1080

1181
## Overview
1282

@@ -52,7 +122,7 @@ The captured file location may be specified and is also reported in a callback.
52122

53123
On Android a pinch/spread gesture controls zoom, and a tap overrides any automatic focus and metering (if available). Some `connect_camera()` options are platform specific.
54124

55-
Be aware Preview operation depends on the performance of the graphics hardware. In general Preview uses the highest available resolution. On devices with low performance graphics hardware sush as low end laptops or Raspberry, you will probably have to explicitly set a lower image resolution inorder to increase the frame rate.
125+
Be aware Preview operation depends on the performance of the graphics hardware. In general Preview uses the highest available resolution for 30fps performance. On devices with low performance graphics hardware sush as low end laptops or Raspberry, you will probably have to explicitly set a lower image resolution inorder to increase the frame rate.
56126

57127
## Install
58128

@@ -66,11 +136,9 @@ A [camera provider](https://github.com/Android-for-Python/camera4kivy#camera-pro
66136

67137
Camera4Kivy depends on Buildozer 1.3.0 or later
68138

69-
`pip3 install buildozer`
70-
71139
#### buildozer.spec:
72140

73-
`android.api = 30` (or higher, min 29)
141+
`android.api = 33` (Constrained by Android packages imported by camerax_provider)
74142

75143
`requirements = python3, kivy, camera4kivy, gestures4kivy`
76144

@@ -127,12 +195,30 @@ To enable viewing images saved to app local storage with the File Manager:
127195

128196
A prerequisite is that a working camera is installed. Test this with the platform's camera app before proceeding. All examples use the platform specific camera provider, and assume the typical default camera_id of '0'. If you find the example does not connect to a camera review the available camera ids and your camera provider choice.
129197

130-
### Tested Examples and Platforms
198+
### Tested Examples
131199

132200
The Photo example illustrates basic camera usage, try this first. The remaining examples illustrate image analysis using various packages.
133201

134202
On Android and iOS the app can rotate when the device rotates, on the desktop you can change the window size to simulate orientation, and thus rotating a mobile device.
135203

204+
#### [C4K-Photo-Example](https://github.com/Android-for-Python/c4k_photo_example)
205+
Illustrates basic layout using screens. Basic camera functionality including photo capture, screenshot capture, and on Android capture of video with audio.
206+
On Raspberry PI a mouse must be used, a touch pad does not work correctly.
207+
208+
#### [C4K-QR-Example](https://github.com/Android-for-Python/c4k_qr_example)
209+
Everything you need to read a restaurant menu. Long press or double click on a highlighted QR code to open a web browser. Illustrates basic analysis, screen annotation, and user interaction.
210+
211+
#### [C4K-OpenCV-Example.](https://github.com/Android-for-Python/c4k_opencv_example)
212+
Edge detect the video stream. Illustrates using OpenCV analysis and replacing the original preview with the transformed image.
213+
214+
#### [C4K-MLKit-Example](https://github.com/Android-for-Python/c4k_mlkit_example)
215+
Face detect, MLKit is Android only. Illustrates using the ImageProxy api.
216+
217+
#### [C4K-TFLite-Example](https://github.com/Android-for-Python/c4k_tflite_example)
218+
Object classification. Illustrates using a large Tensorflow Lite model, and writing text to the Preview image.
219+
220+
### Tested Platforms
221+
136222
| Example | Windows | Macos | Linux | Android | iOS | Coral |
137223
|---------|---------|-------|-------|---------|-----|-------|
138224
| Photo | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | |
@@ -150,22 +236,6 @@ On Android and iOS the app can rotate when the device rotates, on the desktop yo
150236
- iOS : iPhone SE (second generation)
151237
- Coral : [Accelerator](https://coral.ai/products/accelerator) tested with Windows 11 , gave very approximately an order of magnitude speed up.
152238

153-
### [C4K-Photo-Example](https://github.com/Android-for-Python/c4k_photo_example)
154-
Illustrates basic layout using screens. Basic camera functionality including photo capture, screenshot capture, and on Android capture of video with audio.
155-
On Raspberry PI a mouse must be used, a touch pad does not work correctly.
156-
157-
### [C4K-QR-Example](https://github.com/Android-for-Python/c4k_qr_example)
158-
Everything you need to read a restaurant menu. Long press or double click on a highlighted QR code to open a web browser. Illustrates basic analysis, screen annotation, and user interaction.
159-
160-
### [C4K-OpenCV-Example.](https://github.com/Android-for-Python/c4k_opencv_example)
161-
Edge detect the video stream. Illustrates using OpenCV analysis and replacing the original preview with the transformed image.
162-
163-
### [C4K-MLKit-Example](https://github.com/Android-for-Python/c4k_mlkit_example)
164-
Face detect, MLKit is Android only. Illustrates using the ImageProxy api.
165-
166-
### [C4K-TFLite-Example](https://github.com/Android-for-Python/c4k_tflite_example)
167-
Object classification. Illustrates using a large Tensorflow Lite model, and writing text to the Preview image.
168-
169239
## Preview Widget
170240

171241
An app can have multiple `Preview` widgets, but only one can be connected to the physical camera unit at a time. A natural way to implement this is to add a preview widget to a screen's contents, then connect to the camera unit `on_enter` and disconnect `on_pre_leave`. Or if using a ModalView, Popup, or MDDialog use `on_open` and `on_pre_dismiss`. The C4K-Photo-Example illustrates this, the other examples simply connect the camera after `on_start()` and disconnect `on_stop()`.
@@ -259,7 +329,7 @@ However on Android a disconnect immediately after a capture has be initiated may
259329
def stop_capture_video(self): # Android only
260330
```
261331

262-
Video capture is only available on Android.
332+
Video capture is only available on Android or with the OpenCV camera provider. Capturing audio with video is only available on Android.
263333

264334
Captures are never mirrored, except a screenshot capture if the Preview is mirrored. Capture resolution is discussed [here](https://github.com/Android-for-Python/Camera4Kivy#capture-resolution).
265335

@@ -315,10 +385,17 @@ On iOS only, zoom_abs() is called by pinch/spread gesture unless disabled.
315385
```
316386

317387
#### Flash
318-
Android only. For capture photo only, ignored for video and data.
319-
Sequence flash : off, on, auto (default),
388+
Android only, and for capture photo only, the value is ignored for video and data. The `state` argument must be in `['on', 'auto', 'off']`, alternatively if `state=None` sequential calls sequence through that list. Note that 'on' always turns on the flash around the time a photo is captured, 'auto' only does this if the light level is low enough.
389+
320390
```python
321-
def flash(self)
391+
def flash(self, state = None)
392+
```
393+
394+
#### Torch
395+
Android only, immediately turns the flash on in any use case. The `state` argument must be in `['on', 'off']`
396+
397+
```python
398+
def flash(self, state)
322399
```
323400

324401
#### Focus
@@ -327,6 +404,10 @@ Android only, if available on device. Called by a tap gesture unless disabled
327404
def focus(x, y):
328405
```
329406

407+
#### camera_connected
408+
409+
This is a boolean variable describing the camera state. It is `True` immediatedal *after* the camera is connected, and `False` immediately *before* the camera is disconnected.
410+
330411
## Image analysis
331412

332413
### Overview and Examples
@@ -390,10 +471,14 @@ Analysis and canvas annotation callbacks occur on different threads. The result
390471
```python
391472
@mainthread
392473
def make_thread_safe(self, found):
393-
self.annotations = found
474+
if self.camera_connected:
475+
self.annotations = found
476+
else:
477+
self.annotations = []
394478
```
479+
Note that we null the application state when the camera is not connected. This prevents saved annotations from being shown when a camera is re-connected, due to the multi-threaded implementation.
395480

396-
And add the thread safe annotations to the canvas.
481+
Then add the thread safe annotations to the canvas.
397482

398483
```python
399484
def canvas_instructions_callback(self, texture, tex_size, tex_pos):
@@ -618,18 +703,6 @@ Pre-installed
618703

619704
## Known Behavior
620705

621-
### Behavior: Preview has no aspect_ratio = 'fill'
622-
623-
There is no way to specify inverted letterboxing. Where the Preview exactly fills the space available, resulting in one axis of the captured or analyzed image being partially hidden in the Preview.
624-
625-
### Behavior: Raspberry PI Bullseye not available
626-
627-
The RaspberryPI video stack changed with Bullseye. In Bullseye currently the only working camera source is `libcamera`. Picamera is not availible, [apparently](https://www.raspberrypi.com/news/bullseye-camera-system/) a RPI Picamera2 Python interface is in development. And `libcamera` is not compatible with OpenCV or Kivy's GStreamer implementation.
628-
629-
### Behavior: Android Rotation
630-
631-
Rotating the physical device through 'inverted portrait' may result in an 'inverted landscape' display. An additional rotation to 'portrait' and back to 'landscape' corrects the display.
632-
633706
### Behavior: Android .mp4 Orientation
634707

635708
Video file orientation is incorrect if the preview orientation is not the same as the device orientation. Do not use this layout configuration when recording video. [Google issue tracker](https://issuetracker.google.com/issues/201085351).
@@ -638,18 +711,9 @@ Video file orientation is incorrect if the preview orientation is not the same a
638711

639712
Some image viewers (including Kivy Image widget) will incorrectly display a .jpg as rotated by 90 degrees. This occurs if the capture preview orientation is not the same as the device orientation, and the third party viewer does not use the Exif metadata.
640713

641-
### Behavior: Android connect_camera during on_start()
642-
643-
On Android, a `connect_camera()` called during `on_start()` will result in intermittent crashes during app start. The unfiltered logcat will contain: 'library "libdexfile.so" not found'.
644-
Use Kivy clock to schedule the `connect_camera()` one time step later.
645-
646-
### Behavior: Android switching cameras, short duration inverted image.
647-
648-
When switching cameras there may be a short duration inverted image, this is more likely on older Android devices.
649-
650714
### Behavior: Android armeabi-v7a build installed on an arm64-v8a device
651715

652-
The implementation of Google's camerax gradle dependencies is architecture specific, an app built for armeabi-v7a will crash on an arm64-v8a device. To rin on an arm64-v8a device you **must** build for arm64-v8a.
716+
The implementation of Google's camerax gradle dependencies appears to be architecture specific, an app built for armeabi-v7a will crash on an arm64-v8a device. To run on an arm64-v8a device you **must** build for arm64-v8a.
653717

654718
### Behavior: Android "No supported surface combination"
655719

0 commit comments

Comments
 (0)