Skip to content

Commit 9c04ef2

Browse files
hlym123lbuque
authored andcommitted
cmodules: add jpg and code_scanner module
Signed-off-by: hlym123 <lwylwt@qq.com>
1 parent a4282ad commit 9c04ef2

25 files changed

+856
-17
lines changed

docs/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
# from the environment for the first two.
66
SPHINXOPTS ?=
77
SPHINXBUILD ?= sphinx-build
8-
SOURCEDIR = zh_CN
8+
SOURCEDIR = en
99
BUILDDIR = build/$(SOURCEDIR)
1010

1111
# Put it first so that "make" without argument is like "make help".

docs/en/hardware/camera.rst

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
:mod:`camera`
2-
=====================================
3-
The camera module is used for taking pictures.
1+
camera
2+
=============
43

54
.. include:: ../refs/hardware.camera.ref
65

6+
The camera module is used for taking pictures.
7+
78
.. note:: This module is only applicable to the CoreS3 Controller
89

910
.. module:: camera

docs/en/hardware/display.rst

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
:mod:`Display`
2-
=====================================
1+
Display
2+
=======
3+
34
A lcd display library
45

56
.. module:: Display
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
.. |qrcode_detect_example.png| image:: https://static-cdn.m5stack.com/mpy_docs/advanced/openmv/qrcode_detect_example.png
2+
.. |find_qrcodes.png| image:: https://static-cdn.m5stack.com/mpy_docs/advanced/openmv/code_scanner/find_qrcodes.png
3+
.. |type_name.png| image:: https://static-cdn.m5stack.com/mpy_docs/advanced/openmv/code_scanner/type_name.png
4+
.. |payload.png| image:: https://static-cdn.m5stack.com/mpy_docs/advanced/openmv/code_scanner/payload.png
5+
6+
.. |qrcode_detect_example.m5f2| raw:: html
7+
8+
<a
9+
href="https://uiflow2.m5stack.com/?example=https://raw.githubusercontent.com/m5stack/uiflow-micropython/develop/examples/software/camera/qrcode_detect_example.m5f2"
10+
target="_blank"
11+
>
12+
qrcode_detect_example.m5f2
13+
</a>

docs/en/refs/software.image.ref

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
.. |width.png| image:: https://static-cdn.m5stack.com/mpy_docs/advanced/openmv/image/width.png
2+
.. |height.png| image:: https://static-cdn.m5stack.com/mpy_docs/advanced/openmv/image/height.png
3+
.. |format.png| image:: https://static-cdn.m5stack.com/mpy_docs/advanced/openmv/image/format.png
4+
.. |format_option.png| image:: https://static-cdn.m5stack.com/mpy_docs/advanced/openmv/image/format_option.png
5+
.. |size.png| image:: https://static-cdn.m5stack.com/mpy_docs/advanced/openmv/image/size.png
6+
.. |bytearray.png| image:: https://static-cdn.m5stack.com/mpy_docs/advanced/openmv/image/bytearray.png
17
.. |image_draw_example.png| image:: https://static-cdn.m5stack.com/mpy_docs/advanced/openmv/image_draw_example.png
28
.. |draw_string.png| image:: https://static-cdn.m5stack.com/mpy_docs/advanced/openmv/image/draw_string.png
39
.. |draw_rectangle.png| image:: https://static-cdn.m5stack.com/mpy_docs/advanced/openmv/image/draw_rectangle.png

docs/en/refs/software.jpg.ref

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
.. |take_photo_example.png| image:: https://static-cdn.m5stack.com/mpy_docs/advanced/openmv/take_photo_example.png
2+
.. |encode.png| image:: https://static-cdn.m5stack.com/mpy_docs/advanced/openmv/jpg/encode.png
3+
.. |decode.png| image:: https://static-cdn.m5stack.com/mpy_docs/advanced/openmv/jpg/decode.png
4+
5+
.. |take_photo_example.m5f2| raw:: html
6+
7+
<a
8+
href="https://uiflow2.m5stack.com/?example=https://raw.githubusercontent.com/m5stack/uiflow-micropython/develop/examples/software/camera/take_photo_example.m5f2"
9+
target="_blank"
10+
>
11+
take_photo_example.m5f2
12+
</a>

docs/en/software/code_scanner.rst

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
:mod:`code_scanner`
2+
===============================
3+
4+
.. include:: ../refs/software.code_scanner.ref
5+
6+
.. note:: This module is only applicable to the CoreS3 Controller
7+
8+
.. module:: code_scanner
9+
:synopsis:
10+
11+
``code_scanner`` module for qrcode scanning recognition
12+
13+
Micropython Example
14+
--------------------------------
15+
16+
qrcode detect
17+
++++++++++++++++++++++++++++
18+
19+
.. literalinclude:: ../../../examples/softwave/code_scanner/qrcode_detect_example.py
20+
:language: python
21+
:linenos:
22+
23+
24+
UIFlow2.0 Example
25+
--------------------------------
26+
27+
qrcode detect
28+
++++++++++++++++++++++++++++
29+
30+
|qrcode_detect_example.png|
31+
32+
.. only:: builder_html
33+
34+
|qrcode_detect_example.m5f2|
35+
36+
37+
38+
Methods
39+
--------------------------------
40+
41+
.. method:: find_qrcodes(img: image.Image) -> image.qrcode
42+
43+
QR code recognition
44+
45+
- ``img`` Image to be recognized
46+
47+
Returns ``image.qrcode`` instance
48+
49+
UIFlow2.0
50+
51+
|find_qrcodes.png|
52+
53+
54+
class image.QRCode
55+
------------------------------
56+
``QRCode`` The QRCode object is returned by `code_scanner.find_qrcodes(img: image.Image)`.
57+
58+
.. method:: payload() -> str
59+
60+
Return the payload string of the QR code
61+
62+
UIFlow2.0
63+
64+
|payload.png|
65+
66+
.. method:: type_name() -> str
67+
68+
Return the type of the QR code
69+
70+
UIFlow2.0
71+
72+
|type_name.png|
73+
74+
75+

docs/en/software/image.rst

Lines changed: 86 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,50 @@ class image.Image
3434
--------------------------------
3535
The line object is returned by `camera.snapshot()`.
3636

37+
Basic Methods
38+
--------------------------------
39+
40+
.. method:: width() -> int
41+
42+
Returns the image width in pixels.
43+
44+
UIFlow2.0
45+
46+
|width.png|
47+
48+
.. method:: height() -> int
49+
50+
Returns the image height in pixels.
51+
52+
UIFlow2.0
53+
54+
|height.png|
55+
56+
.. method:: format() -> int
57+
58+
Returns the image format
59+
60+
UIFlow2.0
61+
62+
|format.png|
63+
64+
.. method:: size() -> int
65+
66+
Returns the image size in bytes.
67+
68+
UIFlow2.0
69+
70+
|size.png|
71+
72+
.. method:: bytearray() -> bytearray
73+
74+
Returns a bytearray object that points to the image data for byte-level read/write access.
75+
76+
UIFlow2.0
77+
78+
|bytearray.png|
79+
80+
3781
Drawing Methods
3882
--------------------------------
3983

@@ -42,9 +86,9 @@ Drawing Methods
4286
Draws a line from (x0, y0) to (x1, y1) on the image. You may either
4387
pass x0, y0, x1, y1 separately or as a tuple (x0, y0, x1, y1).
4488

45-
- ``color`` is an RGB888 tuple for Grayscale or RGB565 images. Defaults to
46-
white. However, you may also pass the underlying pixel value (0-255) for
47-
grayscale images or a RGB565 value for RGB565 images.
89+
- ``color`` is an RGB888 tuple for Grayscale or RGB565 images. Defaults to
90+
white. However, you may also pass the underlying pixel value (0-255) for
91+
grayscale images or a RGB565 value for RGB565 images.
4892

4993
- ``thickness`` controls how thick the line is in pixels.
5094

@@ -60,8 +104,8 @@ Drawing Methods
60104
or as a tuple (x, y, w, h).
61105

62106
- ``color`` is an RGB888 tuple for Grayscale or RGB565 images. Defaults to
63-
white. However, you may also pass the underlying pixel value (0-255) for
64-
grayscale images or a RGB565 value for RGB565 images.
107+
white. However, you may also pass the underlying pixel value (0-255) for
108+
grayscale images or a RGB565 value for RGB565 images.
65109

66110
- ``thickness`` controls how thick the lines are in pixels.
67111

@@ -79,8 +123,8 @@ Drawing Methods
79123
as a tuple (x, y, radius).
80124

81125
- ``color`` is an RGB888 tuple for Grayscale or RGB565 images. Defaults to
82-
white. However, you may also pass the underlying pixel value (0-255) for
83-
grayscale images or a RGB565 value for RGB565 images.
126+
white. However, you may also pass the underlying pixel value (0-255) for
127+
grayscale images or a RGB565 value for RGB565 images.
84128

85129
- ``thickness`` controls how thick the edges are in pixels.
86130

@@ -99,19 +143,50 @@ Drawing Methods
99143
x, y separately or as a tuple (x, y).
100144

101145
- ``text`` is a string to write to the image. ``\n``, ``\r``, and ``\r\n``
102-
line endings move the cursor to the next line.
146+
line endings move the cursor to the next line.
103147

104148
- ``color`` is an RGB888 tuple for Grayscale or RGB565 images. Defaults to
105-
white. However, you may also pass the underlying pixel value (0-255) for
106-
grayscale images or a RGB565 value for RGB565 images.
149+
white. However, you may also pass the underlying pixel value (0-255) for
150+
grayscale images or a RGB565 value for RGB565 images.
107151

108152
- ``scale`` may be increased to increase/decrease the size of the text on the
109-
image. You can pass greater than 0 integer or floating point values.
153+
image. You can pass greater than 0 integer or floating point values.
110154

111155
Returns the image object so you can call another method using ``.`` notation.
112156

113157

114158
UIFlow2.0
115159

116160
|draw_string.png|
161+
162+
Constants
163+
--------------------------------
164+
165+
.. data:: RGB565
166+
:type: int
167+
168+
RGB565 pixel format. Each pixel is 16-bits, 2-bytes. 5-bits are used for red,
169+
6-bits are used for green, and 5-bits are used for blue.
170+
171+
.. data:: GRAYSCALE
172+
:type: int
173+
174+
GRAYSCALE pixel format. Each pixel is 8-bits, 1-byte.
175+
176+
.. data:: JPEG
177+
:type: int
178+
179+
A JPEG image.
180+
181+
.. data:: YUV422
182+
:type: int
117183

184+
A pixel format that is very easy to jpeg compress. Each pixel is stored as a grayscale
185+
8-bit Y value followed by alternating 8-bit U/V color values that are shared between two
186+
Y values (8-bits Y1, 8-bits U, 8-bits Y2, 8-bits V, etc.). Only some image processing
187+
methods work with YUV422.
188+
189+
UIFlow2.0
190+
191+
|format_option.png|
192+

docs/en/software/index.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,5 @@ Software
1111
umqtt.rst
1212
image.rst
1313
dl.rst
14+
jpg.rst
15+
code_scanner.rst

docs/en/software/jpg.rst

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
:mod:`jpg`
2+
===============================
3+
4+
.. include:: ../refs/software.jpg.ref
5+
6+
.. note:: This module is only applicable to the CoreS3 Controller
7+
8+
.. module:: jpg
9+
:synopsis:
10+
11+
``jpg`` module for encoding and decoding operations of JPG format images
12+
13+
Micropython Example
14+
--------------------------------
15+
16+
take photo
17+
++++++++++++++++++++++++++++
18+
19+
Click the screen to start the countdown and take a photo
20+
21+
.. literalinclude:: ../../../examples/softwave/jpg/take_photo_example.py
22+
:language: python
23+
:linenos:
24+
25+
26+
UIFlow2.0 Example
27+
--------------------------------
28+
29+
take photo
30+
++++++++++++++++++++++++++++
31+
32+
Click the screen to start the countdown and take a photo
33+
34+
|take_photo_example.png|
35+
36+
.. only:: builder_html
37+
38+
|take_photo_example.m5f2|
39+
40+
41+
Methods
42+
--------------------------------
43+
44+
.. method:: encode(img: image.Image, quality=60) -> image.Image
45+
46+
encode to jog photo
47+
48+
- ``img`` Image to be encoded, in the format of image.RGB565
49+
50+
Return ``image.Image`` instance, image format image.JPEG
51+
52+
UIFlow2.0
53+
54+
|encode.png|
55+
56+
.. method:: decode(img_jpg: image.Image) -> image.Image
57+
58+
jpg photo decode
59+
60+
- ``img`` Image to be decoded, in the format of image.JPEG
61+
62+
Return ``image.Image`` instance, image format image.RGB565
63+
64+
UIFlow2.0
65+
66+
|decode.png|
67+
68+
69+

0 commit comments

Comments
 (0)