1 /* -*- C++ -*-
2  *
3  *  This file is part of ART.
4  *
5  *  Copyright (c) 2020 Alberto Griggio <alberto.griggio@gmail.com>
6  *
7  *  ART is free software: you can redistribute it and/or modify
8  *  it under the terms of the GNU General Public License as published by
9  *  the Free Software Foundation, either version 3 of the License, or
10  *  (at your option) any later version.
11  *
12  *  ART is distributed in the hope that it will be useful,
13  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  *  GNU General Public License for more details.
16  *
17  *  You should have received a copy of the GNU General Public License
18  *  along with ART.  If not, see <http://www.gnu.org/licenses/>.
19  */
20 
21 #pragma once
22 
23 #include "lcp.h"
24 #include "procparams.h"
25 #include "rtengine.h"
26 #include <memory>
27 
28 namespace rtengine {
29 
30 class ExifLensCorrection: public LensCorrection {
31 public:
32     static bool ok(const FramesMetaData *meta);
33     ExifLensCorrection(const FramesMetaData *meta, int width, int height, const CoarseTransformParams &coarse, int rawRotationDeg);
34     bool ok() const;
35 
36     void correctDistortion(double &x, double &y, int cx, int cy, double scale) const override;
37     bool isCACorrectionAvailable() const override;
38     void correctCA(double &x, double &y, int cx, int cy, int channel) const override;
39     void processVignette(int width, int height, float** rawData) const override;
processVignette3Channels(int width,int height,float ** rawData)40     void processVignette3Channels(int width, int height, float** rawData) const override {}
41 
42     class CorrectionData {
43     public:
44         virtual ~CorrectionData() = default;
45         virtual void get_coeffs(std::vector<float> &knots, std::vector<float> &dist, std::vector<float> &vig, std::array<std::vector<float>, 3> &ca, bool &is_dng) const = 0;
46     };
47 
48 private:
49     std::unique_ptr<CorrectionData> data_;
50     std::vector<float> knots_;
51     std::vector<float> dist_;
52     std::vector<float> vig_;
53     std::array<std::vector<float>, 3> ca_;
54     bool is_dng_;
55     bool swap_xy_;
56     float w2_;
57     float h2_;
58     float r_;
59 };
60 
61 } // namespace rtengine
62