Skip to content

Commit 4c9dc04

Browse files
davidplowmanchrisruk
authored andcommitted
Add some simple overlay examples
Also include them in the standard list of tests. Signed-off-by: David Plowman <[email protected]>
1 parent 8dd5a32 commit 4c9dc04

File tree

5 files changed

+71
-0
lines changed

5 files changed

+71
-0
lines changed

examples/overlay_drm.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
from picamera2.picamera2 import *
2+
import numpy as np
3+
import time
4+
5+
picam2 = Picamera2()
6+
picam2.configure(picam2.preview_configuration())
7+
picam2.start_preview(Preview.DRM)
8+
picam2.start()
9+
time.sleep(1)
10+
11+
overlay = np.zeros((300, 400, 4), dtype=np.uint8)
12+
overlay[:150, 200:] = (255, 0, 0, 64)
13+
overlay[150:, :200] = (0, 255, 0, 64)
14+
overlay[150:, 200:] = (0, 0, 255, 64)
15+
16+
picam2.set_overlay(overlay)
17+
time.sleep(2)

examples/overlay_gl.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
from picamera2.picamera2 import *
2+
import numpy as np
3+
import time
4+
5+
picam2 = Picamera2()
6+
picam2.configure(picam2.preview_configuration())
7+
picam2.start_preview(Preview.QTGL)
8+
picam2.start()
9+
time.sleep(1)
10+
11+
overlay = np.zeros((300, 400, 4), dtype=np.uint8)
12+
overlay[:150, 200:] = (255, 0, 0, 64)
13+
overlay[150:, :200] = (0, 255, 0, 64)
14+
overlay[150:, 200:] = (0, 0, 255, 64)
15+
16+
picam2.set_overlay(overlay)
17+
time.sleep(2)

examples/overlay_null.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
from picamera2.picamera2 import *
2+
import numpy as np
3+
import time
4+
5+
picam2 = Picamera2()
6+
picam2.configure(picam2.preview_configuration())
7+
picam2.start_preview()
8+
picam2.start()
9+
time.sleep(1)
10+
11+
overlay = np.zeros((300, 400, 4), dtype=np.uint8)
12+
overlay[:150, 200:] = (255, 0, 0, 64)
13+
overlay[150:, :200] = (0, 255, 0, 64)
14+
overlay[150:, 200:] = (0, 0, 255, 64)
15+
16+
picam2.set_overlay(overlay)
17+
time.sleep(2)

examples/overlay_qt.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
from picamera2.picamera2 import *
2+
import numpy as np
3+
import time
4+
5+
picam2 = Picamera2()
6+
picam2.configure(picam2.preview_configuration())
7+
picam2.start_preview(Preview.QT)
8+
picam2.start()
9+
time.sleep(1)
10+
11+
overlay = np.zeros((300, 400, 4), dtype=np.uint8)
12+
overlay[:150, 200:] = (255, 0, 0, 64)
13+
overlay[150:, :200] = (0, 255, 0, 64)
14+
overlay[150:, 200:] = (0, 0, 255, 64)
15+
16+
picam2.set_overlay(overlay)
17+
time.sleep(2)

tests/test_list.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ examples/exposure_fixed.py
99
examples/metadata.py
1010
examples/opencv_face_detect_2.py
1111
examples/opencv_mertens_merge.py
12+
examples/overlay_gl.py
13+
examples/overlay_null.py
14+
examples/overlay_qt.py
1215
examples/preview.py
1316
examples/preview_x_forwarding.py
1417
examples/raw.py

0 commit comments

Comments
 (0)