Skip to content

Commit 1abc822

Browse files
committed
doc: explain adjustments argument
1 parent 0ea47a8 commit 1abc822

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

src/arduino/app_peripherals/camera/README.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,34 @@ with Camera(source, **options) as camera:
4141
# Camera automatically stopped when exiting
4242
```
4343

44+
## Frame Adjustments
45+
46+
The `adjustments` parameter allows you to apply custom transformations to captured frames. This parameter accepts a callable that takes a numpy array (the frame) and returns a modified numpy array. It's also possible to build adjustment pipelines by concatenating these functions with the pipe (|) operator
47+
48+
```python
49+
import cv2
50+
from arduino.app_peripherals.camera import Camera
51+
from arduino.app_utils.image import greyscaled
52+
53+
54+
def blurred():
55+
def apply_blur(frame):
56+
return cv2.GaussianBlur(frame, (15, 15), 0)
57+
return PipeableFunction(apply_blur)
58+
59+
# Using adjustments with Camera
60+
with Camera(0, adjustments=greyscaled) as camera:
61+
frame = camera.capture()
62+
# frame is now grayscale
63+
64+
# Or with multiple transformations
65+
with Camera(0, adjustments=greyscaled | blurred) as camera:
66+
frame = camera.capture()
67+
# frame is now greyscaled and blurred
68+
```
69+
70+
See the arduino.app_utils.image module for more supported adjustments.
71+
4472
## Camera Types
4573
The Camera class provides automatic camera type detection based on the format of its source argument. keyword arguments will be propagated to the underlying implementation.
4674

0 commit comments

Comments
 (0)