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 various cameras (e.g. OV2640, OV5640) on different MicroPython ports, starting with the ESP32 port. The project implements a general API, has precompiled FW images and supports a lot of cameras out of the box. Defaults are set to work with the OV2640.
5
+
This project aims to support various cameras (e.g. OV2640, OV5640) on different MicroPython ports, starting with the ESP32 port. The project implements a general API, has precompiled firmware images and supports a lot of cameras out of the box. Defaults are set to work with the OV2640.
6
6
At the moment, this is a micropython user module, but it might get in the micropython repo in the future.
7
7
The API is stable, but it might change without previous announce.
8
8
9
9
## Content
10
10
11
-
-[Precomiled FW (the easy way)](#precomiled-fw-the-easy-way)
11
+
-[Precompiled firmware (the easy way)](#Precompiled-firmware-the-easy-way)
12
12
-[Using the API](#using-the-api)
13
13
-[Importing the camera module](#importing-the-camera-module)
14
14
-[Creating a camera object](#creating-a-camera-object)
@@ -17,7 +17,7 @@ The API is stable, but it might change without previous announce.
-[Build your custom firmware](#build-your-custom-firmware)
21
21
-[Setting up the build environment (DIY method)](#setting-up-the-build-environment-diy-method)
22
22
-[Add camera configurations to your board (optional, but recommended)](#add-camera-configurations-to-your-board-optional-but-recommended)
23
23
-[Build the API](#build-the-api)
@@ -26,18 +26,28 @@ The API is stable, but it might change without previous announce.
26
26
-[Troubleshooting](#troubleshooting)
27
27
-[Donate](#donate)
28
28
29
-
## Precomiled FW (the easy way)
29
+
## Precompiled firmware (the easy way)
30
30
31
31
If you are not familiar with building custom firmware, visit the [releases](https://github.com/cnadler86/micropython-camera-API/releases) page to download firmware that suits your board. **There are over 20 precompiled board images with the latest micropython!**
32
32
33
+
This firmware binaries also include the (mp_jpeg module)[https://github.com/cnadler86/mp_jpeg] to encode/decode JPEGs.
34
+
33
35
## Using the API
34
36
35
37
### Importing the camera module
36
38
39
+
There general way of using the api is as follow:
40
+
37
41
```python
38
42
from camera import Camera, GrabMode, PixelFormat, FrameSize, GainCeiling
39
43
```
40
44
45
+
There is also a camera class with asyncio support! To use it, you need to import from the acamera package:
46
+
47
+
```python
48
+
from acamera import Camera, GrabMode, PixelFormat, FrameSize, GainCeiling
49
+
```
50
+
41
51
### Creating a camera object
42
52
43
53
Camera construction using defaults. This is the case if you are using a **non-generic** precompiled firmware or if you specified the camera model or pins in mpconfigboard.h during your build. Then you can just call the construction without any keyword arguments.
@@ -117,10 +127,22 @@ cam.init()
117
127
118
128
### Capture image
119
129
130
+
The general way of capturing an image is calling the `capture` method:
131
+
120
132
```python
121
133
img = cam.capture()
122
134
```
123
135
136
+
Each time you call the method, you will receive a new frame.
137
+
138
+
The probably better way of capturing an image would be in an asyncio-loop:
139
+
140
+
```python
141
+
img =await cam.acapture() #To access this method, you need to import from acamera
142
+
```
143
+
144
+
Please consult the [asyncio documentation](https://docs.micropython.org/en/latest/library/asyncio.html), if you have questions on this.
145
+
124
146
### Camera reconfiguration
125
147
126
148
```python
@@ -150,9 +172,10 @@ while not cam.frame_available():
150
172
<do some other stuff>
151
173
print('The frame is available now. You can grab the image by the capture method =)')
152
174
```
153
-
This enables the possibility to create async applications
154
175
155
-
### Additional methods
176
+
This gives you the possibility of creating an asynchronous application
See autocompletions in Thonny in order to see the list of methods.
166
-
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).
189
+
If you want more insights 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).
167
190
Note that each method requires a "get_" or "set_" prefix, depending on the desired action.
168
191
192
+
Take also a look in the examples folder.
193
+
169
194
To get the version of the camera driver used:
170
195
171
196
```python
@@ -175,17 +200,17 @@ vers = camera.Version()
175
200
176
201
### Additional information
177
202
178
-
The FW images support the following cameras out of the box, but is therefore big: OV7670, OV7725, OV2640, OV3660, OV5640, NT99141, GC2145, GC032A, GC0308, BF3005, BF20A6, SC030IOT
203
+
The firmware images support the following cameras out of the box, but is therefore big: OV7670, OV7725, OV2640, OV3660, OV5640, NT99141, GC2145, GC032A, GC0308, BF3005, BF20A6, SC030IOT
179
204
180
-
## Build your custom FW
205
+
## Build your custom firmware
181
206
182
207
### Setting up the build environment (DIY method)
183
208
184
209
To build the project, follow these instructions:
185
210
186
211
-[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).
187
212
- Clone the micropython repo and this repo in a folder, e.g. "MyESPCam". MicroPython version 1.24 or higher is required (at least commit 92484d8).
188
-
- You will have to add the ESP32-Camera driver (I used v2.0.15). To do this, add the following to the respective idf_component.yml file (e.g. in micropython/ports/esp32/main_esp32s3/idf_component.yml):
213
+
- You will have to add the ESP32-Camera driver from my fork. To do this, add the following to the respective idf_component.yml file (e.g. in micropython/ports/esp32/main_esp32s3/idf_component.yml):
189
214
190
215
```yml
191
216
espressif/esp32-camera:
@@ -258,7 +283,11 @@ Example for Xiao sense:
258
283
```
259
284
#### Customize additional camera settings
260
285
261
-
If you want to customize additional camera setting or reduce the FW size by removing support for unused camera sensors, then take a look at the kconfig file of the esp32-camera driver and specify these on the sdkconfig file of your board.
286
+
If you want to customize additional camera setting or reduce the firmware size by removing support for unused camera sensors, then take a look at the kconfig file of the esp32-camera driver and specify these on the sdkconfig file of your board.
287
+
288
+
#### (Optional) Add the mp_jpeg module
289
+
290
+
If you also want to include the [mp_jpeg module](https://github.com/cnadler86/mp_jpeg) in your build, clone the mp_jpeg repo at the same level and folder as the mp_camera_api repo and meet the requirements from the mp_jpeg repo.
262
291
263
292
### Build the API
264
293
@@ -286,8 +315,8 @@ If you experience problems, visit [MicroPython external C modules](https://docs.
286
315
287
316
## Benchmark
288
317
289
-
I didn't use a calibrated osziloscope, but here is a FPS benchmark with my ESP32S3 (xclck_freq = 20MHz, GrabMode=LATEST, fb_count = 1, jpeg_quality=85%) and OV2640.
290
-
Using fb_count=2 theoretically can double the FPS (see JPEG with fb_count=2). This might also aplly for other PixelFormats.
318
+
I didn't use a calibrated oscilloscope, but here is a FPS benchmark with my ESP32S3 (xclk_freq = 20MHz, GrabMode=LATEST, fb_count = 1, jpeg_quality=85%) and OV2640.
319
+
Using fb_count=2 theoretically can double the FPS (see JPEG with fb_count=2). This might also apply for other PixelFormats.
0 commit comments