[libcamera-devel] [PATCH v3 1/2] libcamera: Infrastructure for digital zoom
David Plowman
david.plowman at raspberrypi.com
Thu Jul 23 10:43:37 CEST 2020
These changes add a Digital Zoom control, taking a rectangle as its
argument, indicating the region of the sensor output that the
pipeline will "zoom up" to the final output size.
Additionally, we need to have a method returning the "pipelineCrop"
which gives the dimensions of the sensor output, taken by the
pipeline, and within which we can subsequently pan and zoom.
Signed-off-by: David Plowman <david.plowman at raspberrypi.com>
---
include/libcamera/camera.h | 2 ++
include/libcamera/internal/pipeline_handler.h | 4 +++
src/libcamera/camera.cpp | 27 +++++++++++++++++++
src/libcamera/control_ids.yaml | 10 +++++++
4 files changed, 43 insertions(+)
diff --git a/include/libcamera/camera.h b/include/libcamera/camera.h
index 4d1a4a9..6819b8e 100644
--- a/include/libcamera/camera.h
+++ b/include/libcamera/camera.h
@@ -92,6 +92,8 @@ public:
std::unique_ptr<CameraConfiguration> generateConfiguration(const StreamRoles &roles = {});
int configure(CameraConfiguration *config);
+ Size const &getPipelineCrop() const;
+
Request *createRequest(uint64_t cookie = 0);
int queueRequest(Request *request);
diff --git a/include/libcamera/internal/pipeline_handler.h b/include/libcamera/internal/pipeline_handler.h
index 22e629a..5bfe890 100644
--- a/include/libcamera/internal/pipeline_handler.h
+++ b/include/libcamera/internal/pipeline_handler.h
@@ -89,6 +89,8 @@ public:
const char *name() const { return name_; }
+ Size const &getPipelineCrop() const { return pipelineCrop_; }
+
protected:
void registerCamera(std::shared_ptr<Camera> camera,
std::unique_ptr<CameraData> data);
@@ -100,6 +102,8 @@ protected:
CameraManager *manager_;
+ Size pipelineCrop_;
+
private:
void mediaDeviceDisconnected(MediaDevice *media);
virtual void disconnect();
diff --git a/src/libcamera/camera.cpp b/src/libcamera/camera.cpp
index 69a1b44..f8b8ec6 100644
--- a/src/libcamera/camera.cpp
+++ b/src/libcamera/camera.cpp
@@ -793,6 +793,33 @@ int Camera::configure(CameraConfiguration *config)
return 0;
}
+/**
+ * \brief Return the size of the sensor image being used by the pipeline
+ * to create the output.
+ *
+ * This method returns the size, in pixels, of the raw image read from the
+ * sensor and which is used by the pipeline to form the output image(s)
+ * (rescaling if necessary). Note that these values take account of any
+ * cropping performed on the sensor output so as to produce the correct
+ * aspect ratio. It would normally be necessary to retrieve these values
+ * in order to calculate correct parameters for digital zoom.
+ *
+ * Example: a sensor mode may produce a 1920x1440 output image. But if an
+ * application has requested a 16:9 image, the values returned here might
+ * be 1920x1080 - the largest portion of the sensor output that provides
+ * the correct aspect ratio.
+ *
+ * \context This function is \threadsafe. It will only return valid
+ * (non-zero) values when the camera has been configured.
+ *
+ * \return The dimensions of the sensor image used by the pipeline.
+ */
+
+Size const &Camera::getPipelineCrop() const
+{
+ return p_->pipe_->getPipelineCrop();
+}
+
/**
* \brief Create a request object for the camera
* \param[in] cookie Opaque cookie for application use
diff --git a/src/libcamera/control_ids.yaml b/src/libcamera/control_ids.yaml
index 988b501..5a099d5 100644
--- a/src/libcamera/control_ids.yaml
+++ b/src/libcamera/control_ids.yaml
@@ -262,4 +262,14 @@ controls:
In this respect, it is not necessarily aimed at providing a way to
implement a focus algorithm by the application, rather an indication of
how in-focus a frame is.
+
+ - DigitalZoom:
+ type: Rectangle
+ description: |
+ Sets the portion of the full sensor image, in pixels, that will be
+ used for digital zoom. That is, this part of the sensor output will
+ be scaled up to make the full size output image (and everything else
+ discarded). To obtain the "full sensor image" that is available, the
+ method Camera::getOutputCrop() should be called once the camera is
+ configured. An application may pan and zoom within this rectangle.
...
--
2.20.1
More information about the libcamera-devel
mailing list