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
Add splash image
Update Quick Start section now that examples are frozen into the firmware
Condense example code snippets
Re-organize supported hardware list as tables with emojis
Copy file name to clipboardExpand all lines: README.md
+63-93Lines changed: 63 additions & 93 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,3 +1,7 @@
1
+
<palign="center">
2
+
<img src="opencv-examples/images/splash.png" />
3
+
</p>
4
+
1
5
# MicroPython-OpenCV
2
6
3
7
Welcome to SparkFun's MicroPython port of OpenCV! This is the first known MicroPython port of OpenCV, and as such, there may be some rough edges. Hardware support is limited to SparkFun products.
@@ -6,127 +10,93 @@ Welcome to SparkFun's MicroPython port of OpenCV! This is the first known MicroP
6
10
7
11
1. Flash MicroPython-OpenCV firmware
8
12
* Back up any files you want to keep, they *will* be overwritten!
9
-
* Download the latest firmware from the [Releases tab](https://github.com/sparkfun/micropython-opencv/releases).
13
+
* Download the latest firmware for your board from the [Releases tab](https://github.com/sparkfun/micropython-opencv/releases).
10
14
* If you don't know how to flash firmware to your board, find your board [here](https://micropython.org/download/) and follow the instructions using the OpenCV firmware.
11
-
2. Copy examples (optional)
12
-
* It is suggested to copy the entire examples folder to your MicroPython board to get started. This can be done simply with [mpremote](https://docs.micropython.org/en/latest/reference/mpremote.html):
13
-
*`cd micropython-opencv/examples`
14
-
*`mpremote cp -r . :`
15
-
3. Configure hardware drivers
15
+
* After first boot, the [opencv-examples](opencv-examples) directory will be automatically extraced to the MicroPython filesystem for easy access to all the examples.
16
+
2. Configure hardware driver initialization
16
17
* The MicroPython port of OpenCV depends on hardware drivers to interface with cameras and displays. Drivers are built into the firmware, so there is no need to install them manually.
17
-
* An example module called [cv2_hardware_init](examples/cv2_hardware_init/) is imported by all examples to initialize the drivers. You will likely need to edit the files for your specific hardware and board configuration.
18
-
4. Write OpenCV code!
18
+
* An example module called [cv2_hardware_init](opencv-examples/cv2_hardware_init/) is imported by all examples to initialize the drivers. You will likely need to edit the files for your specific hardware and board configuration.
19
+
3. Write and run OpenCV code
19
20
* Any IDE should work, so use your favorite!
20
-
* The code block below contains snippets from various examples to highlight major features.
21
+
* Start with the examples! Go through them in order, which will verify your hardware is working and demonstrate some basics of OpenCV. Read the comments to understand the differences with the MicroPython port.
22
+
* The code block below contains snippets to highlight major features.
21
23
22
24
```python
23
-
# Import OpenCV, just as you would in any other Python environment!
25
+
# Import OpenCV, just like any other Python environment!
24
26
import cv2 as cv
25
27
26
-
# Standard OpenCV leverages the host operating system to access hardware, but we
27
-
# don't have that luxury in MicroPython. Instead, drivers are provided for
28
-
# various hardware components, which need to be initialized before using them.
29
-
# The exmples import a module called `cv2_hardware_init`, which initializes the
30
-
# drivers. You may need to edit the contents of the `cv2_hardware_init` module
31
-
# based on your specific board and hardware configuration
28
+
# Initialize hardware drivers by importing the example module (you'll likely
29
+
# need to modify it for your specific hardware configuration).
32
30
from cv2_hardware_init import*
33
31
34
-
# Import NumPy, almost like any other Python environment! The only difference is
35
-
# the addition of `from ulab` since MicroPython does not have a full NumPy
36
-
# implementation; ulab NumPy is a lightweight version of standard NumPy
32
+
# Import ulab NumPy and initialize an image, almost like any other Python
33
+
# environment!
37
34
from ulab import numpy as np
38
-
39
-
# Initialize an image (NumPy array) to be displayed, just like in any other
40
-
# Python environment! Here we create a 240x320 pixel image with 3 color channels
41
-
# (BGR order, like standard OpenCV) and a data type of `uint8` (you should
42
-
# always specify the data type, because NumPy defaults to `float`)
43
35
img = np.zeros((240, 320, 3), dtype=np.uint8)
44
36
45
-
# OpenCV's drawing functions can be used to modify the image. Here is the
Hardware support in this repository is mostly limited to SparkFun products. The current list of supported proudcts is very small, but may be expanded in the future. Users are welcome to fork this repository to add support for other products, following our licence requirements. Assistance in adding support for other hardware will not be provided by SparkFun. We may consider pull requests that add support for additional hardware, see [#Contributing](#Contributing).
114
69
115
-
The OpenCV firmware adds ~3MiB on top of the standard MicroPython firmware, which itself be up to 1MiB in size (depending on platform and board). So a board with at least 8MB of flash is recommended, to also have space available for file storage.
70
+
The OpenCV firmware adds over 3MiB on top of the standard MicroPython firmware, which itself be up to 1MiB in size (depending on platform and board). You'll also want some storage space, so a board with at least 8MB of flash is recommended.
116
71
117
72
PSRAM is a requirement to do anything useful with OpenCV. A single 320x240 RGB888 frame buffer requires 225KiB of RAM; most processors only have a few hundred KiB of SRAM. Several frame buffers can be needed for even simple vision pipelines, so you really need at least a few MiB of RAM available. The more the merrier!
| ⚠️ |[OV5640](https://www.sparkfun.com/ov5640-camera-board-5-megapixel-2592x1944-fisheye-lens.html)| See [#22](https://github.com/sparkfun/micropython-opencv/issues/22)|
0 commit comments