You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This project aims to support cameras in different ports in micropython, starting with the ESP32-Port and omnivision (OV2640 & OV5640) cameras. The project implements a general API for cameras in micropython (such as circuitpython have done).
5
6
At the moment, this is a micropython user module, but it might get in the micropython repo in the future.
6
7
The API is stable, but it might change without previous anounce.
7
8
8
9
## Precomiled FW (the easy way)
10
+
9
11
If you are not familiar with building a custom firmware, you can go to the [releases](https://github.com/cnadler86/micropython-camera-API/releases) page and download one of the generic FWs that suits your board.
10
12
11
13
## Using the API
14
+
12
15
```python
13
16
from camera import Camera, GrabMode, PixelFormat, FrameSize, GainCeiling
14
17
15
18
# Camera construction and initialization
19
+
# These pins are just examples and if you use them just like that will get a watchdog error. Adapt them to your board!
16
20
camera = Camera(
17
21
data_pins=[1,2,3,4,5,6,7,8],
18
22
vsync_pin=9,
@@ -44,26 +48,32 @@ camera.set_quality(10)
44
48
45
49
You can get and set sensor properties by the respective methods (e.g. camera.get_brightness() or camera.set_vflip(True). See autocompletitions in Thonny in order to see the list of methods.
46
50
If you want more insides in the methods and what they actually do, you can find a very good documentation [here](https://docs.circuitpython.org/en/latest/shared-bindings/espcamera/index.html).
47
-
Notice that for the methods in here you need to prefix a get/set, depending that you want to do.
51
+
Notice that for the methods in here you need to prefix a get/set, depending on what you want to do.
48
52
49
53
## Build your custom FW
54
+
50
55
### Setup build environment (the DIY way)
56
+
51
57
To build the project, follow the following instructions:
52
-
-[ESP-IDF](https://docs.espressif.com/projects/esp-idf/en/v5.2.3/esp32/get-started/index.html): I used version 5.2.2, but it might work with other versions (see notes).
58
+
59
+
-[ESP-IDF](https://docs.espressif.com/projects/esp-idf/en/v5.2.3/esp32/get-started/index.html): I used version 5.2.3, but it might work with other versions (see notes).
53
60
- Clone the micropython repo and this repo in a folder, e.g. "MyESPCam". I used the actual micropython master branch (between v1.23 and before 1.24).
54
61
- You will have to add the ESP32-Camera driver (I used v2.0.12). To do this, add the following to the respective idf_component.yml file (e.g. in micropython/ports/esp32/main_esp32s3/idf_component.yml):
55
-
```
62
+
63
+
```yml
56
64
espressif/esp32-camera:
57
65
git: https://github.com/espressif/esp32-camera
58
66
```
59
-
You can also clone the https://github.com/espressif/esp32-camera repository inside the esp-idf/components folder instead of altering the idf_component.yml file.
60
67
61
-
### Add camera configurations to your board (Optional, but recomended)
62
-
To make things easier, add the following lines to your board config-file "mpconfigboard.h" with the respective pins and camera parameters. Otherwise you will need to pass all parameters during construction.
63
-
Don't forget the empty line at the buttom.
64
-
Example for xiao sense:
68
+
Alternatively, you can clone the <https://github.com/espressif/esp32-camera> repository inside the esp-idf/components folder instead of altering the idf_component.yml file.
65
69
66
-
```
70
+
### Add camera configurations to your board (Optional, but recommended)
71
+
72
+
To make things easier, add the following lines to your board config-file "mpconfigboard.h" with the respective pins and camera parameters. Otherwise, you will need to pass all parameters during construction.
73
+
Don't forget the empty line at the bottom.
74
+
Example for Xiao sense:
75
+
76
+
```c
67
77
#define MICROPY_CAMERA_PIN_D0 (15)
68
78
#define MICROPY_CAMERA_PIN_D1 (17)
69
79
#define MICROPY_CAMERA_PIN_D2 (18)
@@ -78,27 +88,35 @@ Example for xiao sense:
78
88
#define MICROPY_CAMERA_PIN_XCLK (10)
79
89
#define MICROPY_CAMERA_PIN_PWDN (-1)
80
90
#define MICROPY_CAMERA_PIN_RESET (-1)
81
-
#define MICROPY_CAMERA_PIN_SIOD (40)
82
-
#define MICROPY_CAMERA_PIN_SIOC (39)
83
-
#define MICROPY_CAMERA_XCLK_FREQ (20000000)
84
-
#define MICROPY_CAMERA_FB_COUNT (2)
85
-
#define MICROPY_CAMERA_JPEG_QUALITY (10)
86
-
#define MICROPY_CAMERA_GRAB_MODE (1)
91
+
#define MICROPY_CAMERA_PIN_SIOD (40) // SDA
92
+
#define MICROPY_CAMERA_PIN_SIOC (39) // SCL
93
+
#define MICROPY_CAMERA_XCLK_FREQ (20000000) // Frequencies are normally either 10 MHz or 20 MHz
94
+
#define MICROPY_CAMERA_FB_COUNT (2) // Usually the value is between 1 (slow) and 2 (fast, but more load on CPU)
95
+
#define MICROPY_CAMERA_JPEG_QUALITY (10) // Quality of JPEG output. 0-63 lower means higher quality. Definition will change in the future
96
+
#define MICROPY_CAMERA_GRAB_MODE (1) // 0=WHEN_EMPTY (might have old data, but less resources), 1=LATEST (best, but more resources)
87
97
88
98
```
89
99
90
100
### Build the API
101
+
91
102
To build the project, you could do it the following way:
92
103
93
104
```bash
94
-
$ .<path2esp-idf>/esp-idf/export.sh
95
-
$ cd MyESPCam/micropython/ports/esp32
96
-
$ make USER_C_MODULES=../../../../micropython-camera-API/src/micropython.cmake BOARD=<Your-Board> clean
97
-
$ make USER_C_MODULES=../../../../micropython-camera-API/src/micropython.cmake BOARD=<Your-Board> submodules
98
-
$ make USER_C_MODULES=../../../../micropython-camera-API/src/micropython.cmake BOARD=<Your-Board> all
105
+
.<path2esp-idf>/esp-idf/export.sh
106
+
cd MyESPCam/micropython/ports/esp32
107
+
make USER_C_MODULES=../../../../micropython-camera-API/src/micropython.cmake BOARD=<Your-Board> clean
108
+
make USER_C_MODULES=../../../../micropython-camera-API/src/micropython.cmake BOARD=<Your-Board> submodules
109
+
make USER_C_MODULES=../../../../micropython-camera-API/src/micropython.cmake BOARD=<Your-Board> all
99
110
```
100
-
if you experience problems, visit [MicroPython external C modules](https://docs.micropython.org/en/latest/develop/cmodules.html).
101
111
112
+
If you experience problems, visit [MicroPython external C modules](https://docs.micropython.org/en/latest/develop/cmodules.html).
102
113
## Notes
114
+
103
115
- The OV5640 pinout is compatible with boards designed for the OV2640 but the voltage supply is too high for the internal 1.5V regulator, so the camera overheats unless a heat sink is applied. For recording purposes the OV5640 should only be used with an ESP32S3 board. Frame sizes above FHD framesize should only be used for still images due to memory limitations.
104
-
- If your target board is a ESP32, I recomend using IDF >= 5.2, since older versions may lead to IRAM overflow during build. Alternatively you can modify your sdkconfig-file (see [issue #1](https://github.com/cnadler86/micropython-camera-API/issues/1)).
116
+
- If your target board is a ESP32, I recommend using IDF >= 5.2, since older versions may lead to IRAM overflow during build. Alternatively you can modify your sdkconfig-file (see [issue #1](https://github.com/cnadler86/micropython-camera-API/issues/1)).
117
+
118
+
## Plans for the future
119
+
-[ ] imolrment structure in repo to include other boards like xiao sense
120
+
-[ ] harmonize properties to standard ones at API level, e.g. jpeg quality to the range 100=very good, 1/0= very bad
121
+
-[ ] edge case: enable usage of pins such as i2c for other applications
122
+
-[ ] provide examples in binary image with lfs-merge
0 commit comments