@@ -142,11 +142,87 @@ class Camera {
142
142
int setMotionDetectionWindow (uint32_t x, uint32_t y, uint32_t w, uint32_t h);
143
143
int setMotionDetectionThreshold (uint32_t threshold);
144
144
int motionDetected ();
145
+
146
+ /* *
147
+ * @brief Zoom to a specific region of the image by setting the zoom window size and its position.
148
+ * The camera resolution must be set to a higher resolution than the zoom resolution for this to work.
149
+ * The zooming is done by cropping a higher resolution image to the zoom window.
150
+ * @note This function is currently only supported by the GC2145 sensor on the Arduino Nicla Vision.
151
+ * @param zoom_resolution The resolution of the zoom window.
152
+ * The resolution must be one of the following:
153
+ * - CAMERA_R160x120
154
+ * - CAMERA_R320x240
155
+ * - CAMERA_R320x320
156
+ * - CAMERA_R640x480
157
+ * - CAMERA_R800x600
158
+ * If the desired resolution doesn't fit in the built-in memory,
159
+ * the framebuffer should be allocated on external RAM.
160
+ * @param zoom_x The x position of the zoom window.
161
+ * The value must be lower or equal to the width of the image minus the width of the zoom window.
162
+ * @param zoom_y The y position of the zoom window.
163
+ * The value must be lower or equal to the height of the image minus the height of the zoom window.
164
+ * @return 0 on success, -1 on failure.
165
+ */
145
166
int zoomTo (int32_t zoom_resolution, uint32_t zoom_x, uint32_t zoom_y);
167
+
168
+ /* *
169
+ * @brief Zoom to the center of the image by setting the zoom window size.
170
+ *
171
+ * @param zoom_resolution The resolution of the zoom window.
172
+ * The resolution must be one of the following:
173
+ * - CAMERA_R160x120
174
+ * - CAMERA_R320x240
175
+ * - CAMERA_R320x320
176
+ * - CAMERA_R640x480
177
+ * - CAMERA_R800x600
178
+ * If the desired resolution doesn't fit in the built-in memory,
179
+ * the framebuffer should be allocated on external RAM.
180
+ * @return 0 on success, -1 on failure.
181
+ */
146
182
int zoomToCenter (int32_t zoom_resolution);
183
+
184
+ /* *
185
+ * @brief Flips the camera image vertically.
186
+ *
187
+ * @param flip_enable Set to true to enable vertical flip, false to disable.
188
+ * @return 0 on success, -1 on failure.
189
+ */
147
190
int setVerticalFlip (bool flip_enable);
191
+
192
+ /* *
193
+ * @brief Mirrors the camera image horizontally.
194
+ *
195
+ * @param mirror_enable Set to true to enable horizontal mirror, false to disable.
196
+ * @return 0 on success, -1 on failure.
197
+ */
148
198
int setHorizontalMirror (bool mirror_enable);
199
+
200
+ /* *
201
+ * @brief Get the width of the current camera resolution.
202
+ * This can for example be used to calculate the zoom window position and size.
203
+ * In the following example, the camera is zoomed to the top right side of the image:
204
+ * @code
205
+ * // Calculate the zoom window position
206
+ * uint32_t max_zoom_x = camera.getResolutionWidth() - 320;
207
+ * // Zoom to the calculated position and size
208
+ * camera.zoomTo(CAMERA_R320x240, max_zoom_x, 0);
209
+ * @endcode
210
+ * @return uint32_t The width of the camera resolution.
211
+ */
149
212
uint32_t getResolutionWidth ();
213
+
214
+ /* *
215
+ * @brief Get the height of the current camera resolution.
216
+ * This can for example be used to calculate the zoom window position and size.
217
+ * In the following example, the camera is zoomed to the bottom left side of the image:
218
+ * @code
219
+ * // Calculate the zoom window position
220
+ * uint32_t max_zoom_y = camera.getResolutionHeight() - 240;
221
+ * // Zoom to the calculated position and size
222
+ * camera.zoomTo(CAMERA_R320x240, 0, max_zoom_y);
223
+ * @endcode
224
+ * @return uint32_t The height of the camera resolution.
225
+ */
150
226
uint32_t getResolutionHeight ();
151
227
void debug (Stream &stream);
152
228
};
0 commit comments