Files
external_libcamera/include/libcamera/internal/converter/converter_dw100_vertexmap.h
T
Stefan Klug b48d41a853 libcamera: converter: Add dw100 vertex map class
Using a custom vertex map the dw100 dewarper is capable of doing
complex and useful transformations on the image data. This class
implements a pipeline featuring:
- Arbitrary ScalerCrop
- Full transform support (Flip, 90deg rotations)
- Arbitrary move, scale, rotate

ScalerCrop and Transform is implemented to provide a interface that is
standardized libcamera wide. The rest is implemented on top for more
flexible dw100 specific features.

Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2025-11-26 17:39:29 +01:00

79 lines
1.9 KiB
C++

/* SPDX-License-Identifier: LGPL-2.1-or-later */
/*
* Copyright (C) 2025, Ideas on Board Oy
*
* DW100 vertex map interface
*/
#pragma once
#include <assert.h>
#include <cmath>
#include <stdint.h>
#include <vector>
#include <libcamera/base/span.h>
#include <libcamera/geometry.h>
#include <libcamera/transform.h>
namespace libcamera {
class Dw100VertexMap
{
public:
enum ScaleMode {
Fill = 0,
Crop = 1,
};
void applyLimits();
void setInputSize(const Size &size)
{
inputSize_ = size;
scalerCrop_ = Rectangle(size);
}
void setSensorCrop(const Rectangle &rect) { sensorCrop_ = rect; }
void setScalerCrop(const Rectangle &rect) { scalerCrop_ = rect; }
const Rectangle &effectiveScalerCrop() const { return effectiveScalerCrop_; }
void setOutputSize(const Size &size) { outputSize_ = size; }
const Size &outputSize() const { return outputSize_; }
void setTransform(const Transform &transform) { transform_ = transform; }
const Transform &transform() const { return transform_; }
void setScale(const float scale) { scale_ = scale; }
float effectiveScale() const { return (effectiveScaleX_ + effectiveScaleY_) * 0.5; }
void setRotation(const float rotation) { rotation_ = rotation; }
float rotation() const { return rotation_; }
void setOffset(const Point &offset) { offset_ = offset; }
const Point &effectiveOffset() const { return effectiveOffset_; }
void setMode(const ScaleMode mode) { mode_ = mode; }
ScaleMode mode() const { return mode_; }
std::vector<uint32_t> getVertexMap();
private:
Rectangle scalerCrop_;
Rectangle sensorCrop_;
Transform transform_ = Transform::Identity;
Size inputSize_;
Size outputSize_;
Point offset_;
double scale_ = 1.0;
double rotation_ = 0.0;
ScaleMode mode_ = Fill;
double effectiveScaleX_;
double effectiveScaleY_;
Point effectiveOffset_;
Rectangle effectiveScalerCrop_;
};
} /* namespace libcamera */