libcamera: dw100_vertexmap: Implement parametric dewarping
Implement functions to allow lens dewarping based on the common lens dewarp model used e.g. by OpenCV. See https://docs.opencv.org/4.12.0/d9/d0c/group__calib3d.html for an in depth explanation of the parameters. Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com> Reviewed-by: Paul Elder <paul.elder@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
This commit is contained in:
@@ -17,6 +17,9 @@
|
||||
#include <libcamera/geometry.h>
|
||||
#include <libcamera/transform.h>
|
||||
|
||||
#include "libcamera/internal/matrix.h"
|
||||
#include "libcamera/internal/vector.h"
|
||||
|
||||
namespace libcamera {
|
||||
|
||||
class Dw100VertexMap
|
||||
@@ -57,9 +60,17 @@ public:
|
||||
void setMode(const ScaleMode mode) { mode_ = mode; }
|
||||
ScaleMode mode() const { return mode_; }
|
||||
|
||||
int setDewarpParams(const Matrix<double, 3, 3> &cm, const Span<const double> &coeffs);
|
||||
bool dewarpParamsValid() { return dewarpParamsValid_; }
|
||||
|
||||
void setLensDewarpEnable(bool enable) { lensDewarpEnable_ = enable; }
|
||||
bool lensDewarpEnable() { return lensDewarpEnable_; }
|
||||
|
||||
std::vector<uint32_t> getVertexMap();
|
||||
|
||||
private:
|
||||
Vector<double, 2> dewarpPoint(const Vector<double, 2> &p);
|
||||
|
||||
Rectangle scalerCrop_;
|
||||
Rectangle sensorCrop_;
|
||||
Transform transform_ = Transform::Identity;
|
||||
@@ -73,6 +84,11 @@ private:
|
||||
double effectiveScaleY_;
|
||||
Point effectiveOffset_;
|
||||
Rectangle effectiveScalerCrop_;
|
||||
|
||||
Matrix<double, 3, 3> dewarpM_ = Matrix<double, 3, 3>::identity();
|
||||
std::array<double, 12> dewarpCoeffs_;
|
||||
bool lensDewarpEnable_ = true;
|
||||
bool dewarpParamsValid_ = false;
|
||||
};
|
||||
|
||||
} /* namespace libcamera */
|
||||
|
||||
Reference in New Issue
Block a user