Skip to content

Commit 060ff9d

Browse files
committed
camera: Add documentation for the zoom feature.
1 parent 36fd82b commit 060ff9d

File tree

1 file changed

+76
-0
lines changed

1 file changed

+76
-0
lines changed

libraries/Camera/src/camera.h

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -530,11 +530,87 @@ class Camera {
530530
* @return int 0 if no motion is detected, non-zero if motion is detected
531531
*/
532532
int motionDetected();
533+
534+
/**
535+
* @brief Zoom to a specific region of the image by setting the zoom window size and its position.
536+
* The camera resolution must be set to a higher resolution than the zoom resolution for this to work.
537+
* The zooming is done by cropping a higher resolution image to the zoom window.
538+
* @note This function is currently only supported by the GC2145 sensor on the Arduino Nicla Vision.
539+
* @param zoom_resolution The resolution of the zoom window.
540+
* The resolution must be one of the following:
541+
* - CAMERA_R160x120
542+
* - CAMERA_R320x240
543+
* - CAMERA_R320x320
544+
* - CAMERA_R640x480
545+
* - CAMERA_R800x600
546+
* If the desired resolution doesn't fit in the built-in memory,
547+
* the framebuffer should be allocated on external RAM.
548+
* @param zoom_x The x position of the zoom window.
549+
* The value must be lower or equal to the width of the image minus the width of the zoom window.
550+
* @param zoom_y The y position of the zoom window.
551+
* The value must be lower or equal to the height of the image minus the height of the zoom window.
552+
* @return 0 on success, -1 on failure.
553+
*/
533554
int zoomTo(int32_t zoom_resolution, uint32_t zoom_x, uint32_t zoom_y);
555+
556+
/**
557+
* @brief Zoom to the center of the image by setting the zoom window size.
558+
*
559+
* @param zoom_resolution The resolution of the zoom window.
560+
* The resolution must be one of the following:
561+
* - CAMERA_R160x120
562+
* - CAMERA_R320x240
563+
* - CAMERA_R320x320
564+
* - CAMERA_R640x480
565+
* - CAMERA_R800x600
566+
* If the desired resolution doesn't fit in the built-in memory,
567+
* the framebuffer should be allocated on external RAM.
568+
* @return 0 on success, -1 on failure.
569+
*/
534570
int zoomToCenter(int32_t zoom_resolution);
571+
572+
/**
573+
* @brief Flips the camera image vertically.
574+
*
575+
* @param flip_enable Set to true to enable vertical flip, false to disable.
576+
* @return 0 on success, -1 on failure.
577+
*/
535578
int setVerticalFlip(bool flip_enable);
579+
580+
/**
581+
* @brief Mirrors the camera image horizontally.
582+
*
583+
* @param mirror_enable Set to true to enable horizontal mirror, false to disable.
584+
* @return 0 on success, -1 on failure.
585+
*/
536586
int setHorizontalMirror(bool mirror_enable);
587+
588+
/**
589+
* @brief Get the width of the current camera resolution.
590+
* This can for example be used to calculate the zoom window position and size.
591+
* In the following example, the camera is zoomed to the top right side of the image:
592+
* @code
593+
* // Calculate the zoom window position
594+
* uint32_t max_zoom_x = camera.getResolutionWidth() - 320;
595+
* // Zoom to the calculated position and size
596+
* camera.zoomTo(CAMERA_R320x240, max_zoom_x, 0);
597+
* @endcode
598+
* @return uint32_t The width of the camera resolution.
599+
*/
537600
uint32_t getResolutionWidth();
601+
602+
/**
603+
* @brief Get the height of the current camera resolution.
604+
* This can for example be used to calculate the zoom window position and size.
605+
* In the following example, the camera is zoomed to the bottom left side of the image:
606+
* @code
607+
* // Calculate the zoom window position
608+
* uint32_t max_zoom_y = camera.getResolutionHeight() - 240;
609+
* // Zoom to the calculated position and size
610+
* camera.zoomTo(CAMERA_R320x240, 0, max_zoom_y);
611+
* @endcode
612+
* @return uint32_t The height of the camera resolution.
613+
*/
538614
uint32_t getResolutionHeight();
539615

540616
/**

0 commit comments

Comments
 (0)