xref: /OK3568_Linux_fs/external/camera_engine_rkaiq/rkaiq/iq_parser_v2/scene/scene_manager.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1 /*
2  *  Copyright (c) 2021 Rockchip Corporation
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */
17 
18 #ifndef __SCENE_MANAGER_H__
19 #define __SCENE_MANAGER_H__
20 
21 #include <iostream>
22 #include <map>
23 
24 #include "RkAiqCalibDbTypesV2.h"
25 #include "RkAiqCalibDbV2Helper.h"
26 #include "cJSON.h"
27 #include "cJSON_Utils.h"
28 
29 namespace RkCam {
30 
31 typedef std::pair<std::string, std::string> AiqScene;
32 
33 class RkAiqSceneManager {
34 public:
35   explicit RkAiqSceneManager() = default;
36   ~RkAiqSceneManager() = default;
37 
38 public:
39   static cJSON *loadIQFile(const char *name);
40   static int addScene(const char *name, const char *base, const char *fragment);
41   static int addScene(const char *name, AiqScene scene);
42   static AiqScene matchScene(const char *name);
43   static const char *getSceneIQ(AiqScene scene);
44   static const char *getSceneIQ(const char *scene);
45   static const char *getSceneIQ(const char *base, const char *fragment);
46 
47   static int addScene(CamCalibDbProj_t *calibproj, const char *main_scene,
48                       const char *sub_scene, CamCalibDbV2Context_t *calib);
49   static CamCalibDbV2Context_t refToScene(CamCalibDbProj_t *calibproj,
50                                            const char *main_scene,
51                                            const char *sub_scene);
52 
53   static cJSON *findMainScene(cJSON *base_json, const char *name);
54   static cJSON *findSubScene(cJSON *main_json, const char *name);
55   static cJSON *findSubScene(cJSON *json, const char *main_scene,
56                              const char *sub_scene);
57 
58   static CamCalibDbV2Context_t* createSceneCalib(CamCalibDbProj_t *calibproj,
59                                                  const char *main_scene,
60                                                  const char *sub_scene);
61 
62   static cJSON *mergeSubMultiScene(cJSON *sub_scene_list,
63                                    cJSON* full_param, bool skip);
64   static cJSON *mergeMainMultiScene(cJSON *main_scene_list);
65   static cJSON *mergeMultiSceneIQ(cJSON *base_json);
66 
67 private:
68   static std::map<std::string, AiqScene> sceneMap;
69 };
70 
71 } // namespace RkCam
72 
73 #endif /*__SCENE_MANAGER_H__*/
74