hc
2023-03-13 2ec15ae1cb4be1b4fcb56c6d621123d7ebdaad6c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
/*
 *  Copyright (c) 2019 Rockchip Corporation
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 */
 
#ifndef __IQCONVERTER_H__
#define __IQCONVERTER_H__
 
#include "RkAiqCalibDb.h"
#include "RkAiqCalibDbV2.h"
 
#include "aec_xml2json.h"
#include "awb_xml2json.h"
#include "bayernr_xml2json_v1.h"
#include "mfnr_xml2json_v1.h"
#include "uvnr_xml2json_v1.h"
#include "ynr_xml2json_v1.h"
#include "sharp_xml2json_v1.h"
#include "edgefilter_xml2json_v1.h"
#include "ccm_xml2json.h"
#include "adrc_xml2json.h"
#include "af_xml2json.h"
#include "adehaze_xml2json.h"
 
#include "bayernr_xml2json_v2.h"
#include "cnr_xml2json_v1.h"
#include "ynr_xml2json_v2.h"
#include "sharp_xml2json_v3.h"
#include "lut3d_xml2json.h"
 
 
 
#define DEF_NEW_CONVERTER(module)                                              \
  class CalibConverter##module : public CalibConverter {                       \
  public:                                                                      \
    CalibConverter##module() { printf("[%s] processing...\n", #module); }      \
    virtual ~CalibConverter##module() {};                                       \
    virtual void convert(CamCalibDbV2Context_t *calibv2,                       \
                         CamCalibDbContext_t *calibv1);                        \
  }
 
/*
 * 1. create object
 * 2. call object->convert(newcalib, oldcalib)
 * 3. delete object
 * */
#define ADD_NEW_CONVERTER(module)                                              \
  CalibConverter##module *module##_converter = new CalibConverter##module();   \
  module##_converter->convert(calibv2, calibv1);                               \
  delete module##_converter;
 
namespace RkCam {
 
class CalibConverter;
 
class CalibConverter {
public:
    CalibConverter() = default;
    virtual ~CalibConverter() = default;
 
public:
    virtual void convert(CamCalibDbV2Context_t *calibv2,
                         CamCalibDbContext_t *calibv1) = 0;
};
 
// define you module here
DEF_NEW_CONVERTER(AE);
DEF_NEW_CONVERTER(AWB);
DEF_NEW_CONVERTER(Ablc);
DEF_NEW_CONVERTER(Adegamma);
DEF_NEW_CONVERTER(Agic);
DEF_NEW_CONVERTER(Adehaze);
DEF_NEW_CONVERTER(Adpcc);
DEF_NEW_CONVERTER(Amerge);
DEF_NEW_CONVERTER(Atmo);
DEF_NEW_CONVERTER(Agamma);
DEF_NEW_CONVERTER(Cpsl);
DEF_NEW_CONVERTER(BAYERNRV1);
DEF_NEW_CONVERTER(MFNRV1);
DEF_NEW_CONVERTER(UVNRV1);
DEF_NEW_CONVERTER(YNRV1);
DEF_NEW_CONVERTER(SHARPV1);
DEF_NEW_CONVERTER(EDGEFILTERV1);
DEF_NEW_CONVERTER(Debayer);
DEF_NEW_CONVERTER(Cproc);
DEF_NEW_CONVERTER(IE);
DEF_NEW_CONVERTER(ALSC);
DEF_NEW_CONVERTER(Aldch);
DEF_NEW_CONVERTER(Afec);
DEF_NEW_CONVERTER(LumaDetect);
DEF_NEW_CONVERTER(ColorAsGrey);
DEF_NEW_CONVERTER(CCM);
DEF_NEW_CONVERTER(LUT3D);
DEF_NEW_CONVERTER(Af);
DEF_NEW_CONVERTER(Thumbnails);
DEF_NEW_CONVERTER(BAYERNRV2);
DEF_NEW_CONVERTER(CNRV1);
DEF_NEW_CONVERTER(YNRV2);
DEF_NEW_CONVERTER(SHARPV3);
DEF_NEW_CONVERTER(Adrc);
 
 
class IQConverter {
public:
    explicit IQConverter(const char *xml, const char *json);
    ~IQConverter() = default;
 
public:
    int convert();
 
private:
    std::string ifile;
    std::string ofile;
    CamCalibDbContext_t *calibv1;
    CamCalibDbV2Context_t *calibv2;
    CamCalibDbProj_t  calibproj;
 
    static int addToScene(CamCalibDbProj_t* calibpj, const char* main_scene,
                          const char* sub_scene, CamCalibDbV2Context_t *calibv2);
 
    void doConvert() {
        // add you converter here
        ADD_NEW_CONVERTER(AE);
        ADD_NEW_CONVERTER(AWB);
        ADD_NEW_CONVERTER(Ablc);
        ADD_NEW_CONVERTER(Adegamma);
        ADD_NEW_CONVERTER(Agic);
        ADD_NEW_CONVERTER(Adehaze);
        ADD_NEW_CONVERTER(Adpcc);
        ADD_NEW_CONVERTER(Amerge);
        ADD_NEW_CONVERTER(Atmo);
        ADD_NEW_CONVERTER(Agamma);
        ADD_NEW_CONVERTER(Cpsl);
        ADD_NEW_CONVERTER(BAYERNRV1);
        ADD_NEW_CONVERTER(MFNRV1);
        ADD_NEW_CONVERTER(UVNRV1);
        ADD_NEW_CONVERTER(YNRV1);
        ADD_NEW_CONVERTER(SHARPV1);
        ADD_NEW_CONVERTER(EDGEFILTERV1);
        ADD_NEW_CONVERTER(Debayer);
        ADD_NEW_CONVERTER(Cproc);
        ADD_NEW_CONVERTER(IE);
        ADD_NEW_CONVERTER(ALSC);
        ADD_NEW_CONVERTER(Afec);
        ADD_NEW_CONVERTER(Aldch);
        ADD_NEW_CONVERTER(LumaDetect);
        ADD_NEW_CONVERTER(ColorAsGrey);
        ADD_NEW_CONVERTER(CCM);
        ADD_NEW_CONVERTER(LUT3D);
        ADD_NEW_CONVERTER(Af);
        ADD_NEW_CONVERTER(Thumbnails);
        ADD_NEW_CONVERTER(BAYERNRV2);
        ADD_NEW_CONVERTER(CNRV1);
        ADD_NEW_CONVERTER(YNRV2);
        ADD_NEW_CONVERTER(SHARPV3);
        ADD_NEW_CONVERTER(Adrc);
    };
};
 
} // namespace RkCam
 
#endif /*__IQCONVERTER_H__*/