libcamera: camera_sensor: Add parameter to limit returned sensor size
The getFormat function takes the aspect ratio and the area of the requested size into account when choosing the best sensor size. In case the sensor is connected to an rkisp1 the maximum supported frame size of the ISP is another constraining factor for the selection of the best format. Add a maxSize parameter to support such a constraint. Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com> Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com> Reviewed-by: Paul Elder <paul.elder@ideasonboard.com> Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
This commit is contained in:
@@ -74,7 +74,8 @@ public:
|
||||
Size resolution() const override;
|
||||
|
||||
V4L2SubdeviceFormat getFormat(const std::vector<unsigned int> &mbusCodes,
|
||||
const Size &size) const override;
|
||||
const Size &size,
|
||||
const Size maxSize) const override;
|
||||
int setFormat(V4L2SubdeviceFormat *format,
|
||||
Transform transform = Transform::Identity) override;
|
||||
int tryFormat(V4L2SubdeviceFormat *format) const override;
|
||||
@@ -699,7 +700,7 @@ Size CameraSensorLegacy::resolution() const
|
||||
|
||||
V4L2SubdeviceFormat
|
||||
CameraSensorLegacy::getFormat(const std::vector<unsigned int> &mbusCodes,
|
||||
const Size &size) const
|
||||
const Size &size, Size maxSize) const
|
||||
{
|
||||
unsigned int desiredArea = size.width * size.height;
|
||||
unsigned int bestArea = UINT_MAX;
|
||||
@@ -716,6 +717,10 @@ CameraSensorLegacy::getFormat(const std::vector<unsigned int> &mbusCodes,
|
||||
for (const SizeRange &range : formats->second) {
|
||||
const Size &sz = range.max;
|
||||
|
||||
if (!maxSize.isNull() &&
|
||||
(sz.width > maxSize.width || sz.height > maxSize.height))
|
||||
continue;
|
||||
|
||||
if (sz.width < size.width || sz.height < size.height)
|
||||
continue;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user